Browse Source

只有广告用户且付费用户才推荐指定书籍,否则推荐普通书籍

wangzq 2 years ago
parent
commit
0e3d98ec68
1 changed files with 27 additions and 9 deletions
  1. 27 9
      app/Http/Controllers/QuickApp/Book/BookController.php

+ 27 - 9
app/Http/Controllers/QuickApp/Book/BookController.php

@@ -601,16 +601,24 @@ class BookController extends BaseController
 
     public function yueaiBackRecom(Request $request)
     {
-
-        $category_id = $request->input('category_id');
-        $bid         = $request->input('bid');
         $package     = $request->header('x-package', '');
         if (empty($package) || $package != 'com.beidao.kuaiying.yueai') {
             return response()->error('PARAM_ERROR');
         }
-        $bid =  [58238,60534,63220,14500,13254,63221,63548,14022,59334,58888,63417,61701];
-        $bid = array_random($bid,4);
-        $books = BookConfigService::getBooksByIds($bid,[],false);
+        $user =  (new QappUserService)->getGolableUser();
+        if(isset($user->uid) && !empty($user->uid) && $this->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 = array_random($bid,4);
+                $books = BookConfigService::getBooksByIds($bid,[],false);
+                return response()->collection(new BookTransformer(), $books);
+            }
+        }
+
+        $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);
     }
 
@@ -623,9 +631,19 @@ class BookController extends BaseController
         if (empty($package) || $package != 'com.beidao.kuaiying.yueai') {
             return response()->success([]);
         }
-        $bid =  [58238,60534,63220,14500,13254,63221,63548,14022,59334,58888,63417,61701];
-        $bid = array_random($bid,4);
-        $books = BookConfigService::getBooksByIds($bid,[],false);
+        $user =  (new QappUserService)->getGolableUser();
+        if(isset($user->uid) && !empty($user->uid) && $this->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 = array_random($bid,4);
+                $books = BookConfigService::getBooksByIds($bid,[],false);
+                return response()->collection(new BookTransformer(), $books);
+            }
+        }
+        $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);
     }