wesmiler hace 2 años
padre
commit
8e771a0737
Se han modificado 1 ficheros con 9 adiciones y 3 borrados
  1. 9 3
      app/Services/Api/VideoService.php

+ 9 - 3
app/Services/Api/VideoService.php

@@ -268,6 +268,7 @@ class VideoService extends BaseService
         // 随机优先匹配推送
         $match = false;
         $list = [];
+        $ids = [];
         if($total > 0 ){
             // 关联推荐数据
             $list = $countModel->selectRaw($field)
@@ -275,14 +276,19 @@ class VideoService extends BaseService
                 ->paginate($pageSize > 0 ? $pageSize : 9999999);
             $list = $list ? $list->toArray() : [];
             $list = isset($list['data']) && $list['data']? $list['data'] :[];
+            if($list){
+                foreach ($list as $item){
+                    $ids[] = $item['id'];
+                }
+            }
         }
 
         // 数据不够补充默认匹配数据
         if($total<$pageSize){
             // 默认推荐数据
-            $list1 = $model->where(function($query) use($uids){
-                    if($uids){
-                        $query->whereNotIn('a.user_id', $uids);
+            $list1 = $model->where(function($query) use($ids){
+                    if($ids){
+                        $query->whereNotIn('a.id', $ids);
                     }
                 })->selectRaw($field)
                 ->orderByRaw($order)