Pārlūkot izejas kodu

Merge branch 'kuaiyingyong' into quickapp_fly

fly 4 gadi atpakaļ
vecāks
revīzija
0968100345

+ 1 - 0
app/Consts/ErrorConst.php

@@ -45,4 +45,5 @@ class ErrorConst
     const ACTIVITY_NOT_START                = '20002:活动还未开始';
     const ACTIVITY_IS_END                   = '20003:活动已经结束';
     const ACTIVITY_INVALID                  = '20004:无效的活动';
+    const ACTIVITY_CHARGE_OUT_OF_LIMIT      = '20005:活动充值已达最大次数限制';
 }

+ 6 - 0
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -253,6 +253,12 @@ class BookController extends BaseController
         if ($status != '') {
             $where['status'] = $status;
         }
+
+        // 搜索关键词的情况下,屏蔽书籍完本状态
+        if ($key && isset($where['status'])) {
+            unset($where['status']);
+        }
+        
         $page_size = $request->input('page_size', 15);
         $books     = BookConfigService::getBooks($where, $order, $page_size);
         return response()->pagination(new BookTransformer, $books);

+ 24 - 11
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -56,6 +56,9 @@ class ChapterController extends BaseController
 
     private function getChapterCatalog(int $bid, $chapters, $book_info)
     {
+        // 查询书籍是否限免
+        $isFree = BookConfigService::judgeBookIsFree($bid);
+
         switch ($book_info->charge_type) {
             case 'BOOK':
                 $price          = $this->getPrice($book_info);
@@ -63,12 +66,24 @@ class ChapterController extends BaseController
                 foreach ($chapters as $v) {
                     $v->is_need_charge = $v->is_vip ? $is_need_charge : false;
                     $v->price          = $price;
+
+                    // 限免判断
+                    if ($isFree) {
+                        $v->is_need_charge = false;
+                        $v->price          = 0;
+                    }
                 }
                 break;
             default:
                 foreach ($chapters as $v) {
-                    $v->price          = $v->is_vip ? $this->getPrice($book_info, $v->size) : 0;
-                    $v->is_need_charge = $v->is_vip ? $this->isChapterNeedCharge($bid, $v->id, $v->price) : false;
+                    // 限免判断
+                    if ($isFree) {
+                        $v->is_need_charge = false;
+                        $v->price          = 0;
+                    } else {
+                        $v->price          = $v->is_vip ? $this->getPrice($book_info, $v->size) : 0;
+                        $v->is_need_charge = $v->is_vip ? $this->isChapterNeedCharge($bid, $v->id, $v->price) : false;
+                    }
                 }
                 break;
         }
@@ -97,12 +112,6 @@ class ChapterController extends BaseController
         }
 
         if ($chapter->is_vip == 0) {
-            if ($chapter->sequence > 1) {
-                ReadRecordService::addReadRecord([
-                    'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-                    'cid' => $cid, 'chapter_name' => $chapter->name
-                ]);
-            }
             ReadRecordService::addReadLog($this->uid, [
                 'distribution_channel_id' => $this->distribution_channel_id,
                 'bid' => $bid,
@@ -111,6 +120,10 @@ class ChapterController extends BaseController
                 'send_order_id' => $this->send_order_id,
                 'sequence' => $chapter->sequence,
             ]);
+            ReadRecordService::addReadRecord([
+                'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
+                'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
+            ]);
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
 
@@ -126,7 +139,7 @@ class ChapterController extends BaseController
             ]);
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-                'cid' => $cid, 'chapter_name' => $chapter->name
+                'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
             ]);
 
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
@@ -175,7 +188,7 @@ class ChapterController extends BaseController
             ]);
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-                'cid' => $cid, 'chapter_name' => $chapter->name
+                'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
             ]);
 
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
@@ -214,7 +227,7 @@ class ChapterController extends BaseController
         if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, $remind)) {
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
-                'cid' => $cid, 'chapter_name' => $chapter->name
+                'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
             ]);
 
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));

+ 10 - 10
app/Http/Controllers/QuickApp/Book/Transformers/ChapterListTransformer.php

