|
|
@ -45,7 +45,6 @@ class PaymentService implements PaymentServiceInterface |
|
|
->where(['state' => OrderState::UNPAID, 'global_order_id' => $globalOrderId, 'user_id' => $userId]) |
|
|
->where(['state' => OrderState::UNPAID, 'global_order_id' => $globalOrderId, 'user_id' => $userId]) |
|
|
->where('created_at', '>=', (time()-900)) |
|
|
->where('created_at', '>=', (time()-900)) |
|
|
->first(); |
|
|
->first(); |
|
|
|
|
|
|
|
|
if (empty($orderMain)) { |
|
|
if (empty($orderMain)) { |
|
|
throw new ErrorCodeException(ErrorCode::ORDER_NOT_AVAILABLE, '[支付订单号]'.$globalOrderId); |
|
|
throw new ErrorCodeException(ErrorCode::ORDER_NOT_AVAILABLE, '[支付订单号]'.$globalOrderId); |
|
|
} |
|
|
} |
|
|
@ -112,10 +111,8 @@ class PaymentService implements PaymentServiceInterface |
|
|
// 已支付的,未退款的,使用微信支付的订单
|
|
|
// 已支付的,未退款的,使用微信支付的订单
|
|
|
$orderMain = OrderMain::query() |
|
|
$orderMain = OrderMain::query() |
|
|
->whereIn('state', [OrderState::PAID, OrderState::DELIVERY, OrderState::COMPLETED, OrderState::EVALUATED, OrderState::REFUNDING]) |
|
|
->whereIn('state', [OrderState::PAID, OrderState::DELIVERY, OrderState::COMPLETED, OrderState::EVALUATED, OrderState::REFUNDING]) |
|
|
->where(['global_order_id' => $globalOrderId, 'user_id' => $userId, 'pay_type' => Payment::WECHAT]) |
|
|
|
|
|
->whereRaw('refund_time is null') |
|
|
|
|
|
|
|
|
->where(['global_order_id' => $globalOrderId, 'user_id' => $userId, 'pay_type' => Payment::WECHAT,'refund_time'=>0]) |
|
|
->first(); |
|
|
->first(); |
|
|
|
|
|
|
|
|
if (empty($orderMain)) { |
|
|
if (empty($orderMain)) { |
|
|
throw new ErrorCodeException(ErrorCode::ORDER_NOT_AVAILABLE, '[支付订单号]'.$globalOrderId); |
|
|
throw new ErrorCodeException(ErrorCode::ORDER_NOT_AVAILABLE, '[支付订单号]'.$globalOrderId); |
|
|
} |
|
|
} |
|
|
@ -130,7 +127,11 @@ class PaymentService implements PaymentServiceInterface |
|
|
'notify_url' => config('wechat.notify_url.refund'), |
|
|
'notify_url' => config('wechat.notify_url.refund'), |
|
|
] |
|
|
] |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if ($result['return_code']=="SUCCESS"&&isset($result['result_code'])&&$result['result_code']=="SUCCESS"){ |
|
|
|
|
|
return true; |
|
|
|
|
|
}else{ |
|
|
|
|
|
throw new ErrorCodeException(ErrorCode::PAYMENT_FAIL, '[退款失败]'.$result['err_code_des']); |
|
|
|
|
|
} |
|
|
} catch (\Exception $e) { |
|
|
} catch (\Exception $e) { |
|
|
$this->log->event(LogLabel::ORDER_PAYMENT_LOG, ['payment_do_exception_msg' => $e->getMessage()]); |
|
|
$this->log->event(LogLabel::ORDER_PAYMENT_LOG, ['payment_do_exception_msg' => $e->getMessage()]); |
|
|
throw new ErrorCodeException(ErrorCode::PAYMENT_FAIL, '[退款失败]'.$e->getMessage()); |
|
|
throw new ErrorCodeException(ErrorCode::PAYMENT_FAIL, '[退款失败]'.$e->getMessage()); |
|
|
|