Merge remote-tracking branch 'origin/master' into akun
正在显示
9 个修改的文件
包含
118 行增加
和
45 行删除
| @@ -89,9 +89,9 @@ class Count extends Command | @@ -89,9 +89,9 @@ class Count extends Command | ||
| 89 | DB::table('gl_count')->insert($data); | 89 | DB::table('gl_count')->insert($data); |
| 90 | } | 90 | } |
| 91 | }catch (\Exception $e){ | 91 | }catch (\Exception $e){ |
| 92 | - echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL; | 92 | + echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL; |
| 93 | } | 93 | } |
| 94 | - echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL; | 94 | + echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL; |
| 95 | echo $this->error; | 95 | echo $this->error; |
| 96 | } | 96 | } |
| 97 | 97 |
| @@ -55,7 +55,7 @@ class VideoTask extends Command | @@ -55,7 +55,7 @@ class VideoTask extends Command | ||
| 55 | /** | 55 | /** |
| 56 | * @var int 最大子任务 | 56 | * @var int 最大子任务 |
| 57 | */ | 57 | */ |
| 58 | - public $max_sub_task = 800; | 58 | + public $max_sub_task = 200; |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * @return bool | 61 | * @return bool |
| @@ -171,7 +171,7 @@ class VideoTask extends Command | @@ -171,7 +171,7 @@ class VideoTask extends Command | ||
| 171 | */ | 171 | */ |
| 172 | public function getProjectKeyword($number) | 172 | public function getProjectKeyword($number) |
| 173 | { | 173 | { |
| 174 | - $keyword_arr_id = Keyword::where('video', null)->whereNotNull('keyword_content')->pluck('id')->toArray(); | 174 | + $keyword_arr_id = Keyword::where('video', null)->where('title', 'not like', '%-tag%')->whereNotNull('keyword_content')->pluck('id')->toArray(); |
| 175 | $keyword_id = array_rand($keyword_arr_id, $number); | 175 | $keyword_id = array_rand($keyword_arr_id, $number); |
| 176 | $keyword = Keyword::whereIn("id", $keyword_id)->get(); | 176 | $keyword = Keyword::whereIn("id", $keyword_id)->get(); |
| 177 | return $keyword; | 177 | return $keyword; |
| @@ -189,23 +189,39 @@ class VideoTask extends Command | @@ -189,23 +189,39 @@ class VideoTask extends Command | ||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | /** | 191 | /** |
| 192 | - * @remark :根据关键字获取产品主图 | ||
| 193 | - * @name :getKeywordList | ||
| 194 | - * @author :lyh | ||
| 195 | - * @method :post | ||
| 196 | - * @time :2024/2/23 16:28 | 192 | + * 根据关键字获取产品主图 |
| 193 | + * @param $keyword_id | ||
| 194 | + * @param $project_id | ||
| 195 | + * @param $domain | ||
| 196 | + * @return array | ||
| 197 | */ | 197 | */ |
| 198 | public function getKeywordImage($keyword_id,$project_id,$domain){ | 198 | public function getKeywordImage($keyword_id,$project_id,$domain){ |
| 199 | $keywordModel = new Keyword(); | 199 | $keywordModel = new Keyword(); |
| 200 | $keywordInfo = $keywordModel->read(['id'=>$keyword_id]); | 200 | $keywordInfo = $keywordModel->read(['id'=>$keyword_id]); |
| 201 | + // TODO 当内容太多时,生成视频过长, 尽量保证生成视频30秒左右, 所以需要控制文案内容长度 | ||
| 202 | + $content = $keywordInfo['keyword_content']; | ||
| 203 | + $content_array = explode(" ", $content); | ||
| 204 | + if (count($content_array) > 80) { | ||
| 205 | + $content_array = preg_split("/[,,。]/u", $content); | ||
| 206 | + $tmp = ''; | ||
| 207 | + foreach ($content_array as $val) { | ||
| 208 | + $tmp .= $val . '.'; | ||
| 209 | + $tmp_array = explode(' ', $tmp); | ||
| 210 | + if (count($tmp_array) > 60) { | ||
| 211 | + $content = $tmp; | ||
| 212 | + break; | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + | ||
| 201 | //TODO::所有产品 | 217 | //TODO::所有产品 |
| 202 | $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); | 218 | $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); |
| 203 | - $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();; | 219 | + $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray(); |
| 204 | $data = [ | 220 | $data = [ |
| 205 | - 'url'=>$domain.'/'.$keywordInfo['route'], | 221 | + 'url'=> 'https://' . $domain.'/'.$keywordInfo['route'], |
| 206 | 'title'=>$keywordInfo['title'], | 222 | 'title'=>$keywordInfo['title'], |
| 207 | 'keyword_title'=>$keywordInfo['keyword_title'], | 223 | 'keyword_title'=>$keywordInfo['keyword_title'], |
| 208 | - 'keyword_content'=>$keywordInfo['keyword_content'], | 224 | + 'keyword_content'=>$content, |
| 209 | 'product_list'=>$thumb ?? [], | 225 | 'product_list'=>$thumb ?? [], |
| 210 | 'keyword_list'=>$keyword_arr ?? [] | 226 | 'keyword_list'=>$keyword_arr ?? [] |
| 211 | ]; | 227 | ]; |
| @@ -271,23 +287,36 @@ class VideoTask extends Command | @@ -271,23 +287,36 @@ class VideoTask extends Command | ||
| 271 | } | 287 | } |
| 272 | 288 | ||
| 273 | /** | 289 | /** |
| 274 | - * @remark :获取图片 | ||
| 275 | - * @name :getImage | ||
| 276 | - * @author :lyh | ||
| 277 | - * @method :post | ||
| 278 | - * @time :2024/3/12 15:29 | 290 | + * 获取图片 |
| 291 | + * @param $domainInfo | ||
| 292 | + * @return array | ||
| 279 | */ | 293 | */ |
| 280 | public function getImage($domainInfo){ | 294 | public function getImage($domainInfo){ |
| 295 | + $logo = $bg = ''; | ||
| 296 | + try { | ||
| 281 | $dom = file_get_html('https://'.$domainInfo['domain'].'/'); | 297 | $dom = file_get_html('https://'.$domainInfo['domain'].'/'); |
| 282 | $logoDom = $dom->find('.logo', 0)->find("img",0); | 298 | $logoDom = $dom->find('.logo', 0)->find("img",0); |
| 283 | if($logoDom != null){ | 299 | if($logoDom != null){ |
| 284 | $logo = $logoDom->src; | 300 | $logo = $logoDom->src; |
| 285 | } | 301 | } |
| 286 | - $bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0); | ||
| 287 | - if($bgDom != null){ | ||
| 288 | - $bg = $bgDom->src; | 302 | + $elements = $dom->find('.section-banner-wrap-block'); |
| 303 | + if (count($elements) >= 2) { | ||
| 304 | + foreach ($elements as $v){ | ||
| 305 | + $image = $v->find('img', 0); | ||
| 306 | + if($image != null){ | ||
| 307 | + break; | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + } else { | ||
| 311 | + $image = $elements->find('img', 0); | ||
| 312 | + } | ||
| 313 | + if($image != null){ | ||
| 314 | + $bg = $image->src; | ||
| 289 | } | 315 | } |
| 290 | $dom->clear(); | 316 | $dom->clear(); |
| 291 | - return ['logo'=>$logo ?? '','bg'=>$bg ?? '']; | 317 | + } catch (\Exception $e) { |
| 318 | + Log::error('file_get_html: ' . $domainInfo['domain'] . ', error message: ' . $e->getMessage()); | ||
| 319 | + } | ||
| 320 | + return ['logo' => $logo, 'bg' => $bg]; | ||
| 292 | } | 321 | } |
| 293 | } | 322 | } |
| @@ -266,7 +266,7 @@ class Demo extends Command | @@ -266,7 +266,7 @@ class Demo extends Command | ||
| 266 | // } | 266 | // } |
| 267 | public function handle(){ | 267 | public function handle(){ |
| 268 | $domainModel = new DomainInfo(); | 268 | $domainModel = new DomainInfo(); |
| 269 | - $domainInfo = $domainModel->read(['project_id'=>1]); | 269 | + $domainInfo = $domainModel->read(['project_id'=>45]); |
| 270 | if($domainInfo === false){ | 270 | if($domainInfo === false){ |
| 271 | dd('11111'); | 271 | dd('11111'); |
| 272 | } | 272 | } |
| @@ -277,12 +277,25 @@ class Demo extends Command | @@ -277,12 +277,25 @@ class Demo extends Command | ||
| 277 | if($logoDom != null){ | 277 | if($logoDom != null){ |
| 278 | $logo = $logoDom->src; | 278 | $logo = $logoDom->src; |
| 279 | } | 279 | } |
| 280 | - $bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0); | ||
| 281 | - if($bgDom != null){ | ||
| 282 | - $bg = $bgDom->src; | 280 | + $elements = $dom->find('.section-banner-wrap-block'); |
| 281 | + if (count($elements) >= 2) { | ||
| 282 | + foreach ($elements as $v){ | ||
| 283 | + $image = $v->find('img', 0); | ||
| 284 | + if($image != null){ | ||
| 285 | + break; | ||
| 286 | + } | ||
| 287 | + } | ||
| 288 | + } else { | ||
| 289 | + $image = $elements->find('img', 0); | ||
| 290 | + } | ||
| 291 | + if($image != null){ | ||
| 292 | + $bg = $image->src; | ||
| 293 | + } | ||
| 294 | + if($image != null){ | ||
| 295 | + $bg = $image->src; | ||
| 283 | } | 296 | } |
| 284 | // return $logo; | 297 | // return $logo; |
| 285 | - dd(['logo'=>$logo ?? '','ng'=>$bg ?? '']); | 298 | + dd(['logo'=>$logo ?? '','bg'=>$bg ?? '']); |
| 286 | // $projectModel = new Project(); | 299 | // $projectModel = new Project(); |
| 287 | // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); | 300 | // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); |
| 288 | // foreach ($list as $v1){ | 301 | // foreach ($list as $v1){ |
| @@ -29,7 +29,7 @@ class KeywordsController extends BaseController | @@ -29,7 +29,7 @@ class KeywordsController extends BaseController | ||
| 29 | ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray(); | 29 | ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray(); |
| 30 | $projectModel = new Project(); | 30 | $projectModel = new Project(); |
| 31 | $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build') | 31 | $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build') |
| 32 | - ->with('deploy_optimize')->get()->toArray(); | 32 | + ->with('deploy_optimize')->with('domainInfo')->get()->toArray(); |
| 33 | $this->response('success',Code::SUCCESS,$lists); | 33 | $this->response('success',Code::SUCCESS,$lists); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| @@ -114,6 +114,7 @@ class ProjectController extends BaseController | @@ -114,6 +114,7 @@ class ProjectController extends BaseController | ||
| 114 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', | 114 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', |
| 115 | 'gl_project_deploy_optimize.design_mid AS design_mid', | 115 | 'gl_project_deploy_optimize.design_mid AS design_mid', |
| 116 | 'gl_project_deploy_optimize.api_no AS api_no', | 116 | 'gl_project_deploy_optimize.api_no AS api_no', |
| 117 | + 'gl_project_deploy_optimize.brand_keyword AS brand_keyword', | ||
| 117 | ]; | 118 | ]; |
| 118 | return $select; | 119 | return $select; |
| 119 | } | 120 | } |
| @@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController | @@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController | ||
| 30 | } | 30 | } |
| 31 | $data['search_keywords'] = $info['search_keywords']; | 31 | $data['search_keywords'] = $info['search_keywords']; |
| 32 | $data['customer_keywords'] = $info['customer_keywords']; | 32 | $data['customer_keywords'] = $info['customer_keywords']; |
| 33 | + $data['brand_keyword'] = $info['brand_keyword']; | ||
| 33 | $this->response('success',Code::SUCCESS,$data); | 34 | $this->response('success',Code::SUCCESS,$data); |
| 34 | } | 35 | } |
| 35 | 36 |
| @@ -778,7 +778,7 @@ class ProjectLogic extends BaseLogic | @@ -778,7 +778,7 @@ class ProjectLogic extends BaseLogic | ||
| 778 | $token = $common->encrypt($param); | 778 | $token = $common->encrypt($param); |
| 779 | $res = Http::withoutVerifying()->get($url, ['token' => $token])->json(); | 779 | $res = Http::withoutVerifying()->get($url, ['token' => $token])->json(); |
| 780 | if(empty($res['code']) || $res['code'] != 200){ | 780 | if(empty($res['code']) || $res['code'] != 200){ |
| 781 | - $this->fail('ProjectToHagro error'); | 781 | + $this->fail($res['msg']); |
| 782 | } | 782 | } |
| 783 | return true; | 783 | return true; |
| 784 | } | 784 | } |
| @@ -47,26 +47,18 @@ class TranslateLogic extends BaseLogic | @@ -47,26 +47,18 @@ class TranslateLogic extends BaseLogic | ||
| 47 | $languageInfo = $this->getLanguage($this->param['language_id']); | 47 | $languageInfo = $this->getLanguage($this->param['language_id']); |
| 48 | // 原始校对内容 | 48 | // 原始校对内容 |
| 49 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); | 49 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); |
| 50 | - //获取当前URl的所有文本内容 | ||
| 51 | - $text_array = $this->getUrlRead($url); | ||
| 52 | - // 原始校对程序 | ||
| 53 | - $old_key = [];//key值组成数据 | ||
| 54 | if($info !== false){ | 50 | if($info !== false){ |
| 55 | $data_read = json_decode($info['data']); | 51 | $data_read = json_decode($info['data']); |
| 56 | foreach ($data_read as $k => $v){ | 52 | foreach ($data_read as $k => $v){ |
| 57 | -// if(!in_array($k,$text_array)){ | ||
| 58 | -// $arr2[] = $k; | ||
| 59 | -// } | ||
| 60 | -// $old_key[] = $k; | ||
| 61 | $data[] = [$k => $v]; | 53 | $data[] = [$k => $v]; |
| 62 | } | 54 | } |
| 55 | + return $this->success($data); | ||
| 63 | }else{ | 56 | }else{ |
| 64 | - $arr2 = array_values(array_diff($text_array, $old_key)); | ||
| 65 | - } | ||
| 66 | - if(!empty($arr2)){ | 57 | + //获取当前URl的所有文本内容 |
| 58 | + $text_array = $this->getUrlRead($url); | ||
| 67 | $i = 0; | 59 | $i = 0; |
| 68 | TranslateText: | 60 | TranslateText: |
| 69 | - $translate_list = Translate::tran($arr2, $languageInfo['short']); | 61 | + $translate_list = Translate::tran($text_array, $languageInfo['short']); |
| 70 | if(empty($translate_list)){ | 62 | if(empty($translate_list)){ |
| 71 | if ($i < 3) { | 63 | if ($i < 3) { |
| 72 | $i++; | 64 | $i++; |
| @@ -74,21 +66,57 @@ class TranslateLogic extends BaseLogic | @@ -74,21 +66,57 @@ class TranslateLogic extends BaseLogic | ||
| 74 | } | 66 | } |
| 75 | $this->fail('翻译失败,请稍后重试!'); | 67 | $this->fail('翻译失败,请稍后重试!'); |
| 76 | } | 68 | } |
| 77 | - if(count($arr2) == 1){ | 69 | + if(count($text_array) == 1){ |
| 78 | $data[] = [ | 70 | $data[] = [ |
| 79 | - $arr2[0]=>$translate_list | 71 | + $text_array[0]=>$translate_list |
| 80 | ]; | 72 | ]; |
| 81 | }else{ | 73 | }else{ |
| 82 | - foreach ($arr2 as $k => $v){ | 74 | + foreach ($text_array as $k => $v){ |
| 83 | $data[] = [ | 75 | $data[] = [ |
| 84 | $v=>$translate_list[$k] | 76 | $v=>$translate_list[$k] |
| 85 | ]; | 77 | ]; |
| 86 | } | 78 | } |
| 87 | } | 79 | } |
| 88 | - } | ||
| 89 | return $this->success($data); | 80 | return $this->success($data); |
| 90 | } | 81 | } |
| 82 | + } | ||
| 91 | 83 | ||
| 84 | + // $old_key = [];//key值组成数据 | ||
| 85 | + // if($info !== false){ | ||
| 86 | + // $data_read = json_decode($info['data']); | ||
| 87 | + // foreach ($data_read as $k => $v){ | ||
| 88 | + //// if(!in_array($k,$text_array)){ | ||
| 89 | + //// $arr2[] = $k; | ||
| 90 | + //// } | ||
| 91 | + //// $old_key[] = $k; | ||
| 92 | + // $data[] = [$k => $v]; | ||
| 93 | + // } | ||
| 94 | + // }else{ | ||
| 95 | + // $arr2 = array_values(array_diff($text_array, $old_key)); | ||
| 96 | + // } | ||
| 97 | + // if(!empty($arr2)){ | ||
| 98 | + // $i = 0; | ||
| 99 | + // TranslateText: | ||
| 100 | + // $translate_list = Translate::tran($arr2, $languageInfo['short']); | ||
| 101 | + // if(empty($translate_list)){ | ||
| 102 | + // if ($i < 3) { | ||
| 103 | + // $i++; | ||
| 104 | + // goto TranslateText; | ||
| 105 | + // } | ||
| 106 | + // $this->fail('翻译失败,请稍后重试!'); | ||
| 107 | + // } | ||
| 108 | + // if(count($arr2) == 1){ | ||
| 109 | + // $data[] = [ | ||
| 110 | + // $arr2[0]=>$translate_list | ||
| 111 | + // ]; | ||
| 112 | + // }else{ | ||
| 113 | + // foreach ($arr2 as $k => $v){ | ||
| 114 | + // $data[] = [ | ||
| 115 | + // $v=>$translate_list[$k] | ||
| 116 | + // ]; | ||
| 117 | + // } | ||
| 118 | + // } | ||
| 119 | + // } | ||
| 92 | 120 | ||
| 93 | /** | 121 | /** |
| 94 | * @remark :获取图片列表 | 122 | * @remark :获取图片列表 |
| @@ -227,9 +227,10 @@ class Project extends Base | @@ -227,9 +227,10 @@ class Project extends Base | ||
| 227 | */ | 227 | */ |
| 228 | public function domainInfo() | 228 | public function domainInfo() |
| 229 | { | 229 | { |
| 230 | - return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'project_id')->select('project_id', 'domain');; | 230 | + return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'id')->select('project_id', 'domain'); |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | + | ||
| 233 | public function setLevelAttribute($value) | 234 | public function setLevelAttribute($value) |
| 234 | { | 235 | { |
| 235 | $this->attributes['level'] = Arr::arrToSet($value); | 236 | $this->attributes['level'] = Arr::arrToSet($value); |
-
请 注册 或 登录 后发表评论