style 订单修复号调整

This commit is contained in:
xxm1995
2024-01-31 15:00:48 +08:00
parent c088d21d2a
commit e05af18c2b
19 changed files with 50 additions and 46 deletions

View File

@@ -97,12 +97,15 @@
- 2024-01-31:
- [x] 微信退款同步策略
- [x] 支付和退款同步时, 填充完成时间和网关订单号
- [ ] 退款操作支持重试
- [ ] 调整订单页面查询条件
- [ ] 支付切换异步方式时, 订单未更换
- 2024-02-01:
-
- [ ]
- 2.0.1 版本内容
- [ ] 退款操作支持重试
- [ ] 支付流程也改为先落库后支付情况, 避免极端情况导致掉单
- [ ] 支付流程涉及异步支付时, 更换支付方式需要控制预防客户重复付款
- [ ] 完善各种同步支付方式
- [ ] 增加聚合支付功能支持
- [ ] 增加手机用户收银台功能

View File

@@ -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;

View File

@@ -43,8 +43,8 @@ public class CallbackLocal {
/** 完成时间(支付/退款) */
private LocalDateTime finishTime;
/** 支付修复ID */
private Long payRepairId;
/** 修复号 */
private String payRepairNo;
/**
* 回调处理状态

View File

@@ -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());

View File

@@ -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());
}
}

View File

@@ -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 {

View File

@@ -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;
/** 修复后状态 */

View File

@@ -14,8 +14,8 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class RefundRepairResult {
/** 修复ID */
private Long repairId;
/** 修复 */
private String repairNo;
/** 退款修复前状态 */
private PayRefundStatusEnum beforeRefundStatus;
/** 退款修复后状态 */

View File

@@ -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);
}
}

View File

@@ -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())

View File

@@ -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());

View File

@@ -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());

View File

@@ -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 = "提示信息")

View File

@@ -29,12 +29,11 @@ import lombok.experimental.Accessors;
public class PayRepairRecord extends MpCreateEntity implements EntityBaseFunction<PayRepairRecordDto> {
/**
* 修复ID
* 如果一次修复产生的修复记录只有一条, 则该字段为与ID一致
* 如果一次修复产生的修复记录有多个, 则使用这个ID作为关联
* 修复
* 如果一次修复产生的修复记录有多个记录, 使用这个ID作为关联
*/
@DbColumn(comment = "修复ID")
private Long repairId;
@DbColumn(comment = "修复")
private String repairNo;
/** 支付ID/退款ID */
@DbColumn(comment = "本地订单ID")

View File

@@ -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;

View File

@@ -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 = "提示信息")

View File

@@ -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")

View File

@@ -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;

View File

@@ -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);