作者 lyh

变更数据

@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Console\Commands\Ai; 10 namespace App\Console\Commands\Ai;
11 11
12 use App\Models\Ai\AiVideo; 12 use App\Models\Ai\AiVideo;
  13 +use App\Models\AyrShare\AyrShare;
13 use App\Models\Domain\DomainInfo; 14 use App\Models\Domain\DomainInfo;
14 use App\Models\Product\Keyword; 15 use App\Models\Product\Keyword;
15 use App\Models\Product\Product; 16 use App\Models\Product\Product;
@@ -241,7 +242,15 @@ class AiVideoAutoPublish extends Command @@ -241,7 +242,15 @@ class AiVideoAutoPublish extends Command
241 $storage = $aiVideoTaskModel->videoSetting()[$video_setting ?? 1]; 242 $storage = $aiVideoTaskModel->videoSetting()[$video_setting ?? 1];
242 $frequency = $aiVideoTaskModel->videoFrequency()[$frequency_setting ?? 1]; 243 $frequency = $aiVideoTaskModel->videoFrequency()[$frequency_setting ?? 1];
243 $frequencyArr = explode('-',$frequency); 244 $frequencyArr = explode('-',$frequency);
244 - $result = $aiVideoService->createTask($info['title'],$info['remark'],array_slice($info['images'], 0, 8),[],$storage); 245 + if($storage == 'YOUTUBE'){
  246 + //查看是否有ayr账号
  247 + $ayrModel = new AyrShare();
  248 + $ayrInfo = $ayrModel->read(['project_id'=>$this->param['project_id'],'bind_platforms'=>['like','%"youtube"%'],'profile_key'=>['!=',null]]);
  249 + if($ayrInfo !== false){
  250 + $ayrshare_profile_key = $ayrInfo['profile_key'];
  251 + }
  252 + }
  253 + $result = $aiVideoService->createTask($info['title'],$info['remark'],array_slice($info['images'], 0, 8),[],$storage,$ayrshare_profile_key ?? '');
245 if($result['status'] == 200){ 254 if($result['status'] == 200){
246 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequencyArr[0] ?? 5,$frequencyArr[1] ?? 7) . 'days')); //每5-7天自动发布 255 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequencyArr[0] ?? 5,$frequencyArr[1] ?? 7) . 'days')); //每5-7天自动发布
247 $aiVideoTaskModel->addReturnId(['next_auto_date'=>$next_auto_date,'task_id'=>$result['data']['task_id'],'project_id'=>$info['project_id'],'storage'=>$storage]); 256 $aiVideoTaskModel->addReturnId(['next_auto_date'=>$next_auto_date,'task_id'=>$result['data']['task_id'],'project_id'=>$info['project_id'],'storage'=>$storage]);
@@ -6,6 +6,7 @@ use App\Helper\Translate; @@ -6,6 +6,7 @@ use App\Helper\Translate;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\Ai\AiBlogAuthor; 7 use App\Models\Ai\AiBlogAuthor;
8 use App\Models\Ai\AiVideo; 8 use App\Models\Ai\AiVideo;
  9 +use App\Models\AyrShare\AyrShare;
9 use App\Models\Project\AiBlogTask; 10 use App\Models\Project\AiBlogTask;
10 use App\Models\Project\AiVideoTask; 11 use App\Models\Project\AiVideoTask;
11 use App\Models\Project\ProjectAiSetting; 12 use App\Models\Project\ProjectAiSetting;
@@ -66,8 +67,16 @@ class AiVideoLogic extends BaseLogic @@ -66,8 +67,16 @@ class AiVideoLogic extends BaseLogic
66 $aiVideoTaskModel = new AiVideoTask(); 67 $aiVideoTaskModel = new AiVideoTask();
67 $aiVideoService = new AiVideoService($this->user['project_id']); 68 $aiVideoService = new AiVideoService($this->user['project_id']);
68 $storage = $aiVideoTaskModel->videoSetting()[$this->user['video_setting'] ?? 1]; 69 $storage = $aiVideoTaskModel->videoSetting()[$this->user['video_setting'] ?? 1];
  70 + if($storage == 'YOUTUBE'){
  71 + //查看是否有ayr账号
  72 + $ayrModel = new AyrShare();
  73 + $ayrInfo = $ayrModel->read(['project_id'=>$this->param['project_id'],'bind_platforms'=>['like','%"youtube"%'],'profile_key'=>['!=',null]]);
  74 + if($ayrInfo !== false){
  75 + $ayrshare_profile_key = $ayrInfo['profile_key'];
  76 + }
  77 + }
