作者 赵彬吉
@@ -82,7 +82,7 @@ class AiBlogAuthorTask extends Command @@ -82,7 +82,7 @@ class AiBlogAuthorTask extends Command
82 DB::disconnect('custom_mysql'); 82 DB::disconnect('custom_mysql');
83 //修改任务状态 83 //修改任务状态
84 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); 84 $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]);
85 - echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); 85 + echo '结束->任务id:' . $info['id'] . PHP_EOL . date('Y-m-d H:i:s');
86 } 86 }
87 return true; 87 return true;
88 } 88 }
@@ -119,22 +119,33 @@ class AiBlogAuthorTask extends Command @@ -119,22 +119,33 @@ class AiBlogAuthorTask extends Command
119 } 119 }
120 $aiBlogAuthorModel = new AiBlogAuthor(); 120 $aiBlogAuthorModel = new AiBlogAuthor();
121 foreach ($data as $v){ 121 foreach ($data as $v){
  122 + $param = [
  123 + 'author_id'=>$v['id'],
  124 + 'title'=>$v['title'],
  125 + 'image'=>str_replace_url($v['picture']),
  126 + 'description'=>$v['description'],
  127 + ];
122 //查询当前数据是否存在 128 //查询当前数据是否存在
123 $info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]); 129 $info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]);
124 - if($info === false){  
125 - $param = [  
126 - 'author_id'=>$v['id'],  
127 - 'title'=>$v['title'],  
128 - 'image'=>str_replace_url($v['picture']),  
129 - 'description'=>$v['description'],  
130 - ];  
131 - try { 130 + try {
  131 + if($info === false){
  132 + echo '执行新增'.PHP_EOL;
132 $id = $aiBlogAuthorModel->addReturnId($param); 133 $id = $aiBlogAuthorModel->addReturnId($param);
133 - $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);  
134 - $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);  
135 - }catch (\Exception $e){  
136 - echo 'error:'.$e->getMessage(); 134 + $param['route'] = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
  135 + $aiBlogAuthorModel->edit(['route'=>$param['route']],['id'=>$id]);
  136 + }else{
  137 + $param['route'] = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $info['id'], $project_id);
  138 + $aiBlogAuthorModel->edit($param,['id'=>$info['id']]);
  139 + echo '执行更新'.PHP_EOL;
137 } 140 }
  141 + $aiSettingInfo = $this->getSetting($project_id);
  142 + $aiBlogService = new AiBlogService();
  143 + $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
  144 + $aiBlogService->key = $aiSettingInfo['key'];
  145 + $aiBlogService->updateAuthorInfo(['author_id'=>$param['author_id'],'route'=>$param['route'],'title'=>$param['title'],'picture'=>$param['image'],'description'=>$param['description']]);
  146 + }catch (\Exception $e){
  147 + echo 'error:'.$e->getMessage();
  148 + continue;
138 } 149 }
139 } 150 }
140 return true; 151 return true;
@@ -9,10 +9,15 @@ @@ -9,10 +9,15 @@
9 9
10 namespace App\Console\Commands\Ai; 10 namespace App\Console\Commands\Ai;
11 11
  12 +use App\Helper\Arr;
12 use App\Models\Ai\AiBlog; 13 use App\Models\Ai\AiBlog;
13 use App\Models\Ai\AiBlogAuthor; 14 use App\Models\Ai\AiBlogAuthor;
14 use App\Models\Ai\AiBlogList; 15 use App\Models\Ai\AiBlogList;
  16 +use App\Models\Com\Notify;
  17 +use App\Models\Devops\ServerConfig;
  18 +use App\Models\Devops\ServersIp;
15 use App\Models\Domain\DomainInfo; 19 use App\Models\Domain\DomainInfo;
  20 +use App\Models\Project\Project;