@@ -10,16 +10,16 @@ class ChapterListTransformer
     public function transform($chapter)
     {
         return [
-            'bid'       =>  Hashids::encode($chapter->bid),
-            'chapter_id'       =>  $chapter->id,
-            'chapter_name'   =>  $chapter->name,
-            'chapter_sequence'   =>  $chapter->sequence,
-            'chapter_is_vip'   =>  $chapter->is_vip,
-            'chapter_size'   =>  $chapter->size,
-            'prev_cid'   =>  $chapter->prev_cid,
-            'next_cid'   =>  $chapter->next_cid,
-            'recent_update_at'   =>  $chapter->recent_update_at,
-            'is_need_charge' => $chapter->is_need_charge ? 1 : 0,
+            'bid'              => Hashids::encode($chapter->bid),
+            'chapter_id'       => $chapter->id,
+            'chapter_name'     => $chapter->name,
+            'chapter_sequence' => $chapter->sequence,
+            'chapter_is_vip'   => $chapter->is_vip,
+            'chapter_size'     => $chapter->size,
+            'prev_cid'         => $chapter->prev_cid,
+            'next_cid'         => $chapter->next_cid,
+            'recent_update_at' => $chapter->recent_update_at,
+            'is_need_charge'   => $chapter->is_need_charge ? 1 : 0,
         ];
     }
 }

+ 29 - 0
app/Http/Controllers/QuickApp/Order/OrdersController.php

@@ -2,6 +2,8 @@
 
 namespace App\Http\Controllers\QuickApp\Order;
 
+use App\Consts\ErrorConst;
+use App\Libs\Utils;
 use App\Modules\Activity\Models\Activity;
 use App\Modules\Statistic\Services\AdVisitStatService;
 use App\Http\Controllers\QuickApp\BaseController;
@@ -20,6 +22,7 @@ use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Services\BookService;
 use App\Modules\Channel\Services\PayTemplateService;
 use App\Modules\Subscribe\Models\Order;
+use App\Modules\Trade\Models\Order as TradeOrder;
 use App\Modules\Trade\Pay\OrderArousePayFactory;
 use App\Modules\Trade\Pay\OrderPaySuccess;
 use App\Modules\Trade\Services\PayMerchantService;
