Wang Chen 4 年之前
父节点
当前提交
843c11d85d

+ 16 - 671
app/Console/Commands/BookTest.php

@@ -2,35 +2,11 @@
 
 
 namespace App\Console\Commands;
 namespace App\Console\Commands;
 
 
-use App\Jobs\SendTexts;
-use App\Modules\Book\Services\BookSubscribleChapterService;
-use App\Modules\Product\Services\ProductService;
-use App\Modules\Subscribe\Services\ChapterOrderService;
-use App\Modules\Subscribe\Services\SubstituteOrderService;
-use App\Modules\User\Services\ReadRecordService;
-use App\Modules\User\Services\UserDivisionCpcPropertyService;
-use App\Modules\User\Services\UserService;
-use App\Modules\YunQi\Models\BookUser;
-use App\Modules\YunQi\Models\YqUserBidRelation;
-use App\Modules\YunQi\Models\YqZsyTest;
-use App\Modules\YunQi\Services\YqZsyTestService;
-use GuzzleHttp\Client;
+use App\Jobs\QappTikTokUser;
+use App\Jobs\QappTikTokUserCharge;
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
-
-use Log;
-use DB;
-use Redis;
-use App\Modules\Book\Models\Book;
-use App\Modules\Book\Models\Chapter;
-use App\Modules\SendOrder\Models\SendOrder;
-use App\Modules\SendOrder\Services\SendOrderService;
-use App\Modules\Subscribe\Models\Order;
-use App\Jobs\SendStatisticsList;
-use App\Jobs\UserAddDeskJob;
-use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
-use App\Modules\User\Services\UserSignService;
-use App\Modules\Book\Models\BookUvStat;
-use App\Modules\Subscribe\Models\ChapterOrder;
+use App\Modules\User\Models\QappUser;
+use App\Modules\User\Models\User;
 
 
 class BookTest extends Command
 class BookTest extends Command
 {
 {
@@ -39,8 +15,7 @@ class BookTest extends Command
      *
      *
      * @var string
      * @var string
      */
      */
-    protected $signature = 'book:test
-                                {--bid= : the id of a book}';
+    protected $signature = 'test';
 
 
     /**
     /**
      * The console command description.
      * The console command description.
@@ -58,7 +33,6 @@ class BookTest extends Command
     public function __construct()
     public function __construct()
     {
     {
         parent::__construct();
         parent::__construct();
-        $this->client = new Client(['timeout' => 8.0, 'allow_redirects' => true]);
     }
     }
 
 
     /**
     /**
@@ -68,650 +42,21 @@ class BookTest extends Command
      */
      */
     public function handle()
     public function handle()
     {
     {
-        //$this->data1();
-        //$this->testTest();
-        //$this->activity();
-        //$this->testBookSmartPushStats();
-        //$this->sendOrderStats105();
-        //$this->you2();
-        //$this->transfromUserOrder();
-        //$this->clearUserReadRecord();
-        //$this->deleteToLongReadRecord();
-        // $this->clearUserReadRecord();
-        $job = new UserAddDeskJob(205384691);
-        $job->handle();
-    }
-
-
-    public function activity()
-    {
-        $res = \App\Modules\Activity\Services\ActivityService::ActivityStatsI(16);
-        $str = "日期,site id,活动页面访问uv,按钮uv,生成订单数,成功支付订单数,首充用户数,点击阅读页面文字链uv,阅读页面文字链订单数,阅读页面文字链成功订单数,阅读页面文字链首充用户数,签到回调文字链uv,签到回调文字链生成订单数,签到回调文字链成功成功订单数,签到回调文字链首充用户数\r\n";
-        $str = mb_convert_encoding($str, 'gbk');
-        $file_name = date('Y-m-d') . '.csv';
-        file_put_contents($file_name, $str);
-        $temp = '';
-        foreach ($res as $val) {
-            $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";
-        }
-        file_put_contents($file_name, $temp, FILE_APPEND);
-    }
-
-    public function data1()
-    {
-        //1,图书uv
-        $keys = Redis::SMEMBERS('book_before_five_uvs');
-        if (!$keys) {
-            return 0;
-        }
-        $data = [];
-        $book_name_arr = [];
-        $i = 0;
-        foreach ($keys as $k) {
-            $k_array = explode('_', $k);
-            $uv = Redis::scard('book_before_five_uv_' . $k);
-            Redis::del('book_before_five_uv_' . $k);
-            if (isset($book_name_arr[$k_array[1]]) &&  !empty($book_name_arr[$k_array[1]])) {
-                $book_name = $book_name_arr[$k_array[1]];
-            } else {
-                $book_name_info = DB::table('book_configs')->where('bid', $k_array[1])->select('book_name')->first();
-                if ($book_name_info) {
-                    $book_name_arr[$k_array[1]] = $book_name_info->book_name;
-                    $book_name = $book_name_info->book_name;
-                } else {
-                    $book_name = '未知';
-                }
-            }
-
-            $data[] = [
-                'bid' => $k_array[1],
-                'day' => $k_array[0],
-                'sequence' => $k_array[2],
-                'book_name' => $book_name,
-                'uv' => $uv,
-                'created_at' => date('Y-m-d H:i:s'),
-                'updated_at' => date('Y-m-d H:i:s')
-            ];
-            $i++;
-            if ($i && $i % 200 == 0) {
-                DB::table('book_five_chapter_uv')->insert($data);
-                $data = [];
-            }
-        }
-        DB::table('book_five_chapter_uv')->insert($data);
-        Redis::del('book_before_five_uvs');
-    }
-
-    public function data2()
-    {
-        //强关
-        $keys = Redis::SMEMBERS('subscribe_page_uv_send_order_ids');
-        $data = [];
-        $i = 0;
-        foreach ($keys as $k) {
-            $subscribe_uv = Redis::scard('subscribe_page_uv' . $k);
-            Redis::del('subscribe_page_uv' . $k);
-            $data[] = [
-                'send_order_id' => $k,
-                'subscribe_uv' => $subscribe_uv,
-                'pay_uv' => 0,
-                'created_at' => date('Y-m-d H:i:s'),
-                'updated_at' => date('Y-m-d H:i:s')
-            ];
-            $i++;
-            if ($i && $i % 200 == 0) {
-                DB::table('subscribe_pay_page_uv')->insert($data);
-                $data = [];
-            }
-        }
-        $keys = null;
-        $k = null;
-        DB::table('subscribe_pay_page_uv')->insert($data);
-        $data = [];
-        //支付
-        $keys = Redis::SMEMBERS('pay_page_uv_send_order_ids');
-        foreach ($keys as $v) {
-            $pay_uv = Redis::scard('pay_page_uv' . $v);
-            Redis::del('pay_page_uv' . $v);
-            $o = DB::table('subscribe_pay_page_uv')->where('send_order_id', $v)->first();
-            if ($o) {
-                DB::table('subscribe_pay_page_uv')->where('send_order_id', $v)->update([
-                    'pay_uv' => $pay_uv
-                ]);
-            } else {
-                DB::table('subscribe_pay_page_uv')->insert([
-                    'send_order_id' => $v,
-                    'subscribe_uv' => 0,
-                    'pay_uv' => $pay_uv,
-                    'created_at' => date('Y-m-d H:i:s'),
-                    'updated_at' => date('Y-m-d H:i:s')
-                ]);
-            }
-        }
-        Redis::del('subscribe_page_uv_send_order_ids');
-        Redis::del('pay_page_uv_send_order_ids');
-    }
-
-    public function testTest()
-    {
-        $res = \App\Modules\Statistic\Services\WapVisitStatService::smartPushTestBookStats(6);
-        echo \Hashids::encode(6) . PHP_EOL;
-        print_r($res);
-    }
-
-    private function testBookChapterStats()
-    {
-
-        function t($bid, $vip_seq)
-        {
-            $data = [];
-            $key1 = 'smartPushTestBookPayPageUv:bid:%s';
-            $pay_page_uv = 0;
-
-            $key2 = 'smartPushTestBookPaidUv:bid:%s';
-            $paid_num = 0;
-
-            $amount = 0;
-
-            for ($i = 1; $i <= 60; $i++) {
-                $key3 = 'smartPushTestBookChapterUv:bid:%s:seq:%s';
-                $sequence_uv = (int)(Redis::scard(sprintf($key3, $bid, $i)));
-                if (!$sequence_uv) {
-                    continue;
-                }
-                $data[] = [
-                    'bid' => $bid,
-                    'sequence' => $i,
-                    'sequence_uv' => $sequence_uv,
-                    'vip_sequence' => $vip_seq,
-                    'pay_page_uv' => $pay_page_uv,
-                    'paid_user_num' => $paid_num,
-                    'amount' => $amount,
-                    'created_at' => date('Y-m-d H:i:s'),
-                    'updated_at' => date('Y-m-d H:i:s')
-                ];
-                //Redis::del($sequence_uv);
-            }
-            if ($data) {
-                DB::table('test_book_smart_push_stats20190709')->insert($data);
-            }
-        }
-        for ($i = 1; $i < 6539; $i++) {
-            t($i, 0);
-        }
-    }
-    private function testBookSmartPushStats()
-    {
-        $sql1 = 'TRUNCATE test_book_smart_push_stats';
-        DB::update($sql1);
-        $result = DB::table('book_configs')->whereIn('test_status', [1, 2])->select('bid', 'vip_seq')->get();
-        /*foreach ($result as $v){
-            t($v->bid,$v->vip_seq);
-        }*/
-        function t($bid, $vip_seq)
-        {
-            $data = [];
-            $key1 = 'smartPushTestBookPayPageUv:bid:%s';
-            $pay_page_uv = (int)(Redis::scard(sprintf($key1, $bid)));
-
-            $key2 = 'smartPushTestBookPaidUv:bid:%s';
-            $paid_num = (int)(Redis::scard(sprintf($key2, $bid)));
-
-            $amount = Redis::Hget('smartPushTestBookPaidAmount', $bid);
-            if (!$amount)
-                $amount = 0;
-
-            for ($i = 1; $i <= 60; $i++) {
-                $key3 = 'smartPushTestBookChapterUv:bid:%s:seq:%s';
-                $sequence_uv = (int)(Redis::scard(sprintf($key3, $bid, $i)));
-                if (!$sequence_uv) {
-                    continue;
-                }
-                $data[] = [
-                    'bid' => $bid,
-                    'sequence' => $i,
-                    'sequence_uv' => $sequence_uv,
-                    'vip_sequence' => $vip_seq,
-                    'pay_page_uv' => $pay_page_uv,
-                    'paid_user_num' => $paid_num,
-                    'amount' => $amount,
-                    'created_at' => date('Y-m-d H:i:s'),
-                    'updated_at' => date('Y-m-d H:i:s')
-                ];
-            }
-            if ($data) {
-                DB::table('test_book_smart_push_stats')->insert($data);
-            }
-        }
-        foreach ($result as $v) {
-            t($v->bid, $v->vip_seq);
-        }
-    }
-
-    private function sendOrderStats105()
-    {
-        //$sql1 = 'TRUNCATE send_order_stats_105';
-        //DB::update($sql1);
-        $send_order_ids = Redis::hgetall('sendOrderIdToBid');
-        if (!$send_order_ids) {
-            return;
-        }
-
-        function one(int $sendOrderId, int $time)
-        {
-            $info = SendOrderService::getById($sendOrderId);
-            if (!$info || !$info->book_id) {
-                return;
-            }
-            $subscribe_chaper_seq = 0;
-            if ($info && $info->subscribe_chapter_seq) {
-                $subscribe_chaper_seq = $info->subscribe_chapter_seq;
-            }
-            if (!$subscribe_chaper_seq) {
-                $subscribe = BookSubscribleChapterService::getSubcribleChapter($info->book_id, $info->distribution_channel_id);
-                if ($subscribe) {
-                    $subscribe_chaper_seq =   (isset($subscribe->subscribe_chapter_id) && $subscribe->subscribe_chapter_id > 0) ? $subscribe->subscribe_chapter_id : 0;
-                }
-            }
-
-            $key_1 = 'accurateSendOrderSubscribePageUv:bid:%s:sendorderid:' . $sendOrderId;
-            //强关页面uv
-            $subscribe_uv = (int)(Redis::scard(sprintf($key_1, $info->book_id)));
-            Redis::del(sprintf($key_1, $info->book_id));
-            $key_2 = 'accurateSendOrderPayPageUv:bid:%s:send_order_id:' . $sendOrderId;
-            //付费页面UV
-            $pay_page_uv = (int)(Redis::scard(sprintf($key_2, $info->book_id)));
-
-            Redis::del(sprintf($key_2, $info->book_id));
-            //强关数
-            $subscribe_num = DB::table('force_subscribe_users')
-                ->where('send_order_id', $sendOrderId)
-                ->where('bid', $info->book_id)
-                ->where('created_at', '>=', date('Y-m-d H:i:s', $time))
-                ->count();
-
-            $paid_user_num = DB::table('orders')
-                ->where('send_order_id', $sendOrderId)
-                ->where('from_bid', $info->book_id)
-                ->where('status', 'PAID')
-                ->where('created_at', '>=', date('Y-m-d H:i:s', $time))
-                ->count();
-            $book_info = DB::table('book_configs')->where('bid', $info->book_id)->select('book_name', 'force_subscribe_chapter_seq', 'vip_seq')->first();
-            $send_order_chapter_sequence_info = DB::table('chapters')->where('id', $info->chapter_id)->select('sequence')->first();
-            $send_order_chapter_sequence = 0;
-            if ($send_order_chapter_sequence_info && $send_order_chapter_sequence_info->sequence) {
-                $send_order_chapter_sequence = $send_order_chapter_sequence_info->sequence;
-            }
-            if (!$subscribe_chaper_seq) {
-                if ($book_info) {
-                    $subscribe_chaper_seq = $book_info->force_subscribe_chapter_seq;
-                } else {
-                    $subscribe_chaper_seq = 0;
-                }
-            }
-            $vip_seq = 0;
-            $vip_seq_info = Chapter::where('bid', $info->book_id)->where('is_vip', 1)->orderBy('sequence')->select('sequence')->first();
-            if ($vip_seq_info) {
-                $vip_seq = $vip_seq_info->sequence;
-            }
-            $data = [];
-            for ($i = 1; $i <= 30; $i++) {
-                $key_3 = 'accurateSendOrderChapterUv:bid:%s:seq:%s:sendorderid:' . $sendOrderId;
-                $chapter_seq_uv = (int)(Redis::scard(sprintf($key_3, $info->book_id, $i)));
-
-                Redis::del(sprintf($key_3, $info->book_id, $i));
-                if (!$chapter_seq_uv) {
-                    continue;
-                }
-                /*$data[] = [
-                    'send_order_id'=>$sendOrderId,
-                    'send_order_chapter_seq'=>$send_order_chapter_sequence,
-                    'bid'=>$info->book_id,
-                    'book_name'=>$book_info?$book_info->book_name:'xx',
-                    'chaper_sequence'=>$i,
-                    'chapter_uv'=>$chapter_seq_uv,
-                    'subscribe_chaper_seq'=>$subscribe_chaper_seq,
-                    'subscribe_page_uv'=>$subscribe_uv,
-                    'subscribe_user_num'=>$subscribe_num,
-                    'vip_chapter_sequence'=>$vip_seq,
-                    'pay_page_uv'=>$pay_page_uv,
-                    'paid_user_num'=>$paid_user_num,
-                    'created_at'=>date('Y-m-d H:i:s'),
-                    'updated_at'=>date('Y-m-d H:i:s')
-                ];*/
-            }
-            if ($data) {
-                DB::table('send_order_stats_105')->insert($data);
-            }
-        }
-
-        foreach ($send_order_ids as $send_order_id => $v) {
-            $array = explode('-', $v);
-            if (count($array) == 2) {
-                one($send_order_id, $array[1]);
-            }
-        }
-
-        Redis::del('sendOrderIdToBid');
-    }
-
-    private function you2()
-    {
-        $sql1 = 'TRUNCATE yq_stats2';
-        DB::update($sql1);
-
-        $info = BookUser::where('type', 'ENABLE')->select('bid', 'uid', 'type', 'updated_at')
-            ->orderBy('updated_at')->limit(1500)->get();
-        $info2 = BookUser::where('type', 'GROUP_1')
-            ->select('bid', 'uid', 'type', 'updated_at')->orderBy('updated_at')->limit(1500)->get();
-        $this->you2Type($info, 'GROUP_2');
-        $this->you2Type($info2, 'GROUP_1');
-    }
-
-
-    private function you2Type($info, $type)
-    {
-        $result = [];
-        $chapter_model = new ChapterOrder();
-        foreach ($info as $item) {
-            $to_bids = YqUserBidRelation::where('uid', $item->uid)->where('to_bid', '>', 0)->select('to_bid', 'created_at')->get();
-            $from_bids = YqUserBidRelation::where('uid', $item->uid)->where('from_bid', '>', 0)->select('from_bid', 'created_at')->get();
-            $chapter_model->setCurrentTable($item->uid);
-            if ($to_bids) {
-                foreach ($to_bids as $v) {
-                    $to_bid = $v->to_bid;
-                    $time = $v->created_at->format('Y-m-d H:i:s');
-                    $end_time = date('Y-m-d H:i:s', strtotime($time) + 2 * 86400);
-                    if (!$to_bid) continue;
-                    $fee = $chapter_model->where('uid', $item->uid)
-                        ->where('bid', $to_bid)
-                        ->where('created_at', '>=', $time)
-                        ->where('created_at', '<=', $end_time)
-                        ->sum('fee');
-                    $amount = Order::where('uid', $item->uid)
-                        ->where('from_bid', $to_bid)
-                        ->where('created_at', '>=', $time)
-                        ->where('created_at', '<=', $end_time)
-                        ->where('status', 'PAID')
-                        ->sum('price');
-                    $result[] = [
-                        'bid' => $to_bid,
-                        'uid' => $item->uid,
-                        'fee' => $fee,
-                        'amount' => $amount,
-                        'start_time' => $time,
-                        'type' => 'to',
-                        'group' => $type,
-                        'created_at' => date('Y-m-d H:i:s'),
-                        'updated_at' => date('Y-m-d H:i:s')
-                    ];
-                }
-                if ($result) {
-                    DB::table('yq_stats2')->insert($result);
-                    $result = [];
-                }
-            }
-            $to_bid = null;
-            if ($from_bids) {
-                foreach ($from_bids as $from_bid) {
-                    $bid = $from_bid->from_bid;
-                    $test = YqZsyTestService::getByBid($bid);
-                    if ($test) continue;
-                    $time = $from_bid->created_at->format('Y-m-d H:i:s');
-                    $end_time = date('Y-m-d H:i:s', strtotime($time) + 2 * 86400);
-                    $fee = $chapter_model->where('uid', $item->uid)
-                        ->where('bid', $bid)
-                        ->where('created_at', '>=', $time)
-                        ->where('created_at', '<=', $end_time)
-                        ->sum('fee');
-                    $amount = Order::where('uid', $item->uid)
-                        ->where('from_bid', $bid)
-                        ->where('created_at', '>=', $time)
-                        ->where('created_at', '<=', $end_time)
-                        ->where('status', 'PAID')
-                        ->sum('price');
-                    $result[] = [
-                        'bid' => $bid,
-                        'uid' => $item->uid,
-                        'fee' => $fee,
-                        'amount' => $amount,
-                        'start_time' => $time,
-                        'type' => 'from',
-                        'group' => $type,
-                        'created_at' => date('Y-m-d H:i:s'),
-                        'updated_at' => date('Y-m-d H:i:s')
-                    ];
-                }
-                if ($result) {
-                    DB::table('yq_stats2')->insert($result);
-                    $result = [];
-                }
-            }
-        }
-    }
-
-    private function transfromUserOrder()
-    {
-        $user = DB::table('users')
-            ->where('distribution_channel_id', 4815)
-            ->where('created_at', '>=', '2019-01-31 15:00:00')
-            ->select('openid', 'id')
+        $users = QappUser::join('orders', 'orders.uid', 'qapp_users.uid')
+            ->where('qapp_users.created_at', '>=', '2020-08-01')
+            ->where('orders.created_at', '>=', '2020-08-01')
+            ->where('orders.status', 'PAID')
+            ->select('orders.uid', 'orders.price', 'orders.created_at')
             ->get();
             ->get();
-        $chapter_model = new ChapterOrder();
-        foreach ($user as $v) {
-            Log::info('now user is :');
-            Log::info('openid is: ' . $v->openid . ',old uid is :' . $v->id);
-            $froce_user = DB::table('force_subscribe_users')
-                ->where('openid', $v->openid)
-                ->where('distribution_channel_id', 384)
-                ->select('uid')
-                ->first();
-            if (!$froce_user) {
-                continue;
-            }
-            Log::info('$froce_user user is :');
-            Log::info('$froce_user is: ' . $froce_user->uid);
-
-            if ($froce_user && $froce_user->uid != $v->id) {
-                $chapter_model->setCurrentTable($froce_user->uid);
-                $data = [];
-                //章节订购
-                $chapter_order_info = $chapter_model->where('uid', $froce_user->uid)->get();
-                Log::info('$chapter_order_info user is :');
-                Log::info($chapter_order_info);
-                if ($chapter_order_info) {
-                    foreach ($chapter_order_info as $chapter_order_item) {
-                        $data = [
-                            'distribution_channel_id' => 4815,
-                            'bid' => $chapter_order_item->bid,
-                            'cid' => $chapter_order_item->cid,
-                            'chapter_name' => $chapter_order_item->chapter_name,
-                            'book_name' => $chapter_order_item->book_name,
-                            'uid' => $v->id,
-                            'send_order_id' => 0,
-                            'fee' => 0,
-                            'created_at' => $chapter_order_item->created_at,
-                            'updated_at' => date('Y-m-d H:i:s'),
-                            'charge_balance' => 0,
-                            'reward_balance' => 0
-                        ];
-                        $chapter_model->setCurrentTable($v->id);
-                        $old = $chapter_model->where('uid', $v->id)
-                            ->where('bid', $chapter_order_item->bid)
-                            ->where('cid', $chapter_order_item->cid)
-                            ->select('id')->first();
-                        if (!$old) {
-                            $chapter_model->insert($data);
-                        }
-                    }
-                }
-                /*if($data){
-                    Log::info('$chapter_order_info user $data is :');
-                    Log::info($data);
-                    $chapter_model->setCurrentTable($v->id);
-                    $chapter_model->insert($data);
-                }*/
-
-                //单本订购
-                if ($froce_user && $froce_user->uid != $v->id) {
-                    $book_order_data = [];
-                    $book_orders = DB::table('book_orders')->where('uid', $froce_user->uid)->get();
-                    Log::info('$book_orders user  is :');
-                    if ($book_orders) {
-                        foreach ($book_orders as $book_order_item) {
-                            $book_order_data[] = [
-                                'uid' => $v->id,
-                                'distribution_channel_id' => 4815,
-                                'bid' => $book_order_item->bid,
-                                'book_name' => $book_order_item->book_name,
-                                'u' => $book_order_item->u,
-                                'send_order_id' => 0,
-                                'charge_balance' => 0,
-                                'reward_balance' => 0,
-                                'fee' => 0,
-                                'created_at' => $book_order_item->created_at,
-                                'updated_at' => date('Y-m-d H:i:s'),
-                            ];
-                        }
-                    }
-                    if ($book_order_data) {
-                        Log::info('$book_order_data user  is :');
-                        Log::info($book_order_data);
-                        foreach ($book_order_data as $book_o) {
-                            $old = DB::table('book_orders')
-                                ->where('uid', $book_o['uid'])
-                                ->where('bid', $book_o['bid'])
-                                ->select('id')->first();
-                            if (!$old) {
-                                DB::table('book_orders')->insert($book_order_data);
-                            }
-                        }
-                    }
-                }
-
-
-                //阅读记录
-                $read_bids = Redis::hgetall('book_read:' . $froce_user->uid);
-
-                Log::info('$read_bids   is :');
-                Log::info($read_bids);
-
-                if ($read_bids) {
-                    foreach ($read_bids as  $key => $field) {
-                        Redis::hset('book_read:' . $v->id, $key, $field);
-                    }
-                }
-
-                //用户信息
-                $old_user = DB::table('users')->where('id', $froce_user->uid)->first();
-                if ($old_user) {
-                    DB::table('users')->where('id', $v->id)->update([
-                        'balance' => $old_user->balance,
-                        'charge_balance' => $old_user->charge_balance,
-                        'reward_balance' => $old_user->reward_balance,
-                    ]);
-                }
-
-                //年费
-                $year = DB::table('year_orders')->where('uid', $froce_user->uid)->orderBy('id', 'desc')->first();
-                if ($year) {
-                    $old_year = DB::table('year_orders')->where('uid', $v->id)->orderBy('id', 'desc')->first();
-                    if (!$old_year) {
-                        DB::table('year_orders')->insert([[
-                            'uid' => $v->id,
-                            'begin_time' => $year->begin_time,
-                            'end_time' => $year->end_time,
-                            'distribution_channel_id' => 4815,
-                            'created_at' => $year->created_at,
-                            'updated_at' => date('Y-m-d H:i:s'),
-                            'fee' => 0,
-                        ]]);
-                    }
-                }
-            }
-        }
-    }
-
-    private function clearUserReadRecord()
-    {
-        $i = 108655782;
-        //$not_uid_key = ['last_read','send_order_id','sign_count','sign_counts','sign_info','sign_day','smart_push','inner_send_order_id','gxhp','property','bind_phone_status','ua'];
-        $k = 0;
-        while ($i < 137406313) {
-            $i++;
-            $last_read = ReadRecordService::getByField($i, 'last_read');
-            if (!$last_read) {
-                $k++;
-                Redis::del('book_read:' . $i, 'userRecommendBids:' . $i);
-                continue;
-            }
-            $last_info = explode('_', $last_read);
-            if (!isset($last_info[2])) {
-                $k++;
-                Redis::del('book_read:' . $i, 'userRecommendBids:' . $i);
-            }
-            if ((time() - $last_info[2]) >= 2 * 30 * 86400) {
-                $record = Redis::hgetall('book_read:' . $i);
-                $data = [];
-
-                foreach ($record as $ks => $item) {
-                    $data[] = [
-                        'uid' => $i, 'field' => $ks, 'value' => $item,
-                        'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')
-                    ];
-                }
-                $k++;
-                Redis::del('book_read:' . $i, 'userRecommendBids:' . $i);
-                DB::table('read_record_from_redis')->insert($data);
-            }
-        }
-        echo 'delete ' . $k . ' keys' . PHP_EOL;
-    }
-
-    private function deleteToLongReadRecord()
-    {
-        $i = 10000;
-        ReadRecordService::delTheLastRecord(109861757);
-        while ($i <= 35600000) {
-            ReadRecordService::delTheLastRecord($i);
-            $i++;
+        foreach ($users as $user) {
+            $this->notify($user);
         }
         }
     }
     }
 
 
-    private function userPropertyV2()
+    private function notify($model)
     {
     {
-        $tmp = 0;
-        //19493455
-        while (true) {
-            $info = DB::table('orders')
-                ->select('id', 'uid', 'price', 'status')
-                ->where('id', '>', $tmp)
-                ->orderBy('id')
-                ->limit(1000)
-                ->get();
-            if ($info->isEmpty()) break;
-            foreach ($info as $item) {
-                if ($item->status != 'PAID') continue;
-                //$old = UserDivisionCpcPropertyService::getUserPropertyV2($item->uid);
-                //if($old) continue;
-                $property = UserDivisionCpcPropertyService::calculateUserPropertyV2($item->uid);
-                if ($property) {
-                    $info = UserDivisionCpcPropertyService::getUserPropertyV2($item->uid);
-                    if ($info == 'none') {
-                        DB::table('user_division_cpc_property_v2')->insert([
-                            'openid' => $property['openid'],
-                            'property' => $property['property'],
-                            'is_enable' => 1,
-                            'created_at' => date('Y-m-d H:i:s'),
-                            'updated_at' => date('Y-m-d H:i:s')
-                        ]);
-                    }
-                    if ($info == 'high') continue;
-                    UserDivisionCpcPropertyService::updateV2($property);
-                }
-            }
-            $tmp = $item->id;
-            if ($tmp >= 19493455) break;
-        }
+        $job = new QappTikTokUserCharge($model->uid, $model->price, $model->created_at, QappTikTokUserCharge::REGISTER_24_CHARGE, '', '');
+        print_r($model->toArray());
+        $job->handle();
     }
     }
 }
 }

