diff --git a/app/Services/Business/BusinessClient.php b/app/Services/Business/BusinessClient.php index 4174924..c9cd15d 100644 --- a/app/Services/Business/BusinessClient.php +++ b/app/Services/Business/BusinessClient.php @@ -155,14 +155,14 @@ abstract class BusinessClient 'headers' => ['Content-type' => 'application/x-www-form-urlencoded;charset=UTF-8'], 'form_params' => $params ]; - $res = (new Client(['verify'=>false]))->request($method, $url, $headers); + $res = (new Client(['verify' => false]))->request($method, $url, $headers); $size = $res->getBody()->getSize(); $res = json_decode($res->getBody()->getContents(), true); $paramsJson = json_encode($params, 256); if (strlen($paramsJson) > 1024) { $paramsJson = ''; } - if (!in_array($params['type'], ['pdd.ktt.increment.order.query', 'pdd.ktt.order.list',"pdd.ktt.after.sales.increment.list","pdd.ktt.order.get"], true)) { + if (!in_array($params['type'], ['pdd.ktt.increment.order.query', 'pdd.ktt.order.list', "pdd.ktt.after.sales.increment.list", "pdd.ktt.order.get"], true)) { $log = new Log(); $log->module = 'plat'; $log->action = $method; @@ -177,7 +177,7 @@ abstract class BusinessClient } $log->save(); } - if (in_array($params['type'], ['pdd.ktt.increment.order.query', 'pdd.ktt.order.list',"pdd.ktt.after.sales.increment.list"], true)) { + if (in_array($params['type'], ['pdd.ktt.increment.order.query', 'pdd.ktt.order.list', "pdd.ktt.after.sales.increment.list"], true)) { } @@ -191,14 +191,19 @@ abstract class BusinessClient foreach ($batchParams as $param) { $options = [ 'headers' => ['Content-type' => 'application/x-www-form-urlencoded;'], - 'form_params' => $param + 'form_params' => $param, + "timeout" => 5 ]; - \Illuminate\Support\Facades\Log::info("请求参数",[$options,time()]); + \Illuminate\Support\Facades\Log::info("快团团请求参数", [$options, time()]); $promises[] = $client->postAsync($url, $options); } if ($promises) { - Promise\Utils::unwrap($promises); + try { + Promise\Utils::unwrap($promises); + } catch (\Exception $e) { + \Illuminate\Support\Facades\Log::error("请求过程中出现错误: " . $e->getMessage()); + } } - \Illuminate\Support\Facades\Log::info("请求结束",[time()]); + \Illuminate\Support\Facades\Log::info("快团团请求结束", [time()]); } }