16 use App\Models\Project\ProjectAiSetting; 21 use App\Models\Project\ProjectAiSetting;
17 use App\Models\RouteMap\RouteMap; 22 use App\Models\RouteMap\RouteMap;
18 use App\Services\AiBlogService; 23 use App\Services\AiBlogService;
@@ -212,8 +217,41 @@ class AiBlogTask extends Command @@ -212,8 +217,41 @@ class AiBlogTask extends Command
212 //获取项目域名 217 //获取项目域名
213 $domain = $domainModel->getProjectIdDomain($project_id); 218 $domain = $domainModel->getProjectIdDomain($project_id);
214 if(!empty($domain)){ 219 if(!empty($domain)){
215 - $url = $domain.'api/update_page/?project_id='.$project_id.'&route=7';  
216 - shell_exec('curl -k "'.$url.'"'); 220 + //判断是否是自建站服务器,如果是,不请求C端接口,数据直接入库
  221 + $project_model = new Project();
  222 + $project_info = $project_model->read(['id'=>$project_id],['serve_id']);
  223 + if(!$project_info){
  224 + echo '项目不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s');
  225 + return true;
  226 + }
  227 + $serve_ip_model = new ServersIp();
  228 + $serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']);
  229 + $servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0;
  230 + if($servers_id == ServerConfig::SELF_SITE_ID){
  231 + //判断是否已有更新进行中
  232 + $notify_model = new Notify();
  233 + $data = [
  234 + 'project_id' => $project_id,
  235 + 'type' => Notify::TYPE_MASTER,
  236 + 'route' => Notify::ROUTE_AI_BLOG,
  237 + 'server_id' => ServerConfig::SELF_SITE_ID,
  238 + 'status' => ['!=',Notify::STATUS_FINISH_SITEMAP]
  239 + ];
  240 + $notify = $notify_model->read($data,['id']);
  241 +
  242 + if(!$notify){
  243 + $domain_array = parse_url($domain);
  244 + $data['data'] = Arr::a2s(['domain'=>$domain_array['host'],'url'=>[],'language'=>[]]);
  245 + $data['status'] = Notify::STATUS_INIT;
  246 + $data['sort'] = 2;
  247 + $notify_model->add($data);
  248 + }
  249 + echo '自建站项目:'.$project_id.'更新';
  250 + }else{
  251 + $url = $domain.'api/update_page/?project_id='.$project_id.'&route=7';
  252 + $res = http_get($url);
  253 + echo '返回数据:'.json_encode($res,true).PHP_EOL;
  254 + }
217 }else{ 255 }else{
218 echo '域名不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s'); 256 echo '域名不存在:' . $project_id . PHP_EOL . date('Y-m-d H:i:s');
219 } 257 }
@@ -240,7 +240,7 @@ class PostInquiryForward extends Command @@ -240,7 +240,7 @@ class PostInquiryForward extends Command
240 $curl = curl_init($url); 240 $curl = curl_init($url);
241 curl_setopt($curl, CURLOPT_POST, 1); 241 curl_setopt($curl, CURLOPT_POST, 1);
242 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 242 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
243 - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); 243 + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
244 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); 244 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
245 curl_setopt($curl, CURLOPT_AUTOREFERER, 1); 245 curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
246 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36'); 246 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36');
@@ -280,7 +280,7 @@ class PostInquiryForward extends Command @@ -280,7 +280,7 @@ class PostInquiryForward extends Command
280 $data['__amp_source_origin'] = trim($website, '/'); 280 $data['__amp_source_origin'] = trim($website, '/');
281 } 281 }
282 $url = $website . 'api/inquiryQd?source=5'; 282 $url = $website . 'api/inquiryQd?source=5';
283 - $res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json(); 283 + $res = Http::withoutVerifying()->timeout(60)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
284 if (empty($res['code']) || $res['code'] != 200) { 284 if (empty($res['code']) || $res['code'] != 200) {
285 $log->status = InquiryRelayDetailLog::STATUS_FAIL; 285 $log->status = InquiryRelayDetailLog::STATUS_FAIL;
286 $log->remark = mb_substr($res['message'] ?? '', 0, 200); 286 $log->remark = mb_substr($res['message'] ?? '', 0, 200);
@@ -307,7 +307,7 @@ class PostInquiryForward extends Command @@ -307,7 +307,7 @@ class PostInquiryForward extends Command
307 'submit_time' => date('Y-m-d H:i:s', time() + 60) 307 'submit_time' => date('Y-m-d H:i:s', time() + 60)
308 ]; 308 ];
309 $url = 'https://' . $detail['website'] . '/wp-admin/admin-ajax.php?action=live_remort_receive'; 309 $url = 'https://' . $detail['website'] . '/wp-admin/admin-ajax.php?action=live_remort_receive';
310 - $res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data); 310 + $res = Http::withoutVerifying()->timeout(60)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data);
311 $status = $res->status(); 311 $status = $res->status();
312 if ($status != 200) { 312 if ($status != 200) {
313 $log->status = InquiryRelayDetailLog::STATUS_FAIL; 313 $log->status = InquiryRelayDetailLog::STATUS_FAIL;
@@ -330,7 +330,7 @@ class PostInquiryForward extends Command @@ -330,7 +330,7 @@ class PostInquiryForward extends Command
330 'source' => 5, 330 'source' => 5,
331 ]; 331 ];
332 $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f'; 332 $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
333 - $res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json(); 333 + $res = Http::withoutVerifying()->timeout(60)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json();
334 if (empty($res['status']) || $res['status'] != 200) { 334 if (empty($res['status']) || $res['status'] != 200) {
335 $log->status = InquiryRelayDetailLog::STATUS_FAIL; 335 $log->status = InquiryRelayDetailLog::STATUS_FAIL;
336 $log->remark = mb_substr($res['message'] ?? '', 0, 200); 336 $log->remark = mb_substr($res['message'] ?? '', 0, 200);
@@ -530,15 +530,17 @@ class UpdateRoute extends Command @@ -530,15 +530,17 @@ class UpdateRoute extends Command
530 $seoModel = new WebSettingSeo(); 530 $seoModel = new WebSettingSeo();
531 $seo_info = $seoModel->read(['project_id'=>$project_id]); 531 $seo_info = $seoModel->read(['project_id'=>$project_id]);
532 if($seo_info !== false){ 532 if($seo_info !== false){
533 - $prefix = $seo_info['product_category_prefix'] ?? [];  
534 - $suffix = $seo_info['product_category_suffix'] ?? []; 533 + $prefix = [];
  534 + $suffix = [];
535 if(!empty($seo_info['product_cate_prefix'])){ 535 if(!empty($seo_info['product_cate_prefix'])){
536 - $prefix[] = ['name'=>$seo_info['product_cate_prefix']]; 536 + $prefix[] = ['val'=>[$seo_info['product_cate_prefix']],'level'=>1];
537 } 537 }
538 if(!empty($seo_info['product_cate_suffix'])){ 538 if(!empty($seo_info['product_cate_suffix'])){
539 - $suffix[] = ['name'=>$seo_info['product_cate_suffix']]; 539 + $suffix[] = ['val'=>[$seo_info['product_cate_suffix']],'level'=>1];
  540 + }
  541 + if(!empty($prefix) && !empty($suffix)){
  542 + $seoModel->edit(['product_category_prefix'=>json_encode($prefix,true),'product_category_suffix'=>json_encode($suffix,true)],['project_id'=>$project_id]);
540 } 543 }
541 - $seoModel->edit(['product_category_prefix'=>json_encode($prefix,true),'product_category_suffix'=>json_encode($suffix,true)],['project_id'=>$project_id]);  
542 } 544 }
543 return true; 545 return true;
544 } 546 }
@@ -314,17 +314,17 @@ class PrivateController extends BaseController @@ -314,17 +314,17 @@ class PrivateController extends BaseController
314 ProjectServer::useProject($project->id); 314 ProjectServer::useProject($project->id);
315 $result = []; 315 $result = [];
316 // 查询有效时间后 有效的产品、新闻、博客、聚合页 链接 316 // 查询有效时间后 有效的产品、新闻、博客、聚合页 链接
317 - $product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route'); 317 +// $product = Product::where(['status' => Product::STATUS_ON])->where('created_at', '>=', $date)->pluck('route');
318 $news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); 318 $news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
319 $blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); 319 $blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url');
320 // $keyword = Keyword::where('created_at', '>', $date)->pluck('route'); 320 // $keyword = Keyword::where('created_at', '>', $date)->pluck('route');
321 $ai_blog = AiBlog::where(['status' => AiBlog::STATUS_FINISH])->where('updated_at', '>=', $date)->pluck('route'); 321 $ai_blog = AiBlog::where(['status' => AiBlog::STATUS_FINISH])->where('updated_at', '>=', $date)->pluck('route');
322 322
323 // 组装链接 323 // 组装链接
324 - foreach ($product as $item) {  
325 - $url = 'https://' . $domain . '/' . $item;  
326 - array_push($result, $url);  
327 - } 324 +// foreach ($product as $item) {
  325 +// $url = 'https://' . $domain . '/' . $item;
  326 +// array_push($result, $url);
  327 +// }