+ 1 - 1
app/Console/Kernel.php

@@ -55,6 +55,6 @@ class Kernel extends ConsoleKernel
         });
         });
 
 
         // 推送任务每分钟执行
         // 推送任务每分钟执行
-        // $schedule->command('push:task')->everyMinute()->sendOutputTo(storage_path('pushCommand-' . date('Y-m-d')));
+        $schedule->command('push:task')->everyMinute()->sendOutputTo(storage_path('pushCommand-' . date('Y-m-d')));
     }
     }
 }
 }

+ 3 - 57
app/Http/Controllers/QuickApp/Book/BookCategoryController.php

@@ -5,65 +5,11 @@ namespace App\Http\Controllers\QuickApp\Book;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Controller;
 use App\Http\Controllers\Controller;
 use App\Modules\Book\Services\BookCategoryService;
 use App\Modules\Book\Services\BookCategoryService;
+
 class BookCategoryController extends Controller
 class BookCategoryController extends Controller
 {
 {
-    /**
-     * @apiDefine Book 图书
-     */
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 获取分类
-     * @api {get} books/getCategory  获取分类
-     * @apiParam {String}  [token]  token
-     * @apiHeader {String} [Authorization]  token 两个token任选其一
-     * @apiGroup Book
-     * @apiName getCategory
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:  [
-     *                   {
-     *                   id: 1,
-     *                   name: "男频",
-     *                   children: [
-     *                           {
-     *                               id: 7,
-     *                               name: "灵异鬼怪"
-     *                           },
-     *                           {
-     *                               id: 8,
-     *                               name: "历史穿越"
-     *                           },
-     *                           {
-     *                               id: 30,
-     *                               name: "青春爱情"
-     *                           }
-     *                       ]
-     *                   },
-     *                   {
-     *                   id: 2,
-     *                   name: "女频",
-     *                   children: [
-     *                           {
-     *                               id: 26,
-     *                               name: "豪门总裁"
-     *                           },
-     *                           {
-     *                               id: 35,
-     *                               name: "民国爱情"
-     *                           }
-     *                       ]
-     *                   }
-     *               ]
-     *       }
-     */
-    public function getCategory(Request $request){
+    public function getCategory(Request $request)
+    {
         $res = BookCategoryService::getCategory(true);
         $res = BookCategoryService::getCategory(true);
         return response()->success($res);
         return response()->success($res);
     }
     }

文件差异内容过多而无法显示
+ 26 - 511
app/Http/Controllers/QuickApp/Book/BookController.php


+ 9 - 233
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -28,73 +28,6 @@ class ChapterController extends BaseController
 
 
     private $book_info;
     private $book_info;
 
 
-    /**
-     * @apiDefine Chapter 章节
-     */
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节列表不分页
-     * @api {get} books/{bid}/allcatalog 章节列表不分页
-     * @apiParam {String}  [token]  token
-     * @apiHeader {String} [Authorization]  token 两个token任选其一
-     * @apiGroup Chapter
-     * @apiName getCatalog
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Array}       data.list 分页结果集
-     * @apiSuccess {Int}         data.list.bid   bid
-     * @apiSuccess {Int}         data.list.chapter_id   章节id
-     * @apiSuccess {String}      data.list.chapter_name   章节名称
-     * @apiSuccess {Int}         data.list.chapter_sequence   序号
-     * @apiSuccess {Int}         data.list.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.list.chapter_size   章节大小
-     * @apiSuccess {Int}         data.list.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.list.next_cid   下一章节
-     * @apiSuccess {String}      data.list.recent_update_at   更新时间
-     * @apiSuccess {Int}      data.list.is_need_charge  是否需要充值
-     * @apiSuccess {object}      data.meta   分页信息
-     * @apiSuccess {Int}         data.meta.total  总条数
-     * @apiSuccess {Int}         data.meta.per_page  每页条数
-     * @apiSuccess {Int}         data.meta.current_page 当前页
-     * @apiSuccess {Int}         data.meta.last_page  最后页
-     * @apiSuccess {String}      data.meta.next_page_url  下一页
-     * @apiSuccess {String}      data.meta.prev_page_url  上一页
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:
-     *            [
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_charge: 0,
-     *            },
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_charge: 0,
-     *            },
-     *          ]
-     *       }
-     */
     public function getCatalog(Request $request, $bid)
     public function getCatalog(Request $request, $bid)
     {
     {
         $bid = BookService::decodeBidStatic($bid);
         $bid = BookService::decodeBidStatic($bid);
@@ -107,79 +40,6 @@ class ChapterController extends BaseController
         return response()->collection(new ChapterListTransformer, $lists);
         return response()->collection(new ChapterListTransformer, $lists);
     }
     }
 
 
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节列表分页
-     * @api {get} books/{bid}/catalog 章节列表分页
-     * @apiParam {String}  [token]  token
-     * @apiHeader {String} [Authorization]  token 两个token任选其一
-     * @apiGroup Chapter
-     * @apiName getCatalogPerPage
-     * @apiParam   {Int}         page_size  分页大小(默认15)
-     * @apiParam   {Int}         page  页码(默认1)
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Array}       data.list 分页结果集
-     * @apiSuccess {Int}         data.list.bid   bid
-     * @apiSuccess {Int}         data.list.chapter_id   章节id
-     * @apiSuccess {String}      data.list.chapter_name   章节名称
-     * @apiSuccess {Int}         data.list.chapter_sequence   序号
-     * @apiSuccess {Int}         data.list.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.list.chapter_size   章节大小
-     * @apiSuccess {Int}         data.list.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.list.next_cid   下一章节
-     * @apiSuccess {String}      data.list.recent_update_at   更新时间
-     * @apiSuccess {Int}      data.list.is_need_charge  是否需要充值
-     * @apiSuccess {object}      data.meta   分页信息
-     * @apiSuccess {Int}         data.meta.total  总条数
-     * @apiSuccess {Int}         data.meta.per_page  每页条数
-     * @apiSuccess {Int}         data.meta.current_page 当前页
-     * @apiSuccess {Int}         data.meta.last_page  最后页
-     * @apiSuccess {String}      data.meta.next_page_url  下一页
-     * @apiSuccess {String}      data.meta.prev_page_url  上一页
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data:
-     *            list:[
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_charge: 0,
-     *            },
-     *             {
-     *               bid: 5,
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               is_need_charge: 0,
-     *            },
-     *          ]
-     *          meta:{
-     *              total: 1253,
-     *              per_page: 15,
-     *              current_page: 1,
-     *              last_page: 84,
-     *              next_page_url: "http://myapi.cn/api/books/1/chapter?page=2",
-     *              prev_page_url: ""
-     *         }
-     *       }
-     */
     public function getCatalogPerPage(Request $request, $bid)
     public function getCatalogPerPage(Request $request, $bid)
     {
     {
         $bid = BookService::decodeBidStatic($bid);
         $bid = BookService::decodeBidStatic($bid);
@@ -215,45 +75,6 @@ class ChapterController extends BaseController
         return $chapters;
         return $chapters;
     }
     }
 
 
