BookTest.php 26 KB

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