fly 5 年之前
父节点
当前提交
4ab7138916
共有 2 个文件被更改,包括 296 次插入353 次删除
  1. 99 108
      app/Http/Controllers/QuickApp/Book/BookController.php
  2. 197 245
      app/Http/Controllers/QuickApp/Book/ChapterController.php

+ 99 - 108
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -1,17 +1,20 @@
 <?php
 <?php
 
 
 namespace App\Http\Controllers\QuickApp\Book;
 namespace App\Http\Controllers\QuickApp\Book;
+
 use App\Modules\RecommendBook\Services\RecommendService;
 use App\Modules\RecommendBook\Services\RecommendService;
 use App\Modules\Book\Services\RecoBannerService;
 use App\Modules\Book\Services\RecoBannerService;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use App\Http\Controllers\QuickApp\BaseController;
 use App\Http\Controllers\QuickApp\BaseController;
 use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
 use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
 use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Services\BookConfigService;
+use App\Modules\Book\Services\BookService;
 use App\Modules\Book\Services\UserShelfBooksService;
 use App\Modules\Book\Services\UserShelfBooksService;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\Book\Services\ChapterService;
 use Hashids;
 use Hashids;
 use App\Modules\Subscribe\Services\YearOrderService;
 use App\Modules\Subscribe\Services\YearOrderService;
 use Log;
 use Log;
+
 class BookController extends BaseController
 class BookController extends BaseController
 {
 {
 
 
@@ -90,24 +93,25 @@ class BookController extends BaseController
      *           }
      *           }
      *       }
      *       }
      */
      */
-    public function index(Request $request,$bid){
-        $bid = Hashids::decode($bid)[0];
+    public function index(Request $request, $bid)
+    {
+        $bid = BookService::decodeBidStatic($bid);
         $book_info = BookConfigService::getBookById($bid);
         $book_info = BookConfigService::getBookById($bid);
-        if(!$book_info){
+        if (!$book_info) {
             return response()->error('QAPP_SYS_ERROR');
             return response()->error('QAPP_SYS_ERROR');
         }
         }
-        if(!in_array($book_info->is_on_shelf,[2])){
+        if (!in_array($book_info->is_on_shelf, [2])) {
             return response()->error('QAPP_OFF  _SHELF');
             return response()->error('QAPP_OFF  _SHELF');
         }
         }
-        $is_on_shelf = UserShelfBooksService::getUserShelfBooksListByUidAndBid($this->uid,$bid);
+        $is_on_shelf = UserShelfBooksService::getUserShelfBooksListByUidAndBid($this->uid, $bid);
 
 
         $book_info['is_on_user_shelf'] = 0;
         $book_info['is_on_user_shelf'] = 0;
 
 
-        if($is_on_shelf){
+        if ($is_on_shelf) {
             $book_info['is_on_user_shelf'] = 1;
             $book_info['is_on_user_shelf'] = 1;
         }
         }
 
 
-        $last_chapter = ChapterService::getChapterNameById($book_info['last_cid'],$bid);//chapter_is_vip
+        $last_chapter = ChapterService::getChapterNameById($book_info['last_cid'], $bid); //chapter_is_vip
 
 
         $book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
         $book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
         return response()->item(new BookTransformer(), $book_info);
         return response()->item(new BookTransformer(), $book_info);
@@ -148,9 +152,10 @@ class BookController extends BaseController
      *               ]
      *               ]
      *       }
      *       }
      */
      */
-    public function getBookLists(Request $request,$sex){
+    public function getBookLists(Request $request, $sex)
+    {
 
 
-        if($sex == 'male'){
+        if ($sex == 'male') {
             $type = [
             $type = [
                 'BOOK_MALE_LOOP',
                 'BOOK_MALE_LOOP',
                 'BOOK_MALE_HOT',
                 'BOOK_MALE_HOT',
@@ -159,8 +164,8 @@ class BookController extends BaseController
                 'BOOK_MALE_NEW_RECOM'
                 'BOOK_MALE_NEW_RECOM'
             ];
             ];
             $channel = 1;
             $channel = 1;
-            $reco_banner_type = ['MALE','PUBLIC'];
-        }else{
+            $reco_banner_type = ['MALE', 'PUBLIC'];
+        } else {
             $type = [
             $type = [
                 'BOOK_FEMALE_LOOP',
                 'BOOK_FEMALE_LOOP',
                 'BOOK_FEMALE_HOT',
                 'BOOK_FEMALE_HOT',
@@ -168,32 +173,19 @@ class BookController extends BaseController
                 'BOOK_FEMALE_RECOM',
                 'BOOK_FEMALE_RECOM',
                 'BOOK_FEMALE_NEW_RECOM'
                 'BOOK_FEMALE_NEW_RECOM'
             ];
             ];
-            $reco_banner_type = ['FEMALE','PUBLIC'];
+            $reco_banner_type = ['FEMALE', 'PUBLIC'];
             $channel = 2;
             $channel = 2;
         }
         }
 
 
-//        $cache_key = 'wap_index_page_'.$sex;
-//        $cache_book =Cache::get($cache_key,'');
-//        if($cache_book){
-//            //$cache_book = json_decode($cache_book);
-//            //return response()->success($cache_book);
-//        }
         $book = [
         $book = [
-            ['type'=>'reco_banner','lable'=>'','books'=>RecoBannerService::getByType($reco_banner_type)],
-            //['type'=>'lunbo','lable'=>'','books'=>collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel,'loop')))],
-            ['type'=>'hot','lable'=>'热门推荐','books'=>collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel,'hot')))],
-            ['type'=>'zhibo','lable'=>'神书直播','books'=>collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel,'live')))],
-            ['type'=>'recom','lable'=>'编辑推荐','books'=>collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel,'recom')))],
-            ['type'=>'new_recom','lable'=>'新书推荐','books'=>collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel,'new_recom')))],
+            ['type' => 'reco_banner', 'lable' => '', 'books' => RecoBannerService::getByType($reco_banner_type)],
+            ['type' => 'hot', 'lable' => '热门推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'hot')))],
+            ['type' => 'zhibo', 'lable' => '神书直播', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'live')))],
+            ['type' => 'recom', 'lable' => '编辑推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'recom')))],
+            ['type' => 'new_recom', 'lable' => '新书推荐', 'books' => collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(RecommendService::getRecommendBooksIds($channel, 'new_recom')))],
 
 
         ];
         ];
-        /*foreach ($type as $key=>$v){
-            $book[$key]['books']  = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',env($v))));
-        }*/
-        //\Log::info($book);
-        //Cache::put($cache_key, json_encode($book), 60*24);
         return response()->success($book);
         return response()->success($book);
-
     }
     }
 
 
 
 
@@ -295,19 +287,18 @@ class BookController extends BaseController
      *           }
      *           }
      *       }
      *       }
      */
      */
-    public function library(Request $request){
+    public function library(Request $request)
+    {
         $where = [];
         $where = [];
-        //$order = ['book_configs.id','asc'];
         $order = [];
         $order = [];
-//        $where['is_on_shelf'] = [1,2];
         $where['is_on_shelf'] = [2];
         $where['is_on_shelf'] = [2];
         $category_id = $request->input('category_id');
         $category_id = $request->input('category_id');
-        if($category_id){
-            if($category_id == 1){
+        if ($category_id) {
+            if ($category_id == 1) {
                 $where['channel_name'] = '男频';
                 $where['channel_name'] = '男频';
-            }elseif($category_id == 2){
+            } elseif ($category_id == 2) {
                 $where['channel_name'] = '女频';
                 $where['channel_name'] = '女频';
-            }else{
+            } else {
                 $where['category_id'] = $category_id;
                 $where['category_id'] = $category_id;
             }
             }
         }
         }
@@ -315,30 +306,29 @@ class BookController extends BaseController
         $where['key'] = $key;
         $where['key'] = $key;
         $order_field = $request->input('order_field');
         $order_field = $request->input('order_field');
         $order_seq = $request->input('order_seq');
         $order_seq = $request->input('order_seq');
-        if($order_field != '' && in_array($order_field,['recommend_index','click_count','update','size','create'])){
-            if($order_field == 'update'){
-                $order = ['book_configs.updated_at','desc'];
-            }elseif ($order_field == 'create') {
-                $order = ['book_configs.created_at','desc'];
-            }
-            else{
-                $order = [$order_field,'desc'];
+        if ($order_field != '' && in_array($order_field, ['recommend_index', 'click_count', 'update', 'size', 'create'])) {
+            if ($order_field == 'update') {
+                $order = ['book_configs.updated_at', 'desc'];
+            } elseif ($order_field == 'create') {
+                $order = ['book_configs.created_at', 'desc'];
+            } else {
+                $order = [$order_field, 'desc'];
             }
             }
 
 
-            if($order_seq == 'asc'){
-                $order = [$order_field,'asc'];
+            if ($order_seq == 'asc') {
+                $order = [$order_field, 'asc'];
             }
             }
-            if($order_seq == 'desc'){
-                $order = [$order_field,'desc'];
+            if ($order_seq == 'desc') {
+                $order = [$order_field, 'desc'];
             }
             }
         }
         }
         $status = $request->input('status');
         $status = $request->input('status');
-        if($status != ''){
+        if ($status != '') {
             $where['status'] = $status;
             $where['status'] = $status;
         }
         }
-        $page_size = $request->input('page_size',15);
-        $books = BookConfigService::getBooks($where,$order,$page_size);
-        return response()->pagination(new BookTransformer,$books);
+        $page_size = $request->input('page_size', 15);
+        $books = BookConfigService::getBooks($where, $order, $page_size);
+        return response()->pagination(new BookTransformer, $books);
     }
     }
 
 
 
 
@@ -417,23 +407,23 @@ class BookController extends BaseController
      *           }
      *           }
      *       }
      *       }
      */
      */
-    public function similarRecom (Request $request){
+    public function similarRecom(Request $request)
+    {
         $category_id = $request->input('category_id');
         $category_id = $request->input('category_id');
         $bid = $request->input('bid');
         $bid = $request->input('bid');
-        if(empty($bid) || empty($category_id)){
+        if (empty($bid) || empty($category_id)) {
             return response()->error('PARAM_ERROR');
             return response()->error('PARAM_ERROR');
         }
         }
-        $bid = Hashids::decode($bid)[0];
-
-        $where = ['category_id'=>$category_id,'is_on_shelf'=>[2]];
-        $books = BookConfigService::getBooks($where,[],4);
+        $bid = BookService::decodeBidStatic($bid);
+        $where = ['category_id' => $category_id, 'is_on_shelf' => [2]];
+        $books = BookConfigService::getBooks($where, [], 4);
         $data = [];
         $data = [];
-        foreach ($books as $v){
-            if($v->bid != $bid && count($data) <3){
+        foreach ($books as $v) {
+            if ($v->bid != $bid && count($data) < 3) {
                 $data[] = $v;
                 $data[] = $v;
             }
             }
         }
         }
-        return response()->collection(new BookTransformer(),$data);
+        return response()->collection(new BookTransformer(), $data);
     }
     }
 
 
 
 
@@ -511,15 +501,16 @@ class BookController extends BaseController
      *           }
      *           }
      *       }
      *       }
      */
      */
