Pārlūkot izejas kodu

Merge branch 'qapp_book_auth' into kuaiyingyong

wangzq 2 gadi atpakaļ
vecāks
revīzija
56350dfcb2

+ 80 - 22
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -9,6 +9,7 @@ use App\Modules\RecommendBook\Services\RecommendService;
 use App\Modules\Book\Services\RecoBannerService;
 use App\Modules\User\Models\QappPackage;
 use App\Modules\User\Services\QappUserService;
+use Hashids\Hashids;
 use Illuminate\Http\Request;
 use App\Http\Controllers\QuickApp\BaseController;
 use App\Http\Controllers\QuickApp\Book\Transformers\BookTransformer;
@@ -169,10 +170,10 @@ class BookController extends BaseController
         $package     = $request->header('x-package', '');
         $brand       = $request->header('x-nbrand', '');
         $codeVersion = $request->header('x-codeversion', '');
-
+        $isAuth = check_qapp_auth($package ,0);
         // 根据包名、平台、版本号判断是否审核
-        if (Utils::checkIsAudit($package, $brand, $codeVersion)) {
-            $result = BookAuditService::getHomeBooksData($sex, $package);
+        if (Utils::checkIsAudit($package, $brand, $codeVersion) || $isAuth == false) {
+            $result = BookAuditService::getHomeBooksData($sex, $package,$isAuth);
             return response()->success($result);
         }
 
@@ -183,18 +184,30 @@ class BookController extends BaseController
             $reco_banner_type = ['FEMALE', 'PUBLIC'];
             $channel          = 2;
         }
-        $books = (new RecoBannerService)->getByType($reco_banner_type, 2);
-        $books->transform(function ($item) {
-            $result    = $this->getBidCidFromUrl($item->redirect_url);
-            $item->bid = $result['bid'];
-            $item->cid = $result['cid'];
-            if ($result['cid']) {
-                $item->redirect_url = "views/Reader";
-            } else {
-                $item->redirect_url = "views/Detail";
-            }
-            return $item;
-        });
+
+        if($isAuth){
+            $books = (new RecoBannerService)->getByType($reco_banner_type, 2);
+
+            $books->transform(function ($item) {
+                $result    = $this->getBidCidFromUrl($item->redirect_url);
+                $item->bid = $result['bid'];
+                $item->cid = $result['cid'];
+                if ($result['cid']) {
+                    $item->redirect_url = "views/Reader";
+                } else {
+                    $item->redirect_url = "views/Detail";
+                }
+                return $item;
+            });
+        }else{
+            $home = config('home.ycsd');
+            $banner      = $home['reco_banner'];
+            $books = $banner[$sex];
+        }
+
+
+
+
 
         //新判断: 根据包名来获取对应所需的bid
         $qapp_package = QappPackage::getPackageByPackage($package);
@@ -203,6 +216,7 @@ class BookController extends BaseController
         }else{
             $package_id = 0;
         }
