OrdersController.php 26 KB

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