Kaynağa Gözat

Merge branch 'kuaiyingyong' of iqiyoo:zhuishuyun_wap into kuaiyingyong

fly 5 yıl önce
ebeveyn
işleme
04023f044e

+ 17 - 11
app/Http/Controllers/QuickApp/BaseController.php

@@ -11,18 +11,24 @@ class BaseController extends Controller
     
     public function __get($name)
     {
+//        if (!isset($this->field[$name])) {
+//            $qapp_user = QappUserService::getGolableUserStatic();
+//            if ($name == '_user_info') {
+//                $this->field[$name] = $qapp_user->user;
+//            }
+//            if ($name == 'uid') {
+//                $this->field[$name] = $qapp_user->uid;
+//            }
+//            if ($name == 'distribution_channel_id') {
+//                $this->field[$name] = $qapp_user->user->distribution_channel_id;
+//            }
+//        }
         if (!isset($this->field[$name])) {
-             QappUserService::setGolableUserStatic(162261523);
-            $qapp_user = QappUserService::getGolableUserStatic();
-            if ($name == 'user_info') {
-                $this->field[$name] = $qapp_user->user;
-            }
-            if ($name == 'uid') {
-                $this->field[$name] = $qapp_user->uid;
-            }
-            if ($name == 'distribution_channel_id') {
-                $this->field[$name] = $qapp_user->user->distribution_channel_id;
-            }
+
+            $this->field['_user_info'] = '';
+            $this->field['uid'] = 1;
+            $this->field['distribution_channel_id'] = 5;
+
         }
         return  $this->field[$name];
     }

+ 34 - 18
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -1,7 +1,8 @@
 <?php
 
 namespace App\Http\Controllers\QuickApp\Book;
-
+use App\Modules\RecommendBook\Services\RecommendService;
+use App\Modules\Book\Services\RecoBannerService;
 use Illuminate\Http\Request;
 use App\Http\Controllers\QuickApp\BaseController;
 use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
@@ -95,8 +96,8 @@ class BookController extends BaseController
         if(!$book_info){
             return response()->error('QAPP_SYS_ERROR');
         }
-        if(!in_array($book_info->is_on_shelf,[1,2])){
-            return response()->error('QAPP_OFF_SHELF');
+        if(!in_array($book_info->is_on_shelf,[2])){
+            return response()->error('QAPP_OFF  _SHELF');
         }
         $is_on_shelf = UserShelfBooksService::getUserShelfBooksListByUidAndBid($this->uid,$bid);
 
@@ -113,7 +114,6 @@ class BookController extends BaseController
     }
 
 
-
     /**
      * @apiVersion 1.0.0
      * @apiDescription 首页(male|female)
@@ -149,6 +149,7 @@ class BookController extends BaseController
      *       }
      */
     public function getBookLists(Request $request,$sex){
+
         if($sex == 'male'){
             $type = [
                 'BOOK_MALE_LOOP',
@@ -157,6 +158,8 @@ class BookController extends BaseController
                 'BOOK_MALE_RECOM',
                 'BOOK_MALE_NEW_RECOM'
             ];
+            $channel = 1;
+            $reco_banner_type = ['MALE','PUBLIC'];
         }else{
             $type = [
                 'BOOK_FEMALE_LOOP',
@@ -165,25 +168,38 @@ class BookController extends BaseController
                 'BOOK_FEMALE_RECOM',
                 'BOOK_FEMALE_NEW_RECOM'
             ];
+            $reco_banner_type = ['FEMALE','PUBLIC'];
+            $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 = [
-            ['type'=>'lunbo','lable'=>'','books'=>''],
-            ['type'=>'hot','lable'=>'热门推荐','books'=>''],
-            ['type'=>'zhibo','lable'=>'神书直播','books'=>''],
-            ['type'=>'recom','lable'=>'编辑推荐','books'=>''],
-            ['type'=>'new_recom','lable'=>'新书推荐','books'=>''],
-        ];
-
+            ['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')))],
 