-
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 章节内容
-     * @api {get} books/{bid}/chapters/{chapter_id} 章节内容
-     * @apiParam {String}  [token]  token
-     * @apiHeader {String} [Authorization]  token 两个token任选其一
-     * @apiGroup Chapter
-     * @apiName index
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.chapter_id   章节id
-     * @apiSuccess {String}      data.chapter_name   章节名称
-     * @apiSuccess {Int}         data.chapter_sequence   序号
-     * @apiSuccess {Int}         data.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.chapter_size   章节大小
-     * @apiSuccess {Int}         data.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.next_cid   下一章节
-     * @apiSuccess {String}      data.recent_update_at   更新时间
-     * @apiSuccess {String}      data.chapter_content  章节内容
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
-     *            }
-     *       }
-     */
     public function index(Request $request, $bid, $cid)
     public function index(Request $request, $bid, $cid)
     {
     {
         $oldbid = $bid;
         $oldbid = $bid;
@@ -346,45 +167,6 @@ class ChapterController extends BaseController
 
 
 
 
 
 
-    /**
-     * @apiVersion 1.0.0
-     * @apiDescription 余额支付
-     * @api {get} books/{bid}/balance/chapterOrders/{cid} 余额支付
-     * @apiParam {String}  [token]  token
-     * @apiHeader {String} [Authorization]  token 两个token任选其一
-     * @apiGroup Chapter
-     * @apiName pay
-     * @apiParam   (Int)         remind 提醒
-     * @apiSuccess {int}         code 状态码
-     * @apiSuccess {String}      msg  信息
-     * @apiSuccess {object}      data 结果集
-     * @apiSuccess {Int}         data.chapter_id   章节id
-     * @apiSuccess {String}      data.chapter_name   章节名称
-     * @apiSuccess {Int}         data.chapter_sequence   序号
-     * @apiSuccess {Int}         data.chapter_is_vip   是否vip
-     * @apiSuccess {Int}         data.chapter_size   章节大小
-     * @apiSuccess {Int}         data.prev_cid   上一章节id
-     * @apiSuccess {Int}         data.next_cid   下一章节
-     * @apiSuccess {String}      data.recent_update_at   更新时间
-     * @apiSuccess {String}      data.chapter_content  章节内容
-     * @apiSuccessExample {json} Success-Response:
-     *     HTTP/1.1 200 OK
-     *     {
-     *       code: 0,
-     *       msg: "",
-     *       data: {
-     *               chapter_id: 5,
-     *               chapter_name: "第1240章 不是我",
-     *               chapter_sequence: 1239,
-     *               chapter_is_vip: 1,
-     *               chapter_size: 2422,
-     *               prev_cid: 0,
-     *               next_cid: 0,
-     *               recent_update_at: 2017-11-20 15:01:56,
-     *               chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
-     *            }
-     *       }
-     */
     public function pay(Request $request, $bid, $cid)
     public function pay(Request $request, $bid, $cid)
     {
     {
         $remind = (int) $request->input('remind');
         $remind = (int) $request->input('remind');
@@ -480,7 +262,7 @@ class ChapterController extends BaseController
         $old = Redis::hget($key, $field);
         $old = Redis::hget($key, $field);
         if (!$old)  $old = 0;
         if (!$old)  $old = 0;
         Redis::hset($key, $field, $old + 1);
         Redis::hset($key, $field, $old + 1);
-        $force_add_desk_type = $this->addDesktopType($bid,$chapter->sequence);
+        $force_add_desk_type = $this->addDesktopType($bid, $chapter->sequence);
         $chapter->force_add_desk_type = $force_add_desk_type;
         $chapter->force_add_desk_type = $force_add_desk_type;
         //统计
         //统计
         $this->stats();
         $this->stats();
@@ -594,13 +376,6 @@ class ChapterController extends BaseController
      * @param $chapter_size
      * @param $chapter_size
      * @return float
      * @return float
      */
      */
-    /*protected function getPrice_($book_info, $chapter_size = 0)
-    {
-        if ($book_info->charge_type == 'BOOK')
-            return $book_info->price * 100;
-        return   ceil($chapter_size / 100);
-    }*/
-
     private function getPrice($book_info, $chapter_size = 0)
     private function getPrice($book_info, $chapter_size = 0)
     {
     {
         if ($book_info->charge_type == 'BOOK') {
         if ($book_info->charge_type == 'BOOK') {
@@ -690,18 +465,19 @@ class ChapterController extends BaseController
     }
     }
 
 
     //加桌类型
     //加桌类型
-    private function addDesktopType($bid,$sequence){
+    private function addDesktopType($bid, $sequence)
+    {
         $force_add_desk_type = 0;
         $force_add_desk_type = 0;
         $send_order_id = ReadRecordService::getSendOrderId($this->uid);
         $send_order_id = ReadRecordService::getSendOrderId($this->uid);
-        if(!$send_order_id) return $force_add_desk_type;
+        if (!$send_order_id) return $force_add_desk_type;
         $send_order_info = SendOrderService::getById($send_order_id);
         $send_order_info = SendOrderService::getById($send_order_id);
-        if(!$send_order_info)  return $force_add_desk_type;
-        if($send_order_info->book_id == $bid){
-            if($send_order_info->force_add_desk_type == 1 && $send_order_info->force_add_desk_type){
+        if (!$send_order_info)  return $force_add_desk_type;
+        if ($send_order_info->book_id == $bid) {
+            if ($send_order_info->force_add_desk_type == 1 && $send_order_info->force_add_desk_type) {
                 $force_add_desk_type = $send_order_info->force_add_desk_type;
                 $force_add_desk_type = $send_order_info->force_add_desk_type;
             }
             }
-            if($send_order_info->force_add_desk_type == 2){
-                if($sequence >= $this->book_info->force_subscribe_chapter_seq && $sequence<= $this->book_info->force_subscribe_chapter_seq+3){
+            if ($send_order_info->force_add_desk_type == 2) {
+                if ($sequence >= $this->book_info->force_subscribe_chapter_seq && $sequence <= $this->book_info->force_subscribe_chapter_seq + 3) {
                     $force_add_desk_type = $send_order_info->force_add_desk_type;
                     $force_add_desk_type = $send_order_info->force_add_desk_type;
                 }
                 }
             }
             }

+ 9 - 9
app/Http/Controllers/QuickApp/Book/Transformers/BookTransformer.php

@@ -25,13 +25,13 @@ class BookTransformer
             'book_category_id' => $book->category_id,
             'book_category_id' => $book->category_id,
             'book_category' => $book->category_name,
             'book_category' => $book->category_name,
             'book_end_status' => $book->status,
             'book_end_status' => $book->status,
-            'book_published_time' => is_null($book->updated_at) ? '' : $book->updated_at,
-            'copyright' => is_null($book->copyright) ? '' : $book->copyright,
-            'charge_type' => is_null($book->charge_type) ? '' : $book->charge_type,
+            'book_published_time' =>  $book->updated_at ?? '',
+            'copyright' =>  $book->copyright ?? '',
+            'charge_type' =>  $book->charge_type ?? '',
             'force_subscribe_chapter_id' => $book->force_subscribe_chapter_seq,
             'force_subscribe_chapter_id' => $book->force_subscribe_chapter_seq,
-            'update_time' => $book->updated_at,
-            'is_on_shelf' => $book->is_on_shelf,
-            'book_price' => is_null($book->price) ? 0 : $book->price,
+            'update_time' => $book->updated_at ?? '',
+            'is_on_shelf' => $book->is_on_shelf ?? 0,
+            'book_price' => $book->price ?? 0,
             'keyword' => $book->keyword,
             'keyword' => $book->keyword,
             'recommend_index' => $book->recommend_index,
             'recommend_index' => $book->recommend_index,
             'is_show_index_content' => $book->is_show_index_content,
             'is_show_index_content' => $book->is_show_index_content,
@@ -42,10 +42,10 @@ class BookTransformer
             'last_chapter' => $book->last_chapter,
             'last_chapter' => $book->last_chapter,
             'first_cid' => $book->first_cid,
             'first_cid' => $book->first_cid,
             'is_on_user_shelf' => $book->is_on_user_shelf,
             'is_on_user_shelf' => $book->is_on_user_shelf,
-            'last_chapter_is_vip' => $book->last_chapter_is_vip,
+            'last_chapter_is_vip' => $book->last_chapter_is_vip ?? 0,
             'is_need_charge' => $book->is_need_charge ? 1 : 0,
             'is_need_charge' => $book->is_need_charge ? 1 : 0,
-            'record_chapter_id' => $book->record_chapter_id,
-            'record_chapter_name' => $book->record_chapter_name,
+            'record_chapter_id' => $book->record_chapter_id ?? 0,
+            'record_chapter_name' => $book->record_chapter_name ?? '',
         ];
         ];
     }
     }
 }
 }

+ 8 - 4
app/Http/Middleware/QuickAppGetUserFromToken.php

@@ -17,8 +17,8 @@ class QuickAppGetUserFromToken extends BaseMiddleware
     /**
     /**
      * Handle an incoming request.
      * Handle an incoming request.
      *
      *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Closure  $next
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure                 $next
      * @return mixed
      * @return mixed
      */
      */
     public function handle(Request $request, Closure $next)
     public function handle(Request $request, Closure $next)
@@ -28,8 +28,8 @@ class QuickAppGetUserFromToken extends BaseMiddleware
             return response()->error('QAPP_NOT_LOGIN');
             return response()->error('QAPP_NOT_LOGIN');
         }
         }
         try {
         try {
-            $user = $this->auth->authenticate($token);
-            $send_order_id =  $request->header('send-order-id', 0);
+            $user          = $this->auth->authenticate($token);
+            $send_order_id = $request->header('send-order-id', 0);
             if ($send_order_id) {
             if ($send_order_id) {
                 UserService::setUserSendOrder($user->id, $send_order_id);
                 UserService::setUserSendOrder($user->id, $send_order_id);
             }
             }
@@ -49,6 +49,10 @@ class QuickAppGetUserFromToken extends BaseMiddleware
         $regId    = $request->header('x-regid', '');
         $regId    = $request->header('x-regid', '');
         PushService::setUserRegId($uid, $regId, $provider, $package);
         PushService::setUserRegId($uid, $regId, $provider, $package);
 
 
+
+        $codeVersion = $request->header('x-codeversion', '');
+        myLog('header')->info('', compact('uid', 'package', 'provider', 'codeVersion'));
+
         return $next($request);
         return $next($request);
     }
     }
 }
 }

