作者 赵彬吉

update

... ... @@ -62,7 +62,7 @@ class postInquiry extends Command
if($log->status != ReInquiryDetailLog::STATUS_INIT){
continue;
}
$this->output('开始执行' . $val->id);
try {
$detail = ReInquiryDetail::find($val['detail_id']);
... ... @@ -107,7 +107,7 @@ class postInquiry extends Command
$res = Http::withoutVerifying()->post($website . 'api/traffic_visit/', $data)->json();
if (empty($res['status']) || $res['status'] != 200) {
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay visit error', [$res, $website . 'api/traffic_visit/',$data]);
... ... @@ -135,13 +135,14 @@ class postInquiry extends Command
'user_agent' => $detail['user_agent'],
"ip" => $detail['ip'],
];
$res = Http::get($website . 'wp-admin/admin-ajax.php', $data)->json();
if($res != 200){
$res = Http::get($website . 'wp-admin/admin-ajax.php', $data);
$status = $res->status();
if($status != 200){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
$log->remark = mb_substr($res->body() ?? '', 0 ,200);
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 visit error', [$res, $website . 'wp-admin/admin-ajax.php', $data]);
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 visit error', [$res->body(), $website . 'wp-admin/admin-ajax.php', $data]);
return false;
}
}
... ... @@ -170,7 +171,7 @@ class postInquiry extends Command
$res = Http::withoutVerifying()->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json();
if(empty($res['code']) || $res['code'] != 200){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]);
... ... @@ -189,17 +190,18 @@ class postInquiry extends Command
'source' => 5,
];
$res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json();
$result = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data);
$res = $result->json();
//兼容接口返回格式
if(!empty($res['data'][0]['status'])){
$res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
}
if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
$log->remark = mb_substr($res['message'] ?? '', 0, 200);
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$res, 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]);
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]);
return false;
}
}
... ...