Browse Source

优化订单退款接口

master
lanzu_qinsheng 5 years ago
parent
commit
e7402c02a3
  1. 29
      app/JsonRpc/OrderService.php
  2. 6
      app/Service/v3/Implementations/PaymentService.php

29
app/JsonRpc/OrderService.php

@ -81,15 +81,24 @@ class OrderService implements OrderServiceInterface
Db::beginTransaction(); Db::beginTransaction();
try { try {
$this->orderOnlineService->doRefund($global_order_id, $user_id);
$result = $this->orderOnlineService->doRefund($global_order_id, $user_id);
Db::commit(); Db::commit();
return [
"status" => 200,
"code" => 0,
"result" => [],
"message" => '处理成功'
];
if ($result['return_code'] == 'SUCCESS' && isset($result['result_code']) && $result['result_code'] == "SUCCESS") {
return [
"status" => 200,
"code" => 0,
"result" => [],
"message" => '处理成功'
];
} else {
return [
"status" => 200,
"code" => -1,
"result" => [],
"message" => $result['err_code_des']
];
}
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollBack(); Db::rollBack();
@ -109,11 +118,11 @@ class OrderService implements OrderServiceInterface
* 退款:2-0.2=1.8 * 退款:2-0.2=1.8
* @param $user_id *用户ID * @param $user_id *用户ID
* @param $global_order_id *全局总订单ID * @param $global_order_id *全局总订单ID
* @param $child_order_id *主订单ID,
* @param $order_goods_id *订单商品ID
* @param $child_order_id *主订单ID,
* @param $order_goods_id *订单商品ID
* @param $note * @param $note
*/ */
public function onlineSingleRefund($user_id, $note, $global_order_id, $child_order_id=null, $order_goods_id=null)
public function onlineSingleRefund($user_id, $note, $global_order_id, $child_order_id = null, $order_goods_id = null)
{ {
if (!$user_id || !$global_order_id || !$note) { if (!$user_id || !$global_order_id || !$note) {
$this->log->event(LogLabel::ORDER_REFUND_LOG, [ $this->log->event(LogLabel::ORDER_REFUND_LOG, [

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

@ -127,11 +127,7 @@ 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']);
}
return $result;
} 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