作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

... ... @@ -89,9 +89,9 @@ class Count extends Command
DB::table('gl_count')->insert($data);
}
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL;
echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL;
echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
echo $this->error;
}
... ...
... ... @@ -55,7 +55,7 @@ class VideoTask extends Command
/**
* @var int 最大子任务
*/
public $max_sub_task = 800;
public $max_sub_task = 200;
/**
* @return bool
... ... @@ -101,6 +101,7 @@ class VideoTask extends Command
$task_project->save();
continue;
}
$logo_bg = $this->getImage($domainInfo);
foreach ($keyword as $val) {
$log = KeywordVideoTaskLog::where(['project_id' => $task_project->project_id, 'keyword_id' => $val->id])->first();
if ($log){
... ... @@ -113,7 +114,7 @@ class VideoTask extends Command
'keyword' => $val->title,
'data' => json_encode(['url' => $keywordInfo['url'],'title' => $keywordInfo['title'],
'description' => $keywordInfo['keyword_content'], 'images' => $keywordInfo['product_list'],
'keywords' => $keywordInfo['keyword_list']]),
'keywords' => $keywordInfo['keyword_list'], 'logo_bg' => $logo_bg]),
'status' => KeywordVideoTaskLog::STATUS_INIT,
'updated_at' => date('Y-m-d H:i:s'),
'created_at' => date('Y-m-d H:i:s'),
... ... @@ -138,8 +139,7 @@ class VideoTask extends Command
return true;
}
foreach ($subTask as $val) {
$logo_bg = $this->getImage($val->project_id);
$valData = (array)json_decode($val->data);
$valData = json_decode($val->data,true);
$task_id = 'v6-' . uniqid();
$data = [
'project_data' => [
... ... @@ -148,8 +148,8 @@ class VideoTask extends Command
'keywords' => $valData['keywords'],
'description' => $valData['description'],
'images' => $valData['images'],
'logo'=> $logo_bg['logo'],
'bg'=> $logo_bg['bg']
'logo'=> $valData['logo_bg']['logo'] ?? '',
'bg'=> $valData['logo_bg']['bg'] ?? ''
],
'task_id' => $task_id,
'callback_url' => env('APP_URL') . '/api/video_task_callback',
... ... @@ -189,23 +189,39 @@ class VideoTask extends Command
}
/**
* @remark :根据关键字获取产品主图
* @name :getKeywordList
* @author :lyh
* @method :post
* @time :2024/2/23 16:28
* 根据关键字获取产品主图
* @param $keyword_id
* @param $project_id
* @param $domain
* @return array
*/
public function getKeywordImage($keyword_id,$project_id,$domain){
$keywordModel = new Keyword();
$keywordInfo = $keywordModel->read(['id'=>$keyword_id]);
// TODO 当内容太多时,生成视频过长, 尽量保证生成视频30秒左右, 所以需要控制文案内容长度
$content = $keywordInfo['keyword_content'];
$content_array = explode(" ", $content);
if (count($content_array) > 80) {
$content_array = preg_split("/[,,。]/u", $content);
$tmp = '';
foreach ($content_array as $val) {
$tmp .= $val . '.';
$tmp_array = explode(' ', $tmp);
if (count($tmp_array) > 60) {
$content = $tmp;
break;
}
}
}
//TODO::所有产品
$thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id);
$keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();;
$keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();
$data = [
'url'=>$domain.'/'.$keywordInfo['route'],
'url'=> 'https://' . $domain.'/'.$keywordInfo['route'],
'title'=>$keywordInfo['title'],
'keyword_title'=>$keywordInfo['keyword_title'],
'keyword_content'=>$keywordInfo['keyword_content'],
'keyword_content'=>$content,
'product_list'=>$thumb ?? [],
'keyword_list'=>$keyword_arr ?? []
];
... ... @@ -271,27 +287,26 @@ class VideoTask extends Command
}
/**
* @remark :获取图片
* @name :getImage
* @author :lyh
* @method :post
* @time :2024/3/12 15:29
* 获取图片
* @param $domainInfo
* @return array
*/
public function getImage($project_id){
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
if($domainInfo === false){
return '';
}
$dom = file_get_html('https://'.$domainInfo['domain'].'/');
$logoDom = $dom->find('.logo', 0)->find("img",0);
if($logoDom != null){
$logo = $logoDom->src;
}
$bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0);
if($bgDom != null){
$bg = $bgDom->src;
public function getImage($domainInfo){
$logo = $bg = '';
try {
$dom = file_get_html('https://'.$domainInfo['domain'].'/');
$logoDom = $dom->find('.logo', 0)->find("img",0);
if($logoDom != null){
$logo = $logoDom->src;
}
$bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0);
if($bgDom != null){
$bg = $bgDom->src;
}
$dom->clear();
} catch (\Exception $e) {
Log::error('file_get_html: ' . $domainInfo['domain'] . ', error message: ' . $e->getMessage());
}
return ['logo'=>$logo ?? '','ng'=>$bg ?? ''];
return ['logo' => $logo, 'bg' => $bg];
}
}
... ...
... ... @@ -665,23 +665,24 @@ class ProjectUpdate extends Command
foreach ($item['extend'] as $ke => $ve) {
$extend = $extend_model->read(['title' => $ke]);
if ($extend) {
$extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]);
if (!$extend_info) {
if ($extend['type'] == 3) {
$gallery = [];
if (is_array($ve)) {
foreach ($ve as $ve_img) {
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}
} else {
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
if ($extend['type'] == 3) {
$gallery = [];
if (is_array($ve)) {
foreach ($ve as $ve_img) {
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}
$value = Arr::a2s($gallery);
} elseif ($extend['type'] == 4) {
$value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]);
} else {
$value = $ve;
$gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}
$value = Arr::a2s($gallery);
} elseif ($extend['type'] == 4) {
$value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]);
} else {
$value = $ve;
}
$extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]);
if (!$extend_info) {
$extend_info_model->add([
'key' => $extend['key'],
'type' => $extend['type'],
... ... @@ -690,6 +691,8 @@ class ProjectUpdate extends Command
'module_id' => $custom_info['id'],
'values' => $value,
]);
} else {
$extend_info_model->edit(['type' => $extend['type'], 'values' => $value], ['key' => $extend['key'], 'content_id' => $id]);
}
}
}
... ...
... ... @@ -114,6 +114,7 @@ class ProjectController extends BaseController
'gl_project_deploy_optimize.quality_mid AS quality_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.api_no AS api_no',
'gl_project_deploy_optimize.brand_keyword AS brand_keyword',
];
return $select;
}
... ...
... ... @@ -778,7 +778,7 @@ class ProjectLogic extends BaseLogic
$token = $common->encrypt($param);
$res = Http::withoutVerifying()->get($url, ['token' => $token])->json();
if(empty($res['code']) || $res['code'] != 200){
$this->fail('ProjectToHagro error');
$this->fail($res['msg']);
}
return true;
}
... ...