作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -36,7 +36,11 @@ class UpdateSeoTdkCrontab extends Command @@ -36,7 +36,11 @@ class UpdateSeoTdkCrontab extends Command
36 { 36 {
37 $project_ids = Project::where('type', Project::TYPE_TWO)->pluck('id')->toArray(); 37 $project_ids = Project::where('type', Project::TYPE_TWO)->pluck('id')->toArray();
38 foreach ($project_ids as $project_id){ 38 foreach ($project_ids as $project_id){
39 - ProjectUpdateTdk::add_task($project_id); 39 + try {
  40 + ProjectUpdateTdk::add_task($project_id);
  41 + }catch (\Exception $e){
  42 +
  43 + }
40 } 44 }
41 } 45 }
42 46
@@ -43,7 +43,7 @@ class Kernel extends ConsoleKernel @@ -43,7 +43,7 @@ class Kernel extends ConsoleKernel
43 $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次 43 $schedule->command('domain_info')->dailyAt('01:20')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
44 $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息 44 $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
45 // $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新 45 // $schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新
46 - $schedule->command('update_seo_tdk_crontab')->dailyAt('00:00')->withoutOverlapping(1); //更新上线项目TDK 46 + $schedule->command('update_seo_tdk_crontab')->dailyAt('20:00')->withoutOverlapping(1); //更新上线项目TDK
47 // $schedule->command('website_data')->dailyAt('01:00')->withoutOverlapping(1); // 向AICC推送数据 47 // $schedule->command('website_data')->dailyAt('01:00')->withoutOverlapping(1); // 向AICC推送数据
48 // $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件 48 // $schedule->command('project_file_pdf')->dailyAt('00:00')->withoutOverlapping(1); // 网站项目数据,生成PDF文件
49 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 49 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
@@ -27,21 +27,21 @@ class QuanqiusouApi @@ -27,21 +27,21 @@ class QuanqiusouApi
27 */ 27 */
28 public function getSiteRes() 28 public function getSiteRes()
29 { 29 {
30 - $key = 'quanqiusou_api_site_res_' . date('Y-m-d');  
31 - $res = Cache::get($key);  
32 - if (!$res) { 30 +// $key = 'quanqiusou_api_site_res_' . date('Y-m-d');
  31 +// $res = Cache::get($key);
  32 +// if (!$res) {
33 $api_url = $this->url . '/google-rank/echo_site_res.php'; 33 $api_url = $this->url . '/google-rank/echo_site_res.php';
34 try { 34 try {
35 $res = HttpUtils::get($api_url, []); 35 $res = HttpUtils::get($api_url, []);
36 if($res){ 36 if($res){
37 $res = Arr::s2a($res); 37 $res = Arr::s2a($res);
38 - Cache::put($key, $res, 2 * 3600); 38 +// Cache::put($key, $res, 2 * 3600);
39 } 39 }
40 } catch (\Exception | GuzzleException $e) { 40 } catch (\Exception | GuzzleException $e) {
41 errorLog('获取站点收录页面数', [], $e); 41 errorLog('获取站点收录页面数', [], $e);
42 return false; 42 return false;
43 } 43 }
44 - } 44 +// }
45 return $res; 45 return $res;
46 } 46 }
47 47
@@ -40,7 +40,11 @@ class UpdateController extends BaseController @@ -40,7 +40,11 @@ class UpdateController extends BaseController
40 ], [ 40 ], [
41 'project_id.required' => 'project_id不能为空', 41 'project_id.required' => 'project_id不能为空',
42 ]); 42 ]);
43 - ProjectUpdateTdk::add_task($this->param['project_id']); 43 + try {
  44 + ProjectUpdateTdk::add_task($this->param['project_id']);
  45 + }catch (\Exception $e){
  46 + $this->fail($e->getMessage());
  47 + }
44 $this->response('任务添加成功'); 48 $this->response('任务添加成功');
45 } 49 }
46 50
@@ -27,14 +27,20 @@ class ProjectUpdateTdk extends Base @@ -27,14 +27,20 @@ class ProjectUpdateTdk extends Base
27 /** 27 /**
28 * 新建任务 28 * 新建任务
29 * @param $project_id 29 * @param $project_id
  30 + * @throws \Exception
30 * @author zbj 31 * @author zbj
31 * @date 2023/11/9 32 * @date 2023/11/9
32 */ 33 */
33 public static function add_task($project_id){ 34 public static function add_task($project_id){
34 - Redis::lpush('updateSeoTdk', $project_id); 35 + $task = self::where('project_id', $project_id)->where('status', self::STATUS_PENDING)->first();
  36 + if($task){
  37 + throw new \Exception('该项目有未执行的任务,请勿重复添加');
  38 + }
35 $model = new self(); 39 $model = new self();
36 $model->project_id = $project_id; 40 $model->project_id = $project_id;
37 $model->save(); 41 $model->save();
  42 +
  43 + Redis::lpush('updateSeoTdk', $project_id);
38 } 44 }
39 45
40 /** 46 /**
@@ -114,6 +120,8 @@ class ProjectUpdateTdk extends Base @@ -114,6 +120,8 @@ class ProjectUpdateTdk extends Base
114 120
115 $data->save(); 121 $data->save();
116 122
  123 + self::where('project_id', $data['project_id'])->where('status', self::STATUS_PENDING)->update(['status' => self::STATUS_SUCCESS]);
  124 +
117 DB::commit(); 125 DB::commit();
118 } catch (\Exception $e) { 126 } catch (\Exception $e) {
119 DB::rollback(); 127 DB::rollback();