From c60f9c71bfa24d6b8d9114325a843536a239acf5 Mon Sep 17 00:00:00 2001
From: YunaiV <>
Date: Sun, 29 Nov 2020 01:43:30 +0800
Subject: [PATCH] =?UTF-8?q?1.=20=E8=BF=81=E7=A7=BB=E6=94=AF=E4=BB=98?=
=?UTF-8?q?=E4=BA=A4=E6=98=93=E7=9A=84=E6=8F=90=E4=BA=A4=20RPC=20=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=202.=20=E8=BF=81=E7=A7=BB=E6=94=AF=E4=BB=98=E4=BA=A4?=
=?UTF-8?q?=E6=98=93=E7=9A=84=E8=8E=B7=E5=8F=96=20RPC=20=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ops/pom.xml | 50 -------
.../cn/iocoder/mall/ops/OpsApplication.java | 15 --
.../rpc/transaction/PayTransactionRpc.java | 18 ++-
.../dto/PayTransactionCreateReqDTO.java | 6 +
.../dto/PayTransactionGetReqDTO.java | 27 ++++
.../dto/PayTransactionRespDTO.java | 96 +++++++++++++
.../dto/PayTransactionSubmitReqDTO.java | 43 ++++++
.../dto/PayTransactionSubmitRespDTO.java | 23 +++
...actory.java => ThirdPayClientFactory.java} | 4 +-
.../transaction/PayTransactionConvert.java | 7 +
.../mysql/dataobject/refund/PayRefundDO.java | 4 +
.../transaction/PayTransactionDO.java | 4 +
.../PayTransactionExtensionMapper.java | 21 +++
.../transaction/PayTransactionRpcImpl.java | 12 +-
.../transaction/PayTransactionService.java | 18 ++-
.../impl/PayTransactionServiceImpl.java | 73 +++++++++-
.../pay-service-integration-test/pom.xml | 29 ++++
.../impl/PayTransactionServiceImplTest.java | 27 ++++
.../service/transaction/package-info.java | 1 +
pay-service-project/pom.xml | 1 +
.../mall/pay/api/PayRefundService.java | 0
.../mall/pay/api/PayTransactionService.java | 4 -
.../mall/pay/api/bo/refund/PayRefundBO.java | 0
.../pay/api/bo/refund/PayRefundPageBO.java | 0
.../pay/api/bo/refund/PayRefundSubmitBO.java | 0
.../api/bo/transaction/PayTransactionBO.java | 0
.../bo/transaction/PayTransactionPageBO.java | 0
.../mall/pay/api/constant/PayNotifyType.java | 0
.../pay/api/constant/PayRefundStatus.java | 0
.../PayTransactionNotifyStatusEnum.java | 0
.../pay/api/dto/refund/PayRefundPageDTO.java | 0
.../api/dto/refund/PayRefundSubmitDTO.java | 0
.../transaction/PayTransactionPageDTO.java | 0
.../AbstractPayNotifySuccessMessage.java | 0
.../api/message/PayRefundSuccessMessage.java | 0
.../message/PayTransactionSuccessMessage.java | 0
.../users/UsersPayTransactionController.java | 72 ----------
.../pay/biz/component/DubboReferencePool.java | 0
.../pay/biz/config/XxlJobConfiguration.java | 0
.../pay/biz/convert/PayNotifyConvert.java | 0
.../pay/biz/convert/PayRefundConvert.java | 0
.../mall/pay/biz/dao/PayNotifyLogMapper.java | 0
.../mall/pay/biz/dao/PayNotifyTaskMapper.java | 0
.../mall/pay/biz/dao/PayRefundMapper.java | 0
.../pay/biz/dao/PayTransactionMapper.java | 0
.../mall/pay/biz/dataobject/PayLogDO.java | 0
.../pay/biz/dataobject/PayNotifyLogDO.java | 0
.../pay/biz/dataobject/PayNotifyTaskDO.java | 0
.../mall/pay/biz/job/PayNotifyJob.java | 0
.../mq/AbstractPayNotifySuccessConsumer.java | 0
.../pay/biz/mq/PayRefundSuccessConsumer.java | 0
.../biz/mq/PayTransactionSuccessConsumer.java | 0
.../pay/biz/service/PayNotifyServiceImpl.java | 0
.../pay/biz/service/PayRefundServiceImpl.java | 0
.../service/PayTransactionServiceImpl.java | 51 +------
.../resources/config/application-test.yaml | 0
.../resources/mapper/PayNotifyLogMapper.xml | 0
.../resources/mapper/PayNotifyTaskMapper.xml | 0
.../main/resources/mapper/PayRefundMapper.xml | 0
.../mapper/PayTransactionExtensionMapper.xml | 0
.../resources/mapper/PayTransactionMapper.xml | 31 ----
.../test/java}/PayRefundServiceImplTest.java | 0
.../dto/transaction/PayTransactionGetDTO.java | 28 ----
pay/pay-service-impl/pom.xml | 136 ------------------
.../dao/PayTransactionExtensionMapper.java | 19 ---
.../src/main/resources/mybatis-config.xml | 19 ---
.../cn/iocoder/mall/pay/biz/Application.java | 7 -
.../PayTransactionServiceImplTest.java | 13 --
pay/pom.xml | 32 -----
shop-web-app/pom.xml | 6 +
.../client/pay/PayTransactionClient.java | 38 +++++
.../pay/PayTransactionController.java | 74 ++++++++++
.../vo/transaction/PayTransactionRespVO.java | 39 +++++
.../PayTransactionSubmitReqVO.java | 12 +-
.../PayTransactionSubmitRespVO.java | 8 +-
.../convert/pay/PayTransactionConvert.java | 23 +++
.../service/pay/PayTransactionService.java | 28 ++++
.../src/main/resources/application.yml | 2 +
.../order/impl/TradeOrderServiceImpl.java | 3 +-
79 files changed, 628 insertions(+), 496 deletions(-)
delete mode 100644 ops/pom.xml
delete mode 100644 ops/src/main/java/cn/iocoder/mall/ops/OpsApplication.java
create mode 100644 pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionGetReqDTO.java
create mode 100644 pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionRespDTO.java
create mode 100644 pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitReqDTO.java
create mode 100644 pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitRespDTO.java
rename pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/{PaySDKFactory.java => ThirdPayClientFactory.java} (83%)
create mode 100644 pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/PayTransactionExtensionMapper.java
create mode 100644 pay-service-project/pay-service-integration-test/pom.xml
create mode 100644 pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImplTest.java
create mode 100644 pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/package-info.java
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/PayRefundService.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java (88%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundBO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundPageBO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundSubmitBO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionBO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionPageBO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/constant/PayNotifyType.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/constant/PayRefundStatus.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/constant/PayTransactionNotifyStatusEnum.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundPageDTO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundSubmitDTO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionPageDTO.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/message/AbstractPayNotifySuccessMessage.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/message/PayRefundSuccessMessage.java (100%)
rename pay/{pay-service-api => pay-application}/src/main/java/cn/iocoder/mall/pay/api/message/PayTransactionSuccessMessage.java (100%)
delete mode 100644 pay/pay-application/src/main/java/cn/iocoder/mall/pay/application/controller/users/UsersPayTransactionController.java
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/component/DubboReferencePool.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/config/XxlJobConfiguration.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/convert/PayNotifyConvert.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/convert/PayRefundConvert.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyLogMapper.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyTaskMapper.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayLogDO.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyLogDO.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyTaskDO.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/job/PayNotifyJob.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/mq/AbstractPayNotifySuccessConsumer.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/mq/PayRefundSuccessConsumer.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/mq/PayTransactionSuccessConsumer.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/service/PayNotifyServiceImpl.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/service/PayRefundServiceImpl.java (100%)
rename pay/{pay-service-impl => pay-application}/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java (78%)
rename pay/{pay-service-impl => pay-application}/src/main/resources/config/application-test.yaml (100%)
rename pay/{pay-service-impl => pay-application}/src/main/resources/mapper/PayNotifyLogMapper.xml (100%)
rename pay/{pay-service-impl => pay-application}/src/main/resources/mapper/PayNotifyTaskMapper.xml (100%)
rename pay/{pay-service-impl => pay-application}/src/main/resources/mapper/PayRefundMapper.xml (100%)
rename pay/{pay-service-impl => pay-application}/src/main/resources/mapper/PayTransactionExtensionMapper.xml (100%)
rename pay/{pay-service-impl => pay-application}/src/main/resources/mapper/PayTransactionMapper.xml (78%)
rename pay/{pay-service-impl/src/test/java/cn/iocoder/mall/pay/biz/service => pay-application/src/test/java}/PayRefundServiceImplTest.java (100%)
delete mode 100644 pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionGetDTO.java
delete mode 100644 pay/pay-service-impl/pom.xml
delete mode 100644 pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionExtensionMapper.java
delete mode 100644 pay/pay-service-impl/src/main/resources/mybatis-config.xml
delete mode 100644 pay/pay-service-impl/src/test/java/cn/iocoder/mall/pay/biz/Application.java
delete mode 100644 pay/pay-service-impl/src/test/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImplTest.java
delete mode 100644 pay/pom.xml
create mode 100644 shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/pay/PayTransactionClient.java
create mode 100644 shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/pay/PayTransactionController.java
create mode 100644 shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/pay/vo/transaction/PayTransactionRespVO.java
rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionSubmitDTO.java => shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/pay/vo/transaction/PayTransactionSubmitReqVO.java (67%)
rename pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionSubmitBO.java => shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/pay/vo/transaction/PayTransactionSubmitRespVO.java (69%)
create mode 100644 shop-web-app/src/main/java/cn/iocoder/mall/shopweb/convert/pay/PayTransactionConvert.java
create mode 100644 shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/pay/PayTransactionService.java
diff --git a/ops/pom.xml b/ops/pom.xml
deleted file mode 100644
index 4ea6e71b..00000000
--- a/ops/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- onemall
- cn.iocoder.mall
- 1.0-SNAPSHOT
-
- 4.0.0
-
- ops
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
-
- de.codecentric
- spring-boot-admin-starter-server
- 2.1.3
-
-
- de.codecentric
- spring-boot-admin-server-ui
- 2.1.3
-
-
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
-
-
-
-
-
-
-
diff --git a/ops/src/main/java/cn/iocoder/mall/ops/OpsApplication.java b/ops/src/main/java/cn/iocoder/mall/ops/OpsApplication.java
deleted file mode 100644
index 81a335d4..00000000
--- a/ops/src/main/java/cn/iocoder/mall/ops/OpsApplication.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.iocoder.mall.ops;
-
-import de.codecentric.boot.admin.server.config.EnableAdminServer;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-@EnableAdminServer
-public class OpsApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(OpsApplication.class, args);
- }
-
-}
\ No newline at end of file
diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java
index 7bd41745..bf57ef6a 100644
--- a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java
+++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java
@@ -1,7 +1,7 @@
package cn.iocoder.mall.payservice.rpc.transaction;
import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
/**
* 支付交易单 RPC 接口
@@ -16,4 +16,20 @@ public interface PayTransactionRpc {
*/
CommonResult createPayTransaction(PayTransactionCreateReqDTO createReqDTO);
+ /**
+ * 提交支付交易单
+ *
+ * @param submitReqDTO 提交信息
+ * @return 提交响应,包含三方支付的响应
+ */
+ CommonResult submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO);
+
+ /**
+ * 获得当支付交易单
+ *
+ * @param getReqDTO 获得条件
+ * @return 支付交易单
+ */
+ CommonResult getPayTransaction(PayTransactionGetReqDTO getReqDTO);
+
}
diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionCreateReqDTO.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionCreateReqDTO.java
index 79ebcaa8..dea26a58 100644
--- a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionCreateReqDTO.java
+++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionCreateReqDTO.java
@@ -17,6 +17,12 @@ import java.util.Date;
@Accessors(chain = true)
public class PayTransactionCreateReqDTO implements Serializable {
+ /**
+ * 用户编号
+ */
+ @NotNull(message = "用户编号不能为空")
+ private Integer userId;
+
/**
* 应用编号
*/
diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionGetReqDTO.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionGetReqDTO.java
new file mode 100644
index 00000000..1da8181c
--- /dev/null
+++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionGetReqDTO.java
@@ -0,0 +1,27 @@
+package cn.iocoder.mall.payservice.rpc.transaction.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotEmpty;
+
+/**
+ * 支付交易获得 Request DTO
+ */
+@Data
+@Accessors(chain = true)
+public class PayTransactionGetReqDTO {
+
+ /**
+ * 应用编号
+ */
+ @NotEmpty(message = "应用编号不能为空")
+ private String appId;
+
+ /**
+ * 订单号
+ */
+ @NotEmpty(message = "订单号不能为空")
+ private String orderId;
+
+}
diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionRespDTO.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionRespDTO.java
new file mode 100644
index 00000000..bf638c9d
--- /dev/null
+++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionRespDTO.java
@@ -0,0 +1,96 @@
+package cn.iocoder.mall.payservice.rpc.transaction.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+* 支付交易 Response DTO
+*/
+@Data
+@Accessors(chain = true)
+public class PayTransactionRespDTO {
+
+ /**
+ * 编号,自增
+ */
+ private Integer id;
+ /**
+ * 用户编号
+ */
+ private Integer userId;
+ /**
+ * 应用编号
+ */
+ private String appId;
+ /**
+ * 发起交易的 IP
+ */
+ private String createIp;
+ /**
+ * 业务线的订单编号
+ */
+ private String orderId;
+ /**
+ * 订单商品名
+ */
+ private String orderSubject;
+ /**
+ * 订单商品描述
+ */
+ private String orderDescription;
+ /**
+ * 订单备注
+ */
+ private String orderMemo;
+ /**
+ * 支付金额,单位:分。
+ */
+ private Integer price;
+ /**
+ * 订单状态
+ */
+ private Integer status;
+ /**
+ * 交易过期时间
+ */
+ private Date expireTime;
+ /**
+ * 回调业务线完成时间
+ */
+ private Date finishTime;
+ /**
+ * 异步通知地址
+ */
+ private String notifyUrl;
+ /**
+ * 成功支付的交易拓展编号
+ */
+ private Integer extensionId;
+ /**
+ * 支付成功的支付渠道
+ */
+ private Integer payChannel;
+ /**
+ * 第三方支付成功的时间
+ */
+ private Date paymentTime;
+ /**
+ * 收到第三方系统通知的时间
+ */
+ private Date notifyTime;
+ /**
+ * 第三方的流水号
+ */
+ private String tradeNo;
+ /**
+ * 退款总金额
+ */
+ private Integer refundTotal;
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+
+}
diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitReqDTO.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitReqDTO.java
new file mode 100644
index 00000000..865ecc4a
--- /dev/null
+++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitReqDTO.java
@@ -0,0 +1,43 @@
+package cn.iocoder.mall.payservice.rpc.transaction.dto;
+
+import cn.iocoder.common.framework.validator.InEnum;
+import cn.iocoder.mall.payservice.enums.PayChannelEnum;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 支付交易提交 Request VO
+ */
+@Data
+@Accessors(chain = true)
+public class PayTransactionSubmitReqDTO {
+
+ /**
+ * 应用编号
+ */
+ @NotEmpty(message = "应用编号不能为空")
+ private String appId;
+
+ /**
+ * 发起交易的 IP
+ */
+ @NotEmpty(message = "IP 不能为空")
+ private String createIp;
+
+ /**
+ * 订单号
+ */
+ @NotEmpty(message = "订单号不能为空")
+ private String orderId;
+
+ /**
+ * 支付渠道
+ */
+ @InEnum(value = PayChannelEnum.class, message = "支付渠道必须是 {value}")
+ @NotNull(message = "支付渠道")
+ private Integer payChannel;
+
+}
diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitRespDTO.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitRespDTO.java
new file mode 100644
index 00000000..8c8d295e
--- /dev/null
+++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/dto/PayTransactionSubmitRespDTO.java
@@ -0,0 +1,23 @@
+package cn.iocoder.mall.payservice.rpc.transaction.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 支付交易提交 Response DTO
+ */
+@Data
+@Accessors(chain = true)
+public class PayTransactionSubmitRespDTO {
+
+ /**
+ * 支付交易拓展单编号
+ */
+ private Integer id;
+
+ /**
+ * 调用三方平台的响应结果
+ */
+ private String invokeResponse;
+
+}
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/PaySDKFactory.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/ThirdPayClientFactory.java
similarity index 83%
rename from pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/PaySDKFactory.java
rename to pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/ThirdPayClientFactory.java
index 46d0b449..c1998cb3 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/PaySDKFactory.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/client/thirdpay/ThirdPayClientFactory.java
@@ -5,7 +5,7 @@ import cn.iocoder.mall.payservice.enums.PayChannelEnum;
import java.util.HashMap;
import java.util.Map;
-public class PaySDKFactory {
+public class ThirdPayClientFactory {
private static Map CLIENTS = new HashMap<>();
@@ -13,7 +13,7 @@ public class PaySDKFactory {
CLIENTS.put(PayChannelEnum.PINGXX.getId(), new PingxxThirdPayClient());
}
- public static AbstractThirdPayClient getSDK(Integer payChannel) {
+ public static AbstractThirdPayClient getThirdPayClient(Integer payChannel) {
AbstractThirdPayClient client = CLIENTS.get(payChannel);
if (client == null) {
throw new NullPointerException("找不到合适的 ThirdPayClient :" + payChannel);
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/PayTransactionConvert.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/PayTransactionConvert.java
index c6870da1..92919504 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/PayTransactionConvert.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/convert/transaction/PayTransactionConvert.java
@@ -1,7 +1,10 @@
package cn.iocoder.mall.payservice.convert.transaction;
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
+import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionExtensionDO;
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionRespDTO;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionSubmitReqDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -12,4 +15,8 @@ public interface PayTransactionConvert {
PayTransactionDO convert(PayTransactionCreateReqDTO bean);
+ PayTransactionExtensionDO convert(PayTransactionSubmitReqDTO bean);
+
+ PayTransactionRespDTO convert(PayTransactionDO bean);
+
}
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/refund/PayRefundDO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/refund/PayRefundDO.java
index 92268f84..081612da 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/refund/PayRefundDO.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/refund/PayRefundDO.java
@@ -21,6 +21,10 @@ public class PayRefundDO extends DeletableDO {
* 编号,自增
*/
private Integer id;
+ /**
+ * 用户编号
+ */
+ private Integer userId;
/**
* 支付交易编号
*/
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/PayTransactionDO.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/PayTransactionDO.java
index 031e5ef4..fb9ca32c 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/PayTransactionDO.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/transaction/PayTransactionDO.java
@@ -23,6 +23,10 @@ public class PayTransactionDO extends DeletableDO {
*/
@TableId
private Integer id;
+ /**
+ * 用户编号
+ */
+ private Integer userId;
/**
* 应用编号
*/
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/PayTransactionExtensionMapper.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/PayTransactionExtensionMapper.java
new file mode 100644
index 00000000..03672017
--- /dev/null
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/PayTransactionExtensionMapper.java
@@ -0,0 +1,21 @@
+package cn.iocoder.mall.payservice.dal.mysql.mapper.transaction;
+
+import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionExtensionDO;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface PayTransactionExtensionMapper extends BaseMapper {
+
+ default int update(PayTransactionExtensionDO entity, Integer whereStatus) {
+ return update(entity, new QueryWrapper()
+ .eq("id", entity.getId()).eq("status", whereStatus));
+ }
+
+ default PayTransactionExtensionDO selectByTransactionCode(String transactionCode) {
+ return selectOne(new QueryWrapper()
+ .eq("transaction_code", transactionCode));
+ }
+
+}
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java
index fde8369d..0339b4e5 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java
@@ -1,7 +1,7 @@
package cn.iocoder.mall.payservice.rpc.transaction;
import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,4 +19,14 @@ public class PayTransactionRpcImpl implements PayTransactionRpc {
return success(payTransactionService.createPayTransaction(createReqDTO));
}
+ @Override
+ public CommonResult submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO) {
+ return success(payTransactionService.submitPayTransaction(submitReqDTO));
+ }
+
+ @Override
+ public CommonResult getPayTransaction(PayTransactionGetReqDTO getReqDTO) {
+ return success(payTransactionService.getPayTransaction(getReqDTO));
+ }
+
}
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/PayTransactionService.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/PayTransactionService.java
index 72f5946c..8df1b7dc 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/PayTransactionService.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/PayTransactionService.java
@@ -1,6 +1,6 @@
package cn.iocoder.mall.payservice.service.transaction;
-import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
/**
* 支付交易单 Service 接口
@@ -15,4 +15,20 @@ public interface PayTransactionService {
*/
Integer createPayTransaction(PayTransactionCreateReqDTO createReqDTO);
+ /**
+ * 提交支付交易单
+ *
+ * @param submitReqDTO 提交信息
+ * @return 提交响应,包含三方支付的响应
+ */
+ PayTransactionSubmitRespDTO submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO);
+
+ /**
+ * 获得当支付交易单
+ *
+ * @param getReqDTO 获得条件
+ * @return 支付交易单
+ */
+ PayTransactionRespDTO getPayTransaction(PayTransactionGetReqDTO getReqDTO);
+
}
diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImpl.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImpl.java
index ed100902..722c4cb0 100644
--- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImpl.java
+++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImpl.java
@@ -1,11 +1,19 @@
package cn.iocoder.mall.payservice.service.transaction.impl;
+import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
+import cn.iocoder.common.framework.util.DateUtil;
+import cn.iocoder.common.framework.util.MathUtil;
+import cn.iocoder.common.framework.vo.CommonResult;
+import cn.iocoder.mall.payservice.client.thirdpay.AbstractThirdPayClient;
+import cn.iocoder.mall.payservice.client.thirdpay.ThirdPayClientFactory;
import cn.iocoder.mall.payservice.convert.transaction.PayTransactionConvert;
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
+import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionExtensionDO;
+import cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.PayTransactionExtensionMapper;
import cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.PayTransactionMapper;
import cn.iocoder.mall.payservice.enums.transaction.PayTransactionStatusEnum;
import cn.iocoder.mall.payservice.rpc.app.dto.PayAppRespDTO;
-import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
import cn.iocoder.mall.payservice.service.app.PayAppService;
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
import lombok.extern.slf4j.Slf4j;
@@ -13,6 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
+import java.util.Date;
+
+import static cn.iocoder.mall.payservice.enums.PayErrorCodeConstants.PAY_TRANSACTION_NOT_FOUND;
+import static cn.iocoder.mall.payservice.enums.PayErrorCodeConstants.PAY_TRANSACTION_STATUS_IS_NOT_WAITING;
+
/**
* 支付交易单 Service 实现类
*/
@@ -23,6 +36,8 @@ public class PayTransactionServiceImpl implements PayTransactionService {
@Autowired
private PayTransactionMapper payTransactionMapper;
+ @Autowired
+ private PayTransactionExtensionMapper payTransactionExtensionMapper;
@Autowired
private PayAppService payAppService;
@@ -50,4 +65,60 @@ public class PayTransactionServiceImpl implements PayTransactionService {
return payTransaction.getId();
}
+ @Override
+ public PayTransactionSubmitRespDTO submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO) {
+ // TODO 校验支付渠道是否有效
+ // 校验 App 是否有效
+ payAppService.validPayApp(submitReqDTO.getAppId());
+
+ // 获得 PayTransactionDO ,并校验其是否存在
+ PayTransactionDO payTransaction = payTransactionMapper.selectByAppIdAndOrderId(
+ submitReqDTO.getAppId(), submitReqDTO.getOrderId());
+ if (payTransaction == null) { // 是否存在
+ throw ServiceExceptionUtil.exception(PAY_TRANSACTION_NOT_FOUND);
+ }
+ if (!PayTransactionStatusEnum.WAITING.getValue().equals(payTransaction.getStatus())) { // 校验状态,必须是待支付
+ throw ServiceExceptionUtil.exception(PAY_TRANSACTION_STATUS_IS_NOT_WAITING);
+ }
+
+ // 插入 PayTransactionExtensionDO
+ PayTransactionExtensionDO payTransactionExtensionDO = PayTransactionConvert.INSTANCE.convert(submitReqDTO)
+ .setTransactionId(payTransaction.getId()).setTransactionCode(generateTransactionCode())
+ .setStatus(PayTransactionStatusEnum.WAITING.getValue());
+ payTransactionExtensionMapper.insert(payTransactionExtensionDO);
+
+ // 调用三方接口
+ AbstractThirdPayClient thirdPayClient = ThirdPayClientFactory.getThirdPayClient(submitReqDTO.getPayChannel());
+ CommonResult invokeResult = thirdPayClient.submitTransaction(payTransaction, payTransactionExtensionDO, null); // TODO 暂时传入 extra = null
+ invokeResult.checkError();
+
+ // TODO 轮询三方接口,是否已经支付的任务
+ // 返回成功
+ return new PayTransactionSubmitRespDTO().setId(payTransactionExtensionDO.getId()).setInvokeResponse(invokeResult.getData());
+ }
+
+ @Override
+ public PayTransactionRespDTO getPayTransaction(PayTransactionGetReqDTO getReqDTO) {
+ return PayTransactionConvert.INSTANCE.convert(payTransactionMapper.selectByAppIdAndOrderId(
+ getReqDTO.getAppId(), getReqDTO.getOrderId()));
+ }
+
+ private String generateTransactionCode() {
+// wx
+// 2014
+// 10
+// 27
+// 20
+// 09
+// 39
+// 5522657
+// a690389285100
+ // 目前的算法
+ // 时间序列,年月日时分秒 14 位
+ // 纯随机,6 位 TODO 此处估计是会有问题的,后续在调整
+ return DateUtil.format(new Date(), "yyyyMMddHHmmss") + // 时间序列
+ MathUtil.random(100000, 999999) // 随机。为什么是这个范围,因为偷懒
+ ;
+ }
+
}
diff --git a/pay-service-project/pay-service-integration-test/pom.xml b/pay-service-project/pay-service-integration-test/pom.xml
new file mode 100644
index 00000000..d76113f4
--- /dev/null
+++ b/pay-service-project/pay-service-integration-test/pom.xml
@@ -0,0 +1,29 @@
+
+
+
+ pay-service-project
+ cn.iocoder.mall
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ pay-service-integration-test
+
+
+
+ cn.iocoder.mall
+ pay-service-app
+ 1.0-SNAPSHOT
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
diff --git a/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImplTest.java b/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImplTest.java
new file mode 100644
index 00000000..0ec6f416
--- /dev/null
+++ b/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/impl/PayTransactionServiceImplTest.java
@@ -0,0 +1,27 @@
+package cn.iocoder.mall.payservice.service.transaction.impl;
+
+import cn.iocoder.mall.payservice.enums.PayChannelEnum;
+import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionSubmitReqDTO;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class PayTransactionServiceImplTest {
+
+ @Autowired
+ private PayTransactionServiceImpl payTransactionService;
+
+ @Test
+ public void testSubmitPayTransaction() {
+ payTransactionService.submitPayTransaction(new PayTransactionSubmitReqDTO()
+ .setAppId("POd4RC6a")
+ .setCreateIp("127.0.0.1")
+ .setOrderId("239")
+ .setPayChannel(PayChannelEnum.PINGXX.getId()));
+ }
+
+}
diff --git a/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/package-info.java b/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/package-info.java
new file mode 100644
index 00000000..c80ad27f
--- /dev/null
+++ b/pay-service-project/pay-service-integration-test/src/test/java/cn/iocoder/mall/payservice/service/transaction/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.mall.payservice.service.transaction;
diff --git a/pay-service-project/pom.xml b/pay-service-project/pom.xml
index 801f60be..3c5450e5 100644
--- a/pay-service-project/pom.xml
+++ b/pay-service-project/pom.xml
@@ -15,6 +15,7 @@
pay-service-api
pay-service-app
+ pay-service-integration-test
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/PayRefundService.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/PayRefundService.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/PayRefundService.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/PayRefundService.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java
similarity index 88%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java
index 5422f422..22e9b5f2 100644
--- a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java
+++ b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/PayTransactionService.java
@@ -14,10 +14,6 @@ import java.util.List;
public interface PayTransactionService {
- PayTransactionBO getTransaction(PayTransactionGetDTO payTransactionGetDTO);
-
- PayTransactionSubmitBO submitTransaction(PayTransactionSubmitDTO payTransactionSubmitDTO);
-
/**
* 更新交易支付成功
*
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundBO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundBO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundBO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundBO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundPageBO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundPageBO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundPageBO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundPageBO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundSubmitBO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundSubmitBO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundSubmitBO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/refund/PayRefundSubmitBO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionBO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionBO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionBO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionBO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionPageBO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionPageBO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionPageBO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/bo/transaction/PayTransactionPageBO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/constant/PayNotifyType.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant/PayNotifyType.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/constant/PayNotifyType.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant/PayNotifyType.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/constant/PayRefundStatus.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant/PayRefundStatus.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/constant/PayRefundStatus.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant/PayRefundStatus.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/constant/PayTransactionNotifyStatusEnum.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant/PayTransactionNotifyStatusEnum.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/constant/PayTransactionNotifyStatusEnum.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant/PayTransactionNotifyStatusEnum.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundPageDTO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundPageDTO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundPageDTO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundPageDTO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundSubmitDTO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundSubmitDTO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundSubmitDTO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/dto/refund/PayRefundSubmitDTO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionPageDTO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionPageDTO.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionPageDTO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/dto/transaction/PayTransactionPageDTO.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/message/AbstractPayNotifySuccessMessage.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/message/AbstractPayNotifySuccessMessage.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/message/AbstractPayNotifySuccessMessage.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/message/AbstractPayNotifySuccessMessage.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/message/PayRefundSuccessMessage.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/message/PayRefundSuccessMessage.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/message/PayRefundSuccessMessage.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/message/PayRefundSuccessMessage.java
diff --git a/pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/message/PayTransactionSuccessMessage.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/message/PayTransactionSuccessMessage.java
similarity index 100%
rename from pay/pay-service-api/src/main/java/cn/iocoder/mall/pay/api/message/PayTransactionSuccessMessage.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/message/PayTransactionSuccessMessage.java
diff --git a/pay/pay-application/src/main/java/cn/iocoder/mall/pay/application/controller/users/UsersPayTransactionController.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/application/controller/users/UsersPayTransactionController.java
deleted file mode 100644
index eff2c35e..00000000
--- a/pay/pay-application/src/main/java/cn/iocoder/mall/pay/application/controller/users/UsersPayTransactionController.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package cn.iocoder.mall.pay.application.controller.users;
-
-import cn.iocoder.common.framework.util.HttpUtil;
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.pay.api.PayTransactionService;
-import cn.iocoder.mall.pay.api.bo.transaction.PayTransactionBO;
-import cn.iocoder.mall.pay.api.bo.transaction.PayTransactionSubmitBO;
-import cn.iocoder.mall.pay.api.constant.PayChannelEnum;
-import cn.iocoder.mall.pay.api.dto.transaction.PayTransactionGetDTO;
-import cn.iocoder.mall.pay.api.dto.transaction.PayTransactionSubmitDTO;
-import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.dubbo.config.annotation.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.BufferedReader;
-import java.io.IOException;
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-@RestController
-@RequestMapping("users/transaction")
-@Api("【用户】支付交易 API")
-public class UsersPayTransactionController {
-
- private Logger logger = LoggerFactory.getLogger(getClass());
-
- @Reference(validation = "true", version = "${dubbo.provider.PayTransactionService.version}")
- private PayTransactionService payTransactionService;
-
- @GetMapping("/get")
- @ApiOperation("获得支付交易")
- public CommonResult get(PayTransactionGetDTO payTransactionGetDTO) {
- payTransactionGetDTO.setUserId(UserSecurityContextHolder.getContext().getUserId());
- return success(payTransactionService.getTransaction(payTransactionGetDTO));
- }
-
- @PostMapping("/submit")
- @ApiOperation("提交支付交易")
- public CommonResult submit(HttpServletRequest request,
- PayTransactionSubmitDTO payTransactionSubmitDTO) {
- payTransactionSubmitDTO.setCreateIp(HttpUtil.getIp(request));
- // 提交支付提交
- return success(payTransactionService.submitTransaction(payTransactionSubmitDTO));
- }
-
- @PostMapping(value = "pingxx_pay_success", consumes = MediaType.APPLICATION_JSON_VALUE)
-// @GetMapping(value = "pingxx_pay_success")
- public String pingxxPaySuccess(HttpServletRequest request) throws IOException {
- logger.info("[pingxxPaySuccess][被回调]");
- // 读取 webhook
- StringBuilder sb = new StringBuilder();
- try (BufferedReader reader = request.getReader()) {
- String line;
- while ((line = reader.readLine()) != null) {
- sb.append(line);
- }
- }
-
-// JSONObject bodyObj = JSON.parseObject(sb.toString());
-// bodyObj.put("webhookId", bodyObj.remove("id"));
-// String body = bodyObj.toString();
- payTransactionService.updateTransactionPaySuccess(PayChannelEnum.PINGXX.getId(), sb.toString());
- return "success";
- }
-
-}
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/component/DubboReferencePool.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/component/DubboReferencePool.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/component/DubboReferencePool.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/component/DubboReferencePool.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/XxlJobConfiguration.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/config/XxlJobConfiguration.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/XxlJobConfiguration.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/config/XxlJobConfiguration.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/convert/PayNotifyConvert.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/convert/PayNotifyConvert.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/convert/PayNotifyConvert.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/convert/PayNotifyConvert.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/convert/PayRefundConvert.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/convert/PayRefundConvert.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/convert/PayRefundConvert.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/convert/PayRefundConvert.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyLogMapper.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyLogMapper.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyLogMapper.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyLogMapper.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyTaskMapper.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyTaskMapper.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyTaskMapper.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayNotifyTaskMapper.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayLogDO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayLogDO.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayLogDO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayLogDO.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyLogDO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyLogDO.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyLogDO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyLogDO.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyTaskDO.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyTaskDO.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyTaskDO.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dataobject/PayNotifyTaskDO.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/job/PayNotifyJob.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/job/PayNotifyJob.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/job/PayNotifyJob.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/job/PayNotifyJob.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/mq/AbstractPayNotifySuccessConsumer.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/AbstractPayNotifySuccessConsumer.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/mq/AbstractPayNotifySuccessConsumer.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/AbstractPayNotifySuccessConsumer.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/mq/PayRefundSuccessConsumer.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/PayRefundSuccessConsumer.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/mq/PayRefundSuccessConsumer.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/PayRefundSuccessConsumer.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/mq/PayTransactionSuccessConsumer.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/PayTransactionSuccessConsumer.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/mq/PayTransactionSuccessConsumer.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/PayTransactionSuccessConsumer.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayNotifyServiceImpl.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayNotifyServiceImpl.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayNotifyServiceImpl.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayNotifyServiceImpl.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayRefundServiceImpl.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayRefundServiceImpl.java
similarity index 100%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayRefundServiceImpl.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayRefundServiceImpl.java
diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java
similarity index 78%
rename from pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java
rename to pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java
index 922f9c28..610dbcb5 100644
--- a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java
+++ b/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/service/PayTransactionServiceImpl.java
@@ -79,39 +79,6 @@ public class PayTransactionServiceImpl implements PayTransactionService {
return PayTransactionConvert.INSTANCE.convert(payTransaction);
}
- @Override
- @SuppressWarnings("Duplicates")
- public PayTransactionSubmitBO submitTransaction(PayTransactionSubmitDTO payTransactionSubmitDTO) {
- // TODO 校验支付渠道是否有效
- // 校验 App 是否有效
- payAppService.validPayApp(payTransactionSubmitDTO.getAppId());
- // 获得 PayTransactionDO ,并校验其是否存在
- PayTransactionDO payTransaction = payTransactionMapper.selectByAppIdAndOrderId(
- payTransactionSubmitDTO.getAppId(), payTransactionSubmitDTO.getOrderId());
- if (payTransaction == null) { // 是否存在
- throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_TRANSACTION_NOT_FOUND.getCode());
- }
- if (!PayTransactionStatusEnum.WAITING.getValue().equals(payTransaction.getStatus())) { // 校验状态,必须是待支付
- throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_TRANSACTION_STATUS_IS_NOT_WAITING.getCode());
- }
- // 插入 PayTransactionExtensionDO
- PayTransactionExtensionDO payTransactionExtensionDO = PayTransactionConvert.INSTANCE.convert(payTransactionSubmitDTO)
- .setTransactionId(payTransaction.getId())
- .setTransactionCode(generateTransactionCode())
- .setStatus(PayTransactionStatusEnum.WAITING.getValue());
- payTransactionExtensionMapper.insert(payTransactionExtensionDO);
- // 调用三方接口
- AbstractPaySDK paySDK = PaySDKFactory.getSDK(payTransactionSubmitDTO.getPayChannel());
- CommonResult invokeResult = paySDK.submitTransaction(payTransaction, payTransactionExtensionDO, null); // TODO 暂时传入 extra = null
- if (invokeResult.isError()) {
- throw ServiceExceptionUtil.exception(invokeResult.getCode(), invokeResult.getMessage());
- }
- // TODO 轮询三方接口,是否已经支付的任务
- // 返回成功
- return new PayTransactionSubmitBO().setId(payTransactionExtensionDO.getId())
- .setInvokeResponse(invokeResult.getData());
- }
-
@Override
@Transactional
public Boolean updateTransactionPaySuccess(Integer payChannel, String params) {
@@ -199,23 +166,7 @@ public class PayTransactionServiceImpl implements PayTransactionService {
return null;
}
- private String generateTransactionCode() {
-// wx
-// 2014
-// 10
-// 27
-// 20
-// 09
-// 39
-// 5522657
-// a690389285100
- // 目前的算法
- // 时间序列,年月日时分秒 14 位
- // 纯随机,6 位 TODO 此处估计是会有问题的,后续在调整
- return DateUtil.format(new Date(), "yyyyMMddHHmmss") + // 时间序列
- MathUtil.random(100000, 999999) // 随机。为什么是这个范围,因为偷懒
- ;
- }
+
}
diff --git a/pay/pay-service-impl/src/main/resources/config/application-test.yaml b/pay/pay-application/src/main/resources/config/application-test.yaml
similarity index 100%
rename from pay/pay-service-impl/src/main/resources/config/application-test.yaml
rename to pay/pay-application/src/main/resources/config/application-test.yaml
diff --git a/pay/pay-service-impl/src/main/resources/mapper/PayNotifyLogMapper.xml b/pay/pay-application/src/main/resources/mapper/PayNotifyLogMapper.xml
similarity index 100%
rename from pay/pay-service-impl/src/main/resources/mapper/PayNotifyLogMapper.xml
rename to pay/pay-application/src/main/resources/mapper/PayNotifyLogMapper.xml
diff --git a/pay/pay-service-impl/src/main/resources/mapper/PayNotifyTaskMapper.xml b/pay/pay-application/src/main/resources/mapper/PayNotifyTaskMapper.xml
similarity index 100%
rename from pay/pay-service-impl/src/main/resources/mapper/PayNotifyTaskMapper.xml
rename to pay/pay-application/src/main/resources/mapper/PayNotifyTaskMapper.xml
diff --git a/pay/pay-service-impl/src/main/resources/mapper/PayRefundMapper.xml b/pay/pay-application/src/main/resources/mapper/PayRefundMapper.xml
similarity index 100%
rename from pay/pay-service-impl/src/main/resources/mapper/PayRefundMapper.xml
rename to pay/pay-application/src/main/resources/mapper/PayRefundMapper.xml
diff --git a/pay/pay-service-impl/src/main/resources/mapper/PayTransactionExtensionMapper.xml b/pay/pay-application/src/main/resources/mapper/PayTransactionExtensionMapper.xml
similarity index 100%
rename from pay/pay-service-impl/src/main/resources/mapper/PayTransactionExtensionMapper.xml
rename to pay/pay-application/src/main/resources/mapper/PayTransactionExtensionMapper.xml
diff --git a/pay/pay-service-impl/src/main/resources/mapper/PayTransactionMapper.xml b/pay/pay-application/src/main/resources/mapper/PayTransactionMapper.xml
similarity index 78%
rename from pay/pay-service-impl/src/main/resources/mapper/PayTransactionMapper.xml
rename to pay/pay-application/src/main/resources/mapper/PayTransactionMapper.xml
index 0ed1bf80..a46325ab 100644
--- a/pay/pay-service-impl/src/main/resources/mapper/PayTransactionMapper.xml
+++ b/pay/pay-application/src/main/resources/mapper/PayTransactionMapper.xml
@@ -9,20 +9,6 @@
notify_time, trade_no, refund_total, create_time
-
- INSERT INTO transaction (
- app_id, create_ip, order_id, order_subject,
- order_description, order_memo, price, status, expire_time,
- finish_time, notify_url, extension_id, pay_channel, payment_time,
- notify_time, trade_no, create_time
- ) VALUES (
- #{appId}, #{createIp}, #{orderId}, #{orderSubject},
- #{orderDescription}, #{orderMemo}, #{price}, #{status}, #{expireTime},
- #{finishTime}, #{notifyUrl}, #{extensionId}, #{payChannel}, #{paymentTime},
- #{notifyTime}, #{tradeNo}, #{createTime}
- )
-
-
UPDATE transaction
@@ -68,23 +54,6 @@
AND order_id = #{orderId}
-
-
-
-