69 //todo::获取ayr的key 78 //todo::获取ayr的key
70 - $result = $aiVideoService->createTask($this->param['title'],$this->param['description'],$this->param['images'],$this->param['anchor'] ?? [],$storage); 79 + $result = $aiVideoService->createTask($this->param['title'],$this->param['description'],$this->param['images'],$this->param['anchor'] ?? [],$storage,$ayrshare_profile_key ?? '');
71 if($result['status'] == 200){ 80 if($result['status'] == 200){
72 $aiVideoTaskModel->addReturnId(['task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'storage'=>$storage]); 81 $aiVideoTaskModel->addReturnId(['task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'storage'=>$storage]);
73 $id = $this->model->addReturnId(['title'=>$this->param['title'],'task_id'=>$result['data']['task_id'],'description'=>$this->param['description'],'project_id'=>$this->user['project_id'],'images'=>json_encode($this->param['images'],true),'anchor'=>json_encode($this->param['anchor'] ?? [],true)]); 82 $id = $this->model->addReturnId(['title'=>$this->param['title'],'task_id'=>$result['data']['task_id'],'description'=>$this->param['description'],'project_id'=>$this->user['project_id'],'images'=>json_encode($this->param['images'],true),'anchor'=>json_encode($this->param['anchor'] ?? [],true)]);
@@ -120,7 +120,7 @@ class GeoQuestionResLogic extends BaseLogic @@ -120,7 +120,7 @@ class GeoQuestionResLogic extends BaseLogic
120 'core_question_count'=>$core_question_count,//核心问题总数 120 'core_question_count'=>$core_question_count,//核心问题总数
121 'keywords_url_count'=>$keywordUrlCount, 121 'keywords_url_count'=>$keywordUrlCount,
122 'keywords_arr' => $keywordArr, 122 'keywords_arr' => $keywordArr,
123 - 'core_keyword_url_count'=>$coreKeywordUrlCount ?? 0 123 + 'core_keyword_url_count'=>$coreKeywordUrlCount ?? 0,
124 ]; 124 ];
125 }else{ 125 }else{
126 $keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]); 126 $keywordUrlCount = $questionLogModel->counts(['project_id'=>$this->user['project_id'],'hit'=>['!=',0]]);
@@ -147,6 +147,11 @@ class GeoQuestionResLogic extends BaseLogic @@ -147,6 +147,11 @@ class GeoQuestionResLogic extends BaseLogic
147 ->where('hit','!=',0)->whereIn('platform',['openai', 'gemini','google_ai_overview']) 147 ->where('hit','!=',0)->whereIn('platform',['openai', 'gemini','google_ai_overview'])
148 ->select(DB::raw('COUNT(DISTINCT question) as total')) 148 ->select(DB::raw('COUNT(DISTINCT question) as total'))
149 ->value('total'); 149 ->value('total');
  150 + $latestCreatedAt = $questionLogModel
  151 + ->where('project_id', $this->user['project_id'])
  152 + ->orderBy('id', 'desc')
  153 + ->value('created_at');
  154 + $data['date'] = $latestCreatedAt ? date('Y-m-d', strtotime($latestCreatedAt)) : null;
150 return $this->success($data); 155 return $this->success($data);
151 } 156 }
152 157