作者 lyh

gx

... ... @@ -211,13 +211,17 @@ class VideoTask extends Command
$productIds[] = $item->id;
}
if (count($productIds)<7){
$randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get();
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();
$product_id = array_rand($product_all_id, 13-count($productIds));
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
$products = $productsQuery->merge($randomData);
}else{
$products = $productsQuery;
}
}else{
$products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get();
$product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();
$product_id = array_rand($product_all_id, 13);
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
}
}
$data = [];
... ...
... ... @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Com\KeywordVideoTask;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
class KeywordVideoController extends BaseController
{
... ... @@ -26,6 +27,13 @@ class KeywordVideoController extends BaseController
public function lists(){
$keywordModel = new KeywordVideoTask();
$lists = $keywordModel->lists($this->map,$this->page,$this->row);
if(!empty($lists) && !empty($lists['list'])){
$projectModel = new Project();
foreach ($lists['list'] as $k => $v){
$v['project_name'] = $projectModel->read(['id'=>$v['project_id']],['id','title'])['title'];
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -139,7 +139,6 @@ class RankDataLogic extends BaseLogic
'data' => $rank_week['data'] ?? [],
'labels' => $rank_week['date'] ?? [],
];
return $data;
}
... ...