|
...
|
...
|
@@ -135,7 +135,6 @@ class VideoTask extends Command |
|
|
|
],
|
|
|
|
'task_id' => $task_id,
|
|
|
|
'callback_url' => env('APP_URL') . '/api/video_task_callback',
|
|
|
|
// 'callback_url' => url('a/getKeywordVideo?project_id='.$val->project_id.'&keyword_id='.$val->keyword_id.'&video='),
|
|
|
|
];
|
|
|
|
$result = Http::post('http://216.250.255.116:7866/create_task', $data);
|
|
|
|
$val->task_id = $task_id;
|
|
...
|
...
|
@@ -176,26 +175,9 @@ class VideoTask extends Command |
|
|
|
*/
|
|
|
|
public function getKeywordImage($keyword_id,$project_id){
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
|
|
|
|
$productModel = new Product();
|
|
|
|
$productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],['thumb','title']);
|
|
|
|
if(count($productList) < 5){
|
|
|
|
$productList = $productModel->inRandomOrder()->take(100)->get()->toArray();
|
|
|
|
//获取7个产品主图
|
|
|
|
}
|
|
|
|
$product_image = [];
|
|
|
|
foreach ($productList as $v){
|
|
|
|
$v = (array)$v;
|
|
|
|
$image = [];
|
|
|
|
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
|
|
|
|
$image['image'] = getImageUrl($v['thumb']['url']);
|
|
|
|
$image['title'] = $v['title'];
|
|
|
|
$product_image[] = $image;
|
|
|
|
}
|
|
|
|
if(count($product_image) > 6){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$thumb = $keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
|
|
|
|
//TODO::所有产品
|
|
|
|
$this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
|
|
|
|
$domainModel = new DomainInfo();
|
|
|
|
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
|
|
|
|
if(!empty($domainInfo)){
|
|
...
|
...
|
@@ -206,8 +188,41 @@ class VideoTask extends Command |
|
|
|
'title'=>$keywordInfo['title'],
|
|
|
|
'keyword_title'=>$keywordInfo['keyword_title'],
|
|
|
|
'keyword_content'=>$keywordInfo['keyword_content'],
|
|
|
|
'product_list'=>$product_image
|
|
|
|
'product_list'=>$thumb ?? []
|
|
|
|
];
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关键词聚合页-推荐&热门产品
|
|
|
|
*/
|
|
|
|
public function getRecommendAndHotProducts($project,$route): ?array
|
|
|
|
{
|
|
|
|
$productIds = [];
|
|
|
|
$productKeyword = Keyword::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
if (!empty($productKeyword)){
|
|
|
|
$productsQuery = Product::where("project_id", $project->id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
|
|
|
|
if (!empty($productsQuery)){
|
|
|
|
foreach ($productsQuery as $item){
|
|
|
|
$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();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
|
|
}else{
|
|
|
|
$products = $productsQuery;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$products = Product::where("project_id", $project->id)->where("status",1)->inRandomOrder()->take(13)->get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data = [];
|
|
|
|
if (!empty($products)){
|
|
|
|
foreach ($products as $item){
|
|
|
|
$data[] = !empty($item->thumb) && $item->thumb != "[]"? getImageUrl(json_decode($item->thumb)->url) : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|