+ 3 - 3
app/Http/Routes/QuickApp/QuickAppRoutes.php

@@ -31,6 +31,9 @@ Route::group(['domain' => env('QUICKAPP_DOMAIN'), 'namespace' => 'App\Http\Contr
 
 
         // 相似推荐
         // 相似推荐
         Route::get('books/similar', 'Book\BookController@similarRecom');
         Route::get('books/similar', 'Book\BookController@similarRecom');
+        
+        //排行榜
+        Route::get('books/rank', 'Book\BookController@rank');
     });
     });
 
 
     Route::group(['prefix' => 'api', 'middleware' => 'jwttoken'], function () {
     Route::group(['prefix' => 'api', 'middleware' => 'jwttoken'], function () {
@@ -40,8 +43,6 @@ Route::group(['domain' => env('QUICKAPP_DOMAIN'), 'namespace' => 'App\Http\Contr
         Route::get('books/recommen', 'Book\BookController@recommen');
         Route::get('books/recommen', 'Book\BookController@recommen');
         //阅读完后的推荐
         //阅读完后的推荐
         Route::get('books/readOverRecommend', 'Book\BookController@readOverRecommend');
         Route::get('books/readOverRecommend', 'Book\BookController@readOverRecommend');
-        //排行榜
-        Route::get('books/rank', 'Book\BookController@rank');
         //图书详情
         //图书详情
         Route::get('book/{bid}', 'Book\BookController@index');
         Route::get('book/{bid}', 'Book\BookController@index');
         //目录不分页
         //目录不分页
@@ -102,7 +103,6 @@ Route::group(['domain' => env('QUICKAPP_DOMAIN'), 'namespace' => 'App\Http\Contr
         Route::get('shortcut/add', 'User\ShortcutController@add');
         Route::get('shortcut/add', 'User\ShortcutController@add');
         //删除快捷方式
         //删除快捷方式
         Route::get('shortcut/delete', 'User\ShortcutController@delete');
         Route::get('shortcut/delete', 'User\ShortcutController@delete');
-
     });
     });
 
 
     // 推送
     // 推送

+ 1 - 1
app/Libs/Pay/Merchants/AliPay.php

@@ -79,7 +79,7 @@ class AliPay implements PayMerchantInterface
 
 
     public function notify(array $data)
     public function notify(array $data)
     {
     {
-        if (isset($data['sign'])) {
+        if (isset($data['sign']) && isset($data['trade_status'])  && $data['trade_status'] == 'TRADE_SUCCESS') {
             return $this->aop->rsaCheckV1($data, $this->rsaPublicKeyFilePath, self::SIGN_TYPE);
             return $this->aop->rsaCheckV1($data, $this->rsaPublicKeyFilePath, self::SIGN_TYPE);
         } else {
         } else {
             return false;
             return false;

+ 0 - 18
app/Modules/BaseService.php

@@ -1,18 +0,0 @@
-<?php
-
-namespace App\Modules;
-
-
-trait BaseService
-{
-    private static $_instance;
-
-    public static function __callStatic($name, $arguments)
-    {
-        $name = preg_replace('/Static$/', '', $name);
-        if (self::$_instance == null) {
-            self::$_instance = new self;
-        }
-        return self::$_instance->$name(...$arguments);
-    }
-}

+ 2 - 29
app/Modules/Book/Models/BookConfig.php

@@ -23,29 +23,7 @@ class BookConfig extends Model
         'copyright', 'charge_type', 'hot', 'is_on_shelf', 'source_domain', 'recommend_index', 'roles', 'test_status', 'plan_push_user_num', 'test_update_time',
         'copyright', 'charge_type', 'hot', 'is_on_shelf', 'source_domain', 'recommend_index', 'roles', 'test_status', 'plan_push_user_num', 'test_update_time',
         'is_show_index_content', 'click_count', 'promotion_domain', 'copyright_limit_data', 'recommend_cid', 'is_high_quality', 'vip_seq', 'editor_recommend', 'is_current_week_promotion'
         'is_show_index_content', 'click_count', 'promotion_domain', 'copyright_limit_data', 'recommend_cid', 'is_high_quality', 'vip_seq', 'editor_recommend', 'is_current_week_promotion'
     ];
     ];
-    /*
-    public static function getBooks($where, $order, $page_size = 15, $category = [], $key = null)
-    {
-        $res = self::join('books', 'book_configs.bid', '=', 'books.id')
-            ->join('book_categories', 'books.category_id', 'book_categories.id')
-            ->select('book_configs.bid', 'book_configs.force_subscribe_chapter_seq', 'book_configs.price',
-                'book_configs.cover', 'book_configs.book_name', 'book_configs.copyright', 'book_configs.charge_type', 'book_configs.is_on_shelf',
-                'books.author', 'books.intro', 'books.category_name', 'books.category_id', 'status', 'chapter_count', 'book_configs.click_count',
-                'first_cid', 'last_cid', 'size', 'last_chapter', 'books.keyword', 'book_configs.recommend_index', 'book_configs.is_show_index_content', 'book_configs.product_id'
-                , 'book_categories.channel_name', 'books.last_cid', 'books.last_chapter'
-            )
-            ->where($where)
-            ->orderBy($order[0], $order[1]);
 
 
-        if ($category) {
-            $res = $res->whereIn('books.category_id', $category);
-        }
-        if ($key) {
-            $res = $res->orwhere('book_configs.name', 'like', $key['name'])->orwhere('books.author', 'like', $key['author']);
-        }
-        return $res->paginate($page_size);
-    }
-    */
     /**
     /**
      * 根据条件获取图书
      * 根据条件获取图书
      * @param array $where
      * @param array $where
@@ -104,8 +82,6 @@ class BookConfig extends Model
             foreach ($where as $key => $v) {
             foreach ($where as $key => $v) {
                 //关键词查询
                 //关键词查询
                 if ($key == 'key' && $v) {
                 if ($key == 'key' && $v) {
-
-                    //$res = $res->where('book_configs.book_name', 'like', '%' . $v . '%');
                     $res = $res->where(function ($query) use ($v) {
                     $res = $res->where(function ($query) use ($v) {
                         $query->where('book_configs.book_name', 'like', '%' . $v . '%');
                         $query->where('book_configs.book_name', 'like', '%' . $v . '%');
                         if (mb_strlen($v) <= 5) {
                         if (mb_strlen($v) <= 5) {
@@ -115,9 +91,6 @@ class BookConfig extends Model
                             }
                             }
                         }
                         }
                     });
                     });
-                    //->orWhere('books.intro', 'like', '%' . $v . '%')
-                    //->orWhere('books.category_name', 'like', '%' . $v . '%')->orWhere('books.author', 'like', '%' . $v . '%')
-                    //->orWhere('books.keyword', 'like', '%' . $v . '%');
                 }
                 }
                 //分类id查询
                 //分类id查询
                 if ($key == 'category_id' && $v) {
                 if ($key == 'category_id' && $v) {
@@ -189,7 +162,6 @@ class BookConfig extends Model
                 }
                 }
             }
             }
         }
         }
-        //$res->orderBy('book_configs.updated_at','desc');
         return $res->orderBy($order[0], $order[1])->orderBy('book_configs.updated_at', 'desc')->paginate($page_size);
         return $res->orderBy($order[0], $order[1])->orderBy('book_configs.updated_at', 'desc')->paginate($page_size);
     }
     }
 
 
@@ -383,7 +355,8 @@ class BookConfig extends Model
                 'books.name as old_name',
                 'books.name as old_name',
                 'book_configs.recommend_cid'
                 'book_configs.recommend_cid'
             )
             )
-            ->whereIn('book_configs.bid', $bid_arr);
+            ->whereIn('book_configs.bid', $bid_arr)
+            ->where('is_on_shelf', 2);
         if ($order) {
         if ($order) {
             $res->orderBy($order[0], $order[1]);
             $res->orderBy($order[0], $order[1]);
         } else {
         } else {

+ 1 - 8
app/Modules/Book/Services/BookService.php

@@ -2,7 +2,6 @@
 
 
 namespace App\Modules\Book\Services;
 namespace App\Modules\Book\Services;
 
 
-use App\Modules\BaseService;
 use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\Book;
 use App\Modules\Book\Models\Chapter;
 use App\Modules\Book\Models\Chapter;
 use Hashids;
 use Hashids;
@@ -10,15 +9,9 @@ use Redis;
 use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\Statistic\Services\WapVisitStatService;
 use DB;
 use DB;
 
 
-/**
- * 
- * @method static int decodeBidStatic(string $bid) 解析bid
- */
 class BookService
 class BookService
 {
 {
-    use BaseService;
-
-    public function decodeBid(string $bid)
+    public static function decodeBidStatic(string $bid)
     {
     {
         return Hashids::decode($bid)[0];
         return Hashids::decode($bid)[0];
     }
     }

+ 2 - 2
app/Modules/Push/Services/PushMessageService.php

@@ -23,11 +23,11 @@ class PushMessageService
      * @param $title
      * @param $title
      * @param $content
      * @param $content
      * @param $url
      * @param $url
-     * @return bool
+     * @return array|bool|mixed|string|null
      * @throws ApiException
      * @throws ApiException
      * @throws GuzzleException
      * @throws GuzzleException
      */
      */
-    public static function pushMessageToUser($uid, $title, $content, $url): bool
+    public static function pushMessageToUser($uid, $title, $content, $url)
     {
     {
         // 获取用户push信息
         // 获取用户push信息
         $pushUser  = QappPushUser::getPushUserByUid($uid);
         $pushUser  = QappPushUser::getPushUserByUid($uid);

+ 6 - 3
app/Modules/Push/Services/PushService.php

@@ -32,8 +32,9 @@ class PushService
     public static function setUserRegId($uid, string $regId, string $provider, string $package): bool
     public static function setUserRegId($uid, string $regId, string $provider, string $package): bool
     {
     {
         // push服务商(转小写)
         // push服务商(转小写)
-        $provider = strtolower($provider);
-        if (empty($uid) || empty($regId) || empty($package) || empty($provider) || $package !== 'com.app.kyy.xnyd') {
+        $provider      = strtolower($provider);
+        $validPackages = ['com.app.kyy.xnyd', 'com.beidao.kuaiying.zsy'];
+        if (empty($uid) || empty($regId) || empty($package) || empty($provider) || !in_array($package, $validPackages, true)) {
             return false;
             return false;
         }
         }
 
 
@@ -52,6 +53,8 @@ class PushService
             return false;
             return false;
         }
         }
 
 
+        myLog('push')->info('setUserRegId', compact('uid', 'regId', 'provider', 'token', 'lock'));
+
         // 获取包信息
         // 获取包信息
         $packageInfo = QappPackage::getPackageByPackage($package);
         $packageInfo = QappPackage::getPackageByPackage($package);
         $packageId   = getProp($packageInfo, 'id');
         $packageId   = getProp($packageInfo, 'id');
@@ -99,7 +102,7 @@ class PushService
         }
         }
 
 
         // 释放锁
         // 释放锁
-        LockCache::releaseLock($token);
+//        LockCache::releaseLock($token);
 
 
         return $result;
         return $result;
     }
     }

+ 1 - 7
app/Modules/RecommendBook/Services/RecommendService.php

@@ -9,17 +9,11 @@
 
 
 namespace App\Modules\RecommendBook\Services;
 namespace App\Modules\RecommendBook\Services;
 
 
-use App\Modules\BaseService;
 use App\Modules\RecommendBook\Models\Recommend;
 use App\Modules\RecommendBook\Models\Recommend;
 
 
-/**
- * @method static array getRecommendIdsStatic(int $channel, string $type)
- */
 class RecommendService
 class RecommendService
 {
 {
-    use BaseService;
-
-    public function getRecommendIds(int $channel, string $type)
+    public static function getRecommendIdsStatic(int $channel, string $type)
     {
     {
         return Recommend::where([
         return Recommend::where([
             ['is_show', '=', 1],
             ['is_show', '=', 1],

+ 1 - 9
app/Modules/SendOrder/Services/SendOrderService.php

@@ -9,7 +9,6 @@
 
 
 namespace App\Modules\SendOrder\Services;
 namespace App\Modules\SendOrder\Services;
 
 
-use App\Modules\BaseService;
 use App\Modules\SendOrder\Models\QuickAppSendOrder;
 use App\Modules\SendOrder\Models\QuickAppSendOrder;
 use App\Modules\SendOrder\Models\SendOrder;
 use App\Modules\SendOrder\Models\SendOrder;
 use App\Modules\SendOrder\Models\SendOrderExtraStat;
 use App\Modules\SendOrder\Models\SendOrderExtraStat;
@@ -17,16 +16,9 @@ use App\Modules\Statistic\Services\WapVisitStatService;
 use DB;
 use DB;
 use Redis;
 use Redis;
 
 
-/**
- * 
- * @method static \App\Modules\SendOrder\Models\SendOrder getSendOrderStatic(int $id) 根据ID获取派单信息
- * @method static \App\Modules\SendOrder\Models\QuickAppSendOrder getQuickAppSendOrderStatic(int $send_order_id) 获取快应用派单信息
- */
 class SendOrderService
 class SendOrderService
 {
 {
-    use BaseService;
-
-    public function getSendOrder(int $id)
+    public static function getSendOrderStatic(int $id)
     {
     {
         return SendOrder::find($id);
         return SendOrder::find($id);
     }
     }

+ 0 - 7
app/Modules/Subscribe/Services/ChapterOrderService.php

@@ -2,19 +2,12 @@
 
 
 namespace App\Modules\Subscribe\Services;
 namespace App\Modules\Subscribe\Services;
 
 
-use App\Modules\BaseService;
 use DB;
 use DB;
 use App\Modules\User\Services\UserService;
 use App\Modules\User\Services\UserService;
 use App\Modules\Subscribe\Models\ChapterOrder;
 use App\Modules\Subscribe\Models\ChapterOrder;
 
 
-/**
- * 
- * @method static int checkIsOrderedStatic($uid, $bid, $cid)
- */
 class ChapterOrderService
 class ChapterOrderService
 {
 {
-    use BaseService;
-
     //判断是否订购
     //判断是否订购
     public function checkIsOrdered($uid, $bid, $cid)
     public function checkIsOrdered($uid, $bid, $cid)
     {
     {

+ 5 - 3
app/Modules/User/Services/QappUserService.php

@@ -44,6 +44,8 @@ class QappUserService
                 }
                 }
             }
             }
 
 
+            myLog('login')->info('register', compact('codeVersion', 'device_no', 'channel_id', 'lockToken'));
+
             // 初始化新用户
             // 初始化新用户
             $isNewRegister = true;
             $isNewRegister = true;
             $qapp_user     = $this->createQuickAppUser($data);
             $qapp_user     = $this->createQuickAppUser($data);
@@ -61,9 +63,9 @@ class QappUserService
             QappAddDeskTopService::incrAddDeskTop($uid, QuickConst::FIELD_REGISTER);
             QappAddDeskTopService::incrAddDeskTop($uid, QuickConst::FIELD_REGISTER);
 
 
             // 释放锁
             // 释放锁
-            if ($lockToken) {
-                LockCache::releaseLock($lockToken);
-            }
+//            if ($lockToken) {
+//                LockCache::releaseLock($lockToken);
+//            }
         }
         }
         return compact('token', 'time', 'uid');
         return compact('token', 'time', 'uid');
     }
     }

+ 28 - 25
app/Modules/User/Services/ReadRecordService.php

@@ -9,7 +9,6 @@
 
 
 namespace App\Modules\User\Services;
 namespace App\Modules\User\Services;
 
 
-use App\Modules\BaseService;
 use App\Modules\User\Models\ReadRecordFromRedis;
 use App\Modules\User\Models\ReadRecordFromRedis;
 use Redis;
 use Redis;
 use Hashids;
 use Hashids;
@@ -17,16 +16,9 @@ use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Models\Chapter;
 use App\Modules\Book\Models\Chapter;
 use DB;
 use DB;
 
 
-/**
- * @method static delReadRecordStatic(int $uid, array $bids) 删除最近阅读记录
- * @method static getBookReadRecordStatic(int $uid, int $bid) 获取单本书籍的最近阅读记录
- */
 class ReadRecordService
 class ReadRecordService
 {
 {
-    #region 以后按照这种方式写静态方法
-    use BaseService;
-
-    public function getBookReadRecord(int $uid, int $bid)
+    public static function getBookReadRecordStatic(int $uid, int $bid)
     {
     {
         $record = Redis::hGet('book_read:' . $uid, $bid);
         $record = Redis::hGet('book_read:' . $uid, $bid);
         if ($record) {
         if ($record) {
@@ -42,7 +34,7 @@ class ReadRecordService
      * @param int $uid
      * @param int $uid
      * @param array $bids
      * @param array $bids
      */
      */
-    public function delReadRecord(int $uid, array $bids)
+    public static function delReadRecordStatic(int $uid, array $bids)
     {
     {
         $key = 'book_read:' . $uid;
         $key = 'book_read:' . $uid;
         $last_record = explode('_', Redis::hGet($key, 'last_read'));
         $last_record = explode('_', Redis::hGet($key, 'last_read'));
@@ -55,7 +47,7 @@ class ReadRecordService
             Redis::hDel($key, $bid);
             Redis::hDel($key, $bid);
         }
         }
         if ($is_del_last) {
         if ($is_del_last) {
-            $this->reSetLastRecord($uid);
+            self::reSetLastRecord($uid);
         }
         }
     }
     }
 
 
@@ -63,7 +55,7 @@ class ReadRecordService
      * 重置用户最近阅读记录
      * 重置用户最近阅读记录
      * @param int $uid
      * @param int $uid
      */
      */
-    public function reSetLastRecord($uid)
+    public static function reSetLastRecord($uid)
     {
     {
         $key = 'book_read:' . $uid;
         $key = 'book_read:' . $uid;
         $alls = Redis::hGetAll($key);
         $alls = Redis::hGetAll($key);
@@ -88,7 +80,6 @@ class ReadRecordService
             Redis::hDel($key, 'last_read');
             Redis::hDel($key, 'last_read');
         }
         }
     }
     }
-    #endregion
 
 
     //阅读记录数
     //阅读记录数
     const RECORD_COUNT = 50;
     const RECORD_COUNT = 50;
@@ -278,7 +269,8 @@ class ReadRecordService
                 $bid = $record_arr[0];
                 $bid = $record_arr[0];
                 return (int) $bid;
                 return (int) $bid;
             }
             }
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return 0;
         return 0;
     }
     }
 
 
@@ -417,7 +409,8 @@ class ReadRecordService
                 'created_at' => date('Y-m-d H:i:s'),
                 'created_at' => date('Y-m-d H:i:s'),
                 'updated_at' => date('Y-m-d H:i:s'),
                 'updated_at' => date('Y-m-d H:i:s'),
             ]);
             ]);
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
     }
     }
 
 
     /**
     /**
@@ -431,7 +424,8 @@ class ReadRecordService
             $send_order_id = Redis::hget('book_read:' . $uid, 'send_order_id');
             $send_order_id = Redis::hget('book_read:' . $uid, 'send_order_id');
             if ($send_order_id)
             if ($send_order_id)
                 return (int) $send_order_id;
                 return (int) $send_order_id;
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return 0;
         return 0;
     }
     }
 
 
@@ -444,7 +438,8 @@ class ReadRecordService
     {
     {
         try {
         try {
             Redis::hset('book_read:' . $uid, 'inner_send_order_id', $inner_order_id);
             Redis::hset('book_read:' . $uid, 'inner_send_order_id', $inner_order_id);
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
     }
     }
 
 
     /**
     /**
@@ -460,7 +455,8 @@ class ReadRecordService
                 return $inner_send_order_id;
                 return $inner_send_order_id;
             }
             }
             return '';
             return '';
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return '';
         return '';
     }
     }
     /**
     /**
@@ -472,7 +468,8 @@ class ReadRecordService
     {
     {
         try {
         try {
             return Redis::hget('book_read:' . $uid, 'sign_day');
             return Redis::hget('book_read:' . $uid, 'sign_day');
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return -1;
         return -1;
     }
     }
 
 
@@ -511,7 +508,8 @@ class ReadRecordService
             if ($count) {
             if ($count) {
                 return $count;
                 return $count;
             }
             }
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return 0;
         return 0;
     }
     }
 
 
@@ -528,7 +526,8 @@ class ReadRecordService
                 return (int) $count;
                 return (int) $count;
             }
             }
             return 0;
             return 0;
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return 0;
         return 0;
     }
     }
 
 
@@ -568,7 +567,8 @@ class ReadRecordService
     {
     {
         try {
         try {
             return Redis::hget('book_read:' . $uid, $field);
             return Redis::hget('book_read:' . $uid, $field);
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return '';
         return '';
     }
     }
 
 
@@ -576,7 +576,8 @@ class ReadRecordService
     {
     {
         try {
         try {
             return Redis::hmget('book_read:' . $uid, $field);
             return Redis::hmget('book_read:' . $uid, $field);
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return '';
         return '';
     }
     }
 
 
@@ -587,7 +588,8 @@ class ReadRecordService
         }
         }
         try {
         try {
             return Redis::hset('book_read:' . $uid, $field, $value);
             return Redis::hset('book_read:' . $uid, $field, $value);
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return '';
         return '';
     }
     }
 
 
@@ -601,7 +603,8 @@ class ReadRecordService
         }
         }
         try {
         try {
             return Redis::hmset('book_read:' . $uid, $kv);
             return Redis::hmset('book_read:' . $uid, $kv);
-        } catch (\Exception $e) { }
+        } catch (\Exception $e) {
+        }
         return '';
         return '';
     }
     }
 
 

+ 19 - 0
config/home.php

@@ -0,0 +1,19 @@
+<?php
+return [
+    'hot'       => [
+        'male'   => [11601, 11529, 3365, 11833, 11543, 10377],
+        'female' => [1479, 7836, 7891, 8129, 8167, 8337],
+    ],
+    'live'      => [
+        'male'   => [11696, 2533, 6458, 9024, 11457, 11498],
+        'female' => [8469, 8557, 9117, 9997, 8148, 8476],
+    ],
+    'recom'     => [
+        'male'   => [11506, 11674, 11826, 2563, 11499, 9509],
+        'female' => [9423, 9248, 9973, 9990, 11766, 7629],
+    ],
+    'new_recom' => [
+        'male'   => [10986, 11674, 10375, 10378, 11496, 11501],
+        'female' => [10139, 9248, 7854, 1576, 1952, 2434],
+    ],
+];