@@ -426,6 +429,32 @@ class OrdersController extends BaseController
         if ($activity_token) {
             $activity    = Activity::getActivityBuToken($activity_token);
             $activity_id = (int)getProp($activity, 'id');
+
+            // 校验活动次数
+            $settingJson = getProp($activity, 'setting');
+            if ($settingJson) {
+                $setting      = json_decode($settingJson, true);
+                $productInfos = getProp($setting, 'product_info', []);
+                $productInfo  = collect($productInfos)->firstWhere('product_id', $product_id);
+                $limit        = (int)getProp($productInfo, 'limit');
+                if ($limit > 0) {
+                    // 查询用户通过该活动已经充值的次数
+                    $paidNum = TradeOrder::getActivityOrderNum([
+                        'uid'         => $uid,
+                        'begin_time'  => getProp($activity, 'start_time'),
+                        'end_time'    => getProp($activity, 'end_time'),
+                        'status'      => 'PAID',
+                        'product_id'  => $product_id,
+                        'activity_id' => $activity_id
+                    ]);
+                    myLog('charge')->info('', compact('uid', 'product_id', 'activity', 'paidNum'));
+
+                    // 活动充值次数限制
+                    if ($paidNum >= $limit) {
+                        Utils::throwError(ErrorConst::ACTIVITY_CHARGE_OUT_OF_LIMIT);
+                    }
+                }
+            }
         }
 
         return compact(

+ 9 - 10
app/Http/Controllers/QuickApp/User/ReadRecordController.php

@@ -21,12 +21,11 @@ class ReadRecordController extends BaseController
      */
 
 
-
     /**
      * @apiVersion 1.0.0
      * @apiDescription 获取阅读记录
      * @api {get} readrecord 获取阅读记录
-     * @apiHeader {String} [Authorization]  token 
+     * @apiHeader {String} [Authorization]  token
      * @apiGroup ReadRecord
      * @apiName index
      * @apiSuccess {int}         code 状态码
@@ -65,21 +64,21 @@ class ReadRecordController extends BaseController
     public function index(Request $request)
     {
         $user = $this->user_info;
-        $res = ReadRecordService::getReadRecord($this->uid);
+        $res  = ReadRecordService::getReadRecord($this->uid);
         if ($res) {
             $id_arr = [];
             foreach ($res as $key => $value) {
                 $id_arr[] = $value['bid'];
             }
 
-            $book = BookConfigService::getBooksByIds($id_arr);
+            $book = BookConfigService::getBooksByIds($id_arr, [], false);//下架图书最近阅读可看到
             foreach ($res as $key => &$value) {
-                $value['cover'] = '';
+                $value['cover']        = '';
                 $value['last_chapter'] = 0;
-                foreach ($book as  $val) {
+                foreach ($book as $val) {
                     if ($value['bid'] == $val->bid) {
-                        $value['book_name'] = $val->book_name;
-                        $value['cover'] = $val->cover;
+                        $value['book_name']    = $val->book_name;
+                        $value['cover']        = $val->cover;
                         $value['last_chapter'] = $val->last_chapter;
                         break;
                     }
@@ -90,7 +89,7 @@ class ReadRecordController extends BaseController
             if ($a['time'] >= $b['time']) return -1;
             return 1;
         });
-        return response()->collection(new ReadRecordTransformer(),  array_to_object($res));
+        return response()->collection(new ReadRecordTransformer(), array_to_object($res));
     }
 
 
@@ -136,7 +135,7 @@ class ReadRecordController extends BaseController
      * @apiDescription 删除阅读记录
      * @api {get} readrecord/delete 删除阅读记录
      * @apiGroup ReadRecord
-     * @apiHeader {String} [Authorization]  token 
+     * @apiHeader {String} [Authorization]  token
      * @apiName delReadRecord
      * @apiParam   {String}         bid     多个bid以,分隔
      * @apiSuccess {int}         code 状态码

+ 14 - 8
app/Http/Controllers/QuickApp/User/UserShelfBooksController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\QuickApp\User;
 
+use App\Libs\Utils;
 use Illuminate\Http\Request;
 use App\Http\Controllers\QuickApp\BaseController;
 use Redis;
@@ -103,15 +104,20 @@ class UserShelfBooksController extends BaseController
      */
     public function delShelf(Request $request)
     {
-        $bid = $request->input('bid');
-        if (empty($bid)) return response()->error('LACK_PARAM');
-        $param['uid'] = $this->uid;
-        $param['bid'] = Hashids::decode($bid)[0];
-        $res          = UserShelfBooksService::del($this->uid, $param['bid']);
-        if ($res) {
-            return response()->success();
+        $uid       = $this->uid;
+        $bid       = $request->input('bid');
+        $decodeBid = Utils::getDecodeId($bid);
+        if (empty($bid) || empty($decodeBid)) {
+            return response()->error('LACK_PARAM');
         }
-        return response()->error('QAPP_SYS_ERROR');
+
+        // 删除书架中的书籍
+        UserShelfBooksService::del($uid, $decodeBid);
+
+        // 删除最近阅读记录
+        ReadRecordService::delReadRecordStatic($uid, [$decodeBid]);
+
+        return response()->success();
     }
 
 

+ 5 - 3
app/Modules/Book/Models/BookConfig.php

@@ -315,7 +315,7 @@ class BookConfig extends Model
      * @param array $order
      * @return mixed
      */
-    public static function getBooksByIds(array $bid_arr, array $order = [])
+    public static function getBooksByIds(array $bid_arr, array $order = [], $is_external_shelf = true)
     {
         $res = self::join('books', 'book_configs.bid', '=', 'books.id')
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
@@ -355,8 +355,10 @@ class BookConfig extends Model
                 'books.name as old_name',
                 'book_configs.recommend_cid'
             )
-            ->whereIn('book_configs.bid', $bid_arr)
-            ->where('is_on_shelf', 2);
+            ->whereIn('book_configs.bid', $bid_arr);
+
+        if($is_external_shelf) $res->where('is_on_shelf',2);// 默认外部上架
+
         if ($order) {
             $res->orderBy($order[0], $order[1]);
         } else {

+ 3 - 3
app/Modules/Book/Services/BookConfigService.php

@@ -42,15 +42,15 @@ class BookConfigService
      * @param null $order
      * @return mixed
      */
-    public static function getBooksByIds(array $where, $order = [])
+    public static function getBooksByIds(array $where, $order = [],$is_external_shelf=true)
     {
         if (empty($where)) {
             return (object)array();
         }
         if ($order)
-            $res = BookConfig::getBooksByIds($where, $order);
+            $res = BookConfig::getBooksByIds($where,$order,$is_external_shelf);
         else
-            $res = BookConfig::getBooksByIds($where);
+            $res = BookConfig::getBooksByIds($where,[],$is_external_shelf);
         return $res;
     }
 

+ 2 - 0
app/Modules/Trade/Models/Order.php

@@ -215,10 +215,12 @@ class Order extends Model
     static function getActivityOrderNum($params = [])
     {
         $search_obj = self::orderBy('created_at', 'desc');
+        if (isset($params['uid']) && $params['uid']) $search_obj->where('uid', $params['uid']);
         if (isset($params['status']) && $params['status']) $search_obj->where('status', $params['status']);
         if (isset($params['activity_id']) && $params['activity_id']) $search_obj->where('activity_id', $params['activity_id']);
         if (isset($params['begin_time']) && $params['begin_time']) $search_obj->where('created_at', '>=', $params['begin_time']);
         if (isset($params['end_time']) && $params['end_time']) $search_obj->where('created_at', '<=', $params['end_time']);
+        if (isset($params['product_id']) && $params['product_id']) $search_obj->where('product_id', $params['product_id']);
         if (isset($params['distribution_channel_id']) && $params['distribution_channel_id']) $search_obj->where('distribution_channel_id', $params['distribution_channel_id']);
         return $search_obj->count();
     }

+ 93 - 83
app/Modules/User/Services/ReadRecordService.php

@@ -23,7 +23,7 @@ class ReadRecordService
     {
         $record = Redis::hGet('book_read:' . $uid, $bid);
         if ($record) {
-            $cid = explode('_', $record)[0];
+            $cid  = explode('_', $record)[0];
             $name = self::cid2ChapterName($cid);
             return ['record_chapter_id' => $cid, 'record_chapter_name' => $name];
         }
@@ -32,15 +32,15 @@ class ReadRecordService
 
     /**
      * 删除最近阅读记录
-     * @param int $uid
+     * @param int   $uid
      * @param array $bids
      */
     public static function delReadRecordStatic(int $uid, array $bids)
     {
-        $key = 'book_read:' . $uid;
-        $last_record = explode('_', Redis::hGet($key, 'last_read'));
+        $key             = 'book_read:' . $uid;
+        $last_record     = explode('_', Redis::hGet($key, 'last_read'));
         $last_record_bid = $last_record[0];
-        $is_del_last = false;
+        $is_del_last     = false;
         foreach ($bids as $bid) {
             if ($bid == $last_record_bid) {
                 $is_del_last = true;
@@ -58,18 +58,18 @@ class ReadRecordService
      */
     public static function reSetLastRecord($uid)
     {
-        $key = 'book_read:' . $uid;
-        $alls = Redis::hGetAll($key);
-        $has_record = false;
+        $key            = 'book_read:' . $uid;
+        $alls           = Redis::hGetAll($key);
+        $has_record     = false;
         $last_timestamp = 0;
-        $last_record = '';
+        $last_record    = '';
         foreach ($alls as $k => $v) {
             if (is_numeric($k)) {
                 $has_record = true;
-                $record = explode('_', $v);
-                $timestamp = $record[1];
+                $record     = explode('_', $v);
+                $timestamp  = $record[1];
                 if ($last_timestamp < $timestamp) {
-                    $last_record = $k . '_' . $v;
+                    $last_record    = $k . '_' . $v;
                     $last_timestamp = $timestamp;
                 }
             }
@@ -95,15 +95,15 @@ class ReadRecordService
     public static function getReadRecord_($uid)
     {
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $res = [];
-        $i = 0;
+        $res       = [];
+        $i         = 0;
         foreach ($read_bids as $key => $v) {
-            $record = explode('_', $v);
-            $latest_read_cid = $record[0];
-            $book_name = $record[1];
-            $chapter_name = $record[2];
+            $record           = explode('_', $v);
+            $latest_read_cid  = $record[0];
+            $book_name        = $record[1];
+            $chapter_name     = $record[2];
             $latest_read_time = $record[count($record) - 1];
-            $res[$i] = ['book_name' => $book_name, 'bid' => $key, 'cid' => (int) $latest_read_cid, 'time' => (int) $latest_read_time, 'chapter_name' => $chapter_name];
+            $res[$i]          = ['book_name' => $book_name, 'bid' => $key, 'cid' => (int)$latest_read_cid, 'time' => (int)$latest_read_time, 'chapter_name' => $chapter_name];
             $i++;
         }
         usort($res, function ($a, $b) {
@@ -126,18 +126,18 @@ class ReadRecordService
         }
         self::delTheLastRecord($uid);
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $res = [];
-        $i = 0;
+        $res       = [];
+        $i         = 0;
         foreach ($read_bids as $key => $v) {
             if (in_array($key, self::$not_uid_key)) {
                 continue;
             }
-            $record = explode('_', $v);
-            $latest_read_cid = $record[0];
+            $record           = explode('_', $v);
+            $latest_read_cid  = $record[0];
             $latest_read_time = $record[count($record) - 1];
-            $book_name = self::bid2BookName($key);
-            $chapter_name = self::cid2ChapterName($latest_read_cid);
-            $res[$i] = ['book_name' => $book_name, 'bid' => $key, 'cid' => (int) $latest_read_cid, 'time' => (int) $latest_read_time, 'chapter_name' => $chapter_name];
+            $book_name        = self::bid2BookName($key);
+            $chapter_name     = self::cid2ChapterName($latest_read_cid);
+            $res[$i]          = ['book_name' => $book_name, 'bid' => $key, 'cid' => (int)$latest_read_cid, 'time' => (int)$latest_read_time, 'chapter_name' => $chapter_name];
             $i++;
         }
         usort($res, function ($a, $b) {
@@ -157,10 +157,10 @@ class ReadRecordService
      */
     public static function addReadRecord_($param)
     {
-        $uid = $param['uid'];
-        $bid = $param['bid'];
-        $cid = $param['cid'];
-        $book_name = $param['book_name'];
+        $uid          = $param['uid'];
+        $bid          = $param['bid'];
+        $cid          = $param['cid'];
+        $book_name    = $param['book_name'];
         $chapter_name = $param['chapter_name'];
         Redis::hset('book_base:' . $uid, 'last_read', "{$bid}_{$cid}_{$book_name}_{$chapter_name}_" . time());
         //Redis::hset('book_read:'.$uid, $bid, $cid."_".time());
@@ -169,18 +169,25 @@ class ReadRecordService
 
     /**
      * 添加阅读记录升级版
-     * @param array $param
+     * @param $param
+     * @return bool
+     * @throws \Exception
      */
     public static function addReadRecord($param)
     {
-        $uid = $param['uid'];
-        $bid = $param['bid'];
-        $cid = $param['cid'];
-
-        $book_name = isset($param['book_name']) ? $param['book_name'] : '';
-        $chapter_name = isset($param['chapter_name']) ? $param['chapter_name'] : '';
-        $book_key = 'wap:string:book:' . $bid;
-        $chapter_key = 'wap:string:chapter:' . $cid;
+        // 第一章不计入阅读记录
+        $sequence = (int)getProp($param, 'sequence');
+//        if ($sequence <= 1) {
+//            return false;
+//        }
+
+        $uid          = $param['uid'];
+        $bid          = $param['bid'];
+        $cid          = $param['cid'];
+        $book_name    = getProp($param, 'book_name');
+        $chapter_name = getProp($param, 'chapter_name');
+        $book_key     = 'wap:string:book:' . $bid;
+        $chapter_key  = 'wap:string:chapter:' . $cid;
         if ($book_name) {
             Redis::setex($book_key, 3600, $book_name);
         }
@@ -192,6 +199,8 @@ class ReadRecordService
         if ($num <= 3) {
             self::delTheLastRecord($uid);
         }
+
+        return true;
     }
 
     /**
@@ -204,17 +213,17 @@ class ReadRecordService
         if (empty($all)) return [];
         $first = $all[0];
         if (!$first) return [];
-        if (!isset($first['bid']))  return [];
+        if (!isset($first['bid'])) return [];
         try {
             //$bid = Hashids::encode($first['bid']);
-            $bid = $first['bid'];
+            $bid       = $first['bid'];
             $book_info = BookConfigService::getBookById($bid);
-            $cid = $first['cid'];
+            $cid       = $first['cid'];
             $book_name = $first['book_name'];
-            $res = [
-                'url' => '/reader?bid=' . $bid . '&cid=' . $cid,
-                'book_name' => $book_name,
-                'cover' => $book_info->cover,
+            $res       = [
+                'url'          => '/reader?bid=' . $bid . '&cid=' . $cid,
+                'book_name'    => $book_name,
+                'cover'        => $book_info->cover,
                 'channel_name' => $book_info->channel_name,
             ];
         } catch (\Exception $e) {
@@ -234,21 +243,21 @@ class ReadRecordService
         self::delBookBase($uid);
         $record = Redis::hget('book_read:' . $uid, 'last_read');
         if ($record) {
-            $record_arr = explode('_', $record);
-            $bid = $record_arr[0];
-            $bid = Hashids::encode($bid);
-            $cid = $record_arr[1];
-            $time = $record_arr[2];
-            $book_info = BookConfigService::getBookById($bid);
-            $book_name = isset($book_info->book_name) ? $book_info->book_name : '';
-            $cover = isset($book_info->cover) ? $book_info->cover : '';
+            $record_arr   = explode('_', $record);
+            $bid          = $record_arr[0];
+            $bid          = Hashids::encode($bid);
+            $cid          = $record_arr[1];
+            $time         = $record_arr[2];
+            $book_info    = BookConfigService::getBookById($bid);
+            $book_name    = isset($book_info->book_name) ? $book_info->book_name : '';
+            $cover        = isset($book_info->cover) ? $book_info->cover : '';
             $channel_name = isset($book_info->channel_name) ? $book_info->channel_name : '';
-            $res = [
-                'url' => '/reader?bid=' . $bid . '&cid=' . $cid,
-                'book_name' => $book_name,
-                'cover' => $cover,
+            $res          = [
+                'url'          => '/reader?bid=' . $bid . '&cid=' . $cid,
+                'book_name'    => $book_name,
+                'cover'        => $cover,
                 'channel_name' => $channel_name,
-                'time' => $time
+                'time'         => $time
             ];
             return $res;
         }
@@ -266,8 +275,8 @@ class ReadRecordService
             $record = Redis::hget('book_read:' . $uid, 'last_read');
             if ($record) {
                 $record_arr = explode('_', $record);
-                $bid = $record_arr[0];
-                return (int) $bid;
+                $bid        = $record_arr[0];
+                return (int)$bid;
             }
         } catch (\Exception $e) {
         }
@@ -299,7 +308,7 @@ class ReadRecordService
      */
     public static function bid2BookName($bid)
     {
-        $book_key = 'wap:string:book:' . $bid;
+        $book_key  = 'wap:string:book:' . $bid;
         $book_name = Redis::get($book_key);
         Redis::EXPIRE($book_key, 3600);
         if (!$book_name) {
@@ -318,7 +327,7 @@ class ReadRecordService
      */
     public static function cid2ChapterName($cid)
     {
-        $chapter_key = 'wap:string:chapter:' . $cid;
+        $chapter_key  = 'wap:string:chapter:' . $cid;
         $chapter_name = Redis::get($chapter_key);
         Redis::EXPIRE($chapter_key, 3600);
         if (!$chapter_name) {
@@ -341,10 +350,10 @@ class ReadRecordService
         $base_record = Redis::hget('book_base:' . $uid, 'last_read');
         if ($base_record) {
             $record_arr = explode('_', $base_record);
-            $c = count($record_arr);
+            $c          = count($record_arr);
             if ($c > 3) {
-                $bid = $record_arr[0];
-                $cid = $record_arr[1];
+                $bid  = $record_arr[0];
+                $cid  = $record_arr[1];
                 $time = $record_arr[$c - 1];
                 Redis::hset('book_base:' . $uid, 'last_read', "{$bid}_{$cid}_" . $time);
             }
@@ -352,15 +361,15 @@ class ReadRecordService
         $records = Redis::hgetall('book_read:' . $uid);
         foreach ($records as $key => $v) {
             $record = explode('_', $v);
-            $count = count($record);
+            $count  = count($record);
             if ($count > 3) {
-                $latest_read_cid = $record[0];
-                $book_name = $record[1];
-                $chapter_name = $record[2];
+                $latest_read_cid  = $record[0];
+                $book_name        = $record[1];
+                $chapter_name     = $record[2];
                 $latest_read_time = $record[$count - 1];
                 Redis::hset('book_read:' . $uid, $key, "{$latest_read_cid}_" . $latest_read_time);
 
-                $book_key = 'wap:string:book:' . $key;
+                $book_key    = 'wap:string:book:' . $key;
                 $chapter_key = 'wap:string:chapter:' . $latest_read_cid;
                 Redis::set($book_key, $book_name);
                 Redis::set($chapter_key, $chapter_name);
@@ -385,7 +394,7 @@ class ReadRecordService
     public static function getSimpleReadRecord(int $uid): array
     {
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $res = [];
+        $res       = [];
         if (!$read_bids) {
             return $res;
         }
@@ -403,11 +412,11 @@ class ReadRecordService
     {
         try {
             DB::table('temp_read_active')->insert([
-                'uid' => $uid,
+                'uid'                     => $uid,
                 'distribution_channel_id' => $distribution_channel_id,
-                'from' => $from,
-                'created_at' => date('Y-m-d H:i:s'),
-                'updated_at' => date('Y-m-d H:i:s'),
+                'from'                    => $from,
+                'created_at'              => date('Y-m-d H:i:s'),
+                'updated_at'              => date('Y-m-d H:i:s'),
             ]);
         } catch (\Exception $e) {
         }
@@ -423,7 +432,7 @@ class ReadRecordService
         try {
             $send_order_id = Redis::hget('book_read:' . $uid, 'send_order_id');
             if ($send_order_id)
-                return (int) $send_order_id;
+                return (int)$send_order_id;
         } catch (\Exception $e) {
         }
         return 0;
@@ -459,6 +468,7 @@ class ReadRecordService
         }
         return '';
     }
+
     /**
      * 签到日期
      * @param int $uid
@@ -523,7 +533,7 @@ class ReadRecordService
         try {
             $count = Redis::hget('book_read:' . $uid, 'sign_counts');
             if ($count) {
-                return (int) $count;
+                return (int)$count;
             }
             return 0;
         } catch (\Exception $e) {
@@ -556,7 +566,7 @@ class ReadRecordService
 
     public static function getSmartPush(int $uid): array
     {
-        $res =  Redis::hget('book_read:' . $uid, 'smart_push');
+        $res = Redis::hget('book_read:' . $uid, 'smart_push');
         if ($res) {
             return explode(',', $res);
         }
@@ -632,15 +642,15 @@ class ReadRecordService
             return;
         }
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $i = 0;
+        $i         = 0;
         foreach ($read_bids as $key => $v) {
             if (in_array($key, self::$not_uid_key)) {
                 continue;
             }
-            $record = explode('_', $v);
-            $latest_read_cid = $record[0];
+            $record           = explode('_', $v);
+            $latest_read_cid  = $record[0];
             $latest_read_time = $record[count($record) - 1];
-            $res[$i++] = ['bid' => $key, 'cid' => (int) $latest_read_cid, 'time' => (int) $latest_read_time];
+            $res[$i++]        = ['bid' => $key, 'cid' => (int)$latest_read_cid, 'time' => (int)$latest_read_time];
         }
         usort($res, function ($a, $b) {
             if ($a['time'] >= $b['time']) return -1;

+ 1 - 0
resources/views/qapp/welcome.blade.php

@@ -335,6 +335,7 @@
             send_order_id: QYY.send_order_id
         };
         try {
+            routerAHap(parmas);
             //尝试直接拉起
             appRouter(QYY.packName, "/" + QYY.entry, parmas);
         } catch (e) {