|
...
|
...
|
@@ -9,11 +9,16 @@ namespace App\Console\Commands\KeywordInVideo; |
|
|
|
|
|
|
|
use App\Console\Commands\Model;
|
|
|
|
use App\Console\Commands\TaskSub;
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Models\Com\KeywordVideoTask;
|
|
|
|
use App\Models\Com\KeywordVideoTaskLog;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
...
|
...
|
@@ -89,11 +94,12 @@ class VideoTask extends Command |
|
|
|
if ($log){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$keywordInfo = $this->getKeywordImage($val->id,$task_project->project_id);
|
|
|
|
$array = [
|
|
|
|
'project_id' => $task_project->project_id,
|
|
|
|
'keyword_id' => $val->id,
|
|
|
|
'keyword' => $val->title,
|
|
|
|
'data' => json_encode(['url' => '', 'description' => '', 'images' => [], 'keywords' => []]),
|
|
|
|
'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'], 'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'], 'keywords' => []]),
|
|
|
|
'status' => KeywordVideoTaskLog::STATUS_INIT,
|
|
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
...
|
...
|
@@ -113,26 +119,26 @@ class VideoTask extends Command |
|
|
|
*/
|
|
|
|
public function sendSubTask()
|
|
|
|
{
|
|
|
|
$subTask = KeywordVideoTaskLog::where(['status' => TaskSub::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get();
|
|
|
|
$subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get();
|
|
|
|
if ($subTask->isEmpty())
|
|
|
|
return true;
|
|
|
|
foreach ($subTask as $val) {
|
|
|
|
$valData = json_decode($val->data);
|
|
|
|
$task_id = 'v6-' . uniqid();
|
|
|
|
$data = [
|
|
|
|
'project_data' => [
|
|
|
|
'tag_url' => '',
|
|
|
|
'title' => '',
|
|
|
|
'tag_url' => $valData['url'],
|
|
|
|
'title' => $valData['title'],
|
|
|
|
'keywords' => [],
|
|
|
|
'description' => '',
|
|
|
|
'images' => ''
|
|
|
|
'description' => $valData['description'],
|
|
|
|
'images' => $valData['images']
|
|
|
|
],
|
|
|
|
'task_id' => $task_id,
|
|
|
|
'callback_url' => '',
|
|
|
|
'callback_url' => env('APP_URL') . '/api/video_task_callback',
|
|
|
|
];
|
|
|
|
$result = Http::post('http://216.250.255.116:7866/create_task', $data);
|
|
|
|
|
|
|
|
$val->task_id = $task_id;
|
|
|
|
$val->status = STATUS_RUNING::STATUS_RUNING;
|
|
|
|
$val->status = KeywordVideoTaskLog::STATUS_RUNNING;
|
|
|
|
$val->request_result = $result;
|
|
|
|
$val->save();
|
|
|
|
}
|
|
...
|
...
|
@@ -159,4 +165,64 @@ class VideoTask extends Command |
|
|
|
$project_id = 110;
|
|
|
|
return $project_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据关键字获取产品主图
|
|
|
|
* @name :getKeywordList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/2/23 16:28
|
|
|
|
*/
|
|
|
|
public function getKeywordImage($keyword_id,$project_id){
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
|
|
|
|
//TODO::所有产品
|
|
|
|
$thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
|
|
|
|
$domainModel = new DomainInfo();
|
|
|
|
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
|
|
|
|
if(!empty($domainInfo)){
|
|
|
|
$keywordInfo['route'] = $domainInfo['domain'].'/'.$keywordInfo['route'];
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'url'=>$keywordInfo['route'],
|
|
|
|
'title'=>$keywordInfo['title'],
|
|
|
|
'keyword_title'=>$keywordInfo['keyword_title'],
|
|
|
|
'keyword_content'=>$keywordInfo['keyword_content'],
|
|
|
|
'product_list'=>$thumb ?? []
|
|
|
|
];
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关键词聚合页-推荐&热门产品
|
|
|
|
*/
|
|
|
|
public function getRecommendAndHotProducts($route,$project_id): ?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['url'] != "" ? getImageUrl($item->thumb['url']) : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|