|
@@ -13,6 +13,7 @@ use support\Db;
|
|
|
use support\exception\BusinessException;
|
|
|
use support\Log as SupportLog;
|
|
|
use support\Redis;
|
|
|
+use Yansongda\Pay\Exceptions\GatewayException;
|
|
|
use Yansongda\Pay\Log;
|
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
@@ -221,9 +222,11 @@ class OrderService
|
|
|
];
|
|
|
try {
|
|
|
$config = config('payment.wxpay');
|
|
|
- $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN').'/notify/orderPay/wxpay';
|
|
|
+ $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN') . '/notify/orderPay/wxpay';
|
|
|
Pay::wechat($config)->pos($payData);
|
|
|
$result = self::findWxpay($params['orderGroupId'], 0);
|
|
|
+ }catch (GatewayException $g){
|
|
|
+ $result = self::findWxpay($params['orderGroupId'], 0);
|
|
|
} catch (\Exception $e) {
|
|
|
$log->error("WXPAY", ['msg' => $e->getMessage()]);
|
|
|
throw new BusinessException("支付失败");
|
|
@@ -245,6 +248,8 @@ class OrderService
|
|
|
$config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN').'/notify/orderPay/alipay';
|
|
|
Pay::alipay($config)->pos($payData);
|
|
|
$result = self::findAlipay($params['orderGroupId'], 0);
|
|
|
+ } catch (GatewayException $g){
|
|
|
+ $result = self::findAlipay($params['orderGroupId'], 0);
|
|
|
} catch (\Exception $e) {
|
|
|
$log->error("ALIPAY", ['msg' => $e->getMessage()]);
|
|
|
throw new BusinessException("支付失败");
|
|
@@ -273,20 +278,21 @@ class OrderService
|
|
|
public static function findWxpay($orderId, $nbr = 0)
|
|
|
{
|
|
|
if ($nbr >= 6) {
|
|
|
+ SupportLog::channel('pay')->error("FIND_WXPAY", ['msg' => '订单查询失败','order_id'=>$orderId]);
|
|
|
throw new BusinessException("订单查询失败");
|
|
|
}
|
|
|
try {
|
|
|
$result = Pay::wechat(config('payment.wxpay'))->find($orderId, 'pos');
|
|
|
$result = json_decode(json_encode($result), true);
|
|
|
} catch (\Exception $e) {
|
|
|
- SupportLog::channel('pay')->error("WXPAY", ['msg' => $e->getMessage()]);
|
|
|
- throw new BusinessException("订单查询失败");
|
|
|
+ SupportLog::channel('pay')->error("FIND_WXPAY", ['msg' => $e->getMessage()]);
|
|
|
}
|
|
|
|
|
|
- if (!empty($result['return_code']) && $result['return_code'] == 'SUCCESS' && !empty($result['result_code']) && $result['result_code'] == 'SUCCESS') {
|
|
|
+ if (!empty($result['return_code']) && $result['return_code'] == 'SUCCESS' && !empty($result['result_code']) && $result['result_code'] == 'SUCCESS' && !empty($result['trade_state']) && $result['trade_state'] == 'SUCCESS') {
|
|
|
return $result;
|
|
|
} else {
|
|
|
sleep(5);
|
|
|
+ SupportLog::channel('pay')->error("FIND_WXPAY", ['nbr' => $nbr,'order_id'=>$orderId]);
|
|
|
self::findWxpay($orderId, $nbr + 1);
|
|
|
}
|
|
|
}
|
|
@@ -304,20 +310,21 @@ class OrderService
|
|
|
public static function findAlipay($orderId, $nbr = 0)
|
|
|
{
|
|
|
if ($nbr >= 6) {
|
|
|
+ SupportLog::channel('pay')->error("FIND_ALIPAY", ['msg' => '订单查询失败','order_id'=>$orderId]);
|
|
|
throw new BusinessException("订单查询失败");
|
|
|
}
|
|
|
try {
|
|
|
$result = Pay::alipay(config('payment.alipay'))->find($orderId);
|
|
|
$result = json_decode(json_encode($result), true);
|
|
|
} catch (\Exception $e) {
|
|
|
- SupportLog::channel('pay')->error("ALIPAY", ['msg' => $e->getMessage()]);
|
|
|
- throw new BusinessException("订单查询失败");
|
|
|
+ SupportLog::channel('pay')->error("FIND_ALIPAY", ['msg' => $e->getMessage()]);
|
|
|
}
|
|
|
|
|
|
if (!empty($result['code']) && $result['code'] == '10000' && !empty($result['trade_status']) && $result['trade_status'] == 'TRADE_SUCCESS') {
|
|
|
return $result;
|
|
|
} else {
|
|
|
sleep(5);
|
|
|
+ SupportLog::channel('pay')->error("FIND_ALIPAY", ['nbr' => $nbr,'order_id'=>$orderId]);
|
|
|
self::findAlipay($orderId, $nbr + 1);
|
|
|
}
|
|
|
}
|