-    public function readOverRecommend(Request $request){
+    public function readOverRecommend(Request $request)
+    {
         $bid = $request->input('bid');
         $bid = $request->input('bid');
-        if(empty($bid)){
+        if (empty($bid)) {
             return response()->error('PARAM_ERROR');
             return response()->error('PARAM_ERROR');
         }
         }
-        $bid = Hashids::decode($bid)[0];
+        $bid = BookService::decodeBidStatic($bid);
         $book_info = BookConfigService::getBookById($bid);
         $book_info = BookConfigService::getBookById($bid);
-        $res = BookConfigService::getQuickAppRecommendBooks($bid,$book_info->category_id);
-        return response()->collection(new BookTransformer(),$res);
+        $res = BookConfigService::getQuickAppRecommendBooks($bid, $book_info->category_id);
+        return response()->collection(new BookTransformer(), $res);
     }
     }
 
 
     /**
     /**
@@ -598,63 +589,63 @@ class BookController extends BaseController
      *           }
      *           }
      *       }
      *       }
      */
      */
-    public function rank(Request $request){
+    public function rank(Request $request)
+    {
         $type = $request->input('type');
         $type = $request->input('type');
         $time = $request->input('time');
         $time = $request->input('time');
 
 
-        if($type == 1){
+        if ($type == 1) {
             //点击帮
             //点击帮
-            if($time == 1){
+            if ($time == 1) {
                 //周
                 //周
-                $midstr = env('CLICK_RANK_MALE_WEEK','677,694,638,642,641,673,635,639,637,4');
-                $fidstr = env('CLICK_RANK_FEMALE_WEEK','614,636,587,48,1,6,354,99,159,355');
-            }elseif($time == 2){
+                $midstr = env('CLICK_RANK_MALE_WEEK', '677,694,638,642,641,673,635,639,637,4');
+                $fidstr = env('CLICK_RANK_FEMALE_WEEK', '614,636,587,48,1,6,354,99,159,355');
+            } elseif ($time == 2) {
                 //月
                 //月
-                $midstr = env('CLICK_RANK_MALE_MONTH','757,775,780,612,638,635,694,639,642,693');
-                $fidstr = env('CLICK_RANK_FEMALE_MONTH','324,614,6,1,5,10,48,57,41,58');
-            }else{
-                $midstr = env('CLICK_RANK_MALE_TOTAL','757,775,780,612,634,677,694,638,642,635');
-                $fidstr = env('CLICK_RANK_FEMALE_TOTAL','324,614,636,1,5,6,521,10,41,48');
+                $midstr = env('CLICK_RANK_MALE_MONTH', '757,775,780,612,638,635,694,639,642,693');
+                $fidstr = env('CLICK_RANK_FEMALE_MONTH', '324,614,6,1,5,10,48,57,41,58');
+            } else {
+                $midstr = env('CLICK_RANK_MALE_TOTAL', '757,775,780,612,634,677,694,638,642,635');
+                $fidstr = env('CLICK_RANK_FEMALE_TOTAL', '324,614,636,1,5,6,521,10,41,48');
             }
             }
-            $female = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$fidstr)));
-            $male = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$midstr)));
-        }elseif($type == 2){
+            $female = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', $fidstr)));
+            $male = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', $midstr)));
+        } elseif ($type == 2) {
             //字数帮
             //字数帮
-            if($time == 1){
+            if ($time == 1) {
                 //周
                 //周
-                $midstr = env('WORD_RANK_MALE_WEEK','638,673,635,637,680,642,86,774,764,736');
-                $fidstr = env('WORD_RANK_FEMALE_WEEK','48,58,324,354,159,262,7,9,11,525');
-            }elseif($time == 2){
+                $midstr = env('WORD_RANK_MALE_WEEK', '638,673,635,637,680,642,86,774,764,736');
+                $fidstr = env('WORD_RANK_FEMALE_WEEK', '48,58,324,354,159,262,7,9,11,525');
+            } elseif ($time == 2) {
                 //月
                 //月
-                $midstr = env('WORD_RANK_MALE_MONTH','2,638,642,635,639,4,743,680,736,73');
-                $fidstr = env('WORD_RANK_FEMALE_MONTH','1,10,48,58,324,354,159,442,355,464');
-            }else{
-                $midstr = env('WORD_RANK_MALE_TOTAL','638,677,694,635,612,693,634,642,775,780');
-                $fidstr = env('WORD_RANK_FEMALE_TOTAL','57,636,614,1,10,48,58,324,354,99');
-            }    
-            $female = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$fidstr)));
-            $male = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$midstr)));
-        }
-        elseif ($type == 3) {
+                $midstr = env('WORD_RANK_MALE_MONTH', '2,638,642,635,639,4,743,680,736,73');
+                $fidstr = env('WORD_RANK_FEMALE_MONTH', '1,10,48,58,324,354,159,442,355,464');
+            } else {
+                $midstr = env('WORD_RANK_MALE_TOTAL', '638,677,694,635,612,693,634,642,775,780');
+                $fidstr = env('WORD_RANK_FEMALE_TOTAL', '57,636,614,1,10,48,58,324,354,99');
+            }
+            $female = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', $fidstr)));
+            $male = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', $midstr)));
+        } elseif ($type == 3) {
             //新书榜
             //新书榜
-            if($time == 1){
+            if ($time == 1) {
                 //周
                 //周
-                $midstr = env('NEW_RANK_MALE_WEEK','635,639,4,642,629,446,741,737,731,86');
-                $fidstr = env('NEW_RANK_FEMALE_WEEK','135,587,617,625,627,467,213,233,529,357');
-            }elseif($time == 2){
+                $midstr = env('NEW_RANK_MALE_WEEK', '635,639,4,642,629,446,741,737,731,86');
+                $fidstr = env('NEW_RANK_FEMALE_WEEK', '135,587,617,625,627,467,213,233,529,357');
+            } elseif ($time == 2) {
                 //月
                 //月
-                $midstr = env('NEW_RANK_MALE_MONTH','757,775,780,612,634,677,694,638,642,635');
-                $fidstr = env('NEW_RANK_FEMALE_MONTH','33,39,40,51,587,617,625,627,50,60');
-            }else{
-                $midstr = env('NEW_RANK_MALE_TOTAL','693,641,673,637,4,3,612,634,677,694');
-                $fidstr = env('NEW_RANK_FEMALE_TOTAL','284,30,33,39,40,51,587,50,60,357');
+                $midstr = env('NEW_RANK_MALE_MONTH', '757,775,780,612,634,677,694,638,642,635');
+                $fidstr = env('NEW_RANK_FEMALE_MONTH', '33,39,40,51,587,617,625,627,50,60');
+            } else {
+                $midstr = env('NEW_RANK_MALE_TOTAL', '693,641,673,637,4,3,612,634,677,694');
+                $fidstr = env('NEW_RANK_FEMALE_TOTAL', '284,30,33,39,40,51,587,50,60,357');
             }
             }
-            $female = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$fidstr)));
-            $male = collectionTransform(new BookTransformer,BookConfigService::getBooksByIds(explode(',',$midstr)));
-        }else{
+            $female = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', $fidstr)));
+            $male = collectionTransform(new BookTransformer, BookConfigService::getBooksByIds(explode(',', $midstr)));
+        } else {
             return response()->error('PARAM_ERROR');
             return response()->error('PARAM_ERROR');
         }
         }