328 // foreach ($keyword as $item) { 328 // foreach ($keyword as $item) {
329 // $url = 'https://' . $domain . '/' . $item; 329 // $url = 'https://' . $domain . '/' . $item;
330 // array_push($result, $url); 330 // array_push($result, $url);
@@ -10,6 +10,7 @@ use App\Models\Project\AiBlogTask; @@ -10,6 +10,7 @@ use App\Models\Project\AiBlogTask;
10 use App\Models\Project\ProjectAiSetting; 10 use App\Models\Project\ProjectAiSetting;
11 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
12 use App\Services\AiBlogService; 12 use App\Services\AiBlogService;
  13 +use Illuminate\Support\Facades\Cache;
13 14
14 class AiBlogLogic extends BaseLogic 15 class AiBlogLogic extends BaseLogic
15 { 16 {
@@ -28,11 +29,16 @@ class AiBlogLogic extends BaseLogic @@ -28,11 +29,16 @@ class AiBlogLogic extends BaseLogic
28 * @time :2025/2/21 14:51 29 * @time :2025/2/21 14:51
29 */ 30 */
30 public function getProjectAiSetting(){ 31 public function getProjectAiSetting(){
  32 + $ai_cache = Cache::get('ai_blog_'.$this->user['project_id']);
  33 + if($ai_cache){
  34 + return $ai_cache;
  35 + }
31 $projectAiSettingModel = new ProjectAiSetting(); 36 $projectAiSettingModel = new ProjectAiSetting();
32 $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); 37 $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
33 if($aiSettingInfo === false){ 38 if($aiSettingInfo === false){
34 $this->fail('请先联系管理员开启Ai博客'); 39 $this->fail('请先联系管理员开启Ai博客');
35 } 40 }
  41 + Cache::put('ai_blog_'.$this->user['project_id'],$aiSettingInfo,3600);
36 return $aiSettingInfo; 42 return $aiSettingInfo;
37 } 43 }
38 44
@@ -76,8 +82,11 @@ class AiBlogLogic extends BaseLogic @@ -76,8 +82,11 @@ class AiBlogLogic extends BaseLogic
76 } 82 }
77 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']); 83 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']);
78 $aiAuthorModel->edit($this->param,['id'=>$this->param['id']]); 84 $aiAuthorModel->edit($this->param,['id'=>$this->param['id']]);
  85 + $aiSettingInfo = $this->getProjectAiSetting();
