code review 退款逻辑

This commit is contained in:
YunaiV 2022-01-04 23:47:31 +08:00
parent 5bf3045544
commit 19b574fd4b
3 changed files with 11 additions and 8 deletions

View File

@ -98,6 +98,7 @@ public class PayRefundDO extends BaseDO {
* 退款单请求号根据规则生成
* 例如说R202109181134287570000
*/
// TODO @jasonmerchantRefundNo =merchantRefundOId
private String merchantRefundNo;
/**

View File

@ -102,6 +102,7 @@ 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())
@ -133,7 +135,8 @@ public class PayRefundCoreServiceImpl implements PayRefundCoreService {
// 向渠道发起退款申请
PayCommonResult<PayRefundUnifiedRespDTO> refundUnifiedResult = client.unifiedRefund(unifiedReqDTO);
// 检查是否失败失败抛出业务异常
//TODO 渠道的异常记录
// TODO 渠道的异常记录
// TODO @jason可以先打个 warn log
refundUnifiedResult.checkError();
// 成功在 退款回调中处理
return PayRefundRespDTO.builder().refundId(payRefundDO.getId()).build();

View File

@ -118,10 +118,9 @@ 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);
}
} catch (AlipayApiException e) {
// TODO 记录异常日志
log.error("[doUnifiedRefund][request({}) 发起退款失败,网络读超时,退款状态未知]", toJsonString(reqDTO), e);