mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-07 21:17:42 +00:00
style 部分类名称变更,readme编写
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.common.context;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.PayCallbackStatusEnum;
|
||||
import lombok.Data;
|
||||
@@ -33,7 +33,7 @@ public class CallbackLocal {
|
||||
/**
|
||||
* 网关返回状态
|
||||
* @see PayStatusEnum 支付状态
|
||||
* @see PayRefundStatusEnum 退款状态
|
||||
* @see RefundStatusEnum 退款状态
|
||||
*/
|
||||
private String gatewayStatus;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.common.context;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class RefundLocal {
|
||||
/**
|
||||
* 退款状态, 默认为成功, 通常含有异步支付时, 才会出现别的状态
|
||||
*/
|
||||
private PayRefundStatusEnum status = PayRefundStatusEnum.SUCCESS;
|
||||
private RefundStatusEnum status = RefundStatusEnum.SUCCESS;
|
||||
|
||||
/** 错误码 */
|
||||
private String errorCode;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayCode;
|
||||
import cn.bootx.platform.daxpay.service.common.context.RefundLocal;
|
||||
@@ -49,10 +49,10 @@ public class AliPayRefundService {
|
||||
}
|
||||
// 接口返回fund_change=Y为退款成功,fund_change=N或无此字段值返回时需通过退款查询接口进一步确认退款状态
|
||||
if (response.getFundChange().equals("Y")){
|
||||
// refundInfo.setStatus(PayRefundStatusEnum.SUCCESS)
|
||||
// refundInfo.setStatus(RefundStatusEnum.SUCCESS)
|
||||
// .setGatewayOrderNo(response.getTradeNo());
|
||||
}
|
||||
refundInfo.setStatus(PayRefundStatusEnum.PROGRESS)
|
||||
refundInfo.setStatus(RefundStatusEnum.PROGRESS)
|
||||
.setGatewayOrderNo(response.getTradeNo());
|
||||
}
|
||||
catch (AlipayApiException e) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
|
||||
|
||||
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PaySyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.AliPayCode;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
|
||||
@@ -96,7 +96,7 @@ public class AliPaySyncService {
|
||||
* 退款同步查询
|
||||
*/
|
||||
public RefundGatewaySyncResult syncRefundStatus(PayRefundOrder refundOrder) {
|
||||
RefundGatewaySyncResult syncResult = new RefundGatewaySyncResult().setSyncStatus(PayRefundSyncStatusEnum.FAIL);
|
||||
RefundGatewaySyncResult syncResult = new RefundGatewaySyncResult().setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
try {
|
||||
AlipayTradeFastpayRefundQueryModel queryModel = new AlipayTradeFastpayRefundQueryModel();
|
||||
// 退款请求号
|
||||
@@ -109,7 +109,7 @@ public class AliPaySyncService {
|
||||
syncResult.setSyncInfo(JSONUtil.toJsonStr(response));
|
||||
// 失败
|
||||
if (!Objects.equals(AliPayCode.SUCCESS, response.getCode())) {
|
||||
syncResult.setSyncStatus(PayRefundSyncStatusEnum.FAIL);
|
||||
syncResult.setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
syncResult.setErrorCode(response.getSubCode());
|
||||
syncResult.setErrorMsg(response.getSubMsg());
|
||||
return syncResult;
|
||||
@@ -120,9 +120,9 @@ public class AliPaySyncService {
|
||||
// 成功
|
||||
if (Objects.equals(tradeStatus, AliPayCode.REFUND_SUCCESS)){
|
||||
LocalDateTime localDateTime = LocalDateTimeUtil.of(response.getGmtRefundPay());
|
||||
return syncResult.setRefundTime(localDateTime).setSyncStatus(PayRefundSyncStatusEnum.SUCCESS);
|
||||
return syncResult.setRefundTime(localDateTime).setSyncStatus(RefundSyncStatusEnum.SUCCESS);
|
||||
} else {
|
||||
return syncResult.setSyncStatus(PayRefundSyncStatusEnum.FAIL).setErrorMsg("支付宝网关反正退款未成功");
|
||||
return syncResult.setSyncStatus(RefundSyncStatusEnum.FAIL).setErrorMsg("支付宝网关反正退款未成功");
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("退款订单同步失败:", e);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.wechat.service;
|
||||
|
||||
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PaySyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.WeChatPayCode;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
@@ -126,16 +126,16 @@ public class WeChatPaySyncService {
|
||||
if (Objects.equals(tradeStatus, WeChatPayCode.REFUND_SUCCESS)) {
|
||||
String timeEnd = result.get(WeChatPayCode.REFUND_SUCCESS_TIME);
|
||||
LocalDateTime time = LocalDateTimeUtil.parse(timeEnd, DatePattern.NORM_DATETIME_PATTERN);
|
||||
return syncResult.setRefundTime(time).setSyncStatus(PayRefundSyncStatusEnum.SUCCESS);
|
||||
return syncResult.setRefundTime(time).setSyncStatus(RefundSyncStatusEnum.SUCCESS);
|
||||
}
|
||||
// 退款中
|
||||
if (Objects.equals(tradeStatus, WeChatPayCode.REFUND_PROCESSING)) {
|
||||
return syncResult.setSyncStatus(PayRefundSyncStatusEnum.PROGRESS);
|
||||
return syncResult.setSyncStatus(RefundSyncStatusEnum.PROGRESS);
|
||||
}
|
||||
return syncResult.setSyncStatus(PayRefundSyncStatusEnum.FAIL);
|
||||
return syncResult.setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
} catch (Exception e) {
|
||||
log.error("查询退款订单失败:", e);
|
||||
syncResult.setSyncStatus(PayRefundSyncStatusEnum.PROGRESS).setErrorMsg(e.getMessage());
|
||||
syncResult.setSyncStatus(RefundSyncStatusEnum.PROGRESS).setErrorMsg(e.getMessage());
|
||||
}
|
||||
return syncResult;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.core.channel.wechat.service;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||
import cn.bootx.platform.daxpay.service.code.WeChatPayCode;
|
||||
import cn.bootx.platform.daxpay.service.common.context.RefundLocal;
|
||||
@@ -59,7 +59,7 @@ public class WechatRefundService {
|
||||
if (StrUtil.isBlank(weChatPayConfig.getP12())){
|
||||
String errorMsg = "微信p.12证书未配置,无法进行退款";
|
||||
refundInfo.setErrorMsg(errorMsg);
|
||||
refundInfo.setErrorCode(PayRefundStatusEnum.FAIL.getCode());
|
||||
refundInfo.setErrorCode(RefundStatusEnum.FAIL.getCode());
|
||||
throw new PayFailureException(errorMsg);
|
||||
}
|
||||
byte[] fileBytes = Base64.decode(weChatPayConfig.getP12());
|
||||
@@ -69,7 +69,7 @@ public class WechatRefundService {
|
||||
Map<String, String> result = WxPayKit.xmlToMap(xmlResult);
|
||||
this.verifyErrorMsg(result);
|
||||
// 微信退款是否成功需要查询状态或者回调, 所以设置为退款中状态
|
||||
refundInfo.setStatus(PayRefundStatusEnum.PROGRESS)
|
||||
refundInfo.setStatus(RefundStatusEnum.PROGRESS)
|
||||
.setGatewayOrderNo(result.get("refund_id"));
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.service.core.order.pay.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.common.core.util.ResultConvertUtil;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.param.pay.PayChannelParam;
|
||||
import cn.bootx.platform.daxpay.service.common.context.AsyncPayLocal;
|
||||
@@ -91,7 +91,7 @@ public class PayChannelOrderService {
|
||||
int refundableBalance = payChannelOrder.getRefundableBalance() - refundChannelOrder.getAmount();
|
||||
payChannelOrder.setRefundableBalance(refundableBalance);
|
||||
// 支付通道订单状态
|
||||
if (Objects.equals(refundChannelOrder.getStatus(), PayRefundStatusEnum.SUCCESS.getCode())){
|
||||
if (Objects.equals(refundChannelOrder.getStatus(), RefundStatusEnum.SUCCESS.getCode())){
|
||||
PayStatusEnum status = refundableBalance == 0 ? PayStatusEnum.REFUNDED : PayStatusEnum.PARTIAL_REFUND;
|
||||
payChannelOrder.setStatus(status.getCode());
|
||||
refundChannelOrder.setRefundTime(LocalDateTime.now());
|
||||
|
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.service.core.order.refund.entity;
|
||||
|
||||
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.order.refund.convert.RefundOrderChannelConvert;
|
||||
import cn.bootx.platform.daxpay.service.dto.order.refund.RefundChannelOrderDto;
|
||||
import cn.bootx.table.modify.annotation.DbColumn;
|
||||
@@ -52,7 +52,7 @@ public class PayRefundChannelOrder extends MpCreateEntity implements EntityBaseF
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
* @see PayRefundStatusEnum
|
||||
* @see RefundStatusEnum
|
||||
*/
|
||||
@DbColumn(comment = "退款状态")
|
||||
private String status;
|
||||
|
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.service.core.order.refund.entity;
|
||||
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.order.refund.convert.PayRefundOrderConvert;
|
||||
import cn.bootx.platform.daxpay.service.dto.order.refund.PayRefundOrderDto;
|
||||
import cn.bootx.table.modify.annotation.DbColumn;
|
||||
@@ -95,7 +95,7 @@ public class PayRefundOrder extends MpBaseEntity implements EntityBaseFunction<P
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
* @see PayRefundStatusEnum
|
||||
* @see RefundStatusEnum
|
||||
*/
|
||||
@DbColumn(comment = "退款状态")
|
||||
private String status;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.core.payment.callback.service;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.PayCallbackStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.RefundRepairWayEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.context.CallbackLocal;
|
||||
@@ -54,12 +54,12 @@ public class PayRefundCallbackService {
|
||||
return;
|
||||
}
|
||||
// 退款单已经被处理, 记录回调记录
|
||||
if (!Objects.equals(PayRefundStatusEnum.PROGRESS.getCode(), refundOrder.getStatus())) {
|
||||
if (!Objects.equals(RefundStatusEnum.PROGRESS.getCode(), refundOrder.getStatus())) {
|
||||
callbackInfo.setCallbackStatus(PayCallbackStatusEnum.IGNORE).setMsg("退款单状态已处理,记录回调记录");
|
||||
}
|
||||
|
||||
// 退款成功还是失败
|
||||
if (Objects.equals(PayRefundStatusEnum.SUCCESS.getCode(), callbackInfo.getGatewayStatus())) {
|
||||
if (Objects.equals(RefundStatusEnum.SUCCESS.getCode(), callbackInfo.getGatewayStatus())) {
|
||||
RefundRepairResult repair = reflectionService.repair(refundOrder, RefundRepairWayEnum.SUCCESS);
|
||||
callbackInfo.setPayRepairNo(repair.getRepairNo());
|
||||
} else {
|
||||
|
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.service.core.payment.refund.service;
|
||||
import cn.bootx.platform.common.core.exception.ValidationFailedException;
|
||||
import cn.bootx.platform.common.core.util.CollUtil;
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||
import cn.bootx.platform.daxpay.param.pay.RefundChannelParam;
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.bootx.platform.daxpay.code.PayRefundStatusEnum.SUCCESS;
|
||||
import static cn.bootx.platform.daxpay.code.RefundStatusEnum.SUCCESS;
|
||||
|
||||
/**
|
||||
* 支付退款支撑服务
|
||||
@@ -148,7 +148,7 @@ public class PayRefundAssistService {
|
||||
// 生成退款订单
|
||||
PayRefundOrder refundOrder = new PayRefundOrder()
|
||||
.setPaymentId(payOrder.getId())
|
||||
.setStatus(PayRefundStatusEnum.PROGRESS.getCode())
|
||||
.setStatus(RefundStatusEnum.PROGRESS.getCode())
|
||||
.setBusinessNo(payOrder.getBusinessNo())
|
||||
.setRefundNo(refundParam.getRefundNo())
|
||||
.setOrderAmount(payOrder.getAmount())
|
||||
|
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.service.core.payment.refund.service;
|
||||
import cn.bootx.platform.common.core.exception.RepetitiveOperationException;
|
||||
import cn.bootx.platform.common.core.function.CollectorsFunction;
|
||||
import cn.bootx.platform.common.core.util.ValidationUtil;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayUnsupportedMethodException;
|
||||
@@ -180,7 +180,7 @@ public class PayRefundService {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// 5. 失败处理
|
||||
PaymentContextLocal.get().getRefundInfo().setStatus(PayRefundStatusEnum.FAIL);
|
||||
PaymentContextLocal.get().getRefundInfo().setStatus(RefundStatusEnum.FAIL);
|
||||
this.errorHandler(refundOrder);
|
||||
throw e;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public class PayRefundService {
|
||||
// 剩余可退款余额
|
||||
int refundableBalance = payRefundOrder.getRefundableBalance();
|
||||
// 设置支付订单状态
|
||||
if (asyncRefundInfo.getStatus() == PayRefundStatusEnum.PROGRESS) {
|
||||
if (asyncRefundInfo.getStatus() == RefundStatusEnum.PROGRESS) {
|
||||
// 设置为退款中
|
||||
payOrder.setStatus(PayStatusEnum.REFUNDING.getCode());
|
||||
} else if (refundableBalance == 0) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.service.core.payment.refund.strategy;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfigService;
|
||||
@@ -61,7 +61,7 @@ public class AliPayRefundStrategy extends AbsRefundStrategy {
|
||||
@Override
|
||||
public void doSuccessHandler() {
|
||||
// 更新退款订单数据状态
|
||||
PayRefundStatusEnum refundStatusEnum = PaymentContextLocal.get()
|
||||
RefundStatusEnum refundStatusEnum = PaymentContextLocal.get()
|
||||
.getRefundInfo()
|
||||
.getStatus();
|
||||
this.getRefundChannelOrder().setStatus(refundStatusEnum.getCode());
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.service.core.payment.refund.strategy;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
|
||||
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayConfigService;
|
||||
@@ -65,7 +65,7 @@ public class WeChatPayRefundStrategy extends AbsRefundStrategy {
|
||||
@Override
|
||||
public void doSuccessHandler() {
|
||||
// 更新退款订单数据状态
|
||||
PayRefundStatusEnum refundStatusEnum = PaymentContextLocal.get()
|
||||
RefundStatusEnum refundStatusEnum = PaymentContextLocal.get()
|
||||
.getRefundInfo()
|
||||
.getStatus();
|
||||
this.getRefundChannelOrder().setStatus(refundStatusEnum.getCode());
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.core.payment.repair.result;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -17,9 +17,9 @@ public class RefundRepairResult {
|
||||
/** 修复号 */
|
||||
private String repairNo;
|
||||
/** 退款修复前状态 */
|
||||
private PayRefundStatusEnum beforeRefundStatus;
|
||||
private RefundStatusEnum beforeRefundStatus;
|
||||
/** 退款修复后状态 */
|
||||
private PayRefundStatusEnum afterRefundStatus;
|
||||
private RefundStatusEnum afterRefundStatus;
|
||||
/** 支付修复前状态 */
|
||||
private PayStatusEnum beforePayStatus;
|
||||
/** 支付修复后状态 */
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.service.core.payment.repair.service;
|
||||
|
||||
import cn.bootx.platform.common.core.function.CollectorsFunction;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.RefundRepairWayEnum;
|
||||
@@ -106,7 +106,7 @@ public class RefundRepairService {
|
||||
// 订单相关状态
|
||||
PayStatusEnum beforePayStatus = PayStatusEnum.findByCode(refundOrder.getStatus());
|
||||
PayStatusEnum afterPayRefundStatus;
|
||||
PayRefundStatusEnum beforeRefundStatus = PayRefundStatusEnum.findByCode(refundOrder.getStatus());
|
||||
RefundStatusEnum beforeRefundStatus = RefundStatusEnum.findByCode(refundOrder.getStatus());
|
||||
|
||||
// 判断订单全部退款还是部分退款
|
||||
if (Objects.equals(payOrder.getRefundableBalance(),0)){
|
||||
@@ -115,7 +115,7 @@ public class RefundRepairService {
|
||||
afterPayRefundStatus = PayStatusEnum.PARTIAL_REFUND;
|
||||
}
|
||||
// 设置退款为完成状态
|
||||
refundOrder.setStatus(PayRefundStatusEnum.SUCCESS.getCode());
|
||||
refundOrder.setStatus(RefundStatusEnum.SUCCESS.getCode());
|
||||
payOrder.setStatus(afterPayRefundStatus.getCode());
|
||||
|
||||
// 执行退款成功逻辑
|
||||
@@ -139,7 +139,7 @@ public class RefundRepairService {
|
||||
.setBeforePayStatus(beforePayStatus)
|
||||
.setAfterPayStatus(afterPayRefundStatus)
|
||||
.setBeforeRefundStatus(beforeRefundStatus)
|
||||
.setAfterRefundStatus(PayRefundStatusEnum.SUCCESS);
|
||||
.setAfterRefundStatus(RefundStatusEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public class RefundRepairService {
|
||||
|
||||
// 订单修复前状态
|
||||
PayStatusEnum beforePayStatus = PayStatusEnum.findByCode(refundOrder.getStatus());
|
||||
PayRefundStatusEnum beforeRefundStatus = PayRefundStatusEnum.findByCode(refundOrder.getStatus());
|
||||
RefundStatusEnum beforeRefundStatus = RefundStatusEnum.findByCode(refundOrder.getStatus());
|
||||
repairResult.setBeforePayStatus(beforePayStatus)
|
||||
.setBeforeRefundStatus(beforeRefundStatus);
|
||||
|
||||
@@ -170,7 +170,7 @@ public class RefundRepairService {
|
||||
|
||||
// 更新支付订单相关的可退款金额
|
||||
payOrder.setRefundableBalance(payOrderAmount);
|
||||
refundOrder.setStatus(PayRefundStatusEnum.CLOSE.getCode());
|
||||
refundOrder.setStatus(RefundStatusEnum.CLOSE.getCode());
|
||||
|
||||
// 执行关闭退款逻辑
|
||||
repairStrategies.forEach(AbsRefundRepairStrategy::doCloseHandler);
|
||||
@@ -222,7 +222,7 @@ public class RefundRepairService {
|
||||
*/
|
||||
private PayRepairRecord refundRepairRecord(PayRefundOrder refundOrder, RefundRepairWayEnum repairType, RefundRepairResult repairResult){
|
||||
// 修复后的状态
|
||||
String afterStatus = Optional.ofNullable(repairResult.getAfterRefundStatus()).map(PayRefundStatusEnum::getCode).orElse(null);
|
||||
String afterStatus = Optional.ofNullable(repairResult.getAfterRefundStatus()).map(RefundStatusEnum::getCode).orElse(null);
|
||||
// 修复发起来源
|
||||
String source = PaymentContextLocal.get()
|
||||
.getRepairInfo()
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package cn.bootx.platform.daxpay.service.core.payment.sync.result;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum.PROGRESS;
|
||||
import static cn.bootx.platform.daxpay.code.RefundSyncStatusEnum.PROGRESS;
|
||||
|
||||
/**
|
||||
* 支付退款同步结果
|
||||
@@ -19,9 +19,9 @@ public class RefundGatewaySyncResult {
|
||||
|
||||
/**
|
||||
* 支付网关订单状态, 默认为退款中
|
||||
* @see PayRefundSyncStatusEnum
|
||||
* @see RefundSyncStatusEnum
|
||||
*/
|
||||
private PayRefundSyncStatusEnum syncStatus = PROGRESS;
|
||||
private RefundSyncStatusEnum syncStatus = PROGRESS;
|
||||
|
||||
/** 同步时网关返回的对象, 序列化为json字符串 */
|
||||
private String syncInfo;
|
||||
|
@@ -2,8 +2,8 @@ package cn.bootx.platform.daxpay.service.core.payment.sync.service;
|
||||
|
||||
import cn.bootx.platform.common.core.exception.BizException;
|
||||
import cn.bootx.platform.common.core.exception.RepetitiveOperationException;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
|
||||
import cn.bootx.platform.daxpay.param.pay.RefundSyncParam;
|
||||
import cn.bootx.platform.daxpay.result.pay.SyncResult;
|
||||
@@ -67,7 +67,7 @@ public class PayRefundSyncService {
|
||||
return new SyncResult().setSuccess(false).setRepair(false).setErrorMsg("订单没有异步通道的退款,不需要同步");
|
||||
}
|
||||
// 如果订单已经关闭, 直接返回失败
|
||||
if (Objects.equals(refundOrder.getStatus(), PayRefundStatusEnum.CLOSE.getCode())){
|
||||
if (Objects.equals(refundOrder.getStatus(), RefundStatusEnum.CLOSE.getCode())){
|
||||
return new SyncResult().setSuccess(false).setRepair(false).setErrorMsg("订单已经关闭,不需要同步");
|
||||
}
|
||||
return this.syncRefundOrder(refundOrder);
|
||||
@@ -93,7 +93,7 @@ public class PayRefundSyncService {
|
||||
RefundGatewaySyncResult syncResult = syncPayStrategy.doSyncStatus();
|
||||
|
||||
// 判断是否同步成功
|
||||
if (Objects.equals(syncResult.getSyncStatus(), PayRefundSyncStatusEnum.FAIL)) {
|
||||
if (Objects.equals(syncResult.getSyncStatus(), RefundSyncStatusEnum.FAIL)) {
|
||||
// 同步失败, 返回失败响应, 同时记录失败的日志
|
||||
return new SyncResult().setErrorMsg(syncResult.getErrorMsg());
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class PayRefundSyncService {
|
||||
}
|
||||
} catch (PayFailureException e) {
|
||||
// 同步失败, 返回失败响应, 同时记录失败的日志
|
||||
syncResult.setSyncStatus(PayRefundSyncStatusEnum.FAIL);
|
||||
syncResult.setSyncStatus(RefundSyncStatusEnum.FAIL);
|
||||
this.saveRecord(refundOrder, syncResult, false, null, e.getMessage());
|
||||
return new SyncResult().setErrorMsg(e.getMessage());
|
||||
}
|
||||
@@ -137,26 +137,26 @@ public class PayRefundSyncService {
|
||||
|
||||
/**
|
||||
* 检查状态是否一致
|
||||
* @see PayRefundSyncStatusEnum 同步返回类型
|
||||
* @see PayRefundStatusEnum 退款单状态
|
||||
* @see RefundSyncStatusEnum 同步返回类型
|
||||
* @see RefundStatusEnum 退款单状态
|
||||
*/
|
||||
private boolean checkSyncStatus(RefundGatewaySyncResult syncResult, PayRefundOrder order){
|
||||
PayRefundSyncStatusEnum syncStatus = syncResult.getSyncStatus();
|
||||
RefundSyncStatusEnum syncStatus = syncResult.getSyncStatus();
|
||||
String orderStatus = order.getStatus();
|
||||
// 退款完成
|
||||
if (Objects.equals(syncStatus, PayRefundSyncStatusEnum.SUCCESS)&&
|
||||
Objects.equals(orderStatus, PayRefundStatusEnum.SUCCESS.getCode())) {
|
||||
if (Objects.equals(syncStatus, RefundSyncStatusEnum.SUCCESS)&&
|
||||
Objects.equals(orderStatus, RefundStatusEnum.SUCCESS.getCode())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 退款失败
|
||||
if (Objects.equals(syncStatus, PayRefundSyncStatusEnum.FAIL)&&
|
||||
Objects.equals(orderStatus, PayRefundStatusEnum.FAIL.getCode())) {
|
||||
if (Objects.equals(syncStatus, RefundSyncStatusEnum.FAIL)&&
|
||||
Objects.equals(orderStatus, RefundStatusEnum.FAIL.getCode())) {
|
||||
return true;
|
||||
}
|
||||
// 退款中
|
||||
if (Objects.equals(syncStatus, PayRefundSyncStatusEnum.PROGRESS)&&
|
||||
Objects.equals(orderStatus, PayRefundStatusEnum.PROGRESS.getCode())) {
|
||||
if (Objects.equals(syncStatus, RefundSyncStatusEnum.PROGRESS)&&
|
||||
Objects.equals(orderStatus, RefundStatusEnum.PROGRESS.getCode())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -166,7 +166,7 @@ public class PayRefundSyncService {
|
||||
* 进行退款订单和支付订单的补偿
|
||||
*/
|
||||
private RefundRepairResult repairHandler(RefundGatewaySyncResult syncResult, PayRefundOrder order){
|
||||
PayRefundSyncStatusEnum syncStatusEnum = syncResult.getSyncStatus();
|
||||
RefundSyncStatusEnum syncStatusEnum = syncResult.getSyncStatus();
|
||||
RefundRepairResult repair = new RefundRepairResult();
|
||||
// 对支付网关同步的结果进行处理
|
||||
switch (syncStatusEnum) {
|
||||
|
@@ -3,7 +3,7 @@ package cn.bootx.platform.daxpay.service.core.record.sync.entity;
|
||||
import cn.bootx.platform.common.core.function.EntityBaseFunction;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PaySyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.record.sync.convert.PaySyncRecordConvert;
|
||||
@@ -63,7 +63,7 @@ public class PaySyncRecord extends MpCreateEntity implements EntityBaseFunction<
|
||||
/**
|
||||
* 网关返回状态
|
||||
* @see PaySyncStatusEnum
|
||||
* @see PayRefundSyncStatusEnum
|
||||
* @see RefundSyncStatusEnum
|
||||
*/
|
||||
@DbColumn(comment = "网关返回状态")
|
||||
private String gatewayStatus;
|
||||
|
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.service.dto.order.refund;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -61,7 +61,7 @@ public class PayRefundOrderDto extends BaseDto {
|
||||
private LocalDateTime refundTime;
|
||||
|
||||
/**
|
||||
* @see PayRefundStatusEnum
|
||||
* @see RefundStatusEnum
|
||||
*/
|
||||
@Schema(description = "退款状态")
|
||||
private String status;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.bootx.platform.daxpay.service.dto.order.refund;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.table.modify.annotation.DbColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -43,7 +43,7 @@ public class RefundChannelOrderDto extends BaseDto {
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
* @see PayRefundStatusEnum
|
||||
* @see RefundStatusEnum
|
||||
*/
|
||||
@Schema(description = "退款状态")
|
||||
private String status;
|
||||
|
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.service.dto.record.sync;
|
||||
|
||||
import cn.bootx.platform.common.core.rest.dto.BaseDto;
|
||||
import cn.bootx.platform.daxpay.code.PayChannelEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PaySyncStatusEnum;
|
||||
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
|
||||
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
|
||||
@@ -53,7 +53,7 @@ public class PaySyncRecordDto extends BaseDto {
|
||||
/**
|
||||
* 网关返回状态
|
||||
* @see PaySyncStatusEnum
|
||||
* @see PayRefundSyncStatusEnum
|
||||
* @see RefundSyncStatusEnum
|
||||
*/
|
||||
@Schema(description = "网关返回状态")
|
||||
private String gatewayStatus;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.func;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayChannelOrder;
|
||||
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
|
||||
@@ -52,7 +52,7 @@ public abstract class AbsRefundRepairStrategy implements PayStrategy{
|
||||
payChannelOrder.setStatus(PayStatusEnum.PARTIAL_REFUND.getCode());
|
||||
|
||||
}
|
||||
refundChannelOrder.setStatus(PayRefundStatusEnum.SUCCESS.getCode());
|
||||
refundChannelOrder.setStatus(RefundStatusEnum.SUCCESS.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public abstract class AbsRefundRepairStrategy implements PayStrategy{
|
||||
}
|
||||
// 如果失败, 可退余额设置为null
|
||||
refundChannelOrder.setRefundableAmount(null);
|
||||
refundChannelOrder.setStatus(PayRefundStatusEnum.CLOSE.getCode());
|
||||
refundChannelOrder.setStatus(RefundStatusEnum.CLOSE.getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.bootx.platform.daxpay.service.func;
|
||||
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.PayStatusEnum;
|
||||
import cn.bootx.platform.daxpay.param.pay.RefundChannelParam;
|
||||
import cn.bootx.platform.daxpay.param.pay.RefundParam;
|
||||
@@ -76,7 +76,7 @@ public abstract class AbsRefundStrategy implements PayStrategy{
|
||||
*/
|
||||
public void doSuccessHandler() {
|
||||
// 更新退款订单数据状态
|
||||
this.refundChannelOrder.setStatus(PayRefundStatusEnum.SUCCESS.getCode()).setRefundTime(LocalDateTime.now());
|
||||
this.refundChannelOrder.setStatus(RefundStatusEnum.SUCCESS.getCode()).setRefundTime(LocalDateTime.now());
|
||||
|
||||
// 支付通道订单可退余额
|
||||
int refundableBalance = this.getPayChannelOrder().getRefundableBalance() - this.refundChannelOrder.getAmount();
|
||||
|
@@ -19,7 +19,7 @@ import lombok.experimental.Accessors;
|
||||
@QueryParam
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "支付订单查询参数")
|
||||
public class PayOrderQuery extends QueryOrder {
|
||||
public class PayOrderQuery extends QueryOrder {
|
||||
|
||||
@QueryParam(type = QueryParam.CompareTypeEnum.EQ)
|
||||
@Schema(description = "支付订单id")
|
||||
|
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.service.param.order;
|
||||
|
||||
import cn.bootx.platform.common.core.annotation.QueryParam;
|
||||
import cn.bootx.platform.common.core.rest.param.QueryOrder;
|
||||
import cn.bootx.platform.daxpay.code.PayRefundStatusEnum;
|
||||
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -38,7 +38,7 @@ public class PayRefundOrderQuery extends QueryOrder {
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* @see PayRefundStatusEnum
|
||||
* @see RefundStatusEnum
|
||||
*/
|
||||
@Schema(description = "退款状态")
|
||||
private String status;
|
||||
|
Reference in New Issue
Block a user