OrdersController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. <?php
  2. namespace App\Http\Controllers\Wap\Order;
  3. use App\Http\Controllers\Wap\BaseController;
  4. use App\Modules\Channel\Services\ChannelService;
  5. use App\Modules\Cpa\Services\AdvertiseUserQueueService;
  6. use App\Modules\OfficialAccount\Services\ForceSubscribeService;
  7. use App\Modules\Statistic\Services\AdVisitStatService;
  8. use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
  9. use App\Modules\User\Services\UserService;
  10. use App\Modules\Book\Services\BookService;
  11. use App\Modules\Channel\Services\PayTemplateService;
  12. use Illuminate\Http\Request;
  13. use App\Modules\Subscribe\Services\BookOrderService;
  14. use App\Modules\Subscribe\Services\ChapterOrderService;
  15. use App\Modules\Subscribe\Services\OrderService;
  16. use App\Http\Controllers\Wap\Order\Transformers\BookOrderTransformer;
  17. use App\Http\Controllers\Wap\Order\Transformers\ChapterOrderTransformer;
  18. use App\Http\Controllers\Wap\Order\Transformers\ChargeListTransformer;
  19. use Redis;
  20. use App\Modules\Product\Services\ProductService;
  21. use App\Modules\Subscribe\Services\SubstituteOrderService;
  22. use Hashids;
  23. use DB;
  24. class OrdersController extends BaseController
  25. {
  26. /**
  27. * @apiDefine Order 订单
  28. */
  29. /**
  30. * @apiVersion 1.0.0
  31. * @apiDescription 充值列表
  32. * @api {get} order/chargeList 充值列表
  33. * @apiGroup Order
  34. * @apiName chargeList
  35. * @apiSuccess {int} code 状态码
  36. * @apiSuccess {String} msg 信息
  37. * @apiSuccess {object} data 结果集
  38. * @apiSuccessExample {json} Success-Response:
  39. * HTTP/1.1 200 OK
  40. * {
  41. * code: 0,
  42. * msg: "",
  43. * data: [
  44. * {
  45. * product_id: 1,
  46. * price: "30.00元",
  47. * vip: 0,
  48. * intro: [
  49. * {
  50. * label: 3000,
  51. * important: false
  52. * },
  53. * {
  54. * label: "书币",
  55. * important: true
  56. * }
  57. * ]
  58. * },
  59. * {
  60. * product_id: 2,
  61. * price: "50.00元",
  62. * vip: 1,
  63. * intro: [
  64. * {
  65. * label: 5000,
  66. * important: false
  67. * },
  68. * {
  69. * label: "1000+",
  70. * important: true
  71. * },
  72. * {
  73. * label: "书币",
  74. * important: false
  75. * }
  76. * ]
  77. * },
  78. * {
  79. * product_id: 5,
  80. * price: "365.00元",
  81. * vip: 0,
  82. * intro: [
  83. * {
  84. * label: "年费VIP会员",
  85. * important: true
  86. * }
  87. * ]
  88. * }
  89. * ]
  90. * }
  91. */
  92. public function chargeList_(Request $request)
  93. {
  94. if (!$this->checkUid()) {
  95. return response()->error('WAP_NOT_LOGIN');
  96. }
  97. $res = ProductService::getChargeProduct();
  98. if (!$res->isEmpty()) {
  99. $data = [];
  100. /*if ($this->send_order_id) {
  101. try {
  102. Redis::sadd('pay_page_uv' . $this->send_order_id, $this->uid);
  103. Redis::sadd('pay_page_uv_send_order_ids', $this->send_order_id);
  104. } catch (\Exception $e) {
  105. }
  106. }*/
  107. foreach ($res as $v) {
  108. $intro = [];
  109. if ($v->given > 0 && $v->type == 'TICKET_RECHARGE') {
  110. $intro = [
  111. [
  112. 'label' => ($v->price * 100) . "+",
  113. 'important' => false,
  114. ],
  115. [
  116. 'label' => $v->given,
  117. 'important' => true,
  118. ],
  119. [
  120. 'label' => '书币',
  121. 'important' => false,
  122. ]
  123. ];
  124. $intro2 = [
  125. ['label' => '多送', 'important' => false],
  126. ['label' => (int)($v->given / 100), 'important' => true],
  127. ['label' => '元', 'important' => false],
  128. ];
  129. $v->vip = 0;
  130. }
  131. if ($v->given == 0 && $v->type == 'TICKET_RECHARGE') {
  132. $intro = [
  133. [
  134. 'label' => $v->price * 100,
  135. 'important' => false,
  136. ],
  137. [
  138. 'label' => '书币',
  139. 'important' => false,
  140. ]
  141. ];
  142. $v->vip = 0;
  143. $intro2 = [];
  144. }
  145. if ($v->given == 0 && $v->type == 'YEAR_ORDER') {
  146. $intro = [
  147. [
  148. 'label' => '年费VIP会员',
  149. 'important' => true,
  150. ]
  151. ];
  152. $v->vip = 1;
  153. $intro2 = [
  154. ['label' => '每天1元,全年免费看', 'important' => false],
  155. ];
  156. }
  157. $data[] = [
  158. 'product_id' => $v->id,
  159. 'price' => (int)$v->price . '元',
  160. 'vip' => $v->vip,
  161. 'intro' => $intro,
  162. 'intro2' => $intro2,
  163. 'is_default' => $v->is_default,
  164. ];
  165. }
  166. return response()->success($data);
  167. } else {
  168. return response()->error('WAP_SYS_ERROR');
  169. }
  170. }
  171. public function chargeList(Request $request)
  172. {
  173. if (!$this->checkUid()) {
  174. return response()->error('WAP_NOT_LOGIN');
  175. }
  176. /*if (env('OTHER_PAY_TEMPLATE') &&
  177. in_array($this->distribution_channel_id,
  178. explode(',', env('OTHER_PAY_TEMPLATE')))
  179. ) {
  180. $template_id = 3;
  181. } else {*/
  182. $bid = $request->input('bid', '');
  183. $temp = $bid;
  184. $template_id = PayTemplateService::getPayTemplate($this->distribution_channel_id);
  185. //}
  186. \Log::info('order:$template_id:' . $template_id);
  187. \Log::info('order:$distribution_channel_id:' . ($this->distribution_channel_id));
  188. if ($template_id == 2) { //模板2只有在长篇小说过来的用户才显示
  189. //部分渠道需要2元模板不管哪个入口进来都展示
  190. $exclude_channels = explode(',', env('PRICE_TWO_SHOW_ALL_CHANNEL'));
  191. if(!in_array($this->distribution_channel_id,$exclude_channels))
  192. {
  193. if ($bid) {
  194. $bid = Hashids::decode($bid)[0];
  195. \Log::info('order:$bid:' . $bid);
  196. $book = BookService::getBookById($bid);
  197. \Log::info('order:$$book:' . json_encode($book));
  198. if ($book->size < 200000) {
  199. $template_id = 1;
  200. }
  201. } else {
  202. $template_id = 1;
  203. }
  204. }
  205. }
  206. if($temp){
  207. $temp_bid = 0;
  208. try{
  209. $temp_bid = Hashids::decode($temp)[0];
  210. }catch (\Exception $e){}
  211. $t = $this->recordFirstIntoPayPage($temp_bid);
  212. if ($t) {
  213. $template_id = $t;
  214. }
  215. }
  216. //男频站点 支付模板
  217. if( ($male_site_template = $this->maleSite($this->distribution_channel_id)) ){
  218. //\Log::info('$male_site_template is: '.$male_site_template);
  219. $template_id = $male_site_template;
  220. }
  221. if( ($compare_id = $this->templateCompare()) ){
  222. $template_id = $compare_id;
  223. }
  224. /*if( ($comparev2_id = $this->templateCompareV2()) ){
  225. $template_id = $comparev2_id;
  226. }*/
  227. \Log::info('recordFirstIntoPayPage:$template_id:' . $template_id);
  228. $res = ProductService::getChargeProduct($template_id);
  229. if (!$res) {
  230. return response()->error('WAP_SYS_ERROR');
  231. }
  232. /*if ($this->send_order_id) {
  233. try {
  234. Redis::sadd('pay_page_uv' . $this->send_order_id, $this->uid);
  235. Redis::sadd('pay_page_uv_send_order_ids', $this->send_order_id);
  236. } catch (\Exception $e) {
  237. }
  238. }*/
  239. //TODO 长篇小数才有模板2
  240. //$user = $this->_user_info;
  241. $uid = $this->uid;
  242. $is_first_recharge = OrderService::judgeUserFirstRecharge($uid);
  243. //yqLog('user')->info('user is ',['user'=>$user]);
  244. //yqLog('user')->info('user is ',['charge_count'=>$user->charge_count]);
  245. $data = [];
  246. $appad =0;
  247. if($this->distribution_channel_id==211){
  248. $appad = $this->appad();
  249. }
  250. foreach ($res as $v) {
  251. if ($v->type == 'NEW_USER' && $is_first_recharge) {
  252. if (env('NO_NEW_USER_CHARGE') &&
  253. in_array(
  254. $this->distribution_channel_id,
  255. explode(',', env('NO_NEW_USER_CHARGE'))
  256. )
  257. ) {
  258. continue;
  259. }
  260. $temp = [
  261. 'price' => (float)$v->price . '元',
  262. 'is_year_order' => 0,
  263. 'text' => sprintf('%s+%s书币', $v->price * 100, $v->given),
  264. 'first_charge' => true,
  265. 'today_special' => false,
  266. 'save_text' => round($v->given / 100, 1) . '元',
  267. 'product_id' => $v->id,
  268. 'show_free_ads'=>$appad
  269. ];
  270. $data[] = $temp;
  271. } elseif ($v->type == 'YEAR_ORDER') {
  272. if ($v->type == 'NEW_USER') {
  273. continue;
  274. }
  275. $save_text = '年费vip会员';
  276. $text = '每天1元,全年免费看';
  277. $temp = [
  278. 'price' => (int)$v->price . '元',
  279. 'is_year_order' => 1,
  280. 'text' => $text,
  281. 'first_charge' => false,
  282. 'today_special' => false,
  283. 'save_text' => $save_text,
  284. 'product_id' => $v->id,
  285. 'show_free_ads'=>$appad
  286. ];
  287. $data[] = $temp;
  288. } else {
  289. if ($v->type == 'NEW_USER') {
  290. continue;
  291. }
  292. $save_text = '';
  293. if ($v->given) {
  294. $save_text = round($v->given / 100, 1) . '元';
  295. $text = sprintf('%s+%s书币', $v->price * 100, $v->given);
  296. } else {
  297. $text = sprintf('%s书币', $v->price * 100);
  298. }
  299. $temp = [
  300. 'price' => (float)$v->price . '元',
  301. 'is_year_order' => 0,
  302. 'text' => $text,
  303. 'first_charge' => false,
  304. 'today_special' => $v->is_default == 1 ? true : false,
  305. 'save_text' => $save_text,
  306. 'product_id' => $v->id,
  307. 'show_free_ads'=>$appad
  308. ];
  309. $data[] = $temp;
  310. }
  311. }
  312. return response()->success($data);
  313. }
  314. public function substitutePayChargeList(Request $request)
  315. {
  316. $default = $request->get('product_id');
  317. if (!$this->checkUid()) {
  318. return response()->error('WAP_NOT_LOGIN');
  319. }
  320. $su = $request->get('su');
  321. $res = ProductService::getChargeProduct();
  322. if (!$res) {
  323. return response()->error('WAP_SYS_ERROR');
  324. }
  325. $is_can_allow_pay = 1;
  326. if ($su) {
  327. $su_user = UserService::getById($su);
  328. $now_user = $this->_user_info;
  329. if ($now_user && $su_user && $su_user->openid == $now_user->openid) {
  330. $is_can_allow_pay = 0;
  331. }
  332. }
  333. SubstituteOrderService::substitutePageUvPv($this->uid, $this->distribution_channel_id);
  334. $data = [];
  335. foreach ($res as $v) {
  336. if ($v->type == 'YEAR_ORDER') {
  337. $temp = [
  338. 'price' => (int)$v->price . '元',
  339. 'text' => '年费VIP会员',
  340. 'first_charge' => false,
  341. 'today_special' => $v->is_default == 1 ? true : false,
  342. 'save_text' => '全年免费',
  343. 'product_id' => $v->id,
  344. 'default' => false,
  345. 'is_vip' => 1,
  346. 'is_can_allow_pay' => $is_can_allow_pay
  347. ];
  348. if ($default) {
  349. if ($default == $v->id) {
  350. $temp['default'] = true;
  351. }
  352. } else {
  353. $temp['default'] = $v->is_default == 1 ? true : false;
  354. }
  355. $data[] = $temp;
  356. } else {
  357. $save_text = '';
  358. if ($v->given) {
  359. $save_text = round($v->given / 100, 1) . '元';
  360. $text = sprintf('%s+%s书币', $v->price * 100, $v->given);
  361. } else {
  362. $text = sprintf('%s书币', $v->price * 100);
  363. }
  364. $temp = [
  365. 'price' => (int)$v->price . '元',
  366. 'text' => $text,
  367. 'first_charge' => false,
  368. 'today_special' => $v->is_default == 1 ? true : false,
  369. 'save_text' => $save_text,
  370. 'product_id' => $v->id,
  371. 'default' => false,
  372. 'is_vip' => 0,
  373. 'is_can_allow_pay' => $is_can_allow_pay
  374. ];
  375. if ($default) {
  376. if ($default == $v->id) {
  377. $temp['default'] = true;
  378. }
  379. } else {
  380. $temp['default'] = $v->is_default == 1 ? true : false;
  381. }
  382. $data[] = $temp;
  383. }
  384. }
  385. return response()->success($data);
  386. }
  387. /**
  388. * @apiVersion 1.0.0
  389. * @apiDescription 单本消费记录
  390. * @api {get} order/bookOrderList 单本消费记录
  391. * @apiGroup Order
  392. * @apiName bookOrderList
  393. * @apiSuccess {int} code 状态码
  394. * @apiSuccess {String} msg 信息
  395. * @apiSuccess {object} data 结果集
  396. * @apiSuccess {Int} uid uid
  397. * @apiSuccess {Int} bid bid
  398. * @apiSuccess {Int} book_name 书名
  399. * @apiSuccess {Int} fee 钱
  400. * @apiSuccess {String} created_at 时间
  401. * @apiSuccessExample {json} Success-Response:
  402. * HTTP/1.1 200 OK
  403. * {
  404. * code: 0,
  405. * msg: "",
  406. * data: list:[
  407. * {
  408. * uid: 4,
  409. * bid: 1,
  410. * book_name: "dfsedfertrwet",
  411. * fee: 100,
  412. * created_at: "2017-12-02 16:24:54"
  413. * }
  414. * ]
  415. * meta: {
  416. * total: 1,
  417. * per_page: 15,
  418. * current_page: 1,
  419. * last_page: 1,
  420. * next_page_url: "",
  421. * prev_page_url: ""
  422. * }
  423. * }
  424. */
  425. public function bookOrderList(Request $request)
  426. {
  427. if (!$this->checkUid()) {
  428. return response()->error('WAP_NOT_LOGIN');
  429. }
  430. $page_size = $request->input('page_size', 15);
  431. $book_order = BookOrderService::getRecord($this->uid, $page_size);
  432. //$book_order = BookOrder::where('uid', $this->uid)->select('bid', 'uid', 'book_name', 'created_at', 'fee')->paginate($page_size);
  433. return response()->pagination(new BookOrderTransformer(), $book_order);
  434. }
  435. /**
  436. * @apiVersion 1.0.0
  437. * @apiDescription 章节消费记录
  438. * @api {get} order/chapterOrderList 章节消费记录
  439. * @apiGroup Order
  440. * @apiName chapterOrderList
  441. * @apiSuccess {int} code 状态码
  442. * @apiSuccess {String} msg 信息
  443. * @apiSuccess {object} data 结果集
  444. * @apiSuccess {Int} uid uid
  445. * @apiSuccess {Int} bid bid
  446. * @apiSuccess {Int} cid cid
  447. * @apiSuccess {Int} chapter_name 章节名
  448. * @apiSuccess {Int} book_name 书名
  449. * @apiSuccess {Int} fee 钱
  450. * @apiSuccess {String} created_at 时间
  451. * @apiSuccessExample {json} Success-Response:
  452. * HTTP/1.1 200 OK
  453. * {
  454. * code: 0,
  455. * msg: "",
  456. * data: list:[
  457. * {
  458. * uid: 4,
  459. * bid: 1,
  460. * cid: 1,
  461. * chapter_name: "sdfsd",
  462. * book_name: "dfsedfertrwet",
  463. * fee: 100,
  464. * created_at: "2017-12-02 16:24:54"
  465. * }
  466. * ]
  467. * meta: {
  468. * total: 1,
  469. * per_page: 15,
  470. * current_page: 1,
  471. * last_page: 1,
  472. * next_page_url: "",
  473. * prev_page_url: ""
  474. * }
  475. * }
  476. */
  477. public function chapterOrderList(Request $request)
  478. {
  479. if (!$this->checkUid()) {
  480. return response()->error('WAP_NOT_LOGIN');
  481. }
  482. $chapter_model = new ChapterOrderService();
  483. $page_size = $request->input('page_size', 15);
  484. $chapter_order = $chapter_model->getByUid($this->uid, $page_size);
  485. foreach ($chapter_order as $item){
  486. if($item->fee == 0){
  487. $result = AdVisitStatService::getInfoV2($this->uid,$item->cid,['UNLOCK','UNLOCK_2']);
  488. if($result) $item->fee = '解锁';
  489. }
  490. }
  491. return response()->pagination(new ChapterOrderTransformer(), $chapter_order);
  492. }
  493. /**
  494. * @apiVersion 1.0.0
  495. * @apiDescription 充值记录
  496. * @api {get} order/chargeRecordLists 充值记录
  497. * @apiGroup Order
  498. * @apiName chargeRecordLists
  499. * @apiSuccess {int} code 状态码
  500. * @apiSuccess {String} msg 信息
  501. * @apiSuccess {object} data 结果集
  502. * @apiSuccess {String} data.price 价格
  503. * @apiSuccess {String} data.status 状态
  504. * @apiSuccess {String} data.trade_no 订单号
  505. * @apiSuccess {String} data.created_at 时间
  506. * @apiSuccessExample {json} Success-Response:
  507. * HTTP/1.1 200 OK
  508. * {
  509. * code: 0,
  510. * msg: "",
  511. * data: {
  512. * list: [
  513. * {
  514. * id: 134,
  515. * price: "1.00",
  516. * status: "PAID",
  517. * trade_no: "201712021915481585670623626232",
  518. * created_at: "2017-12-02 19:15:56"
  519. * }
  520. * ],
  521. * meta: {
  522. * total: 1,
  523. * per_page: 15,
  524. * current_page: 1,
  525. * last_page: 1,
  526. * next_page_url: "",
  527. * prev_page_url: ""
  528. * }
  529. * }
  530. * }
  531. */
  532. public function chargeRecordLists(Request $request)
  533. {
  534. $page_size = $request->input('page_size', 15);
  535. $res = OrderService::getOrderList($this->uid, $page_size);
  536. return response()->pagination(new ChargeListTransformer(), $res);
  537. }
  538. //订单是否成功
  539. public function isSuccess(Request $request)
  540. {
  541. $order = $request->input('order');
  542. $order_info = OrderService::getByTradeNo($order);
  543. if ($order_info && $order_info->status == 'PAID') {
  544. return response()->success();
  545. }
  546. return response()->error('WAP_SYS_ERROR');
  547. }
  548. public function substitutePay(Request $request)
  549. {
  550. if (!$this->checkUid()) {
  551. return response()->error('WAP_NOT_LOGIN');
  552. }
  553. $product_id = $request->get('product_id');
  554. SubstituteOrderService::substituteButtonUvPv($this->uid, $this->distribution_channel_id);
  555. $user = $this->_user_info;
  556. $data = [
  557. 'head_img' => '',
  558. 'nickname' => $user->nickname
  559. ];
  560. //$help_pay_page_channel_id = env('HELP_PAY_PAGE_CHANNEL_ID', 123);
  561. $help_pay_page_channel_id = $this->distribution_channel_id;
  562. $url_format = '%s://site%s.%s.com/helppay?%s';
  563. $param = [];
  564. $param['su'] = $this->uid;
  565. if ($product_id) {
  566. $param['product_id'] = $product_id;
  567. }
  568. $help_pay_page = sprintf(
  569. $url_format,
  570. env('PROTOCOL'),
  571. encodeDistributionChannelId($help_pay_page_channel_id),
  572. env('CUSTOM_HOST'),
  573. http_build_query($param)
  574. );
  575. $data['help_pay_page'] = $help_pay_page;
  576. return response()->success($data);
  577. }
  578. private function recordFirstIntoPayPage($bid)
  579. {
  580. $start_time = env('RECORD_FIRST_VISIT_PAY_PAGE_TIME');
  581. $template_id = 0;
  582. if (in_array($this->distribution_channel_id,[123,211]) && $start_time && $this->uid) {
  583. $user = $this->_user_info;
  584. if (strtotime($user->created_at) > $start_time) {
  585. $old = DB::table('user_first_visit_pay_page')->where('uid', $this->uid)->select('uid', 'template_type')->first();
  586. if ($old) {
  587. $template_id = $old->template_type;
  588. if($template_id) return $template_id;
  589. }
  590. if ($bid && $bid == 1148) {
  591. $template_id = $this->uid % 2 == 0 ? 2 : 1;
  592. if (empty($old)) {
  593. try {
  594. DB::table('user_first_visit_pay_page')->insert([
  595. 'uid' => $this->uid,
  596. 'template_type' => $template_id,
  597. 'created_at' => date('Y-m-d H:i:s'),
  598. 'updated_at' => date('Y-m-d H:i:s')
  599. ]);
  600. } catch (\Exception $e) {
  601. }
  602. }
  603. }
  604. }
  605. }
  606. return $template_id;
  607. }
  608. private function templateCompare(){
  609. //if(!in_array($this->distribution_channel_id,[2,14,211,155,4427,4488,256,691,146,255,722,4364,5,202,318,4237,266,196,273,4236,148,8,4241,160,271,4053,123,4334,4487,4593,695,4025,4426,4174])){
  610. /*$start_time = env('TEMPLATE_COMPARE_START_TIME_3',0);
  611. if(!$start_time){
  612. return 0;
  613. }*/
  614. if(!in_array($this->distribution_channel_id,[14,123,211,5,8,160,4236,4237,4241,374,243,244,245,320,321,324,337,338,538,539,751,752,753,754,4331,4384,4578,4580,4768,4769,4778,130,163,164,165,166,4126])){
  615. return 0;
  616. }
  617. //$user = $this->_user_info;
  618. /*if(strtotime($user->created_at) < $start_time){
  619. return 0;
  620. }*/
  621. $template_id = 0;
  622. $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPARE_V3');
  623. if($user){
  624. $template_id = $user->attach;
  625. }
  626. return $template_id;
  627. }
  628. private function templateCompareV2(){
  629. $start_time = env('TEMPLATE_COMPARE_START_TIME',0);
  630. if(!$start_time){
  631. return 0;
  632. }
  633. if(!in_array($this->distribution_channel_id,[2,146 ,155 ,255 ,256 ,691 ,722 ,4364 ,695 ,4174 ,4025 ,4593 ,4426 ,4742 ,4053 ,4334 ,4487])){
  634. return 0;
  635. }
  636. $user = $this->_user_info;
  637. if(strtotime($user->created_at) < $start_time){
  638. return 0;
  639. }
  640. $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPAREV2');
  641. if($user){
  642. $template_id = $user->attach;
  643. }else{
  644. $template_id = $this->uid % 2 == 0? 1:6;
  645. DataAnalysisSelectUserService::create(
  646. $this->uid,
  647. $this->distribution_channel_id,
  648. 'TEMPLATE_COMPAREV2',
  649. -1, $template_id);
  650. }
  651. return $template_id;
  652. }
  653. private function maleSite($distribution_channel_id){
  654. $info = ChannelService::getChannelCompanyInfo($distribution_channel_id);
  655. //\Log::info('maleSite info is:');
  656. //\Log::info($info);
  657. if($info && isset($info->fans_gender)){
  658. if($info->fans_gender == 1){
  659. return 1;
  660. }
  661. }
  662. return 0;
  663. }
  664. private function appad(){
  665. if(!$this->force_subscribe_info){
  666. $this->force_subscribe_info = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  667. }
  668. if(!$this->force_subscribe_info){
  669. return ['appad'=>false,'appad_banner'=>'','appad_url'=>''];
  670. }
  671. if($this->force_subscribe_info->subscribe_time &&
  672. (time()-strtotime($this->force_subscribe_info->subscribe_time) >=3*86400)
  673. && !OrderService::isPaidUser($this->uid) &&
  674. !AdvertiseUserQueueService::getUserAdvertise($this->uid) &&
  675. $this->distribution_channel_id==211
  676. ){
  677. return 1;
  678. }
  679. return 0;
  680. }
  681. }