diff --git a/_doc/Task.md b/_doc/Task.md index bbddbe5e6..6e2527830 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -9,8 +9,10 @@ - [ ] 微信新增V3版本接口 - [ ] 付款码回退到V2接口 - [ ] 增加转账功能 + - [ ] 支付宝 + - [ ] 微信 - [ ] 云闪付支持对账功能 -- [ ] 结算台DEMO增加云闪付示例 +- [x] 结算台DEMO增加云闪付示例 2.0.x 版本内容 - [ ] 统一关闭接口增加使用撤销关闭订单 diff --git a/_doc/pay/支付业务时序图.puml b/_doc/pay/支付业务时序图.puml new file mode 100644 index 000000000..23807444c --- /dev/null +++ b/_doc/pay/支付业务时序图.puml @@ -0,0 +1,17 @@ +@startuml +autonumber + +actor 客户 as khd +participant 控制器 as kzq +participant 服务类 as fwl +participant DAO as dao + +khd -> kzq: 发送请求 +skinparam responseMessageBelowArrow true +kzq --> fwl ++: 组装参数 +fwl --> kzq ++: 返回功能 +kzq --> fwl --: 继续查询 +kzq --> kzq: 继续查询 +fwl --> dao ++ : 数据查询 +dao --> fwl: 查询 +@enduml diff --git a/_doc/pay/支付代码时序图-重复调起支付.puml b/_doc/pay/支付代码时序图-重复调起支付.puml new file mode 100644 index 000000000..23807444c --- /dev/null +++ b/_doc/pay/支付代码时序图-重复调起支付.puml @@ -0,0 +1,17 @@ +@startuml +autonumber + +actor 客户 as khd +participant 控制器 as kzq +participant 服务类 as fwl +participant DAO as dao + +khd -> kzq: 发送请求 +skinparam responseMessageBelowArrow true +kzq --> fwl ++: 组装参数 +fwl --> kzq ++: 返回功能 +kzq --> fwl --: 继续查询 +kzq --> kzq: 继续查询 +fwl --> dao ++ : 数据查询 +dao --> fwl: 查询 +@enduml diff --git a/_doc/pay/支付代码时序图-首次支付.puml b/_doc/pay/支付代码时序图-首次支付.puml new file mode 100644 index 000000000..103cec56a --- /dev/null +++ b/_doc/pay/支付代码时序图-首次支付.puml @@ -0,0 +1,42 @@ +@startuml +autonumber +skinparam responseMessageBelowArrow true + +title 支付代码时序图-以支付宝支付为例 + +actor 客户端 as Client +participant PayService +participant PayOrderService +participant PayAssistService +participant AliPayStrategy +participant PayStrategyFactory +participant AliPayService +participant ClientNoticeService + +Client -> PayService: 发送请求 +PayService --> PayAssistService: 校验支付状态 +PayService --> PayAssistService: 初始化上下文 +PayService -> PayService: 调用首次支付方法 +PayService -> PayAssistService: 创建支付订单和扩展记录并保存 +PayService <- PayAssistService: 返回支付订单对象 +PayService -> PayService: 调用支付方法进行发起支付 +PayService -> PayStrategyFactory: 通过工厂生成对应的策略组 +PayService <- PayStrategyFactory: 返回支付策略组 +PayService -> AliPayStrategy: 执行支付前处理动作 +AliPayStrategy --> AliPayStrategy: 支付宝参数验证和反序列化通道支付参数 +AliPayStrategy -> AliPayService: 检查并获取支付宝配置, 同时校验支付相关信息 +AliPayStrategy <- AliPayService: 返回检查结果和支付配置 +PayService <- AliPayStrategy: 支付前处理完成 +AliPayStrategy -> AliPayService: 调用网关接口进行进行支付 +AliPayService -> 支付宝支付网关: 根据情况调用对应类型的支付 +AliPayService <- 支付宝支付网关: 返回支付调用结果 +AliPayStrategy <- AliPayService: 返回支付结构体或者支付结果(写到现成变量中) +PayService <- AliPayStrategy: 支付调用完成 +PayService -> AliPayStrategy: 进行支付调用成功后处理 +AliPayStrategy --> ChannelOrderService: 保存通道支付订单 +AliPayStrategy --> ChannelOrderService: 如果已经支付完成, 保存流水记录 +PayService <- AliPayStrategy: 处理完成 +PayService --> ClientNoticeService: 如果支付成功, 发送通知 +Client <- PayService: 返回支付结果 + +@enduml diff --git a/_doc/reconcile/对账代码时序图-支付宝.puml b/_doc/reconcile/对账代码时序图-支付宝.puml new file mode 100644 index 000000000..0361fc74e --- /dev/null +++ b/_doc/reconcile/对账代码时序图-支付宝.puml @@ -0,0 +1,64 @@ +@startuml + +title 对账代码时序图-以支付宝对账为例 + +skinparam responseMessageBelowArrow true + +actor 客户端 as Client +participant ReconcileService +participant ReconcileOrderService +participant ReconcileStrategy +participant AliPayReconcileService +participant ReconcileDiffService +participant ReconcileOrderManager +participant ReconcileContext +participant ReconcileDetailManager +participant ReconcileStrategyFactory +participant AliGateway as 支付宝网关 + +autonumber +Client -> ReconcileService: 发起对账请求 + +group 1. 创建对账订单 + autonumber 1 + ReconcileService -> ReconcileStrategyFactory: 构建对账策略 + ReconcileService <- ReconcileStrategyFactory: 返回对账策略对象 + ReconcileService -> ReconcileStrategy: 生成批次号 + ReconcileService <- ReconcileStrategy: 返回批次号 + ReconcileService -> ReconcileService: 创建对账订单 + ReconcileService -> ReconcileOrderManager: 保存对账订单 + ReconcileService <- ReconcileOrderManager: 返回对账订单 +end + +group 2. 下载对账单并进行保存 + autonumber 1 + ReconcileService -> ReconcileStrategyFactory: 构建对账策略 + ReconcileService <- ReconcileStrategyFactory: 返回对账策略对象 + ReconcileService -> ReconcileStrategy: 下载对账单, 并进行解析进行保存 + ReconcileStrategy -> AliPayReconcileService: 发起对账单下载请求,获取对账单下载地址 + AliPayReconcileService -> AliGateway: 发起对账单下载请求,获取对账单下载地址 + AliPayReconcileService <- AliGateway: 返回对账单下载地址 + AliPayReconcileService -> AliGateway: 下载对账单 + AliPayReconcileService <- AliGateway: 返回对账单内容 + AliPayReconcileService -> AliPayReconcileService: 解析对账单, 同时生成通用对账单记录 + AliPayReconcileService --> ReconcileContext: 将解析后的通用对账单记录放到到上下文 + ReconcileStrategy <- AliPayReconcileService: 处理结束 + ReconcileService <- ReconcileStrategy: 处理结束 + ReconcileService <- ReconcileContext: 获取通用对账单记录 + ReconcileService --> reconcileDetailManager: 保存明细记录 +end + +group 3. 对账单比对 + autonumber 1 + ReconcileService -> ReconcileStrategyFactory: 构建对账策略 + ReconcileService <- ReconcileStrategyFactory: 返回对账策略对象 + ReconcileService <--> ReconcileStrategy: 初始对账策略类 + ReconcileService <- ReconcileStrategy: 获取本地和网关订单数据 + ReconcileService -> ReconcileService: 比对本地和网关订单差异 + ReconcileService --> ReconcileDiffService: 保存差异记录 + +end +autonumber 2 +Client <- ReconcileService: 返回对账结束 + +@enduml diff --git a/_doc/refund/退款代码时序图-全部退款.puml b/_doc/refund/退款代码时序图-全部退款.puml new file mode 100644 index 000000000..1a723bad5 --- /dev/null +++ b/_doc/refund/退款代码时序图-全部退款.puml @@ -0,0 +1,76 @@ +@startuml + +autonumber +skinparam responseMessageBelowArrow true + +title 退款代码时序图-以支付宝退款全部退款为例 + +actor 客户端 as Client +participant RefundService +participant RefundStrategyFactory +participant AliRefundStrategy +participant RefundAssistService +participant AlipayConfigService +participant AliRefundService +participant PayOrderService +participant PayChannelOrderManager +participant PayChannelOrderService +participant AliRecordService +participant ClientNoticeService +participant 支付宝网关 as AlliGateway + +Client -> RefundService: 发起退款请求 + +group 1. 退款发起前准备 +autonumber 1 +RefundService -> RefundService: 使用适配方法发起全部退款 +RefundService <- RefundAssistService: 获取支付订单 +RefundService --> RefundAssistService: 检查退款参数, 同时补充一些数据 +RefundService --> RefundAssistService: 上下文初始化 + +RefundService -> RefundStrategyFactory: 通过工厂生成对应的策略组 +RefundService <- RefundStrategyFactory: 返回支付策略组 + +RefundService --> AliRefundStrategy: 初始化退款策略的参数 +AliRefundStrategy --> AliRefundStrategy: 执行初始化退款策略的参数 + +RefundService --> AliRefundStrategy: 退款前校验操作 +RefundService --> AliRefundStrategy: 生成通道退款订单对象 + +RefundService --> PayChannelOrderManager: 预扣支付相关订单要退款的金额并进行更新 +RefundService --> PayOrderService: 更新支付订单退款状态 +RefundService --> RefundAssistService: 创建退款相关订单,并对数据进行持久化保存 + +end + +group 2. 退款操作 +autonumber 1 + +RefundService -> AliRefundStrategy: 退款前准备操作 +AliRefundStrategy --> AlipayConfigService: 获取并初始化支付配置信息 +RefundService <- AliRefundStrategy: 退款前准备结束 + +RefundService -> AliRefundStrategy: 执行退款策略 +AliRefundStrategy -> AliRefundService : 执行退款操作 +AliRefundService --> AlliGateway: 发送退款指令 +AliRefundService -> AliRefundStrategy: 返回结果 +RefundService <- AliRefundStrategy: 退款执行结束 + +end + +group 3. 退款发起成功后操作 +autonumber 1 +RefundService -> AliRefundStrategy: 执行退款发起成功后操作 +AliRefundStrategy --> AliRefundStrategy: 更新退款订单数据状态 +AliRefundStrategy --> PayChannelOrderService: 更新支付通道订单中的状态属性 +AliRefundStrategy --> AliRecordService: 如果退款完成, 保存流水记录 +RefundService <- AliRefundStrategy: 执行完成 + +RefundService --> PayOrderService: 更新支付订单信息 +RefundService --> RefundAssistService: 更新退款订单和相关通道退款订单 +RefundService --> ClientNoticeService: 如果支付完成发送退款成功通知 + +end +autonumber 2 +Client <- RefundService: 返回退款调用结果 +@enduml diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java index 0a7965197..9e1e860ef 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayReconcileService.java @@ -156,7 +156,6 @@ public class AliPayReconcileService { reconcileDetail.setOrderId(billDetail.getBatchNo()) .setType(ReconcileTradeEnum.REFUND.getCode()); } - return reconcileDetail; } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayReconcileService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayReconcileService.java index d6abb8383..18c126677 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayReconcileService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayReconcileService.java @@ -27,4 +27,11 @@ public class UnionPayReconcileService { // 下载对账单 Map stringObjectMap = unionPayKit.downloadBill(date, RECONCILE_BILL_TYPE); } + + /** + * 转换和保存 + */ + public void convertAndSave(){ + + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java index 3c62062bf..c0733e909 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java @@ -160,7 +160,7 @@ public class PayAssistService { /** * 创建并保存通道支付订单 */ - public void createPayChannelOrder(List payStrategies) { + public void savePayChannelOrder(List payStrategies) { PayLocal payInfo = PaymentContextLocal.get().getPayInfo(); List channelOrders = payStrategies.stream() .map(AbsPayStrategy::getChannelOrder) diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java index be1e1c63c..0444faab1 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java @@ -9,7 +9,6 @@ import cn.bootx.platform.daxpay.result.pay.PayResult; import cn.bootx.platform.daxpay.service.common.context.PayLocal; import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal; import cn.bootx.platform.daxpay.service.core.order.pay.builder.PayBuilder; -import cn.bootx.platform.daxpay.service.core.order.pay.dao.PayChannelOrderManager; import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder; import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrderExtra; import cn.bootx.platform.daxpay.service.core.order.pay.service.PayOrderService; @@ -53,8 +52,6 @@ public class PayService { private final ClientNoticeService clientNoticeService; - private final PayChannelOrderManager payChannelOrderManager; - private final LockTemplate lockTemplate; /** @@ -162,7 +159,7 @@ public class PayService { // 4.2 支付调用成功操作, 进行扣款、创建记录类类似的操作 strategies.forEach(AbsPayStrategy::doSuccessHandler); // 4.3 保存通道支付订单 - payAssistService.createPayChannelOrder(strategies); + payAssistService.savePayChannelOrder(strategies); // 5.1 如果没有异步支付, 直接进行订单完成处理 if (PayUtil.isNotSync(payParam.getPayChannels())) {