同步数据
Showing
1 changed file
with
26 additions
and
17 deletions
... | @@ -75,31 +75,40 @@ class StakeholderIncomeSyncJob implements ShouldQueue | ... | @@ -75,31 +75,40 @@ class StakeholderIncomeSyncJob implements ShouldQueue |
75 | 'title'=>"{$bills->bill_section_start}-{$bills->bill_section_end}账单/{$channel}", | 75 | 'title'=>"{$bills->bill_section_start}-{$bills->bill_section_end}账单/{$channel}", |
76 | ]; | 76 | ]; |
77 | 77 | ||
78 | $http_res = ApiService::walletAddIncome($http_data); | 78 | if ($res = StakeholderIncomeByPayer::query()->where(['serial_no'=>$income_item['serial_no']])->first()) { |
79 | 79 | ||
80 | if (empty($http_res)) { | 80 | if ($res['sync_status'] == 0) { |
81 | //重试 401/403/403 | ||
82 | Log::channel('api')->warning(__METHOD__."streamid:{$id}-api请求失败", ['income_item'=>$income_item, 'http_data'=>$http_data]); | ||
83 | } else { | ||
84 | 81 | ||
85 | $update = [ | 82 | //直接未同步的数据才请求api |
86 | 'http_log'=>json_encode($http_res, JSON_UNESCAPED_UNICODE), | 83 | $http_res = ApiService::walletAddIncome($http_data); |
87 | 'busi_id'=>$http_res['data']['busiId'], | ||
88 | ]; | ||
89 | 84 | ||
90 | if ($http_res['code'] == 0) { | 85 | if (empty($http_res)) { |
91 | $update['sync_status'] = 1; | 86 | //重试 401/403/403 |
92 | } else { | 87 | Log::channel('api')->warning(__METHOD__."streamid:{$id}-api请求失败", ['income_item'=>$income_item, 'http_data'=>$http_data]); |
93 | $update['sync_status'] = 2; | 88 | } else { |
94 | } | 89 | |
90 | $update = [ | ||
91 | 'http_log'=>json_encode($http_res, JSON_UNESCAPED_UNICODE), | ||
92 | 'busi_id'=>$http_res['data']['busiId'], | ||
93 | ]; | ||
94 | |||
95 | if ($http_res['code'] == 0) { | ||
96 | $update['sync_status'] = 1; | ||
97 | } else { | ||
98 | $update['sync_status'] = 2; | ||
99 | } | ||
95 | 100 | ||
96 | //记录请求api返回体并修改状态 | 101 | //记录请求api返回体并修改状态 |
97 | if (StakeholderIncomeByPayer::query()->where(['serial_no'=>$income_item['serial_no']])->update($update)) { | 102 | if (StakeholderIncomeByPayer::query()->where(['serial_no'=>$income_item['serial_no']])->update($update)) { |
103 | $redis->xdel($key, [$id]); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | } else { | ||
98 | $redis->xdel($key, [$id]); | 108 | $redis->xdel($key, [$id]); |
99 | } | 109 | } |
100 | } | 110 | } |
101 | } | 111 | } |
102 | |||
103 | } | 112 | } |
104 | } | 113 | } |
105 | } | 114 | } | ... | ... |
-
Please register or sign in to post a comment