diff --git a/_doc/Task.md b/_doc/Task.md index aa6a77048..0cdd0e655 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -97,12 +97,15 @@ - 2024-01-31: - [x] 微信退款同步策略 - [x] 支付和退款同步时, 填充完成时间和网关订单号 - - [ ] 退款操作支持重试 + - [ ] 调整订单页面查询条件 + - [ ] 支付切换异步方式时, 订单未更换 - 2024-02-01: -- + - [ ] - 2.0.1 版本内容 + - [ ] 退款操作支持重试 - [ ] 支付流程也改为先落库后支付情况, 避免极端情况导致掉单 + - [ ] 支付流程涉及异步支付时, 更换支付方式需要控制预防客户重复付款 - [ ] 完善各种同步支付方式 - [ ] 增加聚合支付功能支持 - [ ] 增加手机用户收银台功能 diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/result/pay/SyncResult.java b/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/result/pay/SyncResult.java index 6365a60d2..3827a0765 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/result/pay/SyncResult.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/bootx/platform/daxpay/result/pay/SyncResult.java @@ -35,8 +35,8 @@ public class SyncResult extends CommonResult { @Schema(description = "是否进行了修复") private boolean repair; - @Schema(description = "修复ID") - private Long repairId; + @Schema(description = "修复号") + private String repairOrderNo; @Schema(description = "失败原因") private String errorMsg; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/common/context/CallbackLocal.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/common/context/CallbackLocal.java index 4b8874c2a..507c1146b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/common/context/CallbackLocal.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/common/context/CallbackLocal.java @@ -43,8 +43,8 @@ public class CallbackLocal { /** 完成时间(支付/退款) */ private LocalDateTime finishTime; - /** 支付修复ID */ - private Long payRepairId; + /** 修复号 */ + private String payRepairNo; /** * 回调处理状态 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayRefundService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayRefundService.java index afdfb4949..d84804249 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayRefundService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayRefundService.java @@ -49,8 +49,8 @@ public class AliPayRefundService { } // 接口返回fund_change=Y为退款成功,fund_change=N或无此字段值返回时需通过退款查询接口进一步确认退款状态 if (response.getFundChange().equals("Y")){ - refundInfo.setStatus(PayRefundStatusEnum.SUCCESS) - .setGatewayOrderNo(response.getTradeNo()); +// refundInfo.setStatus(PayRefundStatusEnum.SUCCESS) +// .setGatewayOrderNo(response.getTradeNo()); } refundInfo.setStatus(PayRefundStatusEnum.PROGRESS) .setGatewayOrderNo(response.getTradeNo()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayCallbackService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayCallbackService.java index 8cf638ee2..927bb0f67 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayCallbackService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayCallbackService.java @@ -95,7 +95,7 @@ public class PayCallbackService { } // 执行支付完成修复逻辑 PayRepairResult repair = payRepairService.repair(payOrder, PayRepairWayEnum.SUCCESS); - callbackInfo.setPayRepairId(repair.getRepairId()); + callbackInfo.setPayRepairNo(repair.getRepairNo()); } /** @@ -115,7 +115,7 @@ public class PayCallbackService { } // 执行支付关闭修复逻辑 PayRepairResult repair = payRepairService.repair(payOrder, PayRepairWayEnum.CLOSE_LOCAL); - callbackInfo.setPayRepairId(repair.getRepairId()); + callbackInfo.setPayRepairNo(repair.getRepairNo()); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayRefundCallbackService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayRefundCallbackService.java index ee8832832..f07873b01 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayRefundCallbackService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/callback/service/PayRefundCallbackService.java @@ -61,10 +61,10 @@ public class PayRefundCallbackService { // 退款成功还是失败 if (Objects.equals(PayRefundStatusEnum.SUCCESS.getCode(), callbackInfo.getGatewayStatus())) { RefundRepairResult repair = reflectionService.repair(refundOrder, RefundRepairWayEnum.SUCCESS); - callbackInfo.setPayRepairId(repair.getRepairId()); + callbackInfo.setPayRepairNo(repair.getRepairNo()); } else { RefundRepairResult repair = reflectionService.repair(refundOrder, RefundRepairWayEnum.FAIL); - callbackInfo.setPayRepairId(repair.getRepairId()); + callbackInfo.setPayRepairNo(repair.getRepairNo()); } } finally { diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/PayRepairResult.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/PayRepairResult.java index 2ccde52c1..d7486ec49 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/PayRepairResult.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/PayRepairResult.java @@ -12,8 +12,8 @@ import lombok.experimental.Accessors; @Data @Accessors(chain = true) public class PayRepairResult { - /** 修复记录ID */ - private Long repairId; + /** 修复号 */ + private String repairNo; /** 修复前状态 */ private PayStatusEnum beforeStatus; /** 修复后状态 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/RefundRepairResult.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/RefundRepairResult.java index 0950b8251..de1b3e528 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/RefundRepairResult.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/result/RefundRepairResult.java @@ -14,8 +14,8 @@ import lombok.experimental.Accessors; @Accessors(chain = true) public class RefundRepairResult { - /** 修复ID */ - private Long repairId; + /** 修复号 */ + private String repairNo; /** 退款修复前状态 */ private PayRefundStatusEnum beforeRefundStatus; /** 退款修复后状态 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/PayRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/PayRepairService.java index 6bdd2cf6b..5a1ee12fc 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/PayRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/PayRepairService.java @@ -87,7 +87,7 @@ public class PayRepairService { log.error("走到了理论上讲不会走到的分支"); } // 设置修复iD - repairResult.setRepairId(IdUtil.getSnowflakeNextId()); + repairResult.setRepairNo(IdUtil.getSnowflakeNextIdStr()); this.saveRecord(order, repairType, repairResult); return repairResult; } @@ -154,7 +154,7 @@ public class PayRepairService { .getRepairInfo() .getSource().getCode(); PayRepairRecord payRepairRecord = new PayRepairRecord() - .setRepairId(repairResult.getRepairId()) + .setRepairNo(repairResult.getRepairNo()) .setOrderId(order.getId()) .setAsyncChannel(order.getAsyncChannel()) .setOrderNo(order.getBusinessNo()) @@ -163,7 +163,6 @@ public class PayRepairService { .setRepairType(PaymentTypeEnum.PAY.getCode()) .setRepairSource(source) .setRepairWay(recordType.getCode()); - payRepairRecord.setId(repairResult.getRepairId()); recordService.saveRecord(payRepairRecord); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/RefundRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/RefundRepairService.java index 90b4097a8..1c3bea315 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/RefundRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/repair/service/RefundRepairService.java @@ -90,7 +90,7 @@ public class RefundRepairService { } // 设置修复ID并保存修复记录 - repairResult.setRepairId(IdUtil.getSnowflakeNextId()); + repairResult.setRepairNo(IdUtil.getSnowflakeNextIdStr()); PayRepairRecord payRepairRecord = this.payRepairRecord(payOrder, repairType, repairResult); PayRepairRecord refundRepairRecord = this.refundRepairRecord(refundOrder, repairType, repairResult); recordService.saveAllRecord(Arrays.asList(payRepairRecord, refundRepairRecord)); @@ -205,7 +205,7 @@ public class RefundRepairService { .getRepairInfo() .getSource().getCode(); return new PayRepairRecord() - .setRepairId(repairResult.getRepairId()) + .setRepairNo(repairResult.getRepairNo()) .setOrderId(order.getId()) .setRepairType(PaymentTypeEnum.PAY.getCode()) .setRepairSource(source) @@ -229,7 +229,7 @@ public class RefundRepairService { .getSource().getCode(); return new PayRepairRecord() .setOrderId(refundOrder.getId()) - .setRepairId(repairResult.getRepairId()) + .setRepairNo(repairResult.getRepairNo()) .setOrderNo(refundOrder.getRefundNo()) .setRepairType(PaymentTypeEnum.REFUND.getCode()) .setBeforeStatus(repairResult.getBeforeRefundStatus().getCode()) diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PayRefundSyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PayRefundSyncService.java index d888b1c44..d0ea87e49 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PayRefundSyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PayRefundSyncService.java @@ -123,12 +123,12 @@ public class PayRefundSyncService { return new SyncResult().setErrorMsg(e.getMessage()); } // 同步成功记录日志 - this.saveRecord(refundOrder, syncResult, !statusSync, repairResult.getRepairId(), null); + this.saveRecord(refundOrder, syncResult, !statusSync, repairResult.getRepairNo(), null); return new SyncResult() .setGatewayStatus(syncResult.getSyncStatus().getCode()) .setSuccess(true) .setRepair(!statusSync) - .setRepairId(repairResult.getRepairId()); + .setRepairOrderNo(repairResult.getRepairNo()); } finally { lockTemplate.releaseLock(lock); } @@ -194,9 +194,10 @@ public class PayRefundSyncService { * @param refundOrder 支付单 * @param syncResult 同步结果 * @param repair 是否修复 + * @param repairOrderNo 修复号 * @param errorMsg 错误信息 */ - private void saveRecord(PayRefundOrder refundOrder, RefundGatewaySyncResult syncResult, boolean repair, Long repairOrderId, String errorMsg){ + private void saveRecord(PayRefundOrder refundOrder, RefundGatewaySyncResult syncResult, boolean repair, String repairOrderNo, String errorMsg){ PaySyncRecord paySyncRecord = new PaySyncRecord() .setOrderId(refundOrder.getId()) .setOrderNo(refundOrder.getRefundNo()) @@ -206,7 +207,7 @@ public class PayRefundSyncService { .setSyncInfo(syncResult.getSyncInfo()) .setGatewayStatus(syncResult.getSyncStatus().getCode()) .setRepairOrder(repair) - .setRepairOrderId(repairOrderId) + .setRepairOrderNo(repairOrderNo) .setErrorMsg(errorMsg) .setClientIp(PaymentContextLocal.get().getRequestInfo().getClientIp()) .setReqId(PaymentContextLocal.get().getRequestInfo().getReqId()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PaySyncService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PaySyncService.java index c996a81fc..b6385857c 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PaySyncService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/sync/service/PaySyncService.java @@ -133,12 +133,12 @@ public class PaySyncService { } // 同步成功记录日志 - this.saveRecord( payOrder, syncResult, !statusSync, repairResult.getRepairId(), null); + this.saveRecord( payOrder, syncResult, !statusSync, repairResult.getRepairNo(), null); return new SyncResult() .setGatewayStatus(syncResult.getSyncStatus().getCode()) .setSuccess(true) .setRepair(!statusSync) - .setRepairId(repairResult.getRepairId()); + .setRepairOrderNo(repairResult.getRepairNo()); } finally { lockTemplate.releaseLock(lock); } @@ -238,9 +238,10 @@ public class PaySyncService { * @param payOrder 支付单 * @param syncResult 同步结果 * @param repair 是否修复 + * @param repairOrderNo 修复号 * @param errorMsg 错误信息 */ - private void saveRecord(PayOrder payOrder, PayGatewaySyncResult syncResult, boolean repair, Long repairOrderId, String errorMsg){ + private void saveRecord(PayOrder payOrder, PayGatewaySyncResult syncResult, boolean repair, String repairOrderNo, String errorMsg){ PaySyncRecord paySyncRecord = new PaySyncRecord() .setOrderId(payOrder.getId()) .setOrderNo(payOrder.getBusinessNo()) @@ -249,7 +250,7 @@ public class PaySyncService { .setSyncInfo(syncResult.getSyncInfo()) .setGatewayStatus(syncResult.getSyncStatus().getCode()) .setRepairOrder(repair) - .setRepairOrderId(repairOrderId) + .setRepairOrderNo(repairOrderNo) .setErrorMsg(errorMsg) .setClientIp(PaymentContextLocal.get().getRequestInfo().getClientIp()) .setReqId(PaymentContextLocal.get().getRequestInfo().getReqId()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/callback/entity/PayCallbackRecord.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/callback/entity/PayCallbackRecord.java index 1ca141e65..515de0099 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/callback/entity/PayCallbackRecord.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/callback/entity/PayCallbackRecord.java @@ -63,8 +63,8 @@ public class PayCallbackRecord extends MpCreateEntity implements EntityBaseFunct private String status; - @Schema(description = "支付单修复ID") - private Long repairOrderId; + @Schema(description = "修复号") + private String repairOrderNo; /** 提示信息 */ @DbColumn(comment = "提示信息") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/repair/entity/PayRepairRecord.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/repair/entity/PayRepairRecord.java index 2aa8bbacb..864eb0e86 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/repair/entity/PayRepairRecord.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/repair/entity/PayRepairRecord.java @@ -29,12 +29,11 @@ import lombok.experimental.Accessors; public class PayRepairRecord extends MpCreateEntity implements EntityBaseFunction { /** - * 修复ID - * 如果一次修复产生的修复记录只有一条, 则该字段为与ID一致 - * 如果一次修复产生的修复记录有多个, 则使用这个ID作为关联 + * 修复号 + * 如果一次修复产生的修复记录有多个记录, 使用这个ID作为关联 */ - @DbColumn(comment = "修复ID") - private Long repairId; + @DbColumn(comment = "修复号") + private String repairNo; /** 支付ID/退款ID */ @DbColumn(comment = "本地订单ID") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/sync/entity/PaySyncRecord.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/sync/entity/PaySyncRecord.java index a9974a55e..48f41c9b8 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/sync/entity/PaySyncRecord.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/record/sync/entity/PaySyncRecord.java @@ -74,8 +74,8 @@ public class PaySyncRecord extends MpCreateEntity implements EntityBaseFunction< @DbColumn(comment = "是否进行修复") private boolean repairOrder; - @DbColumn(comment = "支付单修复ID") - private Long repairOrderId; + @DbColumn(comment = "修复单号") + private String repairOrderNo; @DbColumn(comment = "错误消息") private String errorMsg; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/callback/PayCallbackRecordDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/callback/PayCallbackRecordDto.java index 9abaebf7f..a1d7625b9 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/callback/PayCallbackRecordDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/callback/PayCallbackRecordDto.java @@ -50,8 +50,8 @@ public class PayCallbackRecordDto extends BaseDto { @Schema(description = "回调处理状态") private String status; - @Schema(description = "支付单修复ID") - private Long repairOrderId; + @Schema(description = "修复号") + private String repairOrderNo; /** 提示信息 */ @Schema(description = "提示信息") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/repair/PayRepairRecordDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/repair/PayRepairRecordDto.java index e6361e87f..44c0fae88 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/repair/PayRepairRecordDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/repair/PayRepairRecordDto.java @@ -23,11 +23,12 @@ import lombok.experimental.Accessors; public class PayRepairRecordDto extends BaseDto { /** + * 修复号 * 如果一次修复产生的修复记录只有一条, 则该字段为与ID一致 * 如果一次修复产生的修复记录有多个, 则使用这个ID作为关联 */ - @Schema(description = "修复ID") - private Long repairId; + @Schema(description = "修复号") + private String repairNo; /** 支付ID/退款ID */ @Schema(description = "业务ID") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/sync/PaySyncRecordDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/sync/PaySyncRecordDto.java index bded7af5b..5e8965657 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/sync/PaySyncRecordDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/record/sync/PaySyncRecordDto.java @@ -64,8 +64,8 @@ public class PaySyncRecordDto extends BaseDto { @Schema(description = "是否进行修复") private boolean repairOrder; - @Schema(description = "支付单修复ID") - private Long repairOrderId; + @Schema(description = "修复单号") + private String repairOrderNo; @Schema(description = "错误消息") private String errorMsg; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/func/AbsCallbackStrategy.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/func/AbsCallbackStrategy.java index eb99b9b8f..8051ec63b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/func/AbsCallbackStrategy.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/func/AbsCallbackStrategy.java @@ -114,7 +114,7 @@ public abstract class AbsCallbackStrategy implements PayStrategy { .setOrderId(callbackInfo.getOrderId()) .setGatewayOrderNo(callbackInfo.getGatewayOrderNo()) .setCallbackType(callbackType) - .setRepairOrderId(callbackInfo.getPayRepairId()) + .setRepairOrderNo(callbackInfo.getPayRepairNo()) .setStatus(callbackInfo.getCallbackStatus().getCode()) .setMsg(callbackInfo.getMsg()); callbackRecordService.save(payNotifyRecord);