OrdersController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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 = $this->appad();
  247. foreach ($res as $v) {
  248. if ($v->type == 'NEW_USER' && $is_first_recharge) {
  249. if (env('NO_NEW_USER_CHARGE') &&
  250. in_array(
  251. $this->distribution_channel_id,
  252. explode(',', env('NO_NEW_USER_CHARGE'))
  253. )
  254. ) {
  255. continue;
  256. }
  257. $temp = [
  258. 'price' => (float)$v->price . '元',
  259. 'is_year_order' => 0,
  260. 'text' => sprintf('%s+%s书币', $v->price * 100, $v->given),
  261. 'first_charge' => true,
  262. 'today_special' => false,
  263. 'save_text' => round($v->given / 100, 1) . '元',
  264. 'product_id' => $v->id,
  265. 'show_free_ads'=>$appad
  266. ];
  267. $data[] = $temp;
  268. } elseif ($v->type == 'YEAR_ORDER') {
  269. if ($v->type == 'NEW_USER') {
  270. continue;
  271. }
  272. $save_text = '年费vip会员';
  273. $text = '每天1元,全年免费看';
  274. $temp = [
  275. 'price' => (int)$v->price . '元',
  276. 'is_year_order' => 1,
  277. 'text' => $text,
  278. 'first_charge' => false,
  279. 'today_special' => false,
  280. 'save_text' => $save_text,
  281. 'product_id' => $v->id,
  282. 'show_free_ads'=>$appad
  283. ];
  284. $data[] = $temp;
  285. } else {
  286. if ($v->type == 'NEW_USER') {
  287. continue;
  288. }
  289. $save_text = '';
  290. if ($v->given) {
  291. $save_text = round($v->given / 100, 1) . '元';
  292. $text = sprintf('%s+%s书币', $v->price * 100, $v->given);
  293. } else {
  294. $text = sprintf('%s书币', $v->price * 100);
  295. }
  296. $temp = [
  297. 'price' => (float)$v->price . '元',
  298. 'is_year_order' => 0,
  299. 'text' => $text,
  300. 'first_charge' => false,
  301. 'today_special' => $v->is_default == 1 ? true : false,
  302. 'save_text' => $save_text,
  303. 'product_id' => $v->id,
  304. 'show_free_ads'=>$appad
  305. ];
  306. $data[] = $temp;
  307. }
  308. }
  309. return response()->success($data);
  310. }
  311. public function substitutePayChargeList(Request $request)
  312. {
  313. $default = $request->get('product_id');
  314. if (!$this->checkUid()) {
  315. return response()->error('WAP_NOT_LOGIN');
  316. }
  317. $su = $request->get('su');
  318. $res = ProductService::getChargeProduct();
  319. if (!$res) {
  320. return response()->error('WAP_SYS_ERROR');
  321. }
  322. $is_can_allow_pay = 1;
  323. if ($su) {
  324. $su_user = UserService::getById($su);
  325. $now_user = $this->_user_info;
  326. if ($now_user && $su_user && $su_user->openid == $now_user->openid) {
  327. $is_can_allow_pay = 0;
  328. }
  329. }
  330. SubstituteOrderService::substitutePageUvPv($this->uid, $this->distribution_channel_id);
  331. $data = [];
  332. foreach ($res as $v) {
  333. if ($v->type == 'YEAR_ORDER') {
  334. $temp = [
  335. 'price' => (int)$v->price . '元',
  336. 'text' => '年费VIP会员',
  337. 'first_charge' => false,
  338. 'today_special' => $v->is_default == 1 ? true : false,
  339. 'save_text' => '全年免费',
  340. 'product_id' => $v->id,
  341. 'default' => false,
  342. 'is_vip' => 1,
  343. 'is_can_allow_pay' => $is_can_allow_pay
  344. ];
  345. if ($default) {
  346. if ($default == $v->id) {
  347. $temp['default'] = true;
  348. }
  349. } else {
  350. $temp['default'] = $v->is_default == 1 ? true : false;
  351. }
  352. $data[] = $temp;
  353. } else {
  354. $save_text = '';
  355. if ($v->given) {
  356. $save_text = round($v->given / 100, 1) . '元';
  357. $text = sprintf('%s+%s书币', $v->price * 100, $v->given);
  358. } else {
  359. $text = sprintf('%s书币', $v->price * 100);
  360. }
  361. $temp = [
  362. 'price' => (int)$v->price . '元',
  363. 'text' => $text,
  364. 'first_charge' => false,
  365. 'today_special' => $v->is_default == 1 ? true : false,
  366. 'save_text' => $save_text,
  367. 'product_id' => $v->id,
  368. 'default' => false,
  369. 'is_vip' => 0,
  370. 'is_can_allow_pay' => $is_can_allow_pay
  371. ];
  372. if ($default) {
  373. if ($default == $v->id) {
  374. $temp['default'] = true;
  375. }
  376. } else {
  377. $temp['default'] = $v->is_default == 1 ? true : false;
  378. }
  379. $data[] = $temp;
  380. }
  381. }
  382. return response()->success($data);
  383. }
  384. /**
  385. * @apiVersion 1.0.0
  386. * @apiDescription 单本消费记录
  387. * @api {get} order/bookOrderList 单本消费记录
  388. * @apiGroup Order
  389. * @apiName bookOrderList
  390. * @apiSuccess {int} code 状态码
  391. * @apiSuccess {String} msg 信息
  392. * @apiSuccess {object} data 结果集
  393. * @apiSuccess {Int} uid uid
  394. * @apiSuccess {Int} bid bid
  395. * @apiSuccess {Int} book_name 书名
  396. * @apiSuccess {Int} fee 钱
  397. * @apiSuccess {String} created_at 时间
  398. * @apiSuccessExample {json} Success-Response:
  399. * HTTP/1.1 200 OK
  400. * {
  401. * code: 0,
  402. * msg: "",
  403. * data: list:[
  404. * {
  405. * uid: 4,
  406. * bid: 1,
  407. * book_name: "dfsedfertrwet",
  408. * fee: 100,
  409. * created_at: "2017-12-02 16:24:54"
  410. * }
  411. * ]
  412. * meta: {
  413. * total: 1,
  414. * per_page: 15,
  415. * current_page: 1,
  416. * last_page: 1,
  417. * next_page_url: "",
  418. * prev_page_url: ""
  419. * }
  420. * }
  421. */
  422. public function bookOrderList(Request $request)
  423. {
  424. if (!$this->checkUid()) {
  425. return response()->error('WAP_NOT_LOGIN');
  426. }
  427. $page_size = $request->input('page_size', 15);
  428. $book_order = BookOrderService::getRecord($this->uid, $page_size);
  429. //$book_order = BookOrder::where('uid', $this->uid)->select('bid', 'uid', 'book_name', 'created_at', 'fee')->paginate($page_size);
  430. return response()->pagination(new BookOrderTransformer(), $book_order);
  431. }
  432. /**
  433. * @apiVersion 1.0.0
  434. * @apiDescription 章节消费记录
  435. * @api {get} order/chapterOrderList 章节消费记录
  436. * @apiGroup Order
  437. * @apiName chapterOrderList
  438. * @apiSuccess {int} code 状态码
  439. * @apiSuccess {String} msg 信息
  440. * @apiSuccess {object} data 结果集
  441. * @apiSuccess {Int} uid uid
  442. * @apiSuccess {Int} bid bid
  443. * @apiSuccess {Int} cid cid
  444. * @apiSuccess {Int} chapter_name 章节名
  445. * @apiSuccess {Int} book_name 书名
  446. * @apiSuccess {Int} fee 钱
  447. * @apiSuccess {String} created_at 时间
  448. * @apiSuccessExample {json} Success-Response:
  449. * HTTP/1.1 200 OK
  450. * {
  451. * code: 0,
  452. * msg: "",
  453. * data: list:[
  454. * {
  455. * uid: 4,
  456. * bid: 1,
  457. * cid: 1,
  458. * chapter_name: "sdfsd",
  459. * book_name: "dfsedfertrwet",
  460. * fee: 100,
  461. * created_at: "2017-12-02 16:24:54"
  462. * }
  463. * ]
  464. * meta: {
  465. * total: 1,
  466. * per_page: 15,
  467. * current_page: 1,
  468. * last_page: 1,
  469. * next_page_url: "",
  470. * prev_page_url: ""
  471. * }
  472. * }
  473. */
  474. public function chapterOrderList(Request $request)
  475. {
  476. if (!$this->checkUid()) {
  477. return response()->error('WAP_NOT_LOGIN');
  478. }
  479. $chapter_model = new ChapterOrderService();
  480. $page_size = $request->input('page_size', 15);
  481. $chapter_order = $chapter_model->getByUid($this->uid, $page_size);
  482. foreach ($chapter_order as $item){
  483. if($item->fee == 0){
  484. $result = AdVisitStatService::getInfoV2($this->uid,$item->cid,['UNLOCK','UNLOCK_2']);
  485. if($result) $item->fee = '解锁';
  486. }
  487. }
  488. return response()->pagination(new ChapterOrderTransformer(), $chapter_order);
  489. }
  490. /**
  491. * @apiVersion 1.0.0
  492. * @apiDescription 充值记录
  493. * @api {get} order/chargeRecordLists 充值记录
  494. * @apiGroup Order
  495. * @apiName chargeRecordLists
  496. * @apiSuccess {int} code 状态码
  497. * @apiSuccess {String} msg 信息
  498. * @apiSuccess {object} data 结果集
  499. * @apiSuccess {String} data.price 价格
  500. * @apiSuccess {String} data.status 状态
  501. * @apiSuccess {String} data.trade_no 订单号
  502. * @apiSuccess {String} data.created_at 时间
  503. * @apiSuccessExample {json} Success-Response:
  504. * HTTP/1.1 200 OK
  505. * {
  506. * code: 0,
  507. * msg: "",
  508. * data: {
  509. * list: [
  510. * {
  511. * id: 134,
  512. * price: "1.00",
  513. * status: "PAID",
  514. * trade_no: "201712021915481585670623626232",
  515. * created_at: "2017-12-02 19:15:56"
  516. * }
  517. * ],
  518. * meta: {
  519. * total: 1,
  520. * per_page: 15,
  521. * current_page: 1,
  522. * last_page: 1,
  523. * next_page_url: "",
  524. * prev_page_url: ""
  525. * }
  526. * }
  527. * }
  528. */
  529. public function chargeRecordLists(Request $request)
  530. {
  531. $page_size = $request->input('page_size', 15);
  532. $res = OrderService::getOrderList($this->uid, $page_size);
  533. return response()->pagination(new ChargeListTransformer(), $res);
  534. }
  535. //订单是否成功
  536. public function isSuccess(Request $request)
  537. {
  538. $order = $request->input('order');
  539. $order_info = OrderService::getByTradeNo($order);
  540. if ($order_info && $order_info->status == 'PAID') {
  541. return response()->success();
  542. }
  543. return response()->error('WAP_SYS_ERROR');
  544. }
  545. public function substitutePay(Request $request)
  546. {
  547. if (!$this->checkUid()) {
  548. return response()->error('WAP_NOT_LOGIN');
  549. }
  550. $product_id = $request->get('product_id');
  551. SubstituteOrderService::substituteButtonUvPv($this->uid, $this->distribution_channel_id);
  552. $user = $this->_user_info;
  553. $data = [
  554. 'head_img' => '',
  555. 'nickname' => $user->nickname
  556. ];
  557. //$help_pay_page_channel_id = env('HELP_PAY_PAGE_CHANNEL_ID', 123);
  558. $help_pay_page_channel_id = $this->distribution_channel_id;
  559. $url_format = '%s://site%s.%s.com/helppay?%s';
  560. $param = [];
  561. $param['su'] = $this->uid;
  562. if ($product_id) {
  563. $param['product_id'] = $product_id;
  564. }
  565. $help_pay_page = sprintf(
  566. $url_format,
  567. env('PROTOCOL'),
  568. encodeDistributionChannelId($help_pay_page_channel_id),
  569. env('CUSTOM_HOST'),
  570. http_build_query($param)
  571. );
  572. $data['help_pay_page'] = $help_pay_page;
  573. return response()->success($data);
  574. }
  575. private function recordFirstIntoPayPage($bid)
  576. {
  577. $start_time = env('RECORD_FIRST_VISIT_PAY_PAGE_TIME');
  578. $template_id = 0;
  579. if (in_array($this->distribution_channel_id,[123,211]) && $start_time && $this->uid) {
  580. $user = $this->_user_info;
  581. if (strtotime($user->created_at) > $start_time) {
  582. $old = DB::table('user_first_visit_pay_page')->where('uid', $this->uid)->select('uid', 'template_type')->first();
  583. if ($old) {
  584. $template_id = $old->template_type;
  585. if($template_id) return $template_id;
  586. }
  587. if ($bid && $bid == 1148) {
  588. $template_id = $this->uid % 2 == 0 ? 2 : 1;
  589. if (empty($old)) {
  590. try {
  591. DB::table('user_first_visit_pay_page')->insert([
  592. 'uid' => $this->uid,
  593. 'template_type' => $template_id,
  594. 'created_at' => date('Y-m-d H:i:s'),
  595. 'updated_at' => date('Y-m-d H:i:s')
  596. ]);
  597. } catch (\Exception $e) {
  598. }
  599. }
  600. }
  601. }
  602. }
  603. return $template_id;
  604. }
  605. private function templateCompare(){
  606. //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])){
  607. /*$start_time = env('TEMPLATE_COMPARE_START_TIME_3',0);
  608. if(!$start_time){
  609. return 0;
  610. }*/
  611. 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])){
  612. return 0;
  613. }
  614. //$user = $this->_user_info;
  615. /*if(strtotime($user->created_at) < $start_time){
  616. return 0;
  617. }*/
  618. $template_id = 0;
  619. $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPARE_V3');
  620. if($user){
  621. $template_id = $user->attach;
  622. }
  623. return $template_id;
  624. }
  625. private function templateCompareV2(){
  626. $start_time = env('TEMPLATE_COMPARE_START_TIME',0);
  627. if(!$start_time){
  628. return 0;
  629. }
  630. if(!in_array($this->distribution_channel_id,[2,146 ,155 ,255 ,256 ,691 ,722 ,4364 ,695 ,4174 ,4025 ,4593 ,4426 ,4742 ,4053 ,4334 ,4487])){
  631. return 0;
  632. }
  633. $user = $this->_user_info;
  634. if(strtotime($user->created_at) < $start_time){
  635. return 0;
  636. }
  637. $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPAREV2');
  638. if($user){
  639. $template_id = $user->attach;
  640. }else{
  641. $template_id = $this->uid % 2 == 0? 1:6;
  642. DataAnalysisSelectUserService::create(
  643. $this->uid,
  644. $this->distribution_channel_id,
  645. 'TEMPLATE_COMPAREV2',
  646. -1, $template_id);
  647. }
  648. return $template_id;
  649. }
  650. private function maleSite($distribution_channel_id){
  651. $info = ChannelService::getChannelCompanyInfo($distribution_channel_id);
  652. //\Log::info('maleSite info is:');
  653. //\Log::info($info);
  654. if($info && isset($info->fans_gender)){
  655. if($info->fans_gender == 1){
  656. return 1;
  657. }
  658. }
  659. return 0;
  660. }
  661. private function appad(){
  662. if(!$this->force_subscribe_info){
  663. $this->force_subscribe_info = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  664. }
  665. if(!$this->force_subscribe_info){
  666. return ['appad'=>false,'appad_banner'=>'','appad_url'=>''];
  667. }
  668. if($this->force_subscribe_info->subscribe_time &&
  669. (time()-strtotime($this->force_subscribe_info->subscribe_time) >=3*86400)
  670. && !OrderService::isPaidUser($this->uid) &&
  671. !AdvertiseUserQueueService::getUserAdvertise($this->uid) &&
  672. $this->distribution_channel_id=211
  673. ){
  674. return 1;
  675. }
  676. return 0;
  677. }
  678. }