OrdersController.php 25 KB

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