-        $data = ['male'=>$male,'female'=>$female];
+        $data = ['male' => $male, 'female' => $female];
         return response()->success($data);
         return response()->success($data);
     }
     }
 }
 }

+ 197 - 245
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -10,18 +10,16 @@ use App\Modules\User\Services\ReadRecordService;
 use App\Http\Controllers\QuickApp\Book\Transformers\ChapterTransformer;
 use App\Http\Controllers\QuickApp\Book\Transformers\ChapterTransformer;
 use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Book\Services\BookConfigService;
 use App\Http\Controllers\QuickApp\Book\Transformers\ChapterListTransformer;
 use App\Http\Controllers\QuickApp\Book\Transformers\ChapterListTransformer;
+use App\Modules\Book\Services\BookService;
 use App\Modules\Subscribe\Services\BookOrderService;
 use App\Modules\Subscribe\Services\BookOrderService;
 use App\Modules\Subscribe\Services\ChapterOrderService;
 use App\Modules\Subscribe\Services\ChapterOrderService;
 use App\Modules\Subscribe\Services\YearOrderService;
 use App\Modules\Subscribe\Services\YearOrderService;
 use App\Modules\OfficialAccount\Services\ForceSubscribeService;
 use App\Modules\OfficialAccount\Services\ForceSubscribeService;
 use App\Modules\Subscribe\Services\ChapterReminderService;
 use App\Modules\Subscribe\Services\ChapterReminderService;
-use App\Modules\OfficialAccount\Services\OfficialAccountService;
 use Hashids;
 use Hashids;
-use GuzzleHttp\Client;
-use Log;
-use DB;
 use App\Modules\User\Services\UserSignService;
 use App\Modules\User\Services\UserSignService;
 use App\Modules\User\Services\UserDeepReadTagService;
 use App\Modules\User\Services\UserDeepReadTagService;
+
 class ChapterController extends BaseController
 class ChapterController extends BaseController
 {
 {
 
 
@@ -92,14 +90,11 @@ class ChapterController extends BaseController
      *          ]
      *          ]
      *       }
      *       }
      */
      */
-    public function getCatalog(Request $request,$bid)
+    public function getCatalog(Request $request, $bid)
     {
     {
-
-//        $bid = Hashids::decode($bid)[0];
+        $bid = BookService::decodeBidStatic($bid);
         $lists = ChapterService::getChapterLists($bid);
         $lists = ChapterService::getChapterLists($bid);
-
         $book_info = BookConfigService::getBookById($bid);
         $book_info = BookConfigService::getBookById($bid);
-
         if (!$book_info) {
         if (!$book_info) {
             return response()->error('PARAM_ERROR');
             return response()->error('PARAM_ERROR');
         }
         }
@@ -112,9 +107,9 @@ class ChapterController extends BaseController
                 $v->price = $this->getPrice($book_info, $v);
                 $v->price = $this->getPrice($book_info, $v);
             }
             }
 
 
-            if ($v->sequence==$book_info->force_subscribe_chapter_seq){
+            if ($v->sequence == $book_info->force_subscribe_chapter_seq) {
                 $v->is_need_subscirb = 1;
                 $v->is_need_subscirb = 1;
-            }else{
+            } else {
                 $v->is_need_subscirb = 0;
                 $v->is_need_subscirb = 0;
             }
             }
         }
         }
@@ -194,31 +189,16 @@ class ChapterController extends BaseController
      *         }
      *         }
      *       }
      *       }
      */
      */
