feat 增加支付修复记录

This commit is contained in:
nws
2024-01-07 00:12:39 +08:00
parent 04538cc141
commit 500807062a
7 changed files with 149 additions and 2 deletions

View File

@@ -33,11 +33,12 @@
- [x] 退款功能联调
- 2024-01-06:
- [x] 订单取消/修复/取消/同步等操作添加分布式锁, 防止出现重复操作
- [ ] 增加支付修复记录
- [x] 增加支付修复记录
- 2024-01-07:
- [ ] 增加消息通知机制(通知客户端)
- [ ] 退款状态同步逻辑
- [ ] 退款回调的处理
- [ ] 支付状态同步处理考虑退款情况
- [ ] 增加消息通知机制(通知客户端)
- **任务池**
- 支付状态同步处理退款情况
- 支付配置支持数据库配置和配置文件配置

View File

@@ -8,6 +8,8 @@ import cn.bootx.platform.daxpay.service.core.payment.repair.param.PayRepairParam
import cn.bootx.platform.daxpay.service.core.payment.repair.result.RepairResult;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.core.record.pay.service.PayOrderService;
import cn.bootx.platform.daxpay.service.core.record.repair.entity.PayRepairRecord;
import cn.bootx.platform.daxpay.service.core.record.repair.service.PayRepairRecordService;
import cn.bootx.platform.daxpay.service.func.AbsPayRepairStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -30,6 +32,8 @@ public class PayRepairService {
private final PayOrderService payOrderService;
private final PayRepairRecordService recordService;
/**
* 修复支付单
*/
@@ -71,6 +75,7 @@ public class PayRepairService {
default:
break;
}
this.saveRecord(order, repairParam, repairResult);
return repairResult;
}
@@ -137,4 +142,19 @@ public class PayRepairService {
// 不为0调用退款同步接口
}
/**
* 保存记录
*/
private void saveRecord(PayOrder order, PayRepairParam repairParam, RepairResult repairResult){
PayRepairRecord payRepairRecord = new PayRepairRecord()
.setBeforeStatus(repairResult.getOldStatus().getCode())
.setAfterStatus(repairResult.getRepairStatus().getCode())
.setAmount(repairParam.getAmount())
.setBusinessNo(order.getBusinessNo())
.setRepairSource(repairParam.getRepairSource().getCode())
.setRepairType(repairParam.getRepairType().getCode());
recordService.saveRecord(payRepairRecord);
}
}

View File

@@ -0,0 +1,14 @@
package cn.bootx.platform.daxpay.service.core.record.repair.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
*
* @author xxm
* @since 2024/1/6
*/
@Mapper
public interface PayRepairRecordConvert {
PayRepairRecordConvert CONVERT = Mappers.getMapper(PayRepairRecordConvert.class);
}

View File

@@ -0,0 +1,18 @@
package cn.bootx.platform.daxpay.service.core.record.repair.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.service.core.record.repair.entity.PayRepairRecord;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
/**
*
* @author xxm
* @since 2024/1/6
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class PayRepairRecordManager extends BaseManager<PayRepairRecordMapper, PayRepairRecord> {
}

View File

@@ -0,0 +1,14 @@
package cn.bootx.platform.daxpay.service.core.record.repair.dao;
import cn.bootx.platform.daxpay.service.core.record.repair.entity.PayRepairRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author xxm
* @since 2024/1/6
*/
@Mapper
public interface PayRepairRecordMapper extends BaseMapper<PayRepairRecord> {
}

View File

@@ -0,0 +1,51 @@
package cn.bootx.platform.daxpay.service.core.record.repair.entity;
import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 支付修复记录
* @author xxm
* @since 2024/1/6
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@TableName("pay_repair_record")
@DbTable(comment = "支付修复记录")
public class PayRepairRecord extends MpCreateEntity {
/** 支付ID */
@DbColumn(comment = "支付ID")
private Long paymentId;
/** 业务号 */
@DbColumn(comment = "业务号")
private String businessNo;
/** 修复来源 */
@DbColumn(comment = "修复来源")
private String repairSource;
/** 修复类型 */
@DbColumn(comment = "修复类型")
private String repairType;
/** 修复前状态 */
@DbColumn(comment = "修复前状态")
private String beforeStatus;
/** 修复后状态 */
@DbColumn(comment = "修复后状态")
private String afterStatus;
/** 金额变动 */
@DbColumn(comment = "金额变动")
private Integer amount;
}

View File

@@ -0,0 +1,29 @@
package cn.bootx.platform.daxpay.service.core.record.repair.service;
import cn.bootx.platform.daxpay.service.core.record.repair.dao.PayRepairRecordManager;
import cn.bootx.platform.daxpay.service.core.record.repair.entity.PayRepairRecord;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
*
* @author xxm
* @since 2024/1/6
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PayRepairRecordService {
private final PayRepairRecordManager repairRecordManager;
/**
* 保存记录
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveRecord(PayRepairRecord record){
repairRecordManager.save(record);
}
}