Forráskód Böngészése

Merge branch 'kuaiyingyong' into kuaiyingyong_push_stat

Wang Chen 4 éve
szülő
commit
7a90918a0d

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

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

+ 21 - 6
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -56,6 +56,9 @@ class ChapterController extends BaseController
 
 
     private function getChapterCatalog(int $bid, $chapters, $book_info)
     private function getChapterCatalog(int $bid, $chapters, $book_info)
     {
     {
+        // 查询书籍是否限免
+        $isFree = BookConfigService::judgeBookIsFree($bid);
+
         switch ($book_info->charge_type) {
         switch ($book_info->charge_type) {
             case 'BOOK':
             case 'BOOK':
                 $price          = $this->getPrice($book_info);
                 $price          = $this->getPrice($book_info);
@@ -63,12 +66,24 @@ class ChapterController extends BaseController
                 foreach ($chapters as $v) {
                 foreach ($chapters as $v) {
                     $v->is_need_charge = $v->is_vip ? $is_need_charge : false;
                     $v->is_need_charge = $v->is_vip ? $is_need_charge : false;
                     $v->price          = $price;
                     $v->price          = $price;
+
+                    // 限免判断
+                    if ($isFree) {
+                        $v->is_need_charge = false;
+                        $v->price          = 0;
+                    }
                 }
                 }
                 break;
                 break;
             default:
             default:
                 foreach ($chapters as $v) {
                 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;
                 break;
         }
         }
@@ -99,7 +114,7 @@ class ChapterController extends BaseController
         if ($chapter->is_vip == 0) {
         if ($chapter->is_vip == 0) {
             ReadRecordService::addReadRecord([
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 '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));
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
         }
@@ -108,7 +123,7 @@ class ChapterController extends BaseController
         if ($this->getOrderRecord($bid, $cid) || BookConfigService::judgeBookIsFree($bid)) {
         if ($this->getOrderRecord($bid, $cid) || BookConfigService::judgeBookIsFree($bid)) {
             ReadRecordService::addReadRecord([
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 '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));
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
@@ -149,7 +164,7 @@ class ChapterController extends BaseController
             UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
             UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
             ReadRecordService::addReadRecord([
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 '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));
             return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
@@ -188,7 +203,7 @@ class ChapterController extends BaseController
         if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, $remind)) {
         if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, $remind)) {
             ReadRecordService::addReadRecord([
             ReadRecordService::addReadRecord([
                 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
                 '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));
             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)
     public function transform($chapter)
     {
     {
         return [
         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,
         ];
         ];
     }
     }
 }
 }

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

@@ -444,8 +444,10 @@ class OrdersController extends BaseController
                         'begin_time'  => getProp($activity, 'start_time'),
                         'begin_time'  => getProp($activity, 'start_time'),
                         'end_time'    => getProp($activity, 'end_time'),
                         'end_time'    => getProp($activity, 'end_time'),
                         'status'      => 'PAID',
                         'status'      => 'PAID',
+                        'product_id'  => $product_id,
                         'activity_id' => $activity_id
                         'activity_id' => $activity_id
                     ]);
                     ]);
+                    myLog('charge')->info('', compact('uid', 'product_id', 'activity', 'paidNum'));
 
 
                     // 活动充值次数限制
                     // 活动充值次数限制
                     if ($paidNum >= $limit) {
                     if ($paidNum >= $limit) {

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

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

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

@@ -2,6 +2,7 @@
 
 
 namespace App\Http\Controllers\QuickApp\User;
 namespace App\Http\Controllers\QuickApp\User;
 
 
+use App\Libs\Utils;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use App\Http\Controllers\QuickApp\BaseController;
 use App\Http\Controllers\QuickApp\BaseController;
 use Redis;
 use Redis;
@@ -103,15 +104,20 @@ class UserShelfBooksController extends BaseController
      */
      */
     public function delShelf(Request $request)
     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();
     }
     }
 
 
 
 

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

@@ -220,6 +220,7 @@ class Order extends Model
         if (isset($params['activity_id']) && $params['activity_id']) $search_obj->where('activity_id', $params['activity_id']);
         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['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['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']);
         if (isset($params['distribution_channel_id']) && $params['distribution_channel_id']) $search_obj->where('distribution_channel_id', $params['distribution_channel_id']);
         return $search_obj->count();
         return $search_obj->count();
     }
     }

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

@@ -22,7 +22,7 @@ class ReadRecordService
     {
     {
         $record = Redis::hGet('book_read:' . $uid, $bid);
         $record = Redis::hGet('book_read:' . $uid, $bid);
         if ($record) {
         if ($record) {
-            $cid = explode('_', $record)[0];
+            $cid  = explode('_', $record)[0];
             $name = self::cid2ChapterName($cid);
             $name = self::cid2ChapterName($cid);
             return ['record_chapter_id' => $cid, 'record_chapter_name' => $name];
             return ['record_chapter_id' => $cid, 'record_chapter_name' => $name];
         }
         }
@@ -31,15 +31,15 @@ class ReadRecordService
 
 
     /**
     /**
      * 删除最近阅读记录
      * 删除最近阅读记录
-     * @param int $uid
+     * @param int   $uid
      * @param array $bids
      * @param array $bids
      */
      */
     public static function delReadRecordStatic(int $uid, 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];
         $last_record_bid = $last_record[0];
-        $is_del_last = false;
+        $is_del_last     = false;
         foreach ($bids as $bid) {
         foreach ($bids as $bid) {
             if ($bid == $last_record_bid) {
             if ($bid == $last_record_bid) {
                 $is_del_last = true;
                 $is_del_last = true;
@@ -57,18 +57,18 @@ class ReadRecordService
      */
      */
     public static function reSetLastRecord($uid)
     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_timestamp = 0;
-        $last_record = '';
+        $last_record    = '';
         foreach ($alls as $k => $v) {
         foreach ($alls as $k => $v) {
             if (is_numeric($k)) {
             if (is_numeric($k)) {
                 $has_record = true;
                 $has_record = true;
-                $record = explode('_', $v);
-                $timestamp = $record[1];
+                $record     = explode('_', $v);
+                $timestamp  = $record[1];
                 if ($last_timestamp < $timestamp) {
                 if ($last_timestamp < $timestamp) {
-                    $last_record = $k . '_' . $v;
+                    $last_record    = $k . '_' . $v;
                     $last_timestamp = $timestamp;
                     $last_timestamp = $timestamp;
                 }
                 }
             }
             }
@@ -94,15 +94,15 @@ class ReadRecordService
     public static function getReadRecord_($uid)
     public static function getReadRecord_($uid)
     {
     {
         $read_bids = Redis::hgetall('book_read:' . $uid);
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $res = [];
-        $i = 0;
+        $res       = [];
+        $i         = 0;
         foreach ($read_bids as $key => $v) {
         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];
             $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++;
             $i++;
         }
         }
         usort($res, function ($a, $b) {
         usort($res, function ($a, $b) {
@@ -125,18 +125,18 @@ class ReadRecordService
         }
         }
         self::delTheLastRecord($uid);
         self::delTheLastRecord($uid);
         $read_bids = Redis::hgetall('book_read:' . $uid);
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $res = [];
-        $i = 0;
+        $res       = [];
+        $i         = 0;
         foreach ($read_bids as $key => $v) {
         foreach ($read_bids as $key => $v) {
             if (in_array($key, self::$not_uid_key)) {
             if (in_array($key, self::$not_uid_key)) {
                 continue;
                 continue;
             }
             }
-            $record = explode('_', $v);
-            $latest_read_cid = $record[0];
+            $record           = explode('_', $v);
+            $latest_read_cid  = $record[0];
             $latest_read_time = $record[count($record) - 1];
             $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++;
             $i++;
         }
         }
         usort($res, function ($a, $b) {
         usort($res, function ($a, $b) {
@@ -156,10 +156,10 @@ class ReadRecordService
      */
      */
     public static function addReadRecord_($param)
     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'];
         $chapter_name = $param['chapter_name'];
         Redis::hset('book_base:' . $uid, 'last_read', "{$bid}_{$cid}_{$book_name}_{$chapter_name}_" . time());
         Redis::hset('book_base:' . $uid, 'last_read', "{$bid}_{$cid}_{$book_name}_{$chapter_name}_" . time());
         //Redis::hset('book_read:'.$uid, $bid, $cid."_".time());
         //Redis::hset('book_read:'.$uid, $bid, $cid."_".time());
@@ -168,18 +168,25 @@ class ReadRecordService
 
 
     /**
     /**
      * 添加阅读记录升级版
      * 添加阅读记录升级版
-     * @param array $param
+     * @param $param
+     * @return bool
+     * @throws \Exception
      */
      */
     public static function addReadRecord($param)
     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) {
         if ($book_name) {
             Redis::setex($book_key, 3600, $book_name);
             Redis::setex($book_key, 3600, $book_name);
         }
         }
@@ -191,6 +198,8 @@ class ReadRecordService
         if ($num <= 3) {
         if ($num <= 3) {
             self::delTheLastRecord($uid);
             self::delTheLastRecord($uid);
         }
         }
+
+        return true;
     }
     }
 
 
     /**
     /**
@@ -203,17 +212,17 @@ class ReadRecordService
         if (empty($all)) return [];
         if (empty($all)) return [];
         $first = $all[0];
         $first = $all[0];
         if (!$first) return [];
         if (!$first) return [];
-        if (!isset($first['bid']))  return [];
+        if (!isset($first['bid'])) return [];
         try {
         try {
             //$bid = Hashids::encode($first['bid']);
             //$bid = Hashids::encode($first['bid']);
-            $bid = $first['bid'];
+            $bid       = $first['bid'];
             $book_info = BookConfigService::getBookById($bid);
             $book_info = BookConfigService::getBookById($bid);
-            $cid = $first['cid'];
+            $cid       = $first['cid'];
             $book_name = $first['book_name'];
             $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,
                 'channel_name' => $book_info->channel_name,
             ];
             ];
         } catch (\Exception $e) {
         } catch (\Exception $e) {
@@ -233,21 +242,21 @@ class ReadRecordService
         self::delBookBase($uid);
         self::delBookBase($uid);
         $record = Redis::hget('book_read:' . $uid, 'last_read');
         $record = Redis::hget('book_read:' . $uid, 'last_read');
         if ($record) {
         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 : '';
             $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,
                 'channel_name' => $channel_name,
-                'time' => $time
+                'time'         => $time
             ];
             ];
             return $res;
             return $res;
         }
         }
@@ -265,8 +274,8 @@ class ReadRecordService
             $record = Redis::hget('book_read:' . $uid, 'last_read');
             $record = Redis::hget('book_read:' . $uid, 'last_read');
             if ($record) {
             if ($record) {
                 $record_arr = explode('_', $record);
                 $record_arr = explode('_', $record);
-                $bid = $record_arr[0];
-                return (int) $bid;
+                $bid        = $record_arr[0];
+                return (int)$bid;
             }
             }
         } catch (\Exception $e) {
         } catch (\Exception $e) {
         }
         }
@@ -298,7 +307,7 @@ class ReadRecordService
      */
      */
     public static function bid2BookName($bid)
     public static function bid2BookName($bid)
     {
     {
-        $book_key = 'wap:string:book:' . $bid;
+        $book_key  = 'wap:string:book:' . $bid;
         $book_name = Redis::get($book_key);
         $book_name = Redis::get($book_key);
         Redis::EXPIRE($book_key, 3600);
         Redis::EXPIRE($book_key, 3600);
         if (!$book_name) {
         if (!$book_name) {
@@ -317,7 +326,7 @@ class ReadRecordService
      */
      */
     public static function cid2ChapterName($cid)
     public static function cid2ChapterName($cid)
     {
     {
-        $chapter_key = 'wap:string:chapter:' . $cid;
+        $chapter_key  = 'wap:string:chapter:' . $cid;
         $chapter_name = Redis::get($chapter_key);
         $chapter_name = Redis::get($chapter_key);
         Redis::EXPIRE($chapter_key, 3600);
         Redis::EXPIRE($chapter_key, 3600);
         if (!$chapter_name) {
         if (!$chapter_name) {
@@ -340,10 +349,10 @@ class ReadRecordService
         $base_record = Redis::hget('book_base:' . $uid, 'last_read');
         $base_record = Redis::hget('book_base:' . $uid, 'last_read');
         if ($base_record) {
         if ($base_record) {
             $record_arr = explode('_', $base_record);
             $record_arr = explode('_', $base_record);
-            $c = count($record_arr);
+            $c          = count($record_arr);
             if ($c > 3) {
             if ($c > 3) {
-                $bid = $record_arr[0];
-                $cid = $record_arr[1];
+                $bid  = $record_arr[0];
+                $cid  = $record_arr[1];
                 $time = $record_arr[$c - 1];
                 $time = $record_arr[$c - 1];
                 Redis::hset('book_base:' . $uid, 'last_read', "{$bid}_{$cid}_" . $time);
                 Redis::hset('book_base:' . $uid, 'last_read', "{$bid}_{$cid}_" . $time);
             }
             }
@@ -351,15 +360,15 @@ class ReadRecordService
         $records = Redis::hgetall('book_read:' . $uid);
         $records = Redis::hgetall('book_read:' . $uid);
         foreach ($records as $key => $v) {
         foreach ($records as $key => $v) {
             $record = explode('_', $v);
             $record = explode('_', $v);
-            $count = count($record);
+            $count  = count($record);
             if ($count > 3) {
             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];
                 $latest_read_time = $record[$count - 1];
                 Redis::hset('book_read:' . $uid, $key, "{$latest_read_cid}_" . $latest_read_time);
                 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;
                 $chapter_key = 'wap:string:chapter:' . $latest_read_cid;
                 Redis::set($book_key, $book_name);
                 Redis::set($book_key, $book_name);
                 Redis::set($chapter_key, $chapter_name);
                 Redis::set($chapter_key, $chapter_name);
@@ -384,7 +393,7 @@ class ReadRecordService
     public static function getSimpleReadRecord(int $uid): array
     public static function getSimpleReadRecord(int $uid): array
     {
     {
         $read_bids = Redis::hgetall('book_read:' . $uid);
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $res = [];
+        $res       = [];
         if (!$read_bids) {
         if (!$read_bids) {
             return $res;
             return $res;
         }
         }
@@ -402,11 +411,11 @@ class ReadRecordService
     {
     {
         try {
         try {
             DB::table('temp_read_active')->insert([
             DB::table('temp_read_active')->insert([
-                'uid' => $uid,
+                'uid'                     => $uid,
                 'distribution_channel_id' => $distribution_channel_id,
                 '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) {
         } catch (\Exception $e) {
         }
         }
@@ -422,7 +431,7 @@ class ReadRecordService
         try {
         try {
             $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;
@@ -458,6 +467,7 @@ class ReadRecordService
         }
         }
         return '';
         return '';
     }
     }
+
     /**
     /**
      * 签到日期
      * 签到日期
      * @param int $uid
      * @param int $uid
@@ -522,7 +532,7 @@ class ReadRecordService
         try {
         try {
             $count = Redis::hget('book_read:' . $uid, 'sign_counts');
             $count = Redis::hget('book_read:' . $uid, 'sign_counts');
             if ($count) {
             if ($count) {
-                return (int) $count;
+                return (int)$count;
             }
             }
             return 0;
             return 0;
         } catch (\Exception $e) {
         } catch (\Exception $e) {
@@ -555,7 +565,7 @@ class ReadRecordService
 
 
     public static function getSmartPush(int $uid): array
     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) {
         if ($res) {
             return explode(',', $res);
             return explode(',', $res);
         }
         }
@@ -631,15 +641,15 @@ class ReadRecordService
             return;
             return;
         }
         }
         $read_bids = Redis::hgetall('book_read:' . $uid);
         $read_bids = Redis::hgetall('book_read:' . $uid);
-        $i = 0;
+        $i         = 0;
         foreach ($read_bids as $key => $v) {
         foreach ($read_bids as $key => $v) {
             if (in_array($key, self::$not_uid_key)) {
             if (in_array($key, self::$not_uid_key)) {
                 continue;
                 continue;
             }
             }
-            $record = explode('_', $v);
-            $latest_read_cid = $record[0];
+            $record           = explode('_', $v);
+            $latest_read_cid  = $record[0];
             $latest_read_time = $record[count($record) - 1];
             $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) {
         usort($res, function ($a, $b) {
             if ($a['time'] >= $b['time']) return -1;
             if ($a['time'] >= $b['time']) return -1;