Commit cb229e7c authored by wanjilong's avatar wanjilong

add: 增加服务报错日志

parent 78b6760a
......@@ -13,6 +13,6 @@ class Code
{
const PAY = 101000;
const REFUND = 102000;
const ORDER = 103000;
const WALLET = 104000;
const ORDER = 103000;
const SDK = 104000;
}
\ No newline at end of file
<?php
namespace App\Exception\custom;
use App\Exception\BaseException;
class SdkException extends BaseException
{
protected $base_code = Code::SDK;
protected $cus = [
0 => 'api URL不存在,请核对配置',
1 => 'sdk返回错误',
];
}
......@@ -26,10 +26,25 @@ class Sdk {
$headers = array_merge($headers, $header);
*/
$data = (new Request())->post($url, $params,3000, 'json');
//$data['response'];
//var_export($data);
$data = (new Request())->post($url, $params,2000, 'json');
FileLog::info('sdk_call:' . 'services return', json_encode(['url'=>$url, $headers, 'req'=>$params, 'res'=>$data]));
/*
[
"http_code"=> 200,
"code"=> 0,
"response"=> [
"code"=> 102002,
"status"=> "failed",
"reason"=> "暂未开通钱包"
]
]
*/
if(!empty($data['response']['code'])) {
throw new \Exception($data['response']['reason'], $data['response']['code']);
}
return $data['response'];
}
}
\ No newline at end of file
......@@ -264,7 +264,7 @@ class PayService
try{
if($wallet_list) { //同步成功,返回结果
WalletService::send($wallet_list);
WalletService::send(['list'=>$wallet_list]);
}
PayOrderItem::update([
'notify_account_status' => 2,
......@@ -272,7 +272,7 @@ class PayService
], ['order_item_id' => $order_item_id, 'can_notify_account' => 1]);
} catch (\Exception $e) {
FileLog::error('wallet: 钱包同步失败' . $e->getMessage(), json_encode($wallet_list));
FileLog::error('wallet: 钱包同步失败', json_encode($wallet_list), $e);
//补偿处理
PayOrderItem::update([
'notify_account_status' => 0,
......
......@@ -18,7 +18,7 @@ class WalletService
*/
public static function send($params) {
$url = config('interface', 'wallet.wallet.recharge');
$url = config('interface', 'wallet.account.transfer');
if (!$url) {
throw new CodeSpecialException("failed");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment