作者 赵彬吉

update

@@ -62,7 +62,7 @@ class postInquiry extends Command @@ -62,7 +62,7 @@ class postInquiry extends Command
62 if($log->status != ReInquiryDetailLog::STATUS_INIT){ 62 if($log->status != ReInquiryDetailLog::STATUS_INIT){
63 continue; 63 continue;
64 } 64 }
65 - 65 +
66 $this->output('开始执行' . $val->id); 66 $this->output('开始执行' . $val->id);
67 try { 67 try {
68 $detail = ReInquiryDetail::find($val['detail_id']); 68 $detail = ReInquiryDetail::find($val['detail_id']);
@@ -107,7 +107,7 @@ class postInquiry extends Command @@ -107,7 +107,7 @@ class postInquiry extends Command
107 $res = Http::withoutVerifying()->post($website . 'api/traffic_visit/', $data)->json(); 107 $res = Http::withoutVerifying()->post($website . 'api/traffic_visit/', $data)->json();
108 if (empty($res['status']) || $res['status'] != 200) { 108 if (empty($res['status']) || $res['status'] != 200) {
109 $log->status = ReInquiryDetailLog::STATUS_FAIL; 109 $log->status = ReInquiryDetailLog::STATUS_FAIL;
110 - $log->remark = $res['message'] ?? ''; 110 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
111 $log->save(); 111 $log->save();
112 112
113 Log::channel('inquiry_relay')->error('inquiry_relay visit error', [$res, $website . 'api/traffic_visit/',$data]); 113 Log::channel('inquiry_relay')->error('inquiry_relay visit error', [$res, $website . 'api/traffic_visit/',$data]);
@@ -135,13 +135,14 @@ class postInquiry extends Command @@ -135,13 +135,14 @@ class postInquiry extends Command
135 'user_agent' => $detail['user_agent'], 135 'user_agent' => $detail['user_agent'],
136 "ip" => $detail['ip'], 136 "ip" => $detail['ip'],
137 ]; 137 ];
138 - $res = Http::get($website . 'wp-admin/admin-ajax.php', $data)->json();  
139 - if($res != 200){ 138 + $res = Http::get($website . 'wp-admin/admin-ajax.php', $data);
  139 + $status = $res->status();
  140 + if($status != 200){
140 $log->status = ReInquiryDetailLog::STATUS_FAIL; 141 $log->status = ReInquiryDetailLog::STATUS_FAIL;
141 - $log->remark = $res['message'] ?? ''; 142 + $log->remark = mb_substr($res->body() ?? '', 0 ,200);
142 $log->save(); 143 $log->save();
143 144
144 - Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 visit error', [$res, $website . 'wp-admin/admin-ajax.php', $data]); 145 + Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 visit error', [$res->body(), $website . 'wp-admin/admin-ajax.php', $data]);
145 return false; 146 return false;
146 } 147 }
147 } 148 }
@@ -170,7 +171,7 @@ class postInquiry extends Command @@ -170,7 +171,7 @@ class postInquiry extends Command
170 $res = Http::withoutVerifying()->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json(); 171 $res = Http::withoutVerifying()->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json();
171 if(empty($res['code']) || $res['code'] != 200){ 172 if(empty($res['code']) || $res['code'] != 200){
172 $log->status = ReInquiryDetailLog::STATUS_FAIL; 173 $log->status = ReInquiryDetailLog::STATUS_FAIL;
173 - $log->remark = $res['message'] ?? ''; 174 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
174 $log->save(); 175 $log->save();
175 176
176 Log::channel('inquiry_relay')->error('inquiry_relay v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]); 177 Log::channel('inquiry_relay')->error('inquiry_relay v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]);
@@ -189,17 +190,18 @@ class postInquiry extends Command @@ -189,17 +190,18 @@ class postInquiry extends Command
189 'source' => 5, 190 'source' => 5,
190 ]; 191 ];
191 192
192 - $res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json(); 193 + $result = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data);
  194 + $res = $result->json();
193 //兼容接口返回格式 195 //兼容接口返回格式
194 if(!empty($res['data'][0]['status'])){ 196 if(!empty($res['data'][0]['status'])){
195 $res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400; 197 $res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
196 } 198 }
197 if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){ 199 if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){
198 $log->status = ReInquiryDetailLog::STATUS_FAIL; 200 $log->status = ReInquiryDetailLog::STATUS_FAIL;
199 - $log->remark = $res['message'] ?? ''; 201 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
200 $log->save(); 202 $log->save();
201 203
202 - Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$res, 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]); 204 + Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]);
203 return false; 205 return false;
204 } 206 }
205 } 207 }