-//    public function getCatalogPerPage(Request $request,$bid){
-//        $bid = Hashids::decode($bid)[0];
-//        $page_size = $request->input('page_size',15);
-//        $res = ChapterService::getChapterListsPage($bid,$page_size);
-//        return response()->pagination(new ChapterListTransformer,$res);
-//    }
     public function getCatalogPerPage(Request $request, $bid)
     public function getCatalogPerPage(Request $request, $bid)
     {
     {
-
-
-
-        $bid_array = Hashids::decode($bid);
-//        $bid_array = $bid;
-        if (isset($bid_array[0])) {
-            $bid = $bid_array[0];
-        } else {
-            return response()->error('PARAM_ERROR');
-        }
+        $bid = BookService::decodeBidStatic($bid);
         $book_info = BookConfigService::getBookById($bid);
         $book_info = BookConfigService::getBookById($bid);
         if (!$book_info) {
         if (!$book_info) {
             return response()->error('PARAM_ERROR');
             return response()->error('PARAM_ERROR');
         }
         }
         $this->book_info = $book_info;
         $this->book_info = $book_info;
         $page_size = $request->input('page_size', 15);
         $page_size = $request->input('page_size', 15);
-        if($page_size>=100) $page_size=100;
+        if ($page_size >= 100) $page_size = 100;
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $res = ChapterService::getChapterListsPage($bid, $page_size);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
         foreach ($res as $v) {
         foreach ($res as $v) {
@@ -227,9 +207,9 @@ class ChapterController extends BaseController
             if ($is_show_price) {
             if ($is_show_price) {
                 $v->price = $this->getPrice($book_info, $v);
                 $v->price = $this->getPrice($book_info, $v);
             }
             }
-            if ($v->sequence==$book_info->force_subscribe_chapter_seq){
+            if ($v->sequence == $book_info->force_subscribe_chapter_seq) {
                 $v->is_need_subscirb = 1;
                 $v->is_need_subscirb = 1;
-            }else{
+            } else {
                 $v->is_need_subscirb = 0;
                 $v->is_need_subscirb = 0;
             }
             }
         }
         }
@@ -277,119 +257,118 @@ class ChapterController extends BaseController
      *            }
      *            }
      *       }
      *       }
      */
      */
-    public function index(Request $request,$bid,$cid){
+    public function index(Request $request, $bid, $cid)
+    {
         $oldbid = $bid;
         $oldbid = $bid;
-        $bid = Hashids::decode($bid)[0];
         //获取图书信息
         //获取图书信息
         $book_info  = BookConfigService::getBookById($bid);
         $book_info  = BookConfigService::getBookById($bid);
-
-
-        if(empty($book_info)) return response()->error('QAPP_SYS_ERROR');
-
-        if($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3){
-            //return response()->error('QAPP_OFF_SHELF');
-        }
+        if (empty($book_info)) return response()->error('QAPP_SYS_ERROR');
         //获取章节信息
         //获取章节信息
-        $chapter = ChapterService::getChapterNameById($cid,$bid);
-        if(!$chapter){
+        $chapter = ChapterService::getChapterNameById($cid, $bid);
+        if (!$chapter) {
             return response()->error('QAPP_SYS_ERROR');
             return response()->error('QAPP_SYS_ERROR');
         }
         }
 
 
-        if($chapter->is_vip == 0){
-            ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
-                'cid'=>$cid,'chapter_name'=>$chapter->name ]);
+        if ($chapter->is_vip == 0) {
+            ReadRecordService::addReadRecord([
+                'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
+                'cid' => $cid, 'chapter_name' => $chapter->name
+            ]);
             //用户标签
             //用户标签
-            if($chapter->sequence >= 20){
+            if ($chapter->sequence >= 20) {
                 $this->addTag($book_info);
                 $this->addTag($book_info);
             }
             }
-            return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
+            return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
         }
 
 
         //已经付费
         //已经付费
-        if($this->getOrderRecord($bid,$cid)){
-            ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
-                'cid'=>$cid,'chapter_name'=>$chapter->name ]);
+        if ($this->getOrderRecord($bid, $cid)) {
+            ReadRecordService::addReadRecord([
+                'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
+                'cid' => $cid, 'chapter_name' => $chapter->name
+            ]);
             //用户标签
             //用户标签
-            if($chapter->sequence >= 20){
+            if ($chapter->sequence >= 20) {
                 $this->addTag($book_info);
                 $this->addTag($book_info);
             }
             }
-            return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
+            return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
         }
         }
 
 
         //未付费 要提醒
         //未付费 要提醒
         $user_info = $this->_user_info;
         $user_info = $this->_user_info;
         //未付费 余额不足
         //未付费 余额不足
-        $fee = $this->getPrice($book_info,$chapter->size);
+        $fee = $this->getPrice($book_info, $chapter->size);
         $data = [
         $data = [
-            'book_id'=>$oldbid,
-            'book_name'=>$book_info->book_name,
-            'chapter_name'=>$chapter->name,
-            'chapter_id'=>$cid,
-            'pay_type'=>$book_info->charge_type,
-            'fee'=>$fee,
-            'user_balance'=>$user_info->balance,
-            'product_id'=>$book_info->product_id,
-            'uid'=>$this->uid,
-            'distribution_channel_id'=>$this->distribution_channel_id,
-            'is_discount'=>0,
+            'book_id' => $oldbid,
+            'book_name' => $book_info->book_name,
+            'chapter_name' => $chapter->name,
+            'chapter_id' => $cid,
+            'pay_type' => $book_info->charge_type,
+            'fee' => $fee,
+            'user_balance' => $user_info->balance,
+            'product_id' => $book_info->product_id,
+            'uid' => $this->uid,
+            'distribution_channel_id' => $this->distribution_channel_id,
+            'is_discount' => 0,
             'discount_fee' => '',
             'discount_fee' => '',
-            'discount'=>''
+            'discount' => ''
 
 
         ];
         ];
 
 
-        if($user_info['balance'] < $fee){
+        if ($user_info['balance'] < $fee) {
             //需要提箱
             //需要提箱
-            if($this->isOrderRemind($bid)){
-
-                if($book_info->charge_type == 'BOOK'){
-                    return response()->error('QAPP_BOOK_BALANCE_PAY',$data);
-                }else
-                    if($book_info->charge_type == 'CHAPTER'){
-                        return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE',$data);
-                    }else{
-                        return response()->error('QAPP_SYS_ERROR');
-                    }
-            }else{
+            if ($this->isOrderRemind($bid)) {
+
+                if ($book_info->charge_type == 'BOOK') {
+                    return response()->error('QAPP_BOOK_BALANCE_PAY', $data);
+                } else
+                    if ($book_info->charge_type == 'CHAPTER') {
+                    return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE', $data);
+                } else {
+                    return response()->error('QAPP_SYS_ERROR');
+                }
+            } else {
                 //不需要提醒
                 //不需要提醒
-                if($book_info->charge_type == 'BOOK'){
-                    return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY',$data);
-                }elseif($book_info->charge_type == 'CHAPTER'){
-                    return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY',$data);
-                }else{
+                if ($book_info->charge_type == 'BOOK') {
+                    return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY', $data);
+                } elseif ($book_info->charge_type == 'CHAPTER') {
+                    return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY', $data);
+                } else {
                     return response()->error('QAPP_SYS_ERROR');
                     return response()->error('QAPP_SYS_ERROR');
                 }
                 }
             }
             }
         }
         }
 
 
