10, 'timeout' => 30, 'http_errors' => true, //抛出异常 true是 false否 'verify' => false, //不验证ssl证书 ]); LogService::info(json_encode($data)); //记录日志 //$res = $client->request('GET', $payUrl, ['form_params' => $data]); $result = $client->get($payUrl . '?' . http_build_query($data)); $palmApiEndTime = microtime(true); $apiRunTime = round($palmApiEndTime - $palmApiStartTime, 3); if ($result->getStatusCode() != '200') { LogService::error(sprintf('palmpay_create_order_fail!wxpay_id:%s,wxpay_name:%s,mch_id:%s,channel_id:%s,user_id:%s,money:%s,good_id:%s,out_trade_no:%s,api_run_time:%s s,loop_index:%s,errmessage:%s', $payInfo['id'], $payInfo['name'], $payInfo['quartet_merchant_id'], $orderInfo['admin_id'], $orderInfo['user_id'], $goodsInfo['money'], $orderInfo['goods_id'], $orderInfo['out_trade_no'], $apiRunTime, $loopIndex, json_encode(var_export($result, true), JSON_UNESCAPED_UNICODE))); LogService::error('四方平台订单创建失败!订单内容: ' . json_encode($data) . " 四方平台返回内容: " . json_encode(var_export($result, true), JSON_UNESCAPED_UNICODE)); throw new Exception('订单创建失败,请重新下单!'); } else { $result = json_decode($result->getBody()->getContents(), true); if ($result['errcode'] != '0') { LogService::error(sprintf('palmpay_create_order_fail!wxpay_id:%s,wxpay_name:%s,mch_id:%s,channel_id:%s,user_id:%s,money:%s,good_id:%s,out_trade_no:%s,api_run_time:%s s,loop_index:%s,errmessage:%s', $payInfo['id'], $payInfo['name'], $payInfo['quartet_merchant_id'], $orderInfo['admin_id'], $orderInfo['user_id'], $goodsInfo['money'], $orderInfo['goods_id'], $orderInfo['out_trade_no'], $apiRunTime, $loopIndex, $result['err'])); LogService::error('四方平台订单创建失败!订单内容:' . json_encode(var_export($data, true)) . " 四方平台返回内容: " . $result['err']); throw new Exception('订单创建失败,请重新下单!'); } } LogService::info(sprintf('palmpay_create_order_success!wxpay_id:%s,wxpay_name:%s,mch_id:%s,channel_id:%s,user_id:%s,money:%s,good_id:%s,out_trade_no:%s,api_run_time:%s s,loop_index:%s', $payInfo['id'], $payInfo['name'], $payInfo['quartet_merchant_id'], $orderInfo['admin_id'], $orderInfo['user_id'], $goodsInfo['money'], $orderInfo['goods_id'], $orderInfo['out_trade_no'], $apiRunTime, $loopIndex)); return $result; } catch (GuzzleException $exception) { $palmApiEndTime = microtime(true); $apiRunTime = round($palmApiEndTime - $palmApiStartTime, 3); LogService::error(sprintf('palmpay_create_order_fail!wxpay_id:%s,wxpay_name:%s,mch_id:%s,channel_id:%s,user_id:%s,money:%s,good_id:%s,out_trade_no:%s,api_run_time:%s s,loop_index:%s,errmessage:%s', $payInfo['id'], $payInfo['name'], $payInfo['quartet_merchant_id'], $orderInfo['admin_id'], $orderInfo['user_id'], $goodsInfo['money'], $orderInfo['goods_id'], $orderInfo['out_trade_no'], $apiRunTime, $loopIndex, $exception->getMessage())); LogService::error('四方平台订单创建失败!订单内容: ' . json_encode(var_export($data, true), JSON_UNESCAPED_UNICODE)); LogService::error($exception->getMessage()); LogService::error($exception->getTraceAsString()); if ($loopIndex <= ApiConstants::LOOP_EXEC_API_COUNT) { $loopIndex++; return $this->payPalmApi($data, $payInfo, $goodsInfo, $orderInfo, $loopIndex); } throw new Exception('订单创建失败,请重新下单!'); } } }