From ab7fc45aa141e8d91b35b7156a927efd87c715a8 Mon Sep 17 00:00:00 2001 From: bootx Date: Sun, 26 May 2024 22:48:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E4=B8=80=E4=BA=9B=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=AF=B7=E6=B1=82=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 2 +- .../cn/daxpay/single/code/PaymentApiCode.java | 8 ++- .../param/payment/transfer/TransferParam.java | 19 ++++++ .../controller/UniAllocationController.java | 16 ++--- .../gateway/controller/UniPayController.java | 24 +++---- .../controller/UniPaySyncController.java | 63 +++++++++++++++++++ .../notice/service/PayReturnService.java | 10 +-- .../flow/service/TradeFlowRecordService.java | 1 - .../channel/alipay/AliPayReturnParam.java | 12 ++-- 9 files changed, 114 insertions(+), 41 deletions(-) create mode 100644 daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java create mode 100644 daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPaySyncController.java diff --git a/daxpay-single-start/src/main/resources/application-dev.yml b/daxpay-single-start/src/main/resources/application-dev.yml index 90af7bc6c..b229a1ae1 100644 --- a/daxpay-single-start/src/main/resources/application-dev.yml +++ b/daxpay-single-start/src/main/resources/application-dev.yml @@ -143,7 +143,7 @@ table-modify: update-type: update database-type: mysql fail-fast: true - scan-package: cn.bootx.platform.daxpay + scan-package: cn.daxpay.single dromara: #文件存储配置, x-file-storage: 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 eb305f354..1f319e8a4 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 @@ -14,6 +14,8 @@ public interface PaymentApiCode { String CLOSE = "close"; /** 分账 */ String ALLOCATION = "allocation"; + /** 转账 */ + String TRANSFER = "transfer"; /** 分账完结 */ String ALLOCATION_FINISH = "allocationFinish"; /** 支付同步 */ @@ -22,14 +24,18 @@ public interface PaymentApiCode { String SYNC_REFUND = "syncRefund"; /** 分账同步 */ String SYNC_ALLOCATION = "syncAllocation"; + /** 转账同步 */ + String SYNC_TRANSFER = "syncTransfer"; /** 查询支付订单 */ String QUERY_PAY_ORDER = "queryPayOrder"; /** 查询退款订单 */ String QUERY_REFUND_ORDER = "queryRefundOrder"; /** 查询分账订单 */ String QUERY_ALLOCATION_ORDER = "queryAllocationOrder"; + /** 查询转账订单 */ + String QUERY_TRANSFER_ORDER = "queryTransferOrder"; /** 查询分账接收方 */ - String QUERY_ALLOCATION_RECEIVER = "QueryAllocationReceiver"; + String QUERY_ALLOCATION_RECEIVER = "queryAllocationReceiver"; /** 获取微信授权链接 */ String GET_WX_AUTH_URL = "getWxAuthUrl"; /** 获取微信AccessToken */ diff --git a/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java new file mode 100644 index 000000000..99f50633b --- /dev/null +++ b/daxpay-single/daxpay-single-core/src/main/java/cn/daxpay/single/param/payment/transfer/TransferParam.java @@ -0,0 +1,19 @@ +package cn.daxpay.single.param.payment.transfer; + +import cn.daxpay.single.param.PaymentCommonParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 转账参数 + * @author xxm + * @since 2024/5/26 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +@Schema(title = "转账参数") +public class TransferParam extends PaymentCommonParam { +} 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 index 36484dcf2..6868eb2a4 100644 --- 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 @@ -1,17 +1,18 @@ package cn.daxpay.single.gateway.controller; import cn.daxpay.single.code.PaymentApiCode; -import cn.daxpay.single.param.payment.allocation.*; +import cn.daxpay.single.param.payment.allocation.AllocFinishParam; +import cn.daxpay.single.param.payment.allocation.AllocReceiverAddParam; +import cn.daxpay.single.param.payment.allocation.AllocReceiverRemoveParam; +import cn.daxpay.single.param.payment.allocation.AllocationParam; import cn.daxpay.single.result.DaxResult; import cn.daxpay.single.result.allocation.AllocReceiverAddResult; import cn.daxpay.single.result.allocation.AllocReceiverRemoveResult; import cn.daxpay.single.result.allocation.AllocationResult; -import cn.daxpay.single.result.allocation.AllocationSyncResult; import cn.daxpay.single.service.annotation.PaymentSign; import cn.daxpay.single.service.annotation.PlatformInitContext; 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.core.payment.allocation.service.AllocationSyncService; import cn.daxpay.single.util.DaxRes; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -34,8 +35,6 @@ public class UniAllocationController { private final AllocationService allocationService; - private final AllocationSyncService allocationSyncService; - private final AllocationReceiverService receiverService; @PaymentSign @@ -54,13 +53,6 @@ public class UniAllocationController { return DaxRes.ok(allocationService.finish(param)); } - @PaymentSign - @PlatformInitContext(PaymentApiCode.SYNC_ALLOCATION) - @Operation(summary = "分账同步接口") - @PostMapping("/sync") - public DaxResult sync(@RequestBody AllocSyncParam param){ - return DaxRes.ok(allocationSyncService.sync(param)); - } @PaymentSign @PlatformInitContext(PaymentApiCode.ALLOCATION_RECEIVER_ADD) 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 38c7e0455..ef1b73dbe 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 @@ -4,16 +4,14 @@ import cn.bootx.platform.common.core.annotation.IgnoreAuth; import cn.daxpay.single.code.PaymentApiCode; 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.param.payment.transfer.TransferParam; import cn.daxpay.single.result.DaxResult; 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.PlatformInitContext; import cn.daxpay.single.service.annotation.PaymentSign; +import cn.daxpay.single.service.annotation.PlatformInitContext; 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; @@ -69,20 +67,14 @@ public class UniPayController { return DaxRes.ok(refundService.refund(param)); } - @PaymentSign - @PlatformInitContext(PaymentApiCode.SYNC_PAY) - @Operation(summary = "支付同步接口") - @PostMapping("/syncPay") - public DaxResult syncPay(@RequestBody PaySyncParam param){ - return DaxRes.ok(paySyncService.sync(param)); - } @PaymentSign - @PlatformInitContext(PaymentApiCode.SYNC_REFUND) - @Operation(summary = "退款同步接口") - @PostMapping("/syncRefund") - public DaxResult syncRefund(@RequestBody RefundSyncParam param){ - return DaxRes.ok(refundSyncService.sync(param)); + @PlatformInitContext(PaymentApiCode.TRANSFER) + @Operation(summary = "统一转账接口") + @PostMapping("/transfer") + public DaxResult transfer(@RequestBody TransferParam param){ + return DaxRes.ok(); } + } diff --git a/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPaySyncController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPaySyncController.java new file mode 100644 index 000000000..48fe21b57 --- /dev/null +++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/daxpay/single/gateway/controller/UniPaySyncController.java @@ -0,0 +1,63 @@ +package cn.daxpay.single.gateway.controller; + +import cn.daxpay.single.code.PaymentApiCode; +import cn.daxpay.single.param.payment.allocation.AllocSyncParam; +import cn.daxpay.single.param.payment.pay.PaySyncParam; +import cn.daxpay.single.param.payment.refund.RefundSyncParam; +import cn.daxpay.single.result.DaxResult; +import cn.daxpay.single.result.allocation.AllocationSyncResult; +import cn.daxpay.single.result.pay.SyncResult; +import cn.daxpay.single.service.annotation.PaymentSign; +import cn.daxpay.single.service.annotation.PlatformInitContext; +import cn.daxpay.single.service.core.payment.allocation.service.AllocationSyncService; +import cn.daxpay.single.service.core.payment.sync.service.PaySyncService; +import cn.daxpay.single.service.core.payment.sync.service.RefundSyncService; +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/26 + */ +@Tag(name = "") +@RestController +@RequestMapping("/unipay/sync/") +@RequiredArgsConstructor +public class UniPaySyncController { + + private final PaySyncService paySyncService; + private final RefundSyncService refundSyncService; + private final AllocationSyncService allocationSyncService; + + @PaymentSign + @PlatformInitContext(PaymentApiCode.SYNC_PAY) + @Operation(summary = "支付同步接口") + @PostMapping("/pay") + public DaxResult syncPay(@RequestBody PaySyncParam param){ + return DaxRes.ok(paySyncService.sync(param)); + } + + @PaymentSign + @PlatformInitContext(PaymentApiCode.SYNC_REFUND) + @Operation(summary = "退款同步接口") + @PostMapping("/refund") + public DaxResult syncRefund(@RequestBody RefundSyncParam param){ + return DaxRes.ok(refundSyncService.sync(param)); + } + + + @PaymentSign + @PlatformInitContext(PaymentApiCode.SYNC_ALLOCATION) + @Operation(summary = "分账同步接口") + @PostMapping("/sync") + public DaxResult sync(@RequestBody AllocSyncParam param){ + return DaxRes.ok(allocationSyncService.sync(param)); + } +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/PayReturnService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/PayReturnService.java index cd3ad7ba4..d49b12739 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/PayReturnService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/core/payment/notice/service/PayReturnService.java @@ -35,12 +35,14 @@ public class PayReturnService { * 支付宝同步回调 */ public String alipay(AliPayReturnParam param){ - PayOrderExtra payOrderExtra = payOrderExtraManager.findById(param.getOut_trade_no()).orElse(null); - PayOrder payOrder = payOrderQueryService.findById(param.getOut_trade_no()).orElse(null); - if (Objects.isNull(payOrderExtra) || Objects.isNull(payOrder)){ + PayOrder payOrder = payOrderQueryService.findByOrderNo(param.getOutTradeNo()).orElse(null); + if ( Objects.isNull(payOrder)){ + return StrUtil.format("{}/result/error?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付订单有问题,请排查")); + } + PayOrderExtra payOrderExtra = payOrderExtraManager.findById(payOrder.getId()).orElse(null); + if ( Objects.isNull(payOrderExtra)){ return StrUtil.format("{}/result/error?msg={}", properties.getFrontH5Url(), URLEncodeUtil.encode("支付订单有问题,请排查")); } - // 如果同步跳转参数为空, 获取系统配置地址, 系统配置如果也为空, 则返回默认地址 String returnUrl = payOrderExtra.getReturnUrl(); if (StrUtil.isBlank(returnUrl)){ 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 622b67a03..2c19e6a55 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 @@ -54,7 +54,6 @@ public class TradeFlowRecordService { .setType(TradeFlowRecordTypeEnum.PAY.getCode()) .setAmount(payOrder.getAmount()); tradeFlowRecordManager.save(tradeFlowRecord); - } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/channel/alipay/AliPayReturnParam.java b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/channel/alipay/AliPayReturnParam.java index bc57eabd0..8f6df678a 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/channel/alipay/AliPayReturnParam.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/daxpay/single/service/param/channel/alipay/AliPayReturnParam.java @@ -27,7 +27,7 @@ public class AliPayReturnParam { */ @Schema(description = "支付订单号") @JsonAlias("out_trade_no") - private Long out_trade_no; + private String outTradeNo; /** * 该交易在支付宝系统中的交易流水号。最长 64 位。 @@ -35,7 +35,7 @@ public class AliPayReturnParam { */ @Schema(description = "网关订单号") @JsonAlias("trade_no") - private String trade_no; + private String tradeNo; @Schema(description = "接口名称") @JsonAlias("method") @@ -51,7 +51,7 @@ public class AliPayReturnParam { @Schema(description = "不确定是什么") @JsonAlias("auth_app_id") - private String auth_app_id; + private String authAppId; /** * 支付宝分配给开发者的应用ID。 @@ -59,14 +59,14 @@ public class AliPayReturnParam { */ @Schema(description = "应用ID") @JsonAlias("app_id") - private String app_id; + private String appId; /** * 签名算法类型,目前支持 RSA2 和 RSA,推荐使用RSA2 */ @Schema(description = "签名算法类型") @JsonAlias("sign_type") - private String sign_type; + private String signType; /** * 收款支付宝账号对应的支付宝唯一用户号。以 2088 开头的纯 16 位数字。 @@ -74,7 +74,7 @@ public class AliPayReturnParam { */ @Schema(description = "收款支付宝账号对应的支付宝唯一用户号") @JsonAlias("seller_id") - private String seller_id; + private String sellerId; /** * 前台回跳的时间,格式:yyyy-MM-dd HH:mm:ss。