-        if($this->isOrderRemind($bid)){
-            //return response()->error('INSUFFICIENT_BALANCE',$data);
-            if($book_info->charge_type  == 'BOOK'){
-                return response()->error('QAPP_BOOK_BUY',$data);
-            }else
-                if($book_info->charge_type == 'CHAPTER'){
-                    return response()->error('QAPP_CHAPTER_BUY',$data);
-                }else{
-                    return response()->error('QAPP_SYS_ERROR');
-                }
+        if ($this->isOrderRemind($bid)) {
+            if ($book_info->charge_type  == 'BOOK') {
+                return response()->error('QAPP_BOOK_BUY', $data);
+            } else
+                if ($book_info->charge_type == 'CHAPTER') {
+                return response()->error('QAPP_CHAPTER_BUY', $data);
+            } else {
+                return response()->error('QAPP_SYS_ERROR');
+            }
         }
         }
         //付费 不提醒
         //付费 不提醒
-        if($this->balancePay($book_info,$cid,$chapter->size,$chapter->name,0)){
+        if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, 0)) {
 
 
-            ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
-                'cid'=>$cid,'chapter_name'=>$chapter->name ]);
+            ReadRecordService::addReadRecord([
+                'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
+                'cid' => $cid, 'chapter_name' => $chapter->name
+            ]);
             //用户标签
             //用户标签
-            if($chapter->sequence >= 20){
+            if ($chapter->sequence >= 20) {
                 $this->addTag($book_info);
                 $this->addTag($book_info);
             }
             }
-            return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
-        }else{
+            return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
+        } else {
 
 
             //不需要提醒
             //不需要提醒
-            if($book_info->charge_type == 'BOOK'){
-                return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY',$data);
-            }elseif($book_info->charge_type == 'CHAPTER'){
-                return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY',$data);
-            }else{
+            if ($book_info->charge_type == 'BOOK') {
+                return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY', $data);
+            } elseif ($book_info->charge_type == 'CHAPTER') {
+                return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY', $data);
+            } else {
                 return response()->error('QAPP_SYS_ERROR');
                 return response()->error('QAPP_SYS_ERROR');
             }
             }
         }
         }
@@ -437,57 +416,60 @@ class ChapterController extends BaseController
      *            }
      *            }
      *       }
      *       }
      */
      */
-    public function pay(Request $request,$bid,$cid){
-        $remind = (int)$request->input('remind');
+    public function pay(Request $request, $bid, $cid)
+    {
+        $remind = (int) $request->input('remind');
         $oldbid = $bid;
         $oldbid = $bid;
-        $bid = Hashids::decode($bid)[0];
+        $bid = BookService::decodeBidStatic($bid);
         $book_info = BookConfigService::getBookById($bid);;
         $book_info = BookConfigService::getBookById($bid);;
-        if(empty($book_info)) response()->error('QAPP_SYS_ERROR');
+        if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
 
 
-        if($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3){
-            if(!$this->isBookOrdered($bid)){
+        if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
+            if (!$this->isBookOrdered($bid)) {
                 response()->error('QAPP_OFF_SHELF');
                 response()->error('QAPP_OFF_SHELF');
-            } 
+            }
         }
         }
         //获取章节
         //获取章节
-        $chapter = ChapterService::getChapterNameById($cid,$bid);
-        if(!$chapter){
+        $chapter = ChapterService::getChapterNameById($cid, $bid);
+        if (!$chapter) {
             return response()->error('QAPP_SYS_ERROR');
             return response()->error('QAPP_SYS_ERROR');
         }
         }
 
 
 
 
-        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 ]);
+        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
+            ]);
             //用户标签
             //用户标签
-            if($chapter->sequence >= 20){
+            if ($chapter->sequence >= 20) {
                 $this->addTag($book_info);
                 $this->addTag($book_info);
             }
             }
-            return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
-        }else{
-            $fee = $this->getPrice($book_info,$chapter->size);
+            return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
+        } else {
+            $fee = $this->getPrice($book_info, $chapter->size);
 
 
             $data = [
             $data = [
-                'book_id'=>$oldbid,
-                'book_name'=>$book_info->book_name,
-                'chapter_name'=>$chapter->name,
-                'chapter_id'=>$cid,
-                'pay_type'=>$book_info->charge_type,
-                'fee'=>$fee,
-                'user_balance'=>$this->_user_info['balance'],
-                'product_id'=>$book_info->product_id,
-                'uid'=>$this->uid,
-                'distribution_channel_id'=>$this->distribution_channel_id,
-                'is_discount'=>0,
+                'book_id' => $oldbid,
+                'book_name' => $book_info->book_name,
+                'chapter_name' => $chapter->name,
+                'chapter_id' => $cid,
+                'pay_type' => $book_info->charge_type,
+                'fee' => $fee,
+                'user_balance' => $this->_user_info['balance'],
+                'product_id' => $book_info->product_id,
+                'uid' => $this->uid,
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'is_discount' => 0,
                 'discount_fee' => '',
                 'discount_fee' => '',
-                'discount'=>''
+                'discount' => ''
             ];
             ];
             //不需要提醒
             //不需要提醒
-            if($book_info->charge_type == 'BOOK'){
-                return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY',$data);
-            }elseif($book_info->charge_type == 'CHAPTER'){
-                return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY',$data);
-            }else{
+            if ($book_info->charge_type == 'BOOK') {
+                return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY', $data);
+            } elseif ($book_info->charge_type == 'CHAPTER') {
+                return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY', $data);
+            } else {
                 return response()->error('QAPP_SYS_ERROR');
                 return response()->error('QAPP_SYS_ERROR');
             }
             }
         }
         }
