diff --git a/Dockerfile b/Dockerfile index 3a520459..f75c69b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ WORKDIR / EXPOSE 9000 # 添加执行jar包 -ADD daxpay-single/daxpay-single-start/target/daxpay-start.jar dax-start.jar +ADD daxpay-single-start/target/daxpay-start.jar dax-start.jar # 执行启动命令 CMD java $JAVA_OPTS -jar dax-start.jar diff --git a/_doc/Task.md b/_doc/Task.md index a187bbb1..d96ed0b7 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -1,49 +1,14 @@ ## 单商户 -2.0.6: 去除组合支付, 一系列代码优化 -- [x] 删除现金支付和储值卡支付方式 -- [x] 支付订单 - - [x] 支付改造 - - [x] 回调改造, 不再使用继承类, 简化逻辑 - - [x] 发送通知改造 -- [x] 去除组合支付和场景,降低逻辑的的复杂度 - - [x] 退款场景 - - [x] 关闭支付订单 - - [x] 同步操作时 - - [x] 订单修复 - - [x] 支付和退款回调 - - [x] 去除现金支付和储值卡支付方式 -- [x] 三方支付通道订单号规则优化: 支付P、退款R、分账A,根据环境加前缀:DEV_、DEMO_、PRE_ -- [x] 金额显示统一使用元 -- [x] 使用切面统一处理API调用异常, 做统一包装返回 -- [x] 支付接口优化 -- [x] 前端查询条件适配 -- [x] paymentId替换 -- [x] 对账单改造 - - [x] 去除对账单明细按钮 - - [x] 增加对账结果计算和显示 - - [x] 增加下载原始对账单功能(保证将明细文件进行储存) - - [x] 保存原始的文件 - - [x] 微信 - - [x] 支付宝 - - [x] 云闪付 - - [x] 解析原有文件, 可以转换为指定格式进行下载 - - [x] 增加下载系统对账单功能 - - [x] 增加对单差异数据查看功能和查看功能 -- [x] 支付订单和退款订单页面添加实时金额汇总展示 -- [x] 自动分账改造 - - [x] 创建定时任务, 自动对待分账订单进行分账 - - [x] 增加定时同步分账状态任务 - - [x] 增加自动完结功能 -- [x] 数据加密方式改为类型处理器模式 -- [x] 页面优化 -- [x] 集成bootx-platform到项目中 -- [x] 包结构名称修改为cn.daxpay.single -- [x] 自动同步任务不生效 -- [x] 计算收款金额时对产生退款的支付订单未进行计算 2.0.7: 分账完善和基础架构优化 -- [ ] 新增资金流水 -- [ ] 增加对超时订单进行处理(数据库同步) +- [x] 新增资金流水 +- [x] 增加对超时订单进行处理(数据库同步) - [ ] 支持分账组分账和自己传接收方进行分账 + - [ ] 添加分账接收方 + - [ ] 查询分账接收方 + - [ ] 删除分账接收方 + - [ ] 启动分账 + - [ ] 分账查询 + - [ ] 纷争完结 - [ ] DEMO增加获取微信OpenID和支付宝OpenId功能 - [ ] 分账接收方管理提供接口调用 - [ ] 分账情况查询, 分账结果/剩余可分账金额 @@ -51,8 +16,9 @@ - [ ] 分账组管理提供接口调用 - [ ] 分账通知 - [ ] 分账支持手动和自动分账两种 -- [ ] 金额过小不进行分账, 增加新状态 +- [ ] 金额过小不进行分账, 增加新状态, 金额小于0.01元直接忽略 - [ ] 增加收单收银台功能 +- [ ] 对账提供外部接口调用 2.1.x 版本内容 - [ ] 对账回退及退款 diff --git a/daxpay-single-start/src/main/resources/application-dev.yml b/daxpay-single-start/src/main/resources/application-dev.yml index 54ecafe2..90af7bc6 100644 --- a/daxpay-single-start/src/main/resources/application-dev.yml +++ b/daxpay-single-start/src/main/resources/application-dev.yml @@ -74,9 +74,9 @@ bootx: description: 开源支付平台-单商户版 # 多模块扫码 base-packages: - "[支付网关API]": cn.bootx.platform.daxpay.gateway - "[支付管理接口]": cn.bootx.platform.daxpay.admin - "[支付演示模块]": cn.bootx.platform.daxpay.demo + "[支付网关API]": cn.daxpay.single.gateway + "[支付管理接口]": cn.daxpay.single.admin + "[支付演示模块]": cn.daxpay.single.demo "[BootxPlatform接口]": - cn.bootx.platform.common - cn.bootx.platform.starter diff --git a/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/record/TradeFlowRecordController.java b/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/record/TradeFlowRecordController.java new file mode 100644 index 00000000..7c1f2061 --- /dev/null +++ b/daxpay-single/daxpay-single-admin/src/main/java/cn/daxpay/single/admin/controller/record/TradeFlowRecordController.java @@ -0,0 +1,40 @@ +package cn.daxpay.single.admin.controller.record; + +import cn.bootx.platform.common.core.rest.PageResult; +import cn.bootx.platform.common.core.rest.Res; +import cn.bootx.platform.common.core.rest.ResResult; +import cn.bootx.platform.common.core.rest.param.PageParam; +import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; +import cn.daxpay.single.service.dto.record.flow.TradeFlowRecordDto; +import cn.daxpay.single.service.param.record.TradeFlowRecordQuery; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 交易流水记录控制器 + * @author xxm + * @since 2024/5/17 + */ +@Tag(name = "交易流水记录控制器") +@RestController +@RequestMapping("/record/flow") +@RequiredArgsConstructor +public class TradeFlowRecordController { + private final TradeFlowRecordService service; + + @Operation(summary = "分页查询") + @GetMapping("/page") + public ResResult> page(PageParam pageParam, TradeFlowRecordQuery query) { + return Res.ok(service.page(pageParam, query)); + } + + @Operation(summary = "查询单条") + @GetMapping("/findById") + public ResResult findById(Long id) { + return Res.ok(service.findById(id)); + } +} diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java index b243ce17..12be6972 100644 --- a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/code/PaymentApiCode.java @@ -6,28 +6,37 @@ package cn.daxpay.single.code; * @since 2024/2/25 */ public interface PaymentApiCode { - + /** 支付 */ String PAY = "pay"; - + /** 退款 */ String REFUND = "refund"; - + /** 关闭订单 */ String CLOSE = "close"; - + /** 分账 */ String ALLOCATION = "allocation"; - + /** 分账完结 */ String ALLOCATION_FINISH = "allocationFinish"; - + /** 支付同步 */ String SYNC_PAY = "syncPay"; - + /** 退款同步 */ String SYNC_REFUND = "syncRefund"; - + /** 查询支付订单 */ String QUERY_PAY_ORDER = "queryPayOrder"; - + /** 查询退款订单 */ String QUERY_REFUND_ORDER = "queryRefundOrder"; - + /** 查询分账订单 */ + String QUERY_ALLOCATION_ORDER = "queryAllocationOrder"; + /** 获取微信授权链接 */ String GET_WX_AUTH_URL = "getWxAuthUrl"; - + /** 获取微信AccessToken */ String GET_WX_ACCESS_TOKEN = "getWxAccessToken"; + /** 添加分账方接口 */ + String ALLOCATION_RECEIVER_ADD = "allocationReceiverAdd"; + /** 删除分账方 */ + String ALLOCATION_RECEIVER_REMOVE = "allocationReceiverRemove"; + /** 查询分账方 */ + String ALLOCATION_RECEIVER_QUERY = "allocationReceiverQuery"; + diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/PayGatewayNoticeController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/PayNoticeReceiverController.java similarity index 95% rename from daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/PayGatewayNoticeController.java rename to daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/PayNoticeReceiverController.java index 2caac728..e9fef5a3 100644 --- a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/PayGatewayNoticeController.java +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/PayNoticeReceiverController.java @@ -22,7 +22,7 @@ import java.util.Objects; @RestController @RequestMapping("/gateway/notice") @RequiredArgsConstructor -public class PayGatewayNoticeController { +public class PayNoticeReceiverController { @Operation(summary = "支付宝消息通知") @PostMapping("/alipay") @@ -35,4 +35,5 @@ public class PayGatewayNoticeController { public Map wechatPayNotice() { return new HashMap<>(); } + } diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniAllocationController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniAllocationController.java new file mode 100644 index 00000000..9ac21eb1 --- /dev/null +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniAllocationController.java @@ -0,0 +1,79 @@ +package cn.daxpay.single.gateway.controller; + +import cn.daxpay.single.code.PaymentApiCode; +import cn.daxpay.single.param.payment.allocation.AllocationFinishParam; +import cn.daxpay.single.param.payment.allocation.AllocationStartParam; +import cn.daxpay.single.result.DaxResult; +import cn.daxpay.single.result.allocation.AllocationResult; +import cn.daxpay.single.service.annotation.PaymentApi; +import cn.daxpay.single.service.core.payment.allocation.service.AllocationReceiverService; +import cn.daxpay.single.service.core.payment.allocation.service.AllocationService; +import cn.daxpay.single.service.param.allocation.group.AllocationReceiverParam; +import cn.daxpay.single.util.DaxRes; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 分账控制器 + * @author xxm + * @since 2024/5/17 + */ +@Tag(name = "分账控制器") +@RestController +@RequestMapping("/unipay/allocation") +@RequiredArgsConstructor +public class UniAllocationController { + + private final AllocationService allocationService; + + private final AllocationReceiverService receiverService; + + @PaymentApi(PaymentApiCode.ALLOCATION) + @Operation(summary = "触发分账接口") + @PostMapping("/open") + public DaxResult open(@RequestBody AllocationStartParam param){ + return DaxRes.ok(allocationService.allocation(param)); + } + + @PaymentApi(PaymentApiCode.ALLOCATION_FINISH) + @Operation(summary = "分账完结接口") + @PostMapping("/finish") + public DaxResult finish(@RequestBody AllocationFinishParam param){ + allocationService.finish(param); + return DaxRes.ok(); + } + + @PaymentApi(PaymentApiCode.ALLOCATION_RECEIVER_QUERY) + @Operation(summary = "分账接收方查询接口") + @PostMapping("/allocationReceiverQuery") + public DaxResult allocationReceiverQuery(@RequestBody AllocationReceiverParam param){ + return DaxRes.ok(); + } + + @PaymentApi(PaymentApiCode.ALLOCATION_RECEIVER_ADD) + @Operation(summary = "添加分账接收方接口") + @PostMapping("/allocationReceiverAdd") + public DaxResult allocationReceiverAdd(@RequestBody AllocationReceiverParam param){ + return DaxRes.ok(); + } + + @PaymentApi(PaymentApiCode.ALLOCATION_RECEIVER_REMOVE) + @Operation(summary = "删除分账接收方接口") + @PostMapping("/allocationReceiverRemove") + public DaxResult allocationReceiverRemove(@RequestBody AllocationReceiverParam param){ + return DaxRes.ok(); + } + + @PaymentApi(PaymentApiCode.ALLOCATION_RECEIVER_QUERY) + @Operation(summary = "查询分账接收方接口") + @PostMapping("/allocationReceiverRemoveByGateway") + public DaxResult allocationReceiverRemoveByGateway(@RequestBody AllocationReceiverParam param){ + return DaxRes.ok(); + } + +} diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java index 9a552883..2913b81c 100644 --- a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPayController.java @@ -2,21 +2,17 @@ package cn.daxpay.single.gateway.controller; import cn.bootx.platform.common.core.annotation.IgnoreAuth; import cn.daxpay.single.code.PaymentApiCode; -import cn.daxpay.single.param.payment.allocation.AllocationFinishParam; -import cn.daxpay.single.param.payment.allocation.AllocationStartParam; import cn.daxpay.single.param.payment.pay.PayCloseParam; import cn.daxpay.single.param.payment.pay.PayParam; import cn.daxpay.single.param.payment.pay.PaySyncParam; import cn.daxpay.single.param.payment.refund.RefundParam; import cn.daxpay.single.param.payment.refund.RefundSyncParam; import cn.daxpay.single.result.DaxResult; -import cn.daxpay.single.result.allocation.AllocationResult; import cn.daxpay.single.result.pay.PayCloseResult; import cn.daxpay.single.result.pay.PayResult; import cn.daxpay.single.result.pay.RefundResult; import cn.daxpay.single.result.pay.SyncResult; import cn.daxpay.single.service.annotation.PaymentApi; -import cn.daxpay.single.service.core.payment.allocation.service.AllocationService; import cn.daxpay.single.service.core.payment.close.service.PayCloseService; import cn.daxpay.single.service.core.payment.pay.service.PayService; import cn.daxpay.single.service.core.payment.refund.service.RefundService; @@ -47,7 +43,6 @@ public class UniPayController { private final PaySyncService paySyncService; private final PayCloseService payCloseService; private final RefundSyncService refundSyncService; - private final AllocationService allocationService; @PaymentApi(PaymentApiCode.PAY) @@ -85,21 +80,4 @@ public class UniPayController { return DaxRes.ok(refundSyncService.sync(param)); } - @PaymentApi(PaymentApiCode.ALLOCATION) - @Operation(summary = "开启分账接口") - @PostMapping("/allocation") - public DaxResult allocation(@RequestBody AllocationStartParam param){ - return DaxRes.ok(allocationService.allocation(param)); - } - - @PaymentApi(PaymentApiCode.ALLOCATION_FINISH) - @Operation(summary = "分账完结接口") - @PostMapping("/allocationFinish") - public DaxResult allocationFinish(@RequestBody AllocationFinishParam param){ - allocationService.finish(param); - return DaxRes.ok(); - } - - - } diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniReconcileController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniReconcileController.java new file mode 100644 index 00000000..f557849c --- /dev/null +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniReconcileController.java @@ -0,0 +1,34 @@ +package cn.daxpay.single.gateway.controller; + +import cn.daxpay.single.code.PaymentApiCode; +import cn.daxpay.single.param.payment.pay.PayParam; +import cn.daxpay.single.result.DaxResult; +import cn.daxpay.single.service.annotation.PaymentApi; +import cn.daxpay.single.util.DaxRes; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 对账相关接口 + * @author xxm + * @since 2024/5/17 + */ +@Tag(name = "对账接口处理器") +@RestController +@RequestMapping("/unipay/reconcile") +@RequiredArgsConstructor +public class UniReconcileController { + + @PaymentApi(PaymentApiCode.PAY) + @Operation(summary = "下载指定日期的资金流水") + @PostMapping("/pay") + public DaxResult down(@RequestBody PayParam payParam){ + return DaxRes.ok(); + } + +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java index 75fd19a2..0cf73cd6 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/dao/PayOrderManager.java @@ -99,4 +99,13 @@ public class PayOrderManager extends BaseManager { return baseMapper.getTalAmount(generator); } + /** + * 查询当前超时的未支付订单 + */ + public List queryExpiredOrder() { + return lambdaQuery() + .eq(PayOrder::getStatus, PayStatusEnum.REFUNDING.getCode()) + .lt(PayOrder::getExpiredTime, LocalDateTime.now()) + .list(); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/service/PayOrderQueryService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/service/PayOrderQueryService.java index af21e2b1..7d5b592d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/service/PayOrderQueryService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/order/pay/service/PayOrderQueryService.java @@ -92,6 +92,7 @@ public class PayOrderQueryService { return PayOrderConvert.CONVERT.convertResult(payOrder); } + /** * 查询支付总金额 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java index 4084a63c..da28450a 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/pay/service/PayService.java @@ -11,6 +11,7 @@ import cn.daxpay.single.service.core.order.pay.entity.PayOrderExtra; import cn.daxpay.single.service.core.order.pay.service.PayOrderService; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; import cn.daxpay.single.service.core.payment.pay.factory.PayStrategyFactory; +import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; import cn.daxpay.single.service.func.AbsPayStrategy; import cn.daxpay.single.util.PayUtil; import cn.hutool.extra.spring.SpringUtil; @@ -45,6 +46,8 @@ public class PayService { private final PayOrderExtraManager payOrderExtraManager; + private final TradeFlowRecordService tradeFlowRecordService; + private final LockTemplate lockTemplate; /** @@ -129,8 +132,9 @@ public class PayService { payOrder.setErrorCode(null); payOrder.setErrorMsg(null); payOrderService.updateById(payOrder); - // 如果支付完成 发送通知 + // 如果支付完成 发送通知, 记录流水 if (Objects.equals(payOrder.getStatus(), SUCCESS.getCode())){ + tradeFlowRecordService.savePay(payOrder); clientNoticeService.registerPayNotice(payOrder, payInfo.getPayOrderExtra()); } return payAssistService.buildResult(payOrder); @@ -181,8 +185,9 @@ public class PayService { payOrder.setErrorMsg(null); payOrder.setErrorCode(null); payOrderService.updateById(payOrder); - // 如果支付完成 发送通知 + // 如果支付完成 发送通知, 记录流水 if (Objects.equals(payOrder.getStatus(), SUCCESS.getCode())){ + tradeFlowRecordService.savePay(payOrder); clientNoticeService.registerPayNotice(payOrder, payOrderExtra); } return payAssistService.buildResult(payOrder); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java index 059da5de..3f15365b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/refund/service/RefundService.java @@ -19,6 +19,7 @@ import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; import cn.daxpay.single.service.core.order.refund.entity.RefundOrderExtra; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; import cn.daxpay.single.service.core.payment.refund.factory.RefundStrategyFactory; +import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; import cn.daxpay.single.service.func.AbsRefundStrategy; import cn.hutool.extra.spring.SpringUtil; import cn.hutool.json.JSONUtil; @@ -54,6 +55,8 @@ public class RefundService { private final PayOrderQueryService payOrderQueryService; + private final TradeFlowRecordService tradeFlowRecordService; + private final RefundOrderExtraManager refundOrderExtraManager; private final LockTemplate lockTemplate; @@ -199,16 +202,23 @@ public class RefundService { */ @Transactional(rollbackFor = Exception.class) public void successHandler(RefundOrder refundOrder, PayOrder payOrder) { - RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo(); + RefundLocal refundInfo = PaymentContextLocal.get() + .getRefundInfo(); // 剩余可退款余额 int refundableBalance = payOrder.getRefundableBalance(); - // 设置支付订单状态 + // 退款状态为退款中 if (refundInfo.getStatus() == RefundStatusEnum.PROGRESS) { payOrder.setStatus(PayStatusEnum.REFUNDING.getCode()); - } else if (refundableBalance == 0) { - payOrder.setStatus(PayStatusEnum.REFUNDED.getCode()); - } else { - payOrder.setStatus(PayStatusEnum.PARTIAL_REFUND.getCode()); + } + // 退款状态为成功 + else { + if (refundableBalance == 0) { + payOrder.setStatus(PayStatusEnum.REFUNDED.getCode()); + } else { + payOrder.setStatus(PayStatusEnum.PARTIAL_REFUND.getCode()); + } + // 记录流水 + tradeFlowRecordService.saveRefund(refundOrder); } payOrderService.updateById(payOrder); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java index d9caab51..c9f1a866 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/PayRepairService.java @@ -10,6 +10,7 @@ import cn.daxpay.single.service.core.order.pay.service.PayOrderService; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; import cn.daxpay.single.service.core.payment.repair.factory.PayRepairStrategyFactory; import cn.daxpay.single.service.core.payment.repair.result.PayRepairResult; +import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; import cn.daxpay.single.service.core.record.repair.entity.PayRepairRecord; import cn.daxpay.single.service.core.record.repair.service.PayRepairRecordService; import cn.daxpay.single.service.func.AbsPayRepairStrategy; @@ -41,6 +42,7 @@ public class PayRepairService { private final PayRepairRecordService recordService; private final LockTemplate lockTemplate; + private final TradeFlowRecordService tradeFlowRecordService; /** * 修复支付单 @@ -117,6 +119,7 @@ public class PayRepairService { order.setStatus(PayStatusEnum.SUCCESS.getCode()) .setPayTime(payTime) .setCloseTime(null); + tradeFlowRecordService.savePay(order); payOrderService.updateById(order); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java index 537a586b..a6563fe4 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/repair/service/RefundRepairService.java @@ -13,6 +13,7 @@ import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager; import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; import cn.daxpay.single.service.core.payment.notice.service.ClientNoticeService; import cn.daxpay.single.service.core.payment.repair.result.RefundRepairResult; +import cn.daxpay.single.service.core.record.flow.service.TradeFlowRecordService; import cn.daxpay.single.service.core.record.repair.entity.PayRepairRecord; import cn.daxpay.single.service.core.record.repair.service.PayRepairRecordService; import cn.daxpay.single.util.OrderNoGenerateUtil; @@ -49,6 +50,7 @@ public class RefundRepairService { private final PayRepairRecordService recordService; private final LockTemplate lockTemplate; + private final TradeFlowRecordService tradeFlowRecordService; /** * 修复退款单 @@ -113,11 +115,13 @@ public class RefundRepairService { .setFinishTime(repairInfo.getFinishTime()); payOrder.setStatus(afterPayRefundStatus.getCode()); - // 更新订单和退款相关订单 payOrderService.updateById(payOrder); refundOrderManager.updateById(refundOrder); + // 记录流水 + tradeFlowRecordService.saveRefund(refundOrder); + // 发送通知 List list = Arrays.asList(RefundStatusEnum.SUCCESS.getCode(), RefundStatusEnum.CLOSE.getCode(), RefundStatusEnum.FAIL.getCode()); if (list.contains(refundOrder.getStatus())){ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/convert/TradeFlowRecordConvert.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/convert/TradeFlowRecordConvert.java index 6440e477..93e4af38 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/convert/TradeFlowRecordConvert.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/convert/TradeFlowRecordConvert.java @@ -1,6 +1,9 @@ package cn.daxpay.single.service.core.record.flow.convert; +import cn.daxpay.single.service.core.record.flow.entity.TradeFlowRecord; +import cn.daxpay.single.service.dto.record.flow.TradeFlowRecordDto; import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; /** * @@ -9,4 +12,7 @@ import org.mapstruct.Mapper; */ @Mapper public interface TradeFlowRecordConvert { + TradeFlowRecordConvert CONVERT = Mappers.getMapper(TradeFlowRecordConvert.class); + + TradeFlowRecordDto convert(TradeFlowRecord entity); } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/dao/TradeFlowRecordManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/dao/TradeFlowRecordManager.java index c6ee7e11..67979917 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/dao/TradeFlowRecordManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/dao/TradeFlowRecordManager.java @@ -1,7 +1,13 @@ package cn.daxpay.single.service.core.record.flow.dao; +import cn.bootx.platform.common.core.rest.param.PageParam; import cn.bootx.platform.common.mybatisplus.impl.BaseManager; +import cn.bootx.platform.common.mybatisplus.util.MpUtil; +import cn.bootx.platform.common.query.generator.QueryGenerator; import cn.daxpay.single.service.core.record.flow.entity.TradeFlowRecord; +import cn.daxpay.single.service.param.record.TradeFlowRecordQuery; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Repository; @@ -15,4 +21,13 @@ import org.springframework.stereotype.Repository; @Repository @RequiredArgsConstructor public class TradeFlowRecordManager extends BaseManager { + + /** + * 分页 + */ + public Page page(PageParam pageParam, TradeFlowRecordQuery param){ + Page mpPage = MpUtil.getMpPage(pageParam, TradeFlowRecord.class); + QueryWrapper generator = QueryGenerator.generator(param); + return page(mpPage, generator); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/entity/TradeFlowRecord.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/entity/TradeFlowRecord.java index 843d0afc..a432dc46 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/entity/TradeFlowRecord.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/entity/TradeFlowRecord.java @@ -1,16 +1,17 @@ package cn.daxpay.single.service.core.record.flow.entity; +import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpCreateEntity; +import cn.bootx.table.modify.annotation.DbColumn; import cn.daxpay.single.code.PayChannelEnum; import cn.daxpay.single.service.code.TradeFlowRecordTypeEnum; -import cn.bootx.table.modify.annotation.DbColumn; +import cn.daxpay.single.service.core.record.flow.convert.TradeFlowRecordConvert; +import cn.daxpay.single.service.dto.record.flow.TradeFlowRecordDto; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -import java.time.LocalDateTime; - /** * 资金流水记录 * @author xxm @@ -20,8 +21,9 @@ import java.time.LocalDateTime; @Data @Accessors(chain = true) @Schema(title = "资金流水记录") -public class TradeFlowRecord extends MpCreateEntity { - /** 支付订单标题 */ +public class TradeFlowRecord extends MpCreateEntity implements EntityBaseFunction { + + /** 订单标题 */ @DbColumn(comment = "标题") private String title; @@ -55,7 +57,8 @@ public class TradeFlowRecord extends MpCreateEntity { @DbColumn(comment = "三方系统交易号") private String outTradeNo; - /** 网关完成时间 */ - @DbColumn(comment = "网关完成时间") - private LocalDateTime finishTime; + @Override + public TradeFlowRecordDto toDto() { + return TradeFlowRecordConvert.CONVERT.convert(this); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/service/TradeFlowRecordService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/service/TradeFlowRecordService.java index fc388539..622b67a0 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/service/TradeFlowRecordService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/record/flow/service/TradeFlowRecordService.java @@ -1,5 +1,16 @@ package cn.daxpay.single.service.core.record.flow.service; +import cn.bootx.platform.common.core.exception.DataNotExistException; +import cn.bootx.platform.common.core.rest.PageResult; +import cn.bootx.platform.common.core.rest.param.PageParam; +import cn.bootx.platform.common.mybatisplus.util.MpUtil; +import cn.daxpay.single.service.code.TradeFlowRecordTypeEnum; +import cn.daxpay.single.service.core.order.pay.entity.PayOrder; +import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; +import cn.daxpay.single.service.core.record.flow.dao.TradeFlowRecordManager; +import cn.daxpay.single.service.core.record.flow.entity.TradeFlowRecord; +import cn.daxpay.single.service.dto.record.flow.TradeFlowRecordDto; +import cn.daxpay.single.service.param.record.TradeFlowRecordQuery; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -13,4 +24,53 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class TradeFlowRecordService { + private final TradeFlowRecordManager tradeFlowRecordManager; + + /** + * 分页 + */ + public PageResult page(PageParam pageParam, TradeFlowRecordQuery query){ + return MpUtil.convert2DtoPageResult(tradeFlowRecordManager.page(pageParam, query)); + } + + /** + * 查询详情 + */ + public TradeFlowRecordDto findById(Long id){ + return tradeFlowRecordManager.findById(id).map(TradeFlowRecord::toDto) + .orElseThrow(()->new DataNotExistException("交易流水记录不存在")); + } + + /** + * 支付记账 + */ + public void savePay(PayOrder payOrder){ + TradeFlowRecord tradeFlowRecord = new TradeFlowRecord() + .setTradeNo(payOrder.getOrderNo()) + .setBizTradeNo(payOrder.getBizOrderNo()) + .setOutTradeNo(payOrder.getOutOrderNo()) + .setChannel(payOrder.getChannel()) + .setTitle(payOrder.getTitle()) + .setType(TradeFlowRecordTypeEnum.PAY.getCode()) + .setAmount(payOrder.getAmount()); + tradeFlowRecordManager.save(tradeFlowRecord); + + } + + /** + * 退款记账 + */ + public void saveRefund(RefundOrder refundOrder){ + TradeFlowRecord tradeFlowRecord = new TradeFlowRecord() + .setTradeNo(refundOrder.getRefundNo()) + .setBizTradeNo(refundOrder.getBizRefundNo()) + .setOutTradeNo(refundOrder.getOutRefundNo()) + .setChannel(refundOrder.getChannel()) + .setTitle(refundOrder.getTitle()) + .setType(TradeFlowRecordTypeEnum.PAY.getCode()) + .setAmount(refundOrder.getAmount()); + tradeFlowRecordManager.save(tradeFlowRecord); + } + } + diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/flow/TradeFlowRecordDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/flow/TradeFlowRecordDto.java new file mode 100644 index 00000000..31a49fbd --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/dto/record/flow/TradeFlowRecordDto.java @@ -0,0 +1,53 @@ +package cn.daxpay.single.service.dto.record.flow; + +import cn.bootx.table.modify.annotation.DbColumn; +import cn.daxpay.single.code.PayChannelEnum; +import cn.daxpay.single.service.code.TradeFlowRecordTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 资金流水记录 + * @author xxm + * @since 2024/5/17 + */ +@Data +@Accessors(chain = true) +@Schema(title = "资金流水记录") +public class TradeFlowRecordDto { + + /** 订单标题 */ + @DbColumn(comment = "标题") + private String title; + + /** 金额 */ + @DbColumn(comment = "金额") + private Integer amount; + + /** + * 业务类型 + * @see TradeFlowRecordTypeEnum + */ + @DbColumn(comment = "业务类型") + private String type; + + /** + * 支付通道 + * @see PayChannelEnum + */ + @DbColumn(comment = "支付通道") + private String channel; + + /** 本地交易号 */ + @DbColumn(comment = "本地订单号") + private String tradeNo; + + /** 商户交易号 */ + @DbColumn(comment = "商户交易号") + private String bizTradeNo; + + /** 三方系统交易号 */ + @DbColumn(comment = "三方系统交易号") + private String outTradeNo; +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/TradeFlowRecordQuery.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/TradeFlowRecordQuery.java new file mode 100644 index 00000000..f1927824 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/record/TradeFlowRecordQuery.java @@ -0,0 +1,18 @@ +package cn.daxpay.single.service.param.record; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 流水记录查询类 + * @author xxm + * @since 2024/5/17 + */ +@Data +@Accessors(chain = true) +@Schema(title = "流水记录查询类") +public class TradeFlowRecordQuery { + + +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredByDbTimeTask.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredByDbTimeTask.java new file mode 100644 index 00000000..e7251c83 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredByDbTimeTask.java @@ -0,0 +1,45 @@ +package cn.daxpay.single.service.task; + +import cn.daxpay.single.service.core.order.pay.dao.PayOrderManager; +import cn.daxpay.single.service.core.order.pay.entity.PayOrder; +import cn.daxpay.single.service.core.payment.sync.service.PaySyncService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.quartz.DisallowConcurrentExecution; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.PersistJobDataAfterExecution; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * + * @author xxm + * @since 2024/5/17 + */ +@Slf4j +@Component +@DisallowConcurrentExecution +@PersistJobDataAfterExecution +@RequiredArgsConstructor +public class PayExpiredByDbTimeTask implements Job { + + private final PaySyncService paySyncService; + + private final PayOrderManager payOrderManager; + + @Override + public void execute(JobExecutionContext context) { + // 从数据库查询获取超时的任务对象 + List payOrders = payOrderManager.queryExpiredOrder(); + for (PayOrder order : payOrders) { + try { + // 设置补偿来源为定时任务 + paySyncService.syncPayOrder(order); + } catch (Exception e) { + log.error("超时取消任务 异常", e); + } + } + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredTimeTask.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredTimeTask.java index fed0b5df..8aa25d81 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredTimeTask.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/PayExpiredTimeTask.java @@ -9,21 +9,25 @@ import com.baomidou.lock.LockInfo; import com.baomidou.lock.LockTemplate; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; -import org.springframework.stereotype.Service; +import org.quartz.PersistJobDataAfterExecution; +import org.springframework.stereotype.Component; import java.time.LocalDateTime; import java.util.Objects; import java.util.Set; /** - * 支付超时处理 + * 支付超时处理(手动注册) * @author xxm * @since 2024/1/2 */ @Slf4j -@Service +@Component +@DisallowConcurrentExecution +@PersistJobDataAfterExecution @RequiredArgsConstructor public class PayExpiredTimeTask implements Job { private final PayExpiredTimeRepository repository; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/ReconcileTask.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/ReconcileTask.java index 95c73d52..53eaf6b9 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/ReconcileTask.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/ReconcileTask.java @@ -1,6 +1,7 @@ package cn.daxpay.single.service.task; -import cn.daxpay.single.service.task.service.ReconcileTaskService; +import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileOrder; +import cn.daxpay.single.service.core.payment.reconcile.service.ReconcileService; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import lombok.Getter; @@ -24,7 +25,7 @@ import java.util.Objects; @PersistJobDataAfterExecution @RequiredArgsConstructor public class ReconcileTask implements Job { - private final ReconcileTaskService reconcileTaskService; + private final ReconcileService reconcileService; /** * 任务参数, 格式 @@ -37,7 +38,7 @@ public class ReconcileTask implements Job { * 任务实现 */ @Override - public void execute(JobExecutionContext context) throws JobExecutionException { + public void execute(JobExecutionContext context) { if (StrUtil.isBlank(parameter)){ log.warn("传输参数为空"); return; @@ -50,9 +51,26 @@ public class ReconcileTask implements Job { } else { date = date.minusDays(1); } - reconcileTaskService.reconcileTask(date,bean.channel); + this.reconcileTask(date,bean.channel); } + + /** + * 执行任务 + */ + public void reconcileTask(LocalDate date, String channel){ + + // 1. 查询需要定时对账的通道, 创建出来对账订单 + ReconcileOrder reconcileOrder = reconcileService.create(date, channel); + + // 2. 执行对账任务, 下载对账单并解析, 分别存储为原始数据和通用对账数据 + reconcileService.downAndSave(reconcileOrder); + + // 3. 执行账单明细比对, 生成差异单 + reconcileService.compare(reconcileOrder); + } + + /** * 接收参数 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/RefundSyncTask.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/RefundSyncTask.java index 3c09ab0f..9f899904 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/RefundSyncTask.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/RefundSyncTask.java @@ -1,11 +1,15 @@ package cn.daxpay.single.service.task; -import cn.daxpay.single.service.task.service.RefundSyncTaskService; +import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager; +import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; +import cn.daxpay.single.service.core.payment.sync.service.RefundSyncService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.quartz.*; import org.springframework.stereotype.Component; +import java.util.List; + /** * 退款定时同步任务 一分钟一次, 查询退款中的订单进行同步 * @author xxm @@ -18,10 +22,22 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor public class RefundSyncTask implements Job { - private final RefundSyncTaskService refundSyncTaskService; + private final RefundSyncService refundSyncService; + + private final RefundOrderManager refundOrderManager; @Override public void execute(JobExecutionContext context) throws JobExecutionException { - refundSyncTaskService.syncTask(); + // 查询退款中的退款订单 + List list = refundOrderManager.findAllByProgress(); + for (RefundOrder refundOrder : list) { + try { + // 调用同步方法 + refundSyncService.syncRefundOrder(refundOrder); + } catch (Exception e) { + log.warn("退款执行同步失败, ID: {}",refundOrder.getId()); + log.warn("退款执行同步失败",e); + } + } } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/service/ReconcileTaskService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/service/ReconcileTaskService.java deleted file mode 100644 index 8b641ee4..00000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/service/ReconcileTaskService.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.daxpay.single.service.task.service; - -import cn.daxpay.single.service.core.order.reconcile.entity.ReconcileOrder; -import cn.daxpay.single.service.core.payment.reconcile.service.ReconcileService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.time.LocalDate; - -/** - * 支付对账定时任务服务类 - * @author xxm - * @since 2024/1/20 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class ReconcileTaskService { - private final ReconcileService reconcileService; - - /** - * 执行任务 - */ - public void reconcileTask(LocalDate date, String channel){ - - // 1. 查询需要定时对账的通道, 创建出来对账订单 - ReconcileOrder reconcileOrder = reconcileService.create(date, channel); - - // 2. 执行对账任务, 下载对账单并解析, 分别存储为原始数据和通用对账数据 - reconcileService.downAndSave(reconcileOrder); - - // 3. 执行账单明细比对, 生成差异单 - reconcileService.compare(reconcileOrder); - } - -} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/service/RefundSyncTaskService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/service/RefundSyncTaskService.java deleted file mode 100644 index 5a1553ef..00000000 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/task/service/RefundSyncTaskService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.daxpay.single.service.task.service; - -import cn.daxpay.single.service.core.order.refund.dao.RefundOrderManager; -import cn.daxpay.single.service.core.order.refund.entity.RefundOrder; -import cn.daxpay.single.service.core.payment.sync.service.RefundSyncService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 定时 - * @author xxm - * @since 2024/3/12 - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class RefundSyncTaskService { - - private final RefundSyncService refundSyncService; - - private final RefundOrderManager refundOrderManager; - - /** - * 同步任务 - */ - public void syncTask(){ - // 查询退款中的退款订单 - List list = refundOrderManager.findAllByProgress(); - for (RefundOrder refundOrder : list) { - try { - // 调用同步方法 - refundSyncService.syncRefundOrder(refundOrder); - } catch (Exception e) { - log.warn("退款执行同步失败, ID: {}",refundOrder.getId()); - log.warn("退款执行同步失败",e); - } - } - } -}