Browse Source

调试订单退款接口

master
lanzu_qinsheng 5 years ago
parent
commit
af6607f175
  1. 1
      app/JsonRpc/OrderService.php
  2. 1
      app/Service/v3/Implementations/OrderOnlineService.php
  3. 11
      app/Service/v3/Implementations/PaymentService.php

1
app/JsonRpc/OrderService.php

@ -77,7 +77,6 @@ class OrderService implements OrderServiceInterface
Db::beginTransaction(); Db::beginTransaction();
try { try {
$this->orderOnlineService->doRefund($global_order_id, $user_id); $this->orderOnlineService->doRefund($global_order_id, $user_id);
Db::commit(); Db::commit();

1
app/Service/v3/Implementations/OrderOnlineService.php

@ -551,7 +551,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface
{ {
$orderMain = $this->check($globalOrderId, $userId, OrderState::REFUNDING); $orderMain = $this->check($globalOrderId, $userId, OrderState::REFUNDING);
// 微信退款 // 微信退款
if ($orderMain->pay_type == Payment::WECHAT) { if ($orderMain->pay_type == Payment::WECHAT) {
return $this->paymentService->undo($orderMain->global_order_id, $userId); return $this->paymentService->undo($orderMain->global_order_id, $userId);

11
app/Service/v3/Implementations/PaymentService.php

@ -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());

Loading…
Cancel
Save