作者 lyh

gx

... ... @@ -21,6 +21,7 @@ use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
... ... @@ -133,9 +134,11 @@ class VideoTask extends Command
public function sendSubTask()
{
$subTask = KeywordVideoTaskLog::where(['status' => KeywordVideoTaskLog::STATUS_INIT])->orderBy('id', 'asc')->limit($this->max_sub_task)->get();
if ($subTask->isEmpty())
if ($subTask->isEmpty()){
return true;
}
foreach ($subTask as $val) {
$logo_bg = $this->getImage($val->project_id);
$valData = (array)json_decode($val->data);
$task_id = 'v6-' . uniqid();
$data = [
... ... @@ -145,8 +148,8 @@ class VideoTask extends Command
'keywords' => $valData['keywords'],
'description' => $valData['description'],
'images' => $valData['images'],
'logo'=> $this->getLogo($val->project_id),
'bg'=> $valData['bg']
'logo'=> $logo_bg['logo'],
'bg'=> $logo_bg['bg']
],
'task_id' => $task_id,
'callback_url' => env('APP_URL') . '/api/video_task_callback',
... ... @@ -267,16 +270,28 @@ class VideoTask extends Command
return $data;
}
public function getLogo($project_id){
/**
* @remark :获取图片
* @name :getImage
* @author :lyh
* @method :post
* @time :2024/3/12 15:29
*/
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'].'/');
$logo = $dom->find('.logo', 0)->find("img",0)->src;
$bg = $dom->find('.section-banner-wrap-block',0)->find('img', 0)->src;
DB::disconnect('custom_mysql');
return ['logo'=>$logo,'ng'=>$bg];
$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;
}
return ['logo'=>$logo ?? '','ng'=>$bg ?? ''];
}
}
... ...
... ... @@ -266,7 +266,7 @@ class Demo extends Command
// }
public function handle(){
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>6]);
$domainInfo = $domainModel->read(['project_id'=>151]);
if($domainInfo === false){
dd('11111');
}
... ... @@ -282,7 +282,7 @@ class Demo extends Command
$bg = $bgDom->src;
}
// return $logo;
dd($bg);
dd(['logo'=>$logo ?? '','ng'=>$bg ?? '']);
// $projectModel = new Project();
// $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
// foreach ($list as $v1){
... ...