@@ -502,17 +484,17 @@ class ChapterController extends BaseController
      * @param $chapter_size
      * @param $chapter_size
      * @return bool
      * @return bool
      */
      */
-    protected function balancePay($book_info,$chapter_id,$chapter_size,$chapter_name,$is_remind){
-        $fee = $this->getPrice($book_info,$chapter_size);
-        if((int)$this->_user_info['balance'] >= $fee){
-            if($this->bookOrderOrChapterOrder($book_info,$chapter_id,$fee,$chapter_name,$is_remind)){
+    protected function balancePay($book_info, $chapter_id, $chapter_size, $chapter_name, $is_remind)
+    {
+        $fee = $this->getPrice($book_info, $chapter_size);
+        if ((int) $this->_user_info['balance'] >= $fee) {
+            if ($this->bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)) {
                 return true;
                 return true;
             }
             }
             return false;
             return false;
-        }else{
+        } else {
             return false;
             return false;
         }
         }
-
     }
     }
 
 
 
 
@@ -522,98 +504,68 @@ class ChapterController extends BaseController
      * @param $cid
      * @param $cid
      * @return bool|mixed
      * @return bool|mixed
      */
      */
-    protected function getChapter($bid,$cid,$chapter){
-        $chapter_content = ChapterService::getChapter($bid,$cid);
-        if(!$chapter_content) return false;
-        //$chapter->content = $chapter_content->content;
+    protected function getChapter($bid, $cid, $chapter)
+    {
+        $chapter_content = ChapterService::getChapter($bid, $cid);
+        if (!$chapter_content) return false;
         $chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
         $chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
         //统计点击率
         //统计点击率
-        $key = 'book_click_num_bid_'.$bid;
+        $key = 'book_click_num_bid_' . $bid;
         $field = date('Y-m-d');
         $field = date('Y-m-d');
-        $old = Redis::hget($key,$field);
-        if(!$old)  $old = 0;
-        Redis::hset($key,$field,$old+1);
-        //签到奖励
-        /*
-        $sign_key = 'sign-'.date('Y-m-d');
-        $sign_status = 0;
-        if(!Redis::hexists($sign_key,$this->uid)){
-            Redis::hset($sign_key,$this->uid,time());
-            $sign_status = 1;
-        }*/
-        $sign_status = $this->userSign($this->uid);
-        $chapter->sign_status = $sign_status;
+        $old = Redis::hget($key, $field);
+        if (!$old)  $old = 0;
+        Redis::hset($key, $field, $old + 1);
         return $chapter;
         return $chapter;
     }
     }
 
 
     /**
     /**
-     * 签到
-     * @param $uid
-     * @return int
-     */
-    protected function userSign($uid){
-
-        if($this->distribution_channel_id != 5){
-            return 0;
-        }
-
-        $day = date('Y-m-d');
-        if(UserSignService::isSign($uid,$day)){
-            return 0;
-        }
-        if(UserSignService::sign($uid,$day)){
-            return 1;
-        }
-        return 0;
-
-    }
-    /**
      * 添加订购记录
      * 添加订购记录
      * @param $book_info
      * @param $book_info
      * @param $chapter_id
      * @param $chapter_id
      * @param $fee
      * @param $fee
      * @return bool
      * @return bool
      */
      */
-    protected function bookOrderOrChapterOrder($book_info,$chapter_id,$fee,$chapter_name,$is_remind){
+    protected function bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)
+    {
         $send_order_id = 0;
         $send_order_id = 0;
-        if($book_info['charge_type'] == 'BOOK'){
+        if ($book_info['charge_type'] == 'BOOK') {
             $data = [
             $data = [
-                'uid'=>$this->uid,
-                'fee'=>$fee,
-                'u'=>$send_order_id,
-                'distribution_channel_id'=>$this->distribution_channel_id,
-                'bid'=>$book_info->bid,
-                'book_name'=>$book_info->book_name,
-                'send_order_id'=>$send_order_id,
+                'uid' => $this->uid,
+                'fee' => $fee,
+                'u' => $send_order_id,
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'bid' => $book_info->bid,
+                'book_name' => $book_info->book_name,
+                'send_order_id' => $send_order_id,
             ];
             ];
-            return BookOrderService::addOrderRecodeAndDecrUserBalance($data,$this->uid);
-        }
-        else{
+            return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
+        } else {
             $data = [
             $data = [
-                'uid'=>$this->uid,
-                'fee'=>$fee,
-                'cid'=>$chapter_id,
-                'bid'=>$book_info->bid,
-                'distribution_channel_id'=>$this->distribution_channel_id,
-                'book_name'=>$book_info->book_name,
-                'chapter_name'=>$chapter_name,
-                'send_order_id'=>$send_order_id,
-                'is_remind'=>$is_remind
+                'uid' => $this->uid,
+                'fee' => $fee,
+                'cid' => $chapter_id,
+                'bid' => $book_info->bid,
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'book_name' => $book_info->book_name,
+                'chapter_name' => $chapter_name,
+                'send_order_id' => $send_order_id,
+                'is_remind' => $is_remind
             ];
             ];
             //print_r($data);
             //print_r($data);
-            if($is_remind){
+            if ($is_remind) {
                 $this->addOrderRemind($book_info->bid);
                 $this->addOrderRemind($book_info->bid);
             }
             }
-            return ChapterOrderService::addOrderAndDecrUserBalance($data,$this->uid);
+            return ChapterOrderService::addOrderAndDecrUserBalance($data, $this->uid);
         }
         }
     }
     }
 
 
 
 
