BookTest.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Jobs\SendTexts;
  4. use App\Modules\Book\Services\BookSubscribleChapterService;
  5. use App\Modules\Product\Services\ProductService;
  6. use App\Modules\Subscribe\Services\ChapterOrderService;
  7. use App\Modules\User\Services\ReadRecordService;
  8. use App\Modules\User\Services\UserService;
  9. use App\Modules\YunQi\Models\BookUser;
  10. use App\Modules\YunQi\Models\YqUserBidRelation;
  11. use App\Modules\YunQi\Models\YqZsyTest;
  12. use App\Modules\YunQi\Services\YqZsyTestService;
  13. use GuzzleHttp\Client;
  14. use Illuminate\Console\Command;
  15. use Log;
  16. use DB;
  17. use Redis;
  18. use App\Modules\Book\Models\Book;
  19. use App\Modules\Book\Models\Chapter;
  20. use App\Modules\SendOrder\Models\SendOrder;
  21. use App\Modules\SendOrder\Services\SendOrderService;
  22. use App\Modules\Subscribe\Models\Order;
  23. use App\Jobs\SendStatisticsList;
  24. use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
  25. use App\Modules\User\Services\UserSignService;
  26. use App\Modules\Book\Models\BookUvStat;
  27. use App\Modules\Subscribe\Models\ChapterOrder;
  28. class BookTest extends Command
  29. {
  30. /**
  31. * The name and signature of the console command.
  32. *
  33. * @var string
  34. */
  35. protected $signature = 'book:test
  36. {--bid= : the id of a book}';
  37. /**
  38. * The console command description.
  39. *
  40. * @var string
  41. */
  42. protected $client;
  43. protected $description = 'Command description';
  44. /**
  45. * Create a new command instance.
  46. *
  47. * @return void
  48. */
  49. public function __construct()
  50. {
  51. parent::__construct();
  52. $this->client = new Client(['timeout' => 8.0, 'allow_redirects' => true]);
  53. }
  54. /**
  55. * Execute the console command.
  56. *
  57. * @return mixed
  58. */
  59. public function handle()
  60. {
  61. //$this->data1();
  62. //$this->testTest();
  63. //$this->activity();
  64. //$this->testBookSmartPushStats();
  65. //$this->sendOrderStats105();
  66. //$this->you2();
  67. //$this->transfromUserOrder();
  68. $this->successPayPushMsg();
  69. }
  70. public function activity()
  71. {
  72. $res = \App\Modules\Activity\Services\ActivityService::ActivityStatsI(16);
  73. $str = "日期,site id,活动页面访问uv,按钮uv,生成订单数,成功支付订单数,首充用户数,点击阅读页面文字链uv,阅读页面文字链订单数,阅读页面文字链成功订单数,阅读页面文字链首充用户数,签到回调文字链uv,签到回调文字链生成订单数,签到回调文字链成功成功订单数,签到回调文字链首充用户数\r\n";
  74. $str = mb_convert_encoding($str, 'gbk');
  75. $file_name = date('Y-m-d') . '.csv';
  76. file_put_contents($file_name, $str);
  77. $temp = '';
  78. foreach ($res as $val) {
  79. $temp .= "{$val['day']},{$val['siteid']},{$val['uv']},{$val['button_uv']},{$val['order_num']},{$val['success_order_num']},{$val['first_charge_num']},{$val['reader_uv']},{$val['reader_order']},{$val['reader_success_order']},{$val['reader_first_charge']},{$val['signcallback_uv']},{$val['signcallback_order']},{$val['signcallback_success_order']},{$val['signcallback_first_charge']}\r\n";
  80. }
  81. file_put_contents($file_name, $temp, FILE_APPEND);
  82. }
  83. public function data1(){
  84. //1,图书uv
  85. $keys = Redis::SMEMBERS('book_before_five_uvs');
  86. if(!$keys){
  87. return 0;
  88. }
  89. $data = [];
  90. $book_name_arr = [];
  91. $i = 0;
  92. foreach ($keys as $k){
  93. $k_array = explode('_',$k);
  94. $uv = Redis::scard('book_before_five_uv_'.$k);
  95. if(isset($book_name_arr[$k_array[1]]) && !empty($book_name_arr[$k_array[1]])){
  96. $book_name = $book_name_arr[$k_array[1]];
  97. }else{
  98. $book_name_info = DB::table('book_configs')->where('bid',$k_array[1])->select('book_name')->first();
  99. if($book_name_info){
  100. $book_name_arr[$k_array[1]] = $book_name_info->book_name;
  101. $book_name = $book_name_info->book_name;
  102. }else{
  103. $book_name = '未知';
  104. }
  105. }
  106. $data[] = [
  107. 'bid'=>$k_array[1],
  108. 'day'=>$k_array[0],
  109. 'sequence'=>$k_array[2],
  110. 'book_name'=>$book_name,
  111. 'uv'=>$uv,
  112. 'created_at'=>date('Y-m-d H:i:s'),
  113. 'updated_at'=>date('Y-m-d H:i:s')
  114. ];
  115. $i++;
  116. if($i && $i%200 == 0){
  117. DB::table('book_five_chapter_uv')->insert($data);
  118. $data = [];
  119. }
  120. }
  121. DB::table('book_five_chapter_uv')->insert($data);
  122. }
  123. public function data2(){
  124. //强关
  125. $keys = Redis::SMEMBERS('subscribe_page_uv_send_order_ids');
  126. $data = [];
  127. $i = 0;
  128. foreach ($keys as $k){
  129. $subscribe_uv = Redis::scard('subscribe_page_uv'.$k);
  130. $data[] = [
  131. 'send_order_id'=>$k,
  132. 'subscribe_uv'=>$subscribe_uv,
  133. 'pay_uv'=>0,
  134. 'created_at'=>date('Y-m-d H:i:s'),
  135. 'updated_at'=>date('Y-m-d H:i:s')
  136. ];
  137. $i++;
  138. if($i && $i%200 == 0){
  139. DB::table('subscribe_pay_page_uv')->insert($data);
  140. $data = [];
  141. }
  142. }
  143. $keys = null;
  144. $k = null;
  145. DB::table('subscribe_pay_page_uv')->insert($data);
  146. $data = [];
  147. //支付
  148. $keys = Redis::SMEMBERS('pay_page_uv_send_order_ids');
  149. foreach ($keys as $v){
  150. $pay_uv = Redis::scard('pay_page_uv'.$v);
  151. $o = DB::table('subscribe_pay_page_uv')->where('send_order_id',$v)->first();
  152. if($o){
  153. DB::table('subscribe_pay_page_uv')->where('send_order_id',$v)->update([
  154. 'pay_uv'=>$pay_uv
  155. ]);
  156. }else{
  157. DB::table('subscribe_pay_page_uv')->insert([
  158. 'send_order_id'=>$v,
  159. 'subscribe_uv'=>0,
  160. 'pay_uv'=>$pay_uv,
  161. 'created_at'=>date('Y-m-d H:i:s'),
  162. 'updated_at'=>date('Y-m-d H:i:s')
  163. ]);
  164. }
  165. }
  166. }
  167. public function testTest(){
  168. $res = \App\Modules\Statistic\Services\WapVisitStatService::smartPushTestBookStats(6);
  169. echo \Hashids::encode(6).PHP_EOL;
  170. print_r($res);
  171. }
  172. private function testBookSmartPushStats(){
  173. $sql1 = 'TRUNCATE test_book_smart_push_stats';
  174. DB::update($sql1);
  175. $result = DB::table('book_configs')->whereIn('test_status',[1,2])->select('bid','vip_seq')->get();
  176. /*foreach ($result as $v){
  177. t($v->bid,$v->vip_seq);
  178. }*/
  179. function t($bid,$vip_seq){
  180. $data = [];
  181. $key1 = 'smartPushTestBookPayPageUv:bid:%s';
  182. $pay_page_uv = (int)(Redis::scard(sprintf($key1,$bid)));
  183. $key2 = 'smartPushTestBookPaidUv:bid:%s';
  184. $paid_num = (int)(Redis::scard(sprintf($key2,$bid)));
  185. $amount = Redis::Hget('smartPushTestBookPaidAmount',$bid);
  186. if(!$amount)
  187. $amount = 0;
  188. for ($i = 1;$i<=60;$i++){
  189. $key3 = 'smartPushTestBookChapterUv:bid:%s:seq:%s';
  190. $sequence_uv = (int)(Redis::scard(sprintf($key3,$bid,$i)));
  191. if(!$sequence_uv){
  192. continue;
  193. }
  194. $data[] = [
  195. 'bid'=>$bid,
  196. 'sequence'=>$i,
  197. 'sequence_uv'=>$sequence_uv,
  198. 'vip_sequence'=>$vip_seq,
  199. 'pay_page_uv'=>$pay_page_uv,
  200. 'paid_user_num'=>$paid_num,
  201. 'amount'=>$amount,
  202. 'created_at'=>date('Y-m-d H:i:s'),
  203. 'updated_at'=>date('Y-m-d H:i:s')
  204. ];
  205. }
  206. if($data){
  207. DB::table('test_book_smart_push_stats')->insert($data);
  208. }
  209. }
  210. foreach ($result as $v){
  211. t($v->bid,$v->vip_seq);
  212. }
  213. }
  214. private function sendOrderStats105(){
  215. $sql1 = 'TRUNCATE send_order_stats_105';
  216. DB::update($sql1);
  217. $send_order_ids = Redis::hgetall('sendOrderIdToBid');
  218. if(!$send_order_ids){
  219. return ;
  220. }
  221. function one(int $sendOrderId,int $time){
  222. $info = SendOrderService::getById($sendOrderId);
  223. if(!$info || !$info->book_id){
  224. return ;
  225. }
  226. $subscribe_chaper_seq = 0;
  227. if($info && $info->subscribe_chapter_seq){
  228. $subscribe_chaper_seq = $info->subscribe_chapter_seq;
  229. }
  230. if(!$subscribe_chaper_seq){
  231. $subscribe = BookSubscribleChapterService::getSubcribleChapter($info->book_id,$info->distribution_channel_id);
  232. if ($subscribe) {
  233. $subscribe_chaper_seq = (isset($subscribe->subscribe_chapter_id) && $subscribe->subscribe_chapter_id > 0) ? $subscribe->subscribe_chapter_id : 0;
  234. }
  235. }
  236. $key_1 = 'accurateSendOrderSubscribePageUv:bid:%s:sendorderid:'.$sendOrderId;
  237. //强关页面uv
  238. $subscribe_uv = (int)(Redis::scard(sprintf($key_1,$info->book_id)));
  239. $key_2 = 'accurateSendOrderPayPageUv:bid:%s:send_order_id:'.$sendOrderId;
  240. //付费页面UV
  241. $pay_page_uv = (int)(Redis::scard(sprintf($key_2,$info->book_id)));
  242. //强关数
  243. $subscribe_num = DB::table('force_subscribe_users')
  244. ->where('send_order_id',$sendOrderId)
  245. ->where('bid',$info->book_id)
  246. ->where('created_at','>=',date('Y-m-d H:i:s',$time))
  247. ->count();
  248. $paid_user_num = DB::table('orders')
  249. ->where('send_order_id',$sendOrderId)
  250. ->where('from_bid',$info->book_id)
  251. ->where('status','PAID')
  252. ->where('created_at','>=',date('Y-m-d H:i:s',$time))
  253. ->count();
  254. $book_info = DB::table('book_configs')->where('bid',$info->book_id)->select('book_name','force_subscribe_chapter_seq','vip_seq')->first();
  255. $send_order_chapter_sequence_info = DB::table('chapters')->where('id',$info->chapter_id)->select('sequence')->first();
  256. $send_order_chapter_sequence = 0;
  257. if($send_order_chapter_sequence_info && $send_order_chapter_sequence_info->sequence){
  258. $send_order_chapter_sequence = $send_order_chapter_sequence_info->sequence;
  259. }
  260. if(!$subscribe_chaper_seq){
  261. $subscribe_chaper_seq = $book_info->force_subscribe_chapter_seq;
  262. }
  263. $vip_seq = 0;
  264. $vip_seq_info = Chapter::where('bid',$info->book_id)->where('is_vip',1)->orderBy('sequence')->select('sequence')->first();
  265. if($vip_seq_info){
  266. $vip_seq = $vip_seq_info->sequence;
  267. }
  268. $data = [];
  269. for ($i = 1;$i<=30;$i++){
  270. $key_3 = 'accurateSendOrderChapterUv:bid:%s:seq:%s:sendorderid:'.$sendOrderId;
  271. $chapter_seq_uv = (int)(Redis::scard(sprintf($key_3,$info->book_id,$i)));
  272. if(!$chapter_seq_uv){
  273. continue;
  274. }
  275. $data[] = [
  276. 'send_order_id'=>$sendOrderId,
  277. 'send_order_chapter_seq'=>$send_order_chapter_sequence,
  278. 'bid'=>$info->book_id,
  279. 'book_name'=>$book_info->book_name,
  280. 'chaper_sequence'=>$i,
  281. 'chapter_uv'=>$chapter_seq_uv,
  282. 'subscribe_chaper_seq'=>$subscribe_chaper_seq,
  283. 'subscribe_page_uv'=>$subscribe_uv,
  284. 'subscribe_user_num'=>$subscribe_num,
  285. 'vip_chapter_sequence'=>$vip_seq,
  286. 'pay_page_uv'=>$pay_page_uv,
  287. 'paid_user_num'=>$paid_user_num,
  288. 'created_at'=>date('Y-m-d H:i:s'),
  289. 'updated_at'=>date('Y-m-d H:i:s')
  290. ];
  291. }
  292. if($data){
  293. DB::table('send_order_stats_105')->insert($data);
  294. }
  295. }
  296. foreach ($send_order_ids as $send_order_id=> $v){
  297. $array = explode('-',$v);
  298. if(count($array) == 2){
  299. one($send_order_id,$array[1]);
  300. }
  301. }
  302. }
  303. private function you2(){
  304. $sql1 = 'TRUNCATE yq_stats2';
  305. DB::update($sql1);
  306. $info = BookUser::where('type','ENABLE')->select('bid','uid','type','updated_at')
  307. ->orderBy('updated_at')->limit(1500)->get();
  308. $info2 = BookUser::where('type','GROUP_1')
  309. ->select('bid','uid','type','updated_at')->orderBy('updated_at')->limit(1500)->get();
  310. $this->you2Type($info,'GROUP_2');
  311. $this->you2Type($info2,'GROUP_1');
  312. }
  313. private function you2Type($info,$type){
  314. $result = [];
  315. $chapter_model = new ChapterOrder();
  316. foreach ($info as $item){
  317. $to_bids = YqUserBidRelation::where('uid',$item->uid)->where('to_bid','>',0)->select('to_bid','created_at')->get();
  318. $from_bids = YqUserBidRelation::where('uid',$item->uid)->where('from_bid','>',0)->select('from_bid','created_at')->get();
  319. $chapter_model->setCurrentTable($item->uid);
  320. if($to_bids){
  321. foreach ($to_bids as $v){
  322. $to_bid = $v->to_bid;
  323. $time = $v->created_at->format('Y-m-d H:i:s');
  324. $end_time = date('Y-m-d H:i:s',strtotime($time)+2*86400);
  325. if(!$to_bid) continue;
  326. $fee = $chapter_model->where('uid',$item->uid)
  327. ->where('bid',$to_bid)
  328. ->where('created_at','>=',$time)
  329. ->where('created_at','<=',$end_time)
  330. ->sum('fee');
  331. $amount = Order::where('uid',$item->uid)
  332. ->where('from_bid',$to_bid)
  333. ->where('created_at','>=',$time)
  334. ->where('created_at','<=',$end_time)
  335. ->where('status','PAID')
  336. ->sum('price');
  337. $result[] = [
  338. 'bid'=>$to_bid,
  339. 'uid'=>$item->uid,
  340. 'fee'=>$fee,
  341. 'amount'=>$amount,
  342. 'start_time'=>$time,
  343. 'type'=>'to',
  344. 'group'=>$type,
  345. 'created_at'=>date('Y-m-d H:i:s'),
  346. 'updated_at'=>date('Y-m-d H:i:s')
  347. ];
  348. }
  349. if($result){
  350. DB::table('yq_stats2')->insert($result);
  351. $result = [];
  352. }
  353. }
  354. $to_bid = null;
  355. if($from_bids){
  356. foreach ($from_bids as $from_bid){
  357. $bid = $from_bid->from_bid;
  358. $test = YqZsyTestService::getByBid($bid);
  359. if($test) continue;
  360. $time = $from_bid->created_at->format('Y-m-d H:i:s');
  361. $end_time = date('Y-m-d H:i:s',strtotime($time)+2*86400);
  362. $fee = $chapter_model->where('uid',$item->uid)
  363. ->where('bid',$bid)
  364. ->where('created_at','>=',$time)
  365. ->where('created_at','<=',$end_time)
  366. ->sum('fee');
  367. $amount = Order::where('uid',$item->uid)
  368. ->where('from_bid',$bid)
  369. ->where('created_at','>=',$time)
  370. ->where('created_at','<=',$end_time)
  371. ->where('status','PAID')
  372. ->sum('price');
  373. $result[] = [
  374. 'bid'=>$bid,
  375. 'uid'=>$item->uid,
  376. 'fee'=>$fee,
  377. 'amount'=>$amount,
  378. 'start_time'=>$time,
  379. 'type'=>'from',
  380. 'group'=>$type,
  381. 'created_at'=>date('Y-m-d H:i:s'),
  382. 'updated_at'=>date('Y-m-d H:i:s')
  383. ];
  384. }
  385. if($result){
  386. DB::table('yq_stats2')->insert($result);
  387. $result = [];
  388. }
  389. }
  390. }
  391. }
  392. private function transfromUserOrder(){
  393. $user = DB::table('users')
  394. ->where('distribution_channel_id',4815)
  395. ->where('created_at','>=','2019-01-31 15:00:00')
  396. ->select('openid','id')
  397. ->get();
  398. $chapter_model = new ChapterOrder();
  399. foreach ($user as $v){
  400. Log::info('now user is :');
  401. Log::info('openid is: '.$v->openid.',old uid is :'.$v->id);
  402. $froce_user = DB::table('force_subscribe_users')
  403. ->where('openid',$v->openid)
  404. ->where('distribution_channel_id',384)
  405. ->select('uid')
  406. ->first();
  407. if(!$froce_user){
  408. continue;
  409. }
  410. Log::info('$froce_user user is :');
  411. Log::info('$froce_user is: '.$froce_user->uid);
  412. if($froce_user && $froce_user->uid != $v->id){
  413. $chapter_model->setCurrentTable($froce_user->uid);
  414. $data = [];
  415. //章节订购
  416. $chapter_order_info = $chapter_model->where('uid',$froce_user->uid)->get();
  417. Log::info('$chapter_order_info user is :');
  418. Log::info($chapter_order_info);
  419. if($chapter_order_info){
  420. foreach ($chapter_order_info as $chapter_order_item){
  421. $data = [
  422. 'distribution_channel_id'=>4815,
  423. 'bid'=>$chapter_order_item->bid,
  424. 'cid'=>$chapter_order_item->cid,
  425. 'chapter_name'=>$chapter_order_item->chapter_name,
  426. 'book_name'=>$chapter_order_item->book_name,
  427. 'uid'=>$v->id,
  428. 'send_order_id'=>0,
  429. 'fee'=>0,
  430. 'created_at'=>$chapter_order_item->created_at,
  431. 'updated_at'=>date('Y-m-d H:i:s'),
  432. 'charge_balance'=>0,
  433. 'reward_balance'=>0
  434. ];
  435. $chapter_model->setCurrentTable($v->id);
  436. $old = $chapter_model->where('uid',$v->id)
  437. ->where('bid',$chapter_order_item->bid)
  438. ->where('cid',$chapter_order_item->cid)
  439. ->select('id')->first();
  440. if(!$old){
  441. $chapter_model->insert($data);
  442. }
  443. }
  444. }
  445. /*if($data){
  446. Log::info('$chapter_order_info user $data is :');
  447. Log::info($data);
  448. $chapter_model->setCurrentTable($v->id);
  449. $chapter_model->insert($data);
  450. }*/
  451. //单本订购
  452. if($froce_user && $froce_user->uid != $v->id){
  453. $book_order_data = [];
  454. $book_orders = DB::table('book_orders')->where('uid',$froce_user->uid)->get();
  455. Log::info('$book_orders user is :');
  456. if($book_orders){
  457. foreach ($book_orders as $book_order_item){
  458. $book_order_data[] = [
  459. 'uid'=>$v->id,
  460. 'distribution_channel_id'=>4815,
  461. 'bid'=>$book_order_item->bid,
  462. 'book_name'=>$book_order_item->book_name,
  463. 'u'=>$book_order_item->u,
  464. 'send_order_id'=>0,
  465. 'charge_balance'=>0,
  466. 'reward_balance'=>0,
  467. 'fee'=>0,
  468. 'created_at'=>$book_order_item->created_at,
  469. 'updated_at'=>date('Y-m-d H:i:s'),
  470. ];
  471. }
  472. }
  473. if($book_order_data){
  474. Log::info('$book_order_data user is :');
  475. Log::info($book_order_data);
  476. foreach ($book_order_data as $book_o ){
  477. $old = DB::table('book_orders')
  478. ->where('uid',$book_o['uid'])
  479. ->where('bid',$book_o['bid'])
  480. ->select('id')->first();
  481. if(!$old){
  482. DB::table('book_orders')->insert($book_order_data);
  483. }
  484. }
  485. }
  486. }
  487. //阅读记录
  488. $read_bids = Redis::hgetall('book_read:' . $froce_user->uid);
  489. Log::info('$read_bids is :');
  490. Log::info($read_bids);
  491. if ($read_bids){
  492. foreach ($read_bids as $key=>$field){
  493. Redis::hset('book_read:' . $v->id,$key,$field);
  494. }
  495. }
  496. //用户信息
  497. $old_user = DB::table('users')->where('id', $froce_user->uid)->first();
  498. if($old_user){
  499. DB::table('users')->where('id',$v->id)->update([
  500. 'balance'=>$old_user->balance,
  501. 'charge_balance'=>$old_user->charge_balance,
  502. 'reward_balance'=>$old_user->reward_balance,
  503. ]);
  504. }
  505. //年费
  506. $year = DB::table('year_orders')->where('uid',$froce_user->uid)->orderBy('id','desc')->first();
  507. if($year){
  508. $old_year = DB::table('year_orders')->where('uid',$v->id)->orderBy('id','desc')->first();
  509. if(!$old_year){
  510. DB::table('year_orders')->insert([[
  511. 'uid'=>$v->id,
  512. 'begin_time'=>$year->begin_time,
  513. 'end_time'=>$year->end_time,
  514. 'distribution_channel_id'=>4815,
  515. 'created_at'=>$year->created_at,
  516. 'updated_at'=>date('Y-m-d H:i:s'),
  517. 'fee'=>0,
  518. ]]);
  519. }
  520. }
  521. }
  522. }
  523. }
  524. protected function successPayPushMsg()
  525. {
  526. try {
  527. $uid = 10008;
  528. $order_id = 10910163;
  529. $product_info = ProductService::getProductSingle(2);
  530. $force_sub_info = DB::table('force_subscribe_users')->where('uid',$uid)->where('is_subscribed', 1)->get();
  531. $data = UserService::getById($uid);
  532. if (!in_array($data->distribution_channel_id, [5, 123])) {
  533. //return false;
  534. }
  535. if ($force_sub_info) {
  536. //$content_format = "您好,你已经成功充值\r\n\r\n会员:%s\r\n会员ID:%s\r\n充值金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
  537. if (SubstituteOrderService::getByOrderId($order_id)) {
  538. $content_format = "代充值客服消息:\r\n\r\n你好,您的好友为你代付成功\r\n会员:%s\r\n会员ID:%s\r\n代付金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
  539. } else {
  540. $content_format = "您好,你已经成功充值\r\n\r\n会员:%s\r\n会员ID:%s\r\n充值金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
  541. }
  542. if ($product_info->type == 'YEAR_ORDER') {
  543. $money_text = $product_info->price . '元(尊贵的年费VIP会员)';
  544. } elseif ($product_info->type == 'TICKET_RECHARGE') {
  545. if ($product_info->given) {
  546. $money_text = $product_info->price . '元(' . ($product_info->price * 100) . '书币+赠送' . $product_info->given . '书币)';
  547. } else {
  548. $money_text = $product_info->price . '元(' . ($product_info->price * 100) . '书币)';
  549. }
  550. } else {
  551. $money_text = '未知';
  552. }
  553. $delay = 0;
  554. $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($data->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/continue';;
  555. $content = sprintf($content_format, $data->nickname ? $data->nickname : '匿名', $uid, $money_text, $url);
  556. foreach ($force_sub_info as $item){
  557. $res['openid'] = $item->openid;
  558. $res['appid'] = $item->appid;
  559. $res['content'] = $content;
  560. $res['type'] = 'one_task';
  561. $res['send_time'] = date("Y-m-d H:i:s");
  562. $res['task_id'] = md5('pay_success_push');
  563. $send_data = array(
  564. 'send_time' => date("Y-m-d H:i:s"),
  565. 'data' => $res
  566. );
  567. Log::info($send_data);
  568. dispatch((new SendTexts($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('send_texts_list'));
  569. }
  570. }
  571. } catch (\Exception $e) {
  572. Log::info('pay_success_push error');
  573. Log::info($e);
  574. }
  575. return true;
  576. }
  577. }