+
         \Log::info('un_send_order_book:package_id1:'.$package_id.' $package:'.$package);
         $user =  (new QappUserService)->getGolableUser();
         if(isset($user->uid) && !empty($user->uid)){
@@ -236,10 +250,12 @@ class BookController extends BaseController
      */
     private function getCheckBids($channel,$books,$package_id,$package)
     {
-        $hotBids   = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'hot',$package_id),$channel,$package);
-        $liveBids  = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'live',$package_id),$channel,$package);
-        $recomBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'recom',$package_id),$channel,$package);
-        $newBids   = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'new_recom',$package_id),$channel,$package);
+        $isAuthor = check_qapp_auth($package_id,1);
+        $hotBids   = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'hot',$package_id),$channel,$package,$isAuthor);
+        $liveBids  = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'live',$package_id),$channel,$package,$isAuthor);
+        $recomBids = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'recom',$package_id),$channel,$package,$isAuthor);
+        $newBids   = $this->getCheckBooks(QappRecommendService::getRecommendByPacketId($channel, 'new_recom',$package_id),$channel,$package,$isAuthor);
+
 
         return array_filter([
             ['type' => 'reco_banner', 'lable' => '首页banner', 'books' => $books],
@@ -258,7 +274,8 @@ class BookController extends BaseController
      * @param $package : 频道
      * @return array
      */
-    private function getCheckBooks($bid_list,$channel,$package)
+
+    private function getCheckBooks($bid_list,$channel,$package,$is_author)
     {
         $hidden_cp = getHiddenCp();
         if($package !== 'com.beidao.kuaiying.zsy'){
@@ -266,6 +283,16 @@ class BookController extends BaseController
         }
         //获取书本数量
         $count = count($bid_list);
+        if (!$is_author){
+            $where = [
+                ['book_configs.charge_type','!=','BOOK'],
+                ['book_configs.cp_source','=','ycsd'],
+            ];
+        }else{
+            $where = [
+                ['book_configs.charge_type','!=','BOOK'],
+            ];
+        }
         //获取当前有效书本数量
         $book_count = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
@@ -273,8 +300,11 @@ class BookController extends BaseController
             ->where('book_configs.is_on_shelf',2)
             ->where('book_configs.charge_type','!=','BOOK')
             ->whereNotIn('book_configs.cp_source',$hidden_cp)
+            ->where($where)
+
             ->where('book_categories.pid',$channel)
             ->count();
+
         if($count == $book_count){
             return $bid_list;
         }
@@ -288,7 +318,7 @@ class BookController extends BaseController
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
             ->whereIn('book_configs.bid',$bid_list)
             ->where('book_configs.is_on_shelf',2)
-            ->where('book_configs.charge_type','!=','BOOK')
+            ->where($where)
             ->whereNotIn('book_configs.cp_source',$hidden_cp)
             ->where('book_categories.pid',$channel)
             ->pluck('book_configs.bid')->all();
@@ -298,8 +328,10 @@ class BookController extends BaseController
         $rand_bid = BookConfig::join('books', 'book_configs.bid', '=', 'books.id')
             ->leftjoin('book_categories', 'books.category_id', 'book_categories.id')
             ->where('book_configs.is_on_shelf',2)
-            ->where('book_configs.charge_type','!=','BOOK')
+            // ->where('book_configs.charge_type','!=','BOOK')
+            ->where($where)
             ->whereNotIn('book_configs.cp_source',$hidden_cp)
+
             ->where('book_categories.pid',$channel)
             ->inRandomOrder()
             ->limit($supplement_count)
@@ -371,6 +403,12 @@ class BookController extends BaseController
             $order = ['book_configs.bid', 'desc'];
         }
 
+        // 是否只使用原创书殿的书
+        $isAuth = check_qapp_auth($package ,0);
+        if (!$isAuth){
+            $where['cp_source'] = "ycsd";
+        }
+
         $status = $request->input('status');
         if ($status != '') {
             $where['status'] = $status;
@@ -395,15 +433,23 @@ class BookController extends BaseController
 
     public function similarRecom(Request $request)
     {
+        $package     = $request->header('x-package', '');
         $category_id = $request->input('category_id');
         $bid         = $request->input('bid');
         $package     = $request->header('x-package', '');
         if (empty($bid) || (empty($category_id) && $category_id != 0)) {
             return response()->error('PARAM_ERROR');
         }
+        $isAuth = check_qapp_auth($package ,0);
         $bid   = BookService::decodeBidStatic($bid);
         $where = ['category_id' => $category_id, 'is_on_shelf' => [2]];
+
+        if (!$isAuth){
+            $where['cp_source'] = "ycsd";
+        }
+
         $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+
         $books = BookConfigService::getBooks($where, [], 4);
         $data  = [];
         foreach ($books as $v) {
@@ -474,6 +520,7 @@ class BookController extends BaseController
         $package     = $request->header('x-package', '');
         $brand       = $request->header('x-nbrand', '');
         $codeVersion = $request->header('x-codeversion', '');
+
         if (Utils::checkIsAudit($package, $brand, $codeVersion)) {
             $bids = [2266, 3838, 9700, 10175, 10301, 3422, 1166, 4546, 9163, 2509,
                 7287,14297,12716,14312,14000,13577,16712,13002,12717,15103,13928,
@@ -483,8 +530,19 @@ class BookController extends BaseController
                 $bids = [159, 2439, 6276, 10074, 5409, 9379, 10323, 9078, 3603, 487];
             }
         }
+        
+        $isAuth = check_qapp_auth($package,0);
+        if (!$isAuth){
+            $rank = config('home.rank');
+            $bids = $rank['male'];
+            if ($sex === 2) {
+                $bids =  $rank['female'];;
+            }
+        }
+
         $channel_id = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
         $books = collectionTransform(new BookTransformer, BookConfigService::getBookLists(compact('bids','channel_id')));
+
         return response()->success($books);
     }
 

+ 20 - 0
app/Libs/Helpers.php

@@ -814,4 +814,24 @@ function get_real_package($name)
             break;
     }
     return $package;
+}
+
+if (!function_exists("check_qapp_auth")){
+    function check_qapp_auth($package = "",$isPackageId = 0)
+    {
+        if (empty($package)){
+            return  false;
+        }
+
+        if ($isPackageId == 0){
+            $data = \DB::table('qapp_package_info')->where('package','=',$package)->value('cp_author_status');
+        }else{
+            $data = \DB::table('qapp_package_info')->where('id','=',$package)->value('cp_author_status');
+        }
+
+        if ($data == 1){
+            return  true;
+        }
+         return  false;
+    }
 }

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

@@ -160,6 +160,9 @@ class BookConfig extends Model
 
                     $res->where('book_configs.is_current_week_promotion', $v);
                 }
+                if($key == "cp_source"){
+                    $res = $res->where('book_configs.cp_source', '=', $v);
+                }
             }
         }
         if(isset($where['channel_id']) && $where['channel_id'] == 7477){

+ 5 - 1
app/Modules/Book/Services/BookAuditService.php

@@ -14,7 +14,7 @@ class BookAuditService
      * @param $package
      * @return array[]
      */
-    public static function getHomeBooksData($sex, $package): array
+    public static function getHomeBooksData($sex, $package,$is_auth): array
     {
         // 基本配置数据
         $home = config('home.default');
@@ -22,6 +22,10 @@ class BookAuditService
             $home = config('home.new');
         }
 
+        if (!$is_auth){
+            $home = config('home.ycsd');
+        }
+
         // banner
         $banner      = $home['reco_banner'];
         $bannerBooks = $banner[$sex];

+ 8 - 0
app/Modules/Book/Services/BookConfigService.php

@@ -240,4 +240,12 @@ class BookConfigService
         return BookConfig::join('books','books.id','=','book_configs.bid')->
         whereIn('bid',$bids)->select($field)->get();
     }
