From 2026ca06185e55c668591c9c16711b2394c23e43 Mon Sep 17 00:00:00 2001
From: nws <3239709711@qq.com>
Date: Sun, 17 Dec 2023 22:51:30 +0800
Subject: [PATCH] =?UTF-8?q?feat=20=E6=94=AF=E4=BB=98=E7=BD=91=E5=85=B3?=
=?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dax-pay-sdk/pom.xml | 27 ++++++++
.../pay/PayAmountAbnormalException.java | 22 -------
.../exception/pay/PayFailureException.java | 22 -------
.../exception/pay/PayHasExistedException.java | 18 ------
.../pay/PayIsProcessingException.java | 18 ------
.../exception/pay/PayNotExistedException.java | 18 ------
.../pay/PayUnsupportedMethodException.java | 18 ------
.../cn/bootx/platform/daxpay/util/DaxRes.java | 25 ++++++++
.../platform/daxpay/code/PayChannelEnum.java | 4 +-
.../platform/daxpay/code/PayStatusEnum.java | 31 +++++++++
.../platform/daxpay/code/PayWayEnum.java | 11 +++-
.../platform/daxpay/param/ChannelParam.java | 9 +++
.../daxpay/param/channel/AliPayParam.java | 9 +--
.../daxpay/param/channel/VoucherPayParam.java | 5 +-
.../daxpay/param/channel/WalletPayParam.java | 9 +--
.../daxpay/param/channel/WeChatPayParam.java | 5 +-
.../daxpay/param/pay/CancelParam.java | 14 ++++
.../daxpay/param/pay/PayCommonParam.java | 58 +++++++++++++++++
.../platform/daxpay/param/pay/PayParam.java | 22 ++-----
.../daxpay/param/pay/PayWayParam.java | 13 ++--
.../daxpay/param/pay/SimplePayParam.java | 64 +++++++++++++++++++
.../platform/daxpay/result/DaxResult.java | 27 ++++++++
.../platform/daxpay/result/pay/PayResult.java | 42 ++++++++++++
.../openapi/controller/UniPayController.java | 39 +++++------
pom.xml | 1 +
25 files changed, 348 insertions(+), 183 deletions(-)
create mode 100644 dax-pay-sdk/pom.xml
delete mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayAmountAbnormalException.java
delete mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayFailureException.java
delete mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayHasExistedException.java
delete mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayIsProcessingException.java
delete mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayNotExistedException.java
delete mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayUnsupportedMethodException.java
create mode 100644 daxpay-common/src/main/java/cn/bootx/platform/daxpay/util/DaxRes.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayStatusEnum.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/ChannelParam.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/CancelParam.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayCommonParam.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/SimplePayParam.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/DaxResult.java
create mode 100644 daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/pay/PayResult.java
rename daxpay-single/{daxpay-single-admin => daxpay-single-gateway}/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java (60%)
diff --git a/dax-pay-sdk/pom.xml b/dax-pay-sdk/pom.xml
new file mode 100644
index 00000000..494afe45
--- /dev/null
+++ b/dax-pay-sdk/pom.xml
@@ -0,0 +1,27 @@
+
+
+ 4.0.0
+
+
+ cn.bootx.cloud
+ dax-pay-sdk
+ 2.0.0
+ jar
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ cn.hutool
+ hutool-all
+ 5.8.18
+
+
+
+
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayAmountAbnormalException.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayAmountAbnormalException.java
deleted file mode 100644
index 0186dd94..00000000
--- a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayAmountAbnormalException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.bootx.platform.daxpay.exception.pay;
-
-import cn.bootx.platform.common.core.exception.FatalException;
-import cn.bootx.platform.daxpay.code.DaxPayErrorCode;
-
-/**
- * 异常金额
- *
- * @author xxm
- * @since 2020/12/8
- */
-public class PayAmountAbnormalException extends FatalException {
-
- public PayAmountAbnormalException(String msg) {
- super(DaxPayErrorCode.PAYMENT_AMOUNT_ABNORMAL, msg);
- }
-
- public PayAmountAbnormalException() {
- super(DaxPayErrorCode.PAYMENT_AMOUNT_ABNORMAL, "异常金额");
- }
-
-}
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayFailureException.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayFailureException.java
deleted file mode 100644
index 281f3bd3..00000000
--- a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayFailureException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.bootx.platform.daxpay.exception.pay;
-
-import cn.bootx.platform.common.core.exception.BizException;
-import cn.bootx.platform.daxpay.code.DaxPayErrorCode;
-
-/**
- * 付款错误
- *
- * @author xxm
- * @since 2020/12/8
- */
-public class PayFailureException extends BizException {
-
- public PayFailureException(String message) {
- super(DaxPayErrorCode.PAY_FAILURE, message);
- }
-
- public PayFailureException() {
- super(DaxPayErrorCode.PAY_FAILURE, "支付失败");
- }
-
-}
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayHasExistedException.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayHasExistedException.java
deleted file mode 100644
index 5273c22c..00000000
--- a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayHasExistedException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bootx.platform.daxpay.exception.pay;
-
-import cn.bootx.platform.common.core.exception.BizException;
-import cn.bootx.platform.daxpay.code.DaxPayErrorCode;
-
-/**
- * 付款已存在
- *
- * @author xxm
- * @since 2020/12/8
- */
-public class PayHasExistedException extends BizException {
-
- public PayHasExistedException() {
- super(DaxPayErrorCode.PAYMENT_HAS_EXISTED, "付款已存在");
- }
-
-}
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayIsProcessingException.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayIsProcessingException.java
deleted file mode 100644
index 8b3b17f1..00000000
--- a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayIsProcessingException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bootx.platform.daxpay.exception.pay;
-
-import cn.bootx.platform.common.core.exception.BizException;
-import cn.bootx.platform.daxpay.code.DaxPayErrorCode;
-
-/**
- * 付款正在处理中
- *
- * @author xxm
- * @since 2020/12/8
- */
-public class PayIsProcessingException extends BizException {
-
- public PayIsProcessingException() {
- super(DaxPayErrorCode.PAYMENT_IS_PROCESSING, "付款正在处理中");
- }
-
-}
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayNotExistedException.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayNotExistedException.java
deleted file mode 100644
index 24bbce95..00000000
--- a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayNotExistedException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bootx.platform.daxpay.exception.pay;
-
-import cn.bootx.platform.common.core.exception.BizException;
-import cn.bootx.platform.daxpay.code.DaxPayErrorCode;
-
-/**
- * 付款记录不存在
- *
- * @author xxm
- * @since 2020/12/8
- */
-public class PayNotExistedException extends BizException {
-
- public PayNotExistedException() {
- super(DaxPayErrorCode.PAYMENT_RECORD_NOT_EXISTED, "付款记录不存在");
- }
-
-}
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayUnsupportedMethodException.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayUnsupportedMethodException.java
deleted file mode 100644
index 4a6ee110..00000000
--- a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/exception/pay/PayUnsupportedMethodException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bootx.platform.daxpay.exception.pay;
-
-import cn.bootx.platform.common.core.exception.FatalException;
-import cn.bootx.platform.daxpay.code.DaxPayErrorCode;
-
-/**
- * 付款方式不支持异常
- *
- * @author xxm
- * @since 2020/12/9
- */
-public class PayUnsupportedMethodException extends FatalException {
-
- public PayUnsupportedMethodException() {
- super(DaxPayErrorCode.PAYMENT_METHOD_UNSUPPORT, "不支持的支付方式");
- }
-
-}
diff --git a/daxpay-common/src/main/java/cn/bootx/platform/daxpay/util/DaxRes.java b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/util/DaxRes.java
new file mode 100644
index 00000000..c976ee7c
--- /dev/null
+++ b/daxpay-common/src/main/java/cn/bootx/platform/daxpay/util/DaxRes.java
@@ -0,0 +1,25 @@
+package cn.bootx.platform.daxpay.util;
+
+import cn.bootx.platform.daxpay.result.DaxResult;
+import lombok.experimental.UtilityClass;
+
+import static cn.bootx.platform.common.core.code.CommonCode.SUCCESS_CODE;
+
+/**
+ * 支付相应参数构造工具类
+ * @author xxm
+ * @since 2023/12/17
+ */
+@UtilityClass
+public class DaxRes {
+ private final static String SUCCESS = "success";
+
+ public DaxResult ok(T data) {
+ return new DaxResult<>(SUCCESS_CODE, data, SUCCESS);
+ }
+
+
+ public static DaxResult ok() {
+ return new DaxResult<>(SUCCESS_CODE, SUCCESS);
+ }
+}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayChannelEnum.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayChannelEnum.java
index 0364f65d..e0bded22 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayChannelEnum.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayChannelEnum.java
@@ -53,9 +53,9 @@ public enum PayChannelEnum {
/** 微信 UA */
public static final String UA_WECHAT_PAY = "MicroMessenger";
- /** 异步支付渠道 */
+ /** 异步支付通道 */
public static final List ASYNC_TYPE = Collections.unmodifiableList(Arrays.asList(ALI, WECHAT, UNION_PAY));
-
+ /** 异步支付通道的编码 */
public static final List ASYNC_TYPE_CODE = Collections.unmodifiableList(Arrays.asList(ALI.code, WECHAT.code, UNION_PAY.code));
}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayStatusEnum.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayStatusEnum.java
new file mode 100644
index 00000000..f7f93752
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayStatusEnum.java
@@ -0,0 +1,31 @@
+package cn.bootx.platform.daxpay.code;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 支付状态
+ * @author xxm
+ * @since 2023/12/17
+ */
+@Getter
+@RequiredArgsConstructor
+public enum PayStatusEnum {
+ UNKNOWN("unknown","未知状态"),
+ PROGRESS("progress","支付中"),
+ SUCCESS("success","成功"),
+ FAIL("fail","失败"),
+ CANCEL("cancel","支付取消"),
+ CLOSE("close","支付关闭"),
+ /** 超时取消 */
+ TIMEOUT("timeout","超时取消"),
+ PARTIAL_REFUND("partial_refund","部分退款"),
+ REFUNDED("REFUNDED","已退款");
+
+ /** 支付方式字符编码 */
+ private final String code;
+
+ /** 名称 */
+ private final String name;
+
+ }
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayWayEnum.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayWayEnum.java
index d6da579e..ec9a1780 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayWayEnum.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/code/PayWayEnum.java
@@ -17,10 +17,15 @@ import java.util.Objects;
@AllArgsConstructor
public enum PayWayEnum {
- NORMAL("NORMAL", "常规支付"), WAP("WAP", "wap支付"), APP("APP", "应用支付"), WEB("WEB", "web支付"), QRCODE("QRCODE", "扫码支付"),
- BARCODE("BARCODE", "付款码"), JSAPI("JSAPI", "公众号/小程序支付");
+ NORMAL("normal", "常规支付"),
+ WAP("wap", "wap支付"),
+ APP("app", "应用支付"),
+ WEB("web", "web支付"),
+ QRCODE("qrcode", "扫码支付"),
+ BARCODE("barcode", "付款码"),
+ JSAPI("jsapi", "公众号/小程序支付");
- /** 支付方式字符编码 */
+ /** 编码 */
private final String code;
/** 名称 */
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/ChannelParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/ChannelParam.java
new file mode 100644
index 00000000..f342e6d3
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/ChannelParam.java
@@ -0,0 +1,9 @@
+package cn.bootx.platform.daxpay.param;
+
+/**
+ * 通道支付参数标识
+ * @author xxm
+ * @since 2023/12/17
+ */
+public interface ChannelParam {
+}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/AliPayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/AliPayParam.java
index 9eda654e..a5e4f2ad 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/AliPayParam.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/AliPayParam.java
@@ -1,21 +1,16 @@
package cn.bootx.platform.daxpay.param.channel;
+import cn.bootx.platform.daxpay.param.ChannelParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
/**
* @author xxm
* @since 2021/2/27
*/
@Data
-@Accessors(chain = true)
@Schema(title = "支付宝支付参数")
-public class AliPayParam implements Serializable {
-
- private static final long serialVersionUID = 7467373358780663978L;
+public class AliPayParam implements ChannelParam {
@Schema(description = "授权码(主动扫描用户的付款码)")
private String authCode;
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/VoucherPayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/VoucherPayParam.java
index 368ba757..5387eaa4 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/VoucherPayParam.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/VoucherPayParam.java
@@ -1,8 +1,8 @@
package cn.bootx.platform.daxpay.param.channel;
+import cn.bootx.platform.daxpay.param.ChannelParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import lombok.experimental.Accessors;
/**
* 储值卡支付参数
@@ -11,9 +11,8 @@ import lombok.experimental.Accessors;
* @since 2022/3/14
*/
@Data
-@Accessors(chain = true)
@Schema(title = "储值卡支付参数")
-public class VoucherPayParam {
+public class VoucherPayParam implements ChannelParam {
@Schema(description = "储值卡号")
private String cardNo;
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WalletPayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WalletPayParam.java
index 4968d6f0..b57a23b6 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WalletPayParam.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WalletPayParam.java
@@ -1,10 +1,8 @@
package cn.bootx.platform.daxpay.param.channel;
+import cn.bootx.platform.daxpay.param.ChannelParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
/**
* 钱包支付参数
@@ -13,11 +11,8 @@ import java.io.Serializable;
* @since 2020/12/8
*/
@Data
-@Accessors(chain = true)
@Schema(title = "钱包支付参数")
-public class WalletPayParam implements Serializable {
-
- private static final long serialVersionUID = 3255160458016870367L;
+public class WalletPayParam implements ChannelParam {
@Schema(description = "钱包ID")
private Long walletId;
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WeChatPayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WeChatPayParam.java
index 34a20d67..7fdba674 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WeChatPayParam.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/channel/WeChatPayParam.java
@@ -1,17 +1,16 @@
package cn.bootx.platform.daxpay.param.channel;
+import cn.bootx.platform.daxpay.param.ChannelParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import lombok.experimental.Accessors;
/**
* @author xxm
* @since 2021/6/21
*/
@Data
-@Accessors(chain = true)
@Schema(title = "微信支付参数")
-public class WeChatPayParam {
+public class WeChatPayParam implements ChannelParam {
@Schema(description = "微信openId")
private String openId;
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/CancelParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/CancelParam.java
new file mode 100644
index 00000000..41e87da9
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/CancelParam.java
@@ -0,0 +1,14 @@
+package cn.bootx.platform.daxpay.param.pay;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 支付取消参数
+ * @author xxm
+ * @since 2023/12/17
+ */
+@Data
+@Schema(title = "支付取消参数")
+public class CancelParam {
+}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayCommonParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayCommonParam.java
new file mode 100644
index 00000000..02600cac
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayCommonParam.java
@@ -0,0 +1,58 @@
+package cn.bootx.platform.daxpay.param.pay;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.time.LocalDateTime;
+
+/**
+ * 支付公共参数
+ * @author xxm
+ * @since 2023/12/17
+ */
+@Data
+@Schema(title = "支付公共参数")
+public class PayCommonParam {
+
+ /** 客户端ip */
+ @Schema(description = "客户端ip")
+ private String clientIp;
+
+ /** 商户扩展参数,回调时会原样返回 */
+ @Schema(description = "商户扩展参数,回调时会原样返回")
+ private String extraParam;
+
+ @Schema(description = "是否不进行同步通知的跳转")
+ private boolean notReturn;
+
+ /** 同步通知URL */
+ @Schema(description = "同步通知URL")
+ private String returnUrl;
+
+ /** 是否不启用异步通知 */
+ @Schema(description = "是否不启用异步通知")
+ private boolean notNotify;
+
+ /** 异步通知地址 */
+ @Schema(description = "异步通知地址")
+ private String notifyUrl;
+
+ /** 签名类型 */
+ @Schema(description = "签名类型")
+ private String signType;
+
+ /** 签名 */
+ @Schema(description = "签名")
+ private String sign;
+
+ /** API版本号 */
+ @Schema(description = "API版本号")
+ @NotBlank()
+ private String version;
+
+ /** 请求时间,时间戳转时间 */
+ @Schema(description = "请求时间,传输时间戳")
+ private LocalDateTime reqTime;
+
+}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayParam.java
index 0d5bd069..5b16f75e 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayParam.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayParam.java
@@ -2,7 +2,7 @@ package cn.bootx.platform.daxpay.param.pay;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import lombok.experimental.Accessors;
+import lombok.EqualsAndHashCode;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@@ -10,28 +10,20 @@ import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
- * 支付参数
+ * 统一下单参数
*
* @author xxm
* @since 2020/12/9
*/
+@EqualsAndHashCode(callSuper = true)
@Data
-@Accessors(chain = true)
@Schema(title = "支付参数")
-public class PayParam {
+public class PayParam extends PayCommonParam{
- @Schema(description = "商户编码")
- @NotEmpty(message = "商户应用不可为空")
- private String mchCode;
- @Schema(description = "商户应用编码")
-
- @NotEmpty(message = "商户应用编码不可为空")
- private String mchAppCode;
-
- @Schema(description = "业务ID")
- @NotBlank(message = "业务ID不可为空")
- private String businessId;
+ @Schema(description = "业务号")
+ @NotBlank(message = "业务号不可为空")
+ private String businessNo;
@Schema(description = "支付标题")
@NotBlank(message = "支付标题不可为空")
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayWayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayWayParam.java
index b6ce566f..774b9028 100644
--- a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayWayParam.java
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/PayWayParam.java
@@ -8,25 +8,20 @@ import cn.bootx.platform.daxpay.param.channel.WalletPayParam;
import cn.bootx.platform.daxpay.param.channel.WeChatPayParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
-import java.io.Serializable;
import java.math.BigDecimal;
/**
- * 不只是支付, 退款发起时也是这个参数
+ * 同意下单支付方式参数
*
* @author xxm
* @since 2020/12/8
*/
@Data
-@Accessors(chain = true)
@Schema(title = "支付方式参数")
-public class PayWayParam implements Serializable {
-
- private static final long serialVersionUID = -46959864485463681L;
+public class PayWayParam {
/**
* @see PayChannelEnum#getCode()
@@ -52,6 +47,6 @@ public class PayWayParam implements Serializable {
* @see VoucherPayParam
* @see WalletPayParam
*/
- @Schema(description = "扩展参数的json字符串")
- private String extraParamsJson;
+ @Schema(description = "附加支付参数")
+ private String channelExtra;
}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/SimplePayParam.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/SimplePayParam.java
new file mode 100644
index 00000000..7be74880
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/param/pay/SimplePayParam.java
@@ -0,0 +1,64 @@
+package cn.bootx.platform.daxpay.param.pay;
+
+import cn.bootx.platform.daxpay.code.PayChannelEnum;
+import cn.bootx.platform.daxpay.code.PayWayEnum;
+import cn.bootx.platform.daxpay.param.channel.AliPayParam;
+import cn.bootx.platform.daxpay.param.channel.VoucherPayParam;
+import cn.bootx.platform.daxpay.param.channel.WalletPayParam;
+import cn.bootx.platform.daxpay.param.channel.WeChatPayParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * 简单下单参数
+ * @author xxm
+ * @since 2023/12/17
+ */
+@Data
+@Schema(title = "简单下单参数")
+public class SimplePayParam {
+
+ @Schema(description = "业务号")
+ @NotBlank(message = "业务号不可为空")
+ private String businessNo;
+
+ @Schema(description = "支付标题")
+ @NotBlank(message = "支付标题不可为空")
+ private String title;
+
+ @Schema(description = "支付描述")
+ private String description;
+
+ /**
+ * @see PayChannelEnum#getCode()
+ */
+ @Schema(description = "支付渠道编码")
+ @NotBlank(message = "支付渠道编码不可为空")
+ private String payChannel;
+
+ /**
+ * @see PayWayEnum#getCode()
+ */
+ @Schema(description = "支付方式编码")
+ @NotBlank(message = "支付方式编码不可为空")
+ private String payWay;
+
+ @Schema(description = "支付金额")
+ @NotNull(message = "支付金额不可为空")
+ private BigDecimal amount;
+
+ /**
+ * @see AliPayParam
+ * @see WeChatPayParam
+ * @see VoucherPayParam
+ * @see WalletPayParam
+ */
+ @Schema(description = "附加支付参数")
+ private String channelExtra;
+
+
+}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/DaxResult.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/DaxResult.java
new file mode 100644
index 00000000..9156cf7b
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/DaxResult.java
@@ -0,0 +1,27 @@
+package cn.bootx.platform.daxpay.result;
+
+import cn.bootx.platform.common.core.rest.ResResult;
+import lombok.*;
+
+/**
+ * 支付通用响应参数
+ * @author xxm
+ * @since 2023/12/17
+ */
+@Getter
+@Setter
+@ToString
+@EqualsAndHashCode(callSuper = true)
+public class DaxResult extends ResResult {
+
+ /** 数据签名 */
+ private String sign;
+
+ public DaxResult(int successCode, T data, String success) {
+ super(successCode, data, success);
+ }
+
+ public DaxResult(int successCode, String success) {
+ super(successCode, success);
+ }
+}
diff --git a/daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/pay/PayResult.java b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/pay/PayResult.java
new file mode 100644
index 00000000..8f5e3ad6
--- /dev/null
+++ b/daxpay-core/src/main/java/cn/bootx/platform/daxpay/result/pay/PayResult.java
@@ -0,0 +1,42 @@
+package cn.bootx.platform.daxpay.result.pay;
+
+import cn.bootx.platform.daxpay.code.PayChannelEnum;
+import cn.bootx.platform.daxpay.code.PayStatusEnum;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 统一下单响应参数
+ * @author xxm
+ * @since 2023/12/17
+ */
+@Data
+@Accessors(chain = true)
+@Schema(title = "统一下单响应参数")
+public class PayResult {
+
+ @Schema(description = "支付ID")
+ private Long paymentId;
+
+ @Schema(description = "是否是异步支付")
+ private boolean asyncPayMode;
+
+ /**
+ * @see PayChannelEnum#ASYNC_TYPE_CODE
+ */
+ @Schema(description = "异步支付渠道")
+ private String asyncPayChannel;
+
+
+ /** 支付参数体(通常用于发起异步支付的参数) */
+ @Schema(description = "支付参数体")
+ private String payBody;
+
+ /**
+ * @see PayStatusEnum
+ */
+ @Schema(description = "支付状态")
+ private String payStatus;
+
+}
diff --git a/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java b/daxpay-single/daxpay-single-gateway/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java
similarity index 60%
rename from daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java
rename to daxpay-single/daxpay-single-gateway/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java
index 13a936ab..517cf7e9 100644
--- a/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java
+++ b/daxpay-single/daxpay-single-gateway/src/main/java/cn/bootx/platform/daxpay/openapi/controller/UniPayController.java
@@ -1,12 +1,15 @@
package cn.bootx.platform.daxpay.openapi.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
-import cn.bootx.platform.common.core.rest.Res;
-import cn.bootx.platform.common.core.rest.ResResult;
+import cn.bootx.platform.daxpay.param.pay.PayParam;
+import cn.bootx.platform.daxpay.result.DaxResult;
+import cn.bootx.platform.daxpay.result.pay.PayResult;
+import cn.bootx.platform.daxpay.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;
@@ -24,42 +27,42 @@ public class UniPayController {
@Operation(summary = "统一下单")
@PostMapping("/pay")
- public ResResult pay(){
- return Res.ok();
+ public DaxResult pay(@RequestBody PayParam payParam){
+ return DaxRes.ok();
}
@Operation(summary = "简单下单")
@PostMapping("/simplePay")
- public ResResult simplePay(){
- return Res.ok();
+ public DaxResult simplePay(){
+ return DaxRes.ok();
}
@Operation(summary = "订单撤销")
@PostMapping("/cancel")
- public ResResult cancel(){
- return Res.ok();
+ public DaxResult cancel(){
+ return DaxRes.ok();
}
@Operation(summary = "订单关闭")
@PostMapping("/close")
- public ResResult close(){
- return Res.ok();
+ public DaxResult close(){
+ return DaxRes.ok();
}
@Operation(summary = "统一退款")
@PostMapping("/refund")
- public ResResult refund(){
- return Res.ok();
+ public DaxResult refund(){
+ return DaxRes.ok();
}
@Operation(summary = "简单退款")
@PostMapping("/simpleRefund")
- public ResResult simpleRefund(){
- return Res.ok();
+ public DaxResult simpleRefund(){
+ return DaxRes.ok();
}
@Operation(summary = "支付状态同步")
@PostMapping("/syncPay")
- public ResResult syncPay(){
- return Res.ok();
+ public DaxResult syncPay(){
+ return DaxRes.ok();
}
@Operation(summary = "退款状态同步")
@PostMapping("/syncRefund")
- public ResResult syncRefund(){
- return Res.ok();
+ public DaxResult syncRefund(){
+ return DaxRes.ok();
}
}
diff --git a/pom.xml b/pom.xml
index ca7b1352..e57e8130 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,7 @@
daxpay-core
daxpay-common
daxpay-single
+ dax-pay-sdk