作者 lyh

gx

@@ -21,6 +21,7 @@ use App\Models\Template\BTemplateCommon; @@ -21,6 +21,7 @@ use App\Models\Template\BTemplateCommon;
21 use App\Models\Template\Setting; 21 use App\Models\Template\Setting;
22 use App\Services\ProjectServer; 22 use App\Services\ProjectServer;
23 use Illuminate\Console\Command; 23 use Illuminate\Console\Command;
  24 +use Illuminate\Support\Facades\Cache;
24 use Illuminate\Support\Facades\DB; 25 use Illuminate\Support\Facades\DB;
25 use Illuminate\Support\Facades\Http; 26 use Illuminate\Support\Facades\Http;
26 use Illuminate\Support\Facades\Log; 27 use Illuminate\Support\Facades\Log;
@@ -133,9 +134,11 @@ class VideoTask extends Command @@ -133,9 +134,11 @@ class VideoTask extends Command
133 public function sendSubTask() 134 public function sendSubTask()
134 { 135 {
135 $subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get(); 136 $subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get();
136 - if ($subTask->isEmpty()) 137 + if ($subTask->isEmpty()){
137 return true; 138 return true;
  139 + }
138 foreach ($subTask as $val) { 140 foreach ($subTask as $val) {
  141 + $logo_bg = $this->getImage($val->project_id);
139 $valData = (array)json_decode($val->data); 142 $valData = (array)json_decode($val->data);
140 $task_id = 'v6-' . uniqid(); 143 $task_id = 'v6-' . uniqid();
141 $data = [ 144 $data = [
@@ -145,8 +148,8 @@ class VideoTask extends Command @@ -145,8 +148,8 @@ class VideoTask extends Command
145 'keywords' => $valData['keywords'], 148 'keywords' => $valData['keywords'],
146 'description' => $valData['description'], 149 'description' => $valData['description'],
147 'images' => $valData['images'], 150 'images' => $valData['images'],
148 - 'logo'=> $this->getLogo($val->project_id),  
149 - 'bg'=> $valData['bg'] 151 + 'logo'=> $logo_bg['logo'],
  152 + 'bg'=> $logo_bg['bg']
150 ], 153 ],
151 'task_id' => $task_id, 154 'task_id' => $task_id,
152 'callback_url' => env('APP_URL') . '/api/video_task_callback', 155 'callback_url' => env('APP_URL') . '/api/video_task_callback',
@@ -267,16 +270,28 @@ class VideoTask extends Command @@ -267,16 +270,28 @@ class VideoTask extends Command
267 return $data; 270 return $data;
268 } 271 }
269 272
270 - public function getLogo($project_id){ 273 + /**
  274 + * @remark :获取图片
  275 + * @name :getImage
  276 + * @author :lyh
  277 + * @method :post
  278 + * @time :2024/3/12 15:29
  279 + */
  280 + public function getImage($project_id){
271 $domainModel = new DomainInfo(); 281 $domainModel = new DomainInfo();
272 $domainInfo = $domainModel->read(['project_id'=>$project_id]); 282 $domainInfo = $domainModel->read(['project_id'=>$project_id]);
273 if($domainInfo === false){ 283 if($domainInfo === false){
274 return ''; 284 return '';
275 } 285 }
276 $dom = file_get_html('https://'.$domainInfo['domain'].'/'); 286 $dom = file_get_html('https://'.$domainInfo['domain'].'/');
277 - $logo = $dom->find('.logo', 0)->find("img",0)->src;  
278 - $bg = $dom->find('.section-banner-wrap-block',0)->find('img', 0)->src;  
279 - DB::disconnect('custom_mysql');  
280 - return ['logo'=>$logo,'ng'=>$bg]; 287 + $logoDom = $dom->find('.logo', 0)->find("img",0);
  288 + if($logoDom != null){
  289 + $logo = $logoDom->src;
  290 + }
  291 + $bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0);
  292 + if($bgDom != null){
  293 + $bg = $bgDom->src;
  294 + }
  295 + return ['logo'=>$logo ?? '','ng'=>$bg ?? ''];
281 } 296 }
282 } 297 }
@@ -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'=>6]); 269 + $domainInfo = $domainModel->read(['project_id'=>151]);
270 if($domainInfo === false){ 270 if($domainInfo === false){
271 dd('11111'); 271 dd('11111');
272 } 272 }
@@ -282,7 +282,7 @@ class Demo extends Command @@ -282,7 +282,7 @@ class Demo extends Command
282 $bg = $bgDom->src; 282 $bg = $bgDom->src;
283 } 283 }
284 // return $logo; 284 // return $logo;
285 - dd($bg); 285 + dd(['logo'=>$logo ?? '','ng'=>$bg ?? '']);
286 // $projectModel = new Project(); 286 // $projectModel = new Project();
287 // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); 287 // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
288 // foreach ($list as $v1){ 288 // foreach ($list as $v1){