作者 lyh

gx

@@ -211,13 +211,17 @@ class VideoTask extends Command @@ -211,13 +211,17 @@ class VideoTask extends Command
211 $productIds[] = $item->id; 211 $productIds[] = $item->id;
212 } 212 }
213 if (count($productIds)<7){ 213 if (count($productIds)<7){
214 - $randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get(); 214 + $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();
  215 + $product_id = array_rand($product_all_id, 13-count($productIds));
  216 + $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
215 $products = $productsQuery->merge($randomData); 217 $products = $productsQuery->merge($randomData);
216 }else{ 218 }else{
217 $products = $productsQuery; 219 $products = $productsQuery;
218 } 220 }
219 }else{ 221 }else{
220 - $products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get(); 222 + $product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();
  223 + $product_id = array_rand($product_all_id, 13);
  224 + $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
221 } 225 }
222 } 226 }
223 $data = []; 227 $data = [];
@@ -13,6 +13,7 @@ use App\Enums\Common\Code; @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 use App\Models\Com\KeywordVideoTask; 14 use App\Models\Com\KeywordVideoTask;
15 use App\Models\Domain\DomainInfo; 15 use App\Models\Domain\DomainInfo;
  16 +use App\Models\Project\Project;
16 17
17 class KeywordVideoController extends BaseController 18 class KeywordVideoController extends BaseController
18 { 19 {
@@ -26,6 +27,13 @@ class KeywordVideoController extends BaseController @@ -26,6 +27,13 @@ class KeywordVideoController extends BaseController
26 public function lists(){ 27 public function lists(){
27 $keywordModel = new KeywordVideoTask(); 28 $keywordModel = new KeywordVideoTask();
28 $lists = $keywordModel->lists($this->map,$this->page,$this->row); 29 $lists = $keywordModel->lists($this->map,$this->page,$this->row);
  30 + if(!empty($lists) && !empty($lists['list'])){
  31 + $projectModel = new Project();
  32 + foreach ($lists['list'] as $k => $v){
  33 + $v['project_name'] = $projectModel->read(['id'=>$v['project_id']],['id','title'])['title'];
  34 + $lists['list'][$k] = $v;
  35 + }
  36 + }
29 $this->response('success',Code::SUCCESS,$lists); 37 $this->response('success',Code::SUCCESS,$lists);
30 } 38 }
31 39
@@ -139,7 +139,6 @@ class RankDataLogic extends BaseLogic @@ -139,7 +139,6 @@ class RankDataLogic extends BaseLogic
139 'data' => $rank_week['data'] ?? [], 139 'data' => $rank_week['data'] ?? [],
140 'labels' => $rank_week['date'] ?? [], 140 'labels' => $rank_week['date'] ?? [],
141 ]; 141 ];
142 -  
143 return $data; 142 return $data;
144 } 143 }
145 144