作者 赵彬吉

update

@@ -50,14 +50,21 @@ class RankDataTask extends Command @@ -50,14 +50,21 @@ class RankDataTask extends Command
50 public function handle() 50 public function handle()
51 { 51 {
52 $list = NoticeLog::where('type', NoticeLog::TYPE_RANK_DATA)->where('status', NoticeLog::STATUS_PENDING)->get(); 52 $list = NoticeLog::where('type', NoticeLog::TYPE_RANK_DATA)->where('status', NoticeLog::STATUS_PENDING)->get();
53 - foreach ($list as $item){ 53 + foreach ($list as $item) {
54 echo 'start:' . $item['id'] . PHP_EOL; 54 echo 'start:' . $item['id'] . PHP_EOL;
55 - try { 55 + $error_msg = [];
56 $rankDataLogic = new RankDataLogic(); 56 $rankDataLogic = new RankDataLogic();
  57 + try {
57 //排名数据 58 //排名数据
58 $api = new QuanqiusouApi(); 59 $api = new QuanqiusouApi();
59 $site_res = $api->getSiteRes(); 60 $site_res = $api->getSiteRes();
60 $rankDataLogic->syncRankData($item['data']['api_no'], $site_res, true); 61 $rankDataLogic->syncRankData($item['data']['api_no'], $site_res, true);
  62 + } catch (\Exception $e) {
  63 + Log::channel('rank_data')->error('排名数据更新失败' . $e->getMessage(), $item->toArray());
  64 + $error_msg[] = $e->getMessage();
  65 + }
  66 +
  67 + try {
61 //外链数据 68 //外链数据
62 $rankDataLogic->syncExternalLinks($item['data']['api_no'], true); 69 $rankDataLogic->syncExternalLinks($item['data']['api_no'], true);
63 //外链引荐域名 70 //外链引荐域名
@@ -70,10 +77,14 @@ class RankDataTask extends Command @@ -70,10 +77,14 @@ class RankDataTask extends Command
70 $item->status = NoticeLog::STATUS_SUCCESS; 77 $item->status = NoticeLog::STATUS_SUCCESS;
71 $item->save(); 78 $item->save();
72 echo 'success:' . $item['id'] . PHP_EOL; 79 echo 'success:' . $item['id'] . PHP_EOL;
73 - }catch (\Exception $e){ 80 + } catch (\Exception $e){
74 echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; 81 echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
75 Log::channel('rank_data')->error('排名数据更新失败' . $e->getMessage(), $item->toArray()); 82 Log::channel('rank_data')->error('排名数据更新失败' . $e->getMessage(), $item->toArray());
76 - $this->retry($item, $e->getMessage()); 83 + $error_msg[] = $e->getMessage();
  84 + }
  85 +
  86 + if($error_msg){
  87 + $this->retry($item, implode(',', $error_msg));
77 } 88 }
78 } 89 }
79 } 90 }