+
+    // 获取原创书殿书籍id
+    public static function checkBookId($bookId = [])
+    {
+        $bookId = BookConfig::whereIn('bid',$bookId)->where('cp_source','=','ycsd')->pluck('bid');
+
+        return  $bookId->toArray();
+    }
 }

+ 49 - 2
config/home.php

@@ -48,7 +48,7 @@ return [
                 [
                     'redirect_url' => 'views/Detail',
                     'banner_url'   => 'https://cdn-novel.iycdm.com/h5/reco_banner/20200820145004ZQSS.jpg',
-                    'bid'          => 'dPwBa129vND4MRaNodKj7VobmzEO8YZ6', // 11601 最强杀手
+                    'bid'          => 'mqvQ0OXLZE2ba3KnY8RoDNzyJxMBrAVw', // 574 英雄联盟
                     'cid'          => 0
                 ],
             ],
@@ -81,5 +81,52 @@ return [
             'male'   => [12680, 12521, 11748, 12698, 12682, 13261],
             'female' => [11656, 13092, 11666, 2633, 6303, 12739],
         ],
-    ]
+    ],
+    'ycsd'     => [
+        'reco_banner' => [
+            'label'  => '首页banner',
+            'male'   => [
+                [
+                    'redirect_url' => 'views/Detail',
+                    'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/book/cover/9f55b8615a37fa1f404b0cc1666d6c28.jpeg',
+                    'bid'          => 'dPwBa129vND4MRaNodKj7VobmzEO8YZ6', // 1890 美女总裁的全职保安
+                    'cid'          => 0
+                ],
+            ],
+            'female' => [
+                [
+                    'redirect_url' => 'views/Detail',
+                    'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/book/cover/082576b8d38afc0b8c890c8d6e5dfc93.jpeg',
+                    'bid'          => '2VkOMpjBem8ZNgrxqQKY7d9r5LE03Dwz', // 15720 黑夜见过他深情
+                    'cid'          => 0
+                ],
+            ],
+        ],
+        'hot'         => [
+            'label'  => '今日主推',
+            'male'   => [86,2942,2943,2773,2900,2921],
+            'female' => [14620,58195,11680,59296,13082,11681],
+        ],
+        'zhibo'       => [
+            'label'  => '大家都在看',
+            'male'   => [2929,2935,2940,2944,2903,2928],
+            'female' => [58950,12331,59297,17055,15720,15537],
+        ],
+        'recom'       => [
+            'label'  => '主编精选',
+            'male'   => [2945,2948,17,85,94,141],
+            'female' => [11883,22394,12901,60902,11671,4112],
+        ],
+        'new_recom'   => [
+            'label'  => '畅销精品',
+            'male'   => [574,1190,1780,2885,2887,2915],
+            'female' => [10846,60736,61425,10074,15216,60734],
+        ],
+    ],
+    'rank' =>[
+        'male'   => [86,2942,2943,2773,2900,2921,2929,2935,2940,2944,2903,2928,2945,2948,17,85,94,141,574,1190,1780,2885,2887,2915,2920,2923,2926,2927,2937,2939,2941,2947,2993],
+        'female' => [14163,17055,3697,59004,15720,13082,58950,60902,61012,7567,11671,15537,16133,16184,16220,22393,22394,22395,58329,58801,58864,59020,59295,59293,60238,60736,61425,59297,59579,59813],
+    ],
+
+
 ];