-        foreach ($type as $key=>$v){
-            $Books =  BookConfigService::getBooksByIds(explode(',',env($v)));
-            $book[$key]['books']  = collectionTransform(new BookTransformer,$Books);
-        }
+        ];
+        /*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);
 
     }
 
+
+
+
+
     /**
      * @apiVersion 1.0.0
      * @apiDescription  书库
@@ -283,8 +299,8 @@ class BookController extends BaseController
         $where = [];
         //$order = ['book_configs.id','asc'];
         $order = [];
-        $where['is_on_shelf'] = [1,2];
-
+//        $where['is_on_shelf'] = [1,2];
+        $where['is_on_shelf'] = [2];
         $category_id = $request->input('category_id');
         if($category_id){
             if($category_id == 1){
@@ -409,7 +425,7 @@ class BookController extends BaseController
         }
         $bid = Hashids::decode($bid)[0];
 
-        $where = ['category_id'=>$category_id,'is_on_shelf'=>[1,2]];
+        $where = ['category_id'=>$category_id,'is_on_shelf'=>[2]];
         $books = BookConfigService::getBooks($where,[],4);
         $data = [];
         foreach ($books as $v){

+ 96 - 8
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -92,10 +92,33 @@ class ChapterController extends BaseController
      *          ]
      *       }
      */
-    public function getCatalog(Request $request,$bid){
-        $bid = Hashids::decode($bid)[0];
+    public function getCatalog(Request $request,$bid)
+    {
+
+//        $bid = Hashids::decode($bid)[0];
         $lists = ChapterService::getChapterLists($bid);
-        return response()->collection(new ChapterListTransformer,$lists);
+
+        $book_info = BookConfigService::getBookById($bid);
+
+        if (!$book_info) {
+            return response()->error('PARAM_ERROR');
+        }
+        $this->book_info = $book_info;
+        $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
+        foreach ($lists as $v) {
+            $v->is_show_price = $is_show_price;
+            $v->price = '';
+            if ($is_show_price) {
+                $v->price = $this->getPrice($book_info, $v);
+            }
+
+            if ($v->sequence==$book_info->force_subscribe_chapter_seq){
+                $v->is_need_subscirb = 1;
+            }else{
+                $v->is_need_subscirb = 0;
+            }
+        }
+        return response()->collection(new ChapterListTransformer, $lists);
     }
 
     /**
@@ -171,11 +194,46 @@ 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){
+//        $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)
+    {
+
+
+
+        $bid_array = Hashids::decode($bid);
+//        $bid_array = $bid;
+        if (isset($bid_array[0])) {
+            $bid = $bid_array[0];
+        } else {
+            return response()->error('PARAM_ERROR');
+        }
+        $book_info = BookConfigService::getBookById($bid);
+        if (!$book_info) {
+            return response()->error('PARAM_ERROR');
+        }
+        $this->book_info = $book_info;
+        $page_size = $request->input('page_size', 15);
+        if($page_size>=100) $page_size=100;
+        $res = ChapterService::getChapterListsPage($bid, $page_size);
+        $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
+        foreach ($res as $v) {
+            $v->is_show_price = $is_show_price;
+            $v->price = '';
+            if ($is_show_price) {
+                $v->price = $this->getPrice($book_info, $v);
+            }
+            if ($v->sequence==$book_info->force_subscribe_chapter_seq){
+                $v->is_need_subscirb = 1;
+            }else{
+                $v->is_need_subscirb = 0;
+            }
+        }
+        return response()->pagination(new ChapterListTransformer, $res);
     }
 
 
@@ -658,4 +716,34 @@ class ChapterController extends BaseController
         if($res) return true;
         return false;
     }
+
+    private function showChapterPrice($bid, $charge_type)
+    {
+        if ($charge_type == 'BOOK') {
+            return false;
+        }
+        $show_chapter_price_bid = env('SHOW_CHAPTER_PRICE_BID', 'all');
+        if ($show_chapter_price_bid != 'all') {
+            $show_chapter_price_bid_array = explode(',', $show_chapter_price_bid);
+            if (!in_array($bid, $show_chapter_price_bid_array)) {
+                return false;
+            }
+        }
+        $show_chapter_price_channel = env('SHOW_CHAPTER_PRICE_CHANNEL', '');
+        if (!$show_chapter_price_channel) {
+            return false;
+        }
+
+        if ($show_chapter_price_channel == 'all') {
+            return true;
+        }
+        $show_chapter_price_channel_array = explode(',', $show_chapter_price_channel);
+        if (in_array($this->distribution_channel_id, $show_chapter_price_channel_array)) {
+            return true;
+        }
+        return false;
+    }
 }
+
+
+

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

@@ -17,6 +17,7 @@ class ChapterListTransformer
             'prev_cid'   =>  $chapter->prev_cid,
             'next_cid'   =>  $chapter->next_cid,
             'recent_update_at'   =>  $chapter->recent_update_at,
+            'is_need_subscirbe' =>isset($chapter->is_need_subscirb)?$chapter->is_need_subscirb:'',
         ];
     }
 }