mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
code review 退款逻辑
This commit is contained in:
parent
5bf3045544
commit
19b574fd4b
@ -98,6 +98,7 @@ public class PayRefundDO extends BaseDO {
|
||||
* 退款单请求号,根据规则生成
|
||||
* 例如说,R202109181134287570000
|
||||
*/
|
||||
// TODO @jason:merchantRefundNo =》merchantRefundOId
|
||||
private String merchantRefundNo;
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,8 @@ public class PayRefundCoreServiceImpl implements PayRefundCoreService {
|
||||
}
|
||||
//可以重复提交,保证 退款请求号 一致,由渠道保证幂等
|
||||
}else {
|
||||
//成功,插入退款单 状态为生成.没有和渠道交互
|
||||
// 成功,插入退款单 状态为生成.没有和渠道交互
|
||||
// TODO @jason:搞到 convert 里。一些额外的自动,手动 set 下;
|
||||
payRefundDO = PayRefundDO.builder().channelOrderNo(order.getChannelOrderNo())
|
||||
.appId(order.getAppId())
|
||||
.channelOrderNo(order.getChannelOrderNo())
|
||||
@ -123,6 +124,7 @@ public class PayRefundCoreServiceImpl implements PayRefundCoreService {
|
||||
.build();
|
||||
payRefundCoreMapper.insert(payRefundDO);
|
||||
}
|
||||
// TODO @jason:搞到 convert 里。一些额外的自动,手动 set 下;
|
||||
PayRefundUnifiedReqDTO unifiedReqDTO = new PayRefundUnifiedReqDTO();
|
||||
unifiedReqDTO.setUserIp(req.getUserIp())
|
||||
.setAmount(req.getAmount())
|
||||
@ -132,10 +134,11 @@ public class PayRefundCoreServiceImpl implements PayRefundCoreService {
|
||||
.setReason(req.getReason());
|
||||
// 向渠道发起退款申请
|
||||
PayCommonResult<PayRefundUnifiedRespDTO> refundUnifiedResult = client.unifiedRefund(unifiedReqDTO);
|
||||
//检查是否失败,失败抛出业务异常。
|
||||
//TODO 渠道的异常记录
|
||||
// 检查是否失败,失败抛出业务异常。
|
||||
// TODO 渠道的异常记录。
|
||||
// TODO @jason:可以先打个 warn log 哈;
|
||||
refundUnifiedResult.checkError();
|
||||
//成功在 退款回调中处理
|
||||
// 成功在 退款回调中处理
|
||||
return PayRefundRespDTO.builder().refundId(payRefundDO.getId()).build();
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,11 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl
|
||||
PayRefundUnifiedRespDTO respDTO = new PayRefundUnifiedRespDTO();
|
||||
respDTO.setChannelRefundId("");
|
||||
return PayCommonResult.build(response.getCode(), response.getMsg(), respDTO, codeMapping);
|
||||
}else{
|
||||
//失败。需要抛出异常
|
||||
return PayCommonResult.build(response.getCode(), response.getMsg(), null, codeMapping);
|
||||
}
|
||||
// 失败。需要抛出异常
|
||||
return PayCommonResult.build(response.getCode(), response.getMsg(), null, codeMapping);
|
||||
} catch (AlipayApiException e) {
|
||||
//TODO 记录异常日志
|
||||
// TODO 记录异常日志
|
||||
log.error("[doUnifiedRefund][request({}) 发起退款失败,网络读超时,退款状态未知]", toJsonString(reqDTO), e);
|
||||
return PayCommonResult.build(e.getErrCode(), e.getErrMsg(), null, codeMapping);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user