79 $aiBlogService = new AiBlogService(); 86 $aiBlogService = new AiBlogService();
80 - $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]); 87 + $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
  88 + $aiBlogService->key = $aiSettingInfo['key'];
  89 + $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'route'=>$this->param['route'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
81 }catch (\Exception $e){ 90 }catch (\Exception $e){
82 $this->fail('保存失败,请联系管理员'); 91 $this->fail('保存失败,请联系管理员');
83 } 92 }
@@ -63,7 +63,10 @@ class UserLoginLogic @@ -63,7 +63,10 @@ class UserLoginLogic
63 $projectArr[] = $v['project_id']; 63 $projectArr[] = $v['project_id'];
64 } 64 }
65 $projectModel = new Project(); 65 $projectModel = new Project();
66 - $project_list = $projectModel->list(['id'=>['in',$projectArr],'delete_status'=>0],'id',['id','title']); 66 + $project_list = $projectModel->list(['id'=>['in',$projectArr],'type'=>['!=',8],'delete_status'=>0],'id',['id','title']);
  67 + if(empty($project_list)){
  68 + $this->fail('当前项目已关闭,请联系管理员');
  69 + }
67 foreach ($project_list as $k => $v){ 70 foreach ($project_list as $k => $v){
68 $v['domain'] = (new DomainInfo())->getProjectIdDomain($v['id']); 71 $v['domain'] = (new DomainInfo())->getProjectIdDomain($v['id']);
69 $project_list[$k] = $v; 72 $project_list[$k] = $v;
@@ -181,12 +184,15 @@ class UserLoginLogic @@ -181,12 +184,15 @@ class UserLoginLogic
181 * @time :2023/8/29 15:26 184 * @time :2023/8/29 15:26
182 */ 185 */
183 public function assembleParam($mobile,$project_id){ 186 public function assembleParam($mobile,$project_id){
184 - $info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','wechat','project_id']); 187 + $info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','type','role_id','token','name','wechat','project_id']);
185 //获取项目详情 188 //获取项目详情
186 $project = $this->getProjectInfo($project_id); 189 $project = $this->getProjectInfo($project_id);
187 if($project['site_status'] != 0){//关闭站点 190 if($project['site_status'] != 0){//关闭站点
188 $this->fail('当前网站已过期,请联系管理员及时续费。'); 191 $this->fail('当前网站已过期,请联系管理员及时续费。');
189 } 192 }
  193 + if($project['type'] == 8){//关闭项目
  194 + $this->fail('当前网站已关闭,请联系管理员。');
  195 + }
190 $info = $this->handleInfo($info,$project); 196 $info = $this->handleInfo($info,$project);
191 $info['login_source'] = User::LOGIN_PASSWORD_SOURCE;//账号密码登录返回 197 $info['login_source'] = User::LOGIN_PASSWORD_SOURCE;//账号密码登录返回
192 //保存项目缓存 198 //保存项目缓存
@@ -91,7 +91,8 @@ class Project extends Base @@ -91,7 +91,8 @@ class Project extends Base
91 4 => '推广续网站', 91 4 => '推广续网站',
92 5 => '未续费项目', 92 5 => '未续费项目',
93 6 => '特殊推广项目', 93 6 => '特殊推广项目',
94 - 7 => '提单错误转续费' 94 + 7 => '提单错误转续费',
  95 + 8 => '关闭项目',
95 ]; 96 ];
96 } 97 }
97 98