作者 lyh

未续费项目增加搜索

@@ -110,8 +110,19 @@ class AiBlogAutoPublish extends Command @@ -110,8 +110,19 @@ class AiBlogAutoPublish extends Command
110 } 110 }
111 } 111 }
112 } else { 112 } else {
  113 + if($frequency[0] == '1/2'){//一天2篇
  114 + $aiBlogTaskModel = new AiBlogTaskModel();
  115 + $frequency = explode('/', $frequency[0]);
  116 + //查询当前已发布几篇
  117 + $count = $aiBlogTaskModel->counts(['next_auto_date' => date('Y-m-d'),'project_id' => $project->id]);
  118 + while ($count < ($frequency[1] ?? 2)){
  119 + $this->createTask($keywords, $project->id, [0,1]);
  120 + $count++;
  121 + }
  122 + }else{
113 $this->createTask($keywords, $project->id, $frequency); 123 $this->createTask($keywords, $project->id, $frequency);
114 } 124 }
  125 + }
115 }catch (\Exception $e){ 126 }catch (\Exception $e){
116 (new DingService())->handle([ 127 (new DingService())->handle([
117 'keyword' => 'AI_BLOG自动发布失败', 128 'keyword' => 'AI_BLOG自动发布失败',
@@ -133,18 +144,7 @@ class AiBlogAutoPublish extends Command @@ -133,18 +144,7 @@ class AiBlogAutoPublish extends Command
133 $result = $aiBlogService->createTask($keyword); 144 $result = $aiBlogService->createTask($keyword);
134 if ($result['status'] == 200) { 145 if ($result['status'] == 200) {
135 $aiBlogTaskModel = new AiBlogTaskModel(); 146 $aiBlogTaskModel = new AiBlogTaskModel();
136 - if($frequency[0] == '1/2'){//一天2篇  
137 - $frequency = explode('/', $frequency[0]);  
138 - //查询当前已发布几篇  
139 - $count = $aiBlogTaskModel->counts(['next_auto_date' => date('Y-m-d'),'project_id' => $project_id]);  
140 - if($count < ($frequency[1] ?? 2)){  
141 - $next_auto_date = date('Y-m-d'); //当天未发送固定数量,继续执行  
142 - }else{  
143 - $next_auto_date = date('Y-m-d',strtotime('+' . ($frequency[0] ?? 1) . 'days')); //每3-6天自动发布  
144 - }  
145 - }else {  
146 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0] ?? 3, $frequency[1] ?? 6) . 'days')); //每3-6天自动发布 147 $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0] ?? 3, $frequency[1] ?? 6) . 'days')); //每3-6天自动发布
147 - }  
148 $aiBlogTaskModel->addReturnId(['project_id' => $project_id, 'type' => 2, 'task_id' => $result['data']['task_id'], 'status' => 1, 'next_auto_date' => $next_auto_date]); 148 $aiBlogTaskModel->addReturnId(['project_id' => $project_id, 'type' => 2, 'task_id' => $result['data']['task_id'], 'status' => 1, 'next_auto_date' => $next_auto_date]);
149 ProjectServer::useProject($project_id); 149 ProjectServer::useProject($project_id);
150 $aiBlogModel = new AiBlog(); 150 $aiBlogModel = new AiBlog();
@@ -79,6 +79,7 @@ class Project extends Base @@ -79,6 +79,7 @@ class Project extends Base
79 3=>'2-4', 79 3=>'2-4',
80 4=>'3-5', 80 4=>'3-5',
81 5=>'5-7', 81 5=>'5-7',
  82 + 6=>'1/2'
82 ]; 83 ];
83 if($val){ 84 if($val){
84 return $arr[$val] ?? ''; 85 return $arr[$val] ?? '';