瀏覽代碼

Merge branch 'wzq_fix_book_recom' of iqiyoo:zhuishuyun_wap into kuaiyingyong

zhoulj 2 年之前
父節點
當前提交
853640cf70
共有 3 個文件被更改,包括 67 次插入23 次删除
  1. 24 11
      app/Http/Controllers/QuickApp/Book/BookController.php
  2. 30 0
      app/Modules/Book/Services/BookConfigService.php
  3. 13 12
      config/home.php

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

@@ -584,9 +584,11 @@ class BookController extends BaseController
         $user =  (new QappUserService)->getGolableUser();
         if(isset($user->uid) && !empty($user->uid) && $user->send_order_id >  0){
             $orderRecord = ChapterOrderService::hasUserRecord($user->uid);
-            if($orderRecord){
-                $data = config('home.yueai');
-                $books = $data['task_banner'];
+            $data = config('home.yueai');
+            $books = $data['task_banner'];
+            $bids = BookConfigService::getAvailableBIdsbyBids(array_column($books,'bid'),$this->distribution_channel_id,false);
+
+            if($orderRecord && !empty($bids)){
                 foreach ($books as  &$value){
                     $value['bid'] =Hashids::encode($value['bid']);
                     $value['redirect_url '] = empty($value['cid']) ? "views/Detail" :  "views/Reader";
@@ -629,17 +631,23 @@ class BookController extends BaseController
         }
         $user =  (new QappUserService)->getGolableUser();
         if(isset($user->uid) && !empty($user->uid) && $user->send_order_id >  0){
-            $orderRecord = ChapterOrderService::hasUserRecord($user->uid);
-            if($orderRecord){
-                $bid =  [58238,60534,63220,14500,13254,63221,63548,14022,59334,58888,63417,61701];
+            $bid =  BookConfigService::getAvailableBIdsbyBids([58238,60534,63220,14500,13254,63221,63548,14022,59334,58888,63417,61701],$this->distribution_channel_id,false);
+            if (!empty($bid)){
                 $bid = array_random($bid,4);
-                $books = BookConfigService::getBooksByIds($bid,[],false);
+            }
+            $orderRecord = ChapterOrderService::hasUserRecord($user->uid);
+
+            if($orderRecord && count($bid) >=  4){
+                $where = ['is_on_shelf' => [1,2],'bids' => $bid];
+                // $books = BookConfigService::getBooksByIds($bid,[],false);
+                $books = BookConfigService::getBookLists($where,[],false);
                 return response()->collection(new BookTransformer(), $books);
             }
         }
         return response()->success([]);
         $where = ['is_on_shelf' => [2]];
         $where['channel_id'] = ($package === 'com.beidao.kuaiying.zsy') ? 7477 : 0;
+
         $books = BookConfigService::getBooks($where, [], 4);
         return response()->collection(new BookTransformer(), $books);
     }
@@ -653,13 +661,18 @@ class BookController extends BaseController
         if (empty($package) || $package != 'com.beidao.kuaiying.yueai') {
             return response()->success([]);
         }
+        return response()->success([]);
         $user =  (new QappUserService)->getGolableUser();
         if(isset($user->uid) && !empty($user->uid) && $user->send_order_id  >  0){
-            $orderRecord = ChapterOrderService::hasUserRecord($user->uid);
-            if($orderRecord){
-                $bid =  [58238,60534,63220,14500,13254,63221,63548,14022,59334,58888,63417,61701];
+            $bid =  BookConfigService::getAvailableBIdsbyBids([58238,60534,63220,14500,13254,63221,63548,14022,59334,58888,63417,61701],$this->distribution_channel_id,false);
+            if (!empty($bid)){
                 $bid = array_random($bid,4);
-                $books = BookConfigService::getBooksByIds($bid,[],false);
+            }
+            $orderRecord = ChapterOrderService::hasUserRecord($user->uid);
+            if($orderRecord && count($bid) >  1){
+                $where = ['is_on_shelf' => [1,2],'bids' => $bid];
+                // $books = BookConfigService::getBooksByIds($bid,[],false);
+                $books = BookConfigService::getBookLists($where,[],false);
                 return response()->collection(new BookTransformer(), $books);
             }
         }

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

@@ -17,6 +17,7 @@ use App\Modules\Book\Models\BookKeyword;
 use App\Modules\Book\Models\FreeBook;
 use App\Modules\Book\Models\FreeBookConfig;
 use App\Modules\Book\Models\QappUserSearchBookLog;
+use phpDocumentor\Reflection\Types\This;
 use Redis;
 use DB;
 use Vinkla\Hashids\Facades\Hashids;
@@ -241,4 +242,33 @@ class BookConfigService
         whereIn('bid',$bids)->select($field)->get();
     }
 
+    /**
+     * 根据书籍bid去除无用bid
+     * name: getAvailableBIdsbyBids
+     * @param $bids
+     * @param mixed $channel_id
+     * @param mixed $is_external_shelf
+     * @return array
+     * date 2022/09/20 10:39
+     */
+    public static function  getAvailableBIdsbyBids($bids,$channel_id=0,$is_external_shelf=true)
+    {
+        if (empty($bids)){
+            return [];
+        }
+        $res = BookConfig::whereIn('bid',$bids);
+        if($channel_id == config('qapp_public_package_channel')){
+            $res->whereNotIn('cp_source',getHiddenCp());
+        }else{
+            $res->whereNotIn('cp_source',array_merge(getHiddenCp(),['lianshang']));
+        }
+        if ($is_external_shelf){
+            $res->where('is_on_shelf',2);
+        }else{
+            $res->whereIn('is_on_shelf',[1,2]);
+        }
+
+        return $res->pluck("bid")->toArray();
+    }
+
 }

+ 13 - 12
config/home.php

@@ -133,18 +133,19 @@ return [
                     'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/app/banner/202208121702.jpeg',
                     'bid'          => '95b7L6pwB84Aklkm44R0Y3rV1PqNOvjx', // 63482
                     'cid'          => 0
-                ],[
-                    'redirect_url' => 'views/Detail',
-                    'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/app/banner/202208121709.jpeg',
-                    'bid'          => '5Z30ezoGbVxwMgw8ybRvYEWPjkOr61dJ', // 63547
-                    'cid'          => 0
-                ],
-                [
-                    'redirect_url' => 'views/Detail',
-                    'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/app/banner/202208121707.jpeg',
-                    'bid'          => '9GLjdB1wEYPA3Kd0mAKXx0NDzrWqJpOk', // 60028
-                    'cid'          => 0
-                ],
+                ]
+                // ,[
+                //     'redirect_url' => 'views/Detail',
+                //     'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/app/banner/202208121709.jpeg',
+                //     'bid'          => '5Z30ezoGbVxwMgw8ybRvYEWPjkOr61dJ', // 63547
+                //     'cid'          => 0
+                // ],
+                // [
+                //     'redirect_url' => 'views/Detail',
+                //     'banner_url'   => 'https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/app/banner/202208121707.jpeg',
+                //     'bid'          => '9GLjdB1wEYPA3Kd0mAKXx0NDzrWqJpOk', // 60028
+                //     'cid'          => 0
+                // ],
             ],
             'female' => [
                 [