-    protected  function  addOrderRemind($bid){
-        if(ChapterReminderService::checkIsNoReminder($this->uid,$bid)){
+    protected  function  addOrderRemind($bid)
+    {
+        if (ChapterReminderService::checkIsNoReminder($this->uid, $bid)) {
             return true;
             return true;
-        }else{
-            ChapterReminderService::add($this->uid,$bid);
+        } else {
+            ChapterReminderService::add($this->uid, $bid);
             return true;
             return true;
         }
         }
     }
     }
@@ -622,8 +574,9 @@ class ChapterController extends BaseController
      * @param $chapter_id
      * @param $chapter_id
      * @return bool
      * @return bool
      */
      */
-    protected function isOrderRemind($bid){
-        $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid,$bid) ? 1 : 0;
+    protected function isOrderRemind($bid)
+    {
+        $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid, $bid) ? 1 : 0;
         return $is_no_reminder == 0;
         return $is_no_reminder == 0;
     }
     }
 
 
@@ -632,9 +585,10 @@ class ChapterController extends BaseController
      * @param $uid
      * @param $uid
      * @return bool
      * @return bool
      */
      */
-    protected  function getSubscribe(){
-        $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid'=>$this->uid]);
-        if($res) return true;
+    protected  function getSubscribe()
+    {
+        $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
+        if ($res) return true;
         return false;
         return false;
     }
     }
 
 
@@ -645,22 +599,23 @@ class ChapterController extends BaseController
      * @param $chapter_id
      * @param $chapter_id
      * @return bool
      * @return bool
      */
      */
-    protected function getOrderRecord($bid,$chapter_id){
+    protected function getOrderRecord($bid, $chapter_id)
+    {
         //包年记录
         //包年记录
         $uid = $this->uid;
         $uid = $this->uid;
         $res = YearOrderService::getRecord($uid);
         $res = YearOrderService::getRecord($uid);
-        if($res) return true;
+        if ($res) return true;
         $res = null;
         $res = null;
 
 
         //单本订购记录
         //单本订购记录
-        $res = BookOrderService::getRecordByuidBid($uid,$bid);
-        if($res) return true;
+        $res = BookOrderService::getRecordByuidBid($uid, $bid);
+        if ($res) return true;
         $res = null;
         $res = null;
 
 
         //章节订购记录
         //章节订购记录
         $chapterOrder = new ChapterOrderService();
         $chapterOrder = new ChapterOrderService();
 
 
-        if($chapterOrder->checkIsOrdered($uid,$bid,$chapter_id))  return true;
+        if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id))  return true;
 
 
         return false;
         return false;
     }
     }
@@ -672,10 +627,11 @@ class ChapterController extends BaseController
      * @param $chapter_size
      * @param $chapter_size
      * @return float
      * @return float
      */
      */
-    protected function getPrice($book_info,$chapter_size){
-        if($book_info->charge_type == 'BOOK')
-            return $book_info->price*100;
-        return   ceil($chapter_size/100);
+    protected function getPrice($book_info, $chapter_size)
+    {
+        if ($book_info->charge_type == 'BOOK')
+            return $book_info->price * 100;
+        return   ceil($chapter_size / 100);
     }
     }
 
 
 
 
@@ -685,35 +641,34 @@ class ChapterController extends BaseController
      * 用户添加标签
      * 用户添加标签
      * @param $book_info
      * @param $book_info
      */
      */
-    protected function addTag($book_info){
+    protected function addTag($book_info)
+    {
         $send_order_id = 0;
         $send_order_id = 0;
-        if(!UserDeepReadTagService::isAddTag($this->uid,$book_info->bid)){
-            try{
+        if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
+            try {
                 UserDeepReadTagService::addTag([
                 UserDeepReadTagService::addTag([
-                    'uid'=>$this->uid,
-                    'bid'=>$book_info->bid,
-                    'book_name'=>$book_info->book_name,
-                    'category_id'=>$book_info->category_id,
-                    'category_name'=>$book_info->category_name,
-                    'sex_preference'=>$book_info->channel_name?$book_info->channel_name:'',
-                    'distribution_channel_id'=>$this->distribution_channel_id?$this->distribution_channel_id:'0',
-                    'send_order_id'=>$send_order_id,
+                    'uid' => $this->uid,
+                    'bid' => $book_info->bid,
+                    'book_name' => $book_info->book_name,
+                    'category_id' => $book_info->category_id,
+                    'category_name' => $book_info->category_name,
+                    'sex_preference' => $book_info->channel_name ? $book_info->channel_name : '',
+                    'distribution_channel_id' => $this->distribution_channel_id ? $this->distribution_channel_id : '0',
+                    'send_order_id' => $send_order_id,
                 ]);
                 ]);
-            }catch (\Exception  $e){
-
-            }
-
-        }    
+            } catch (\Exception  $e) { }
+        }
     }
     }
 
 
 
 
-    protected function isBookOrdered($bid){
+    protected function isBookOrdered($bid)
+    {
 
 
-        $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid,$bid);
-        if($chapter_order) return true;
+        $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
+        if ($chapter_order) return true;
 
 
-        $res = BookOrderService::getRecordByuidBid($this->uid,$bid);
-        if($res) return true;
+        $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
+        if ($res) return true;
         return false;
         return false;
     }
     }
 
 
@@ -744,6 +699,3 @@ class ChapterController extends BaseController
         return false;
         return false;
     }
     }
 }
 }
-
-
-