From 81126b2b4b9923b5f56ebdfa1783e63a6e736054 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 18 Oct 2021 09:41:38 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=BC=95=E5=85=A5=20IJPay=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=202.=20=E5=A2=9E=E5=8A=A0=E5=88=9B=E5=BB=BA=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=8D=95=E7=9A=84=20Service=20=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-server/pom.xml | 4 +- .../pay/dal/dataobject/package-info.java | 1 - yudao-core-service/pom.xml | 4 + .../dal/dataobject/config/InfConfigDO.java | 2 +- .../order/PayOrderCoreServiceConvert.java | 15 ++++ .../modules/pay/convert/package-info.java | 6 ++ ...‹é“ Spring Boot å¯¹è±¡è½¬æ¢ MapStruct 入门》.md | 1 + .../pay/dal/dataobject/merchant/PayAppDO.java | 15 ++-- .../dal/dataobject/merchant/PayChannelDO.java | 4 +- .../dataobject/merchant/PayMerchantDO.java | 2 +- .../pay/dal/dataobject/order/PayNotifyDO.java | 2 +- .../pay/dal/dataobject/order/PayOrderDO.java | 49 +++++----- .../dataobject/order/PayOrderExtensionDO.java | 54 +++++++++++ .../pay/dal/dataobject/order/PayRefundDO.java | 19 ++-- .../pay/dal/dataobject/package-info.java | 1 + .../dal/mysql/merchant/PayAppCoreMapper.java | 9 ++ .../dal/mysql/order/PayOrderCoreMapper.java | 16 ++++ .../pay/enums/PayErrorCodeConstants.java | 16 ++++ .../enums/merchant/PayChannelCodeEnum.java | 28 ++++++ .../pay/enums/order/PayOrderStatusEnum.java | 29 ++++++ .../coreservice/modules/pay/package-info.java | 7 ++ .../service/merchant/PayAppCoreService.java | 23 +++++ .../merchant/impl/PayAppCoreServiceImpl.java | 43 +++++++++ .../service/order/PayOrderCoreService.java | 33 +++++++ .../order/dto/PayOrderCreateReqDTO.java | 64 +++++++++++++ .../order/dto/PayOrderSubmitReqDTO.java | 41 +++++++++ .../order/dto/PayOrderSubmitRespDTO.java | 23 +++++ .../order/impl/PayOrderCoreServiceImpl.java | 89 +++++++++++++++++++ .../modules/pay/service/package-info.java | 1 + yudao-dependencies/pom.xml | 13 +++ .../yudao-spring-boot-starter-biz-pay/pom.xml | 21 ++--- .../core/domain/merchant/package-info.java | 8 -- .../pay/core/domain/package-info.java | 8 -- .../pay/core/domain/pay/package-info.java | 8 -- .../pay/core/domain/refund/package-info.java | 8 -- 更新日志.md | 5 +- 36 files changed, 587 insertions(+), 85 deletions(-) delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/package-info.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/order/PayOrderCoreServiceConvert.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/package-info.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/ã€ŠèŠ‹é“ Spring Boot å¯¹è±¡è½¬æ¢ MapStruct 入门》.md rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/pay/dal/dataobject/merchant/PayAppDO.java (82%) rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/pay/dal/dataobject/merchant/PayChannelDO.java (87%) rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/pay/dal/dataobject/merchant/PayMerchantDO.java (93%) rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/pay/dal/dataobject/order/PayNotifyDO.java (85%) rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/pay/dal/dataobject/order/PayOrderDO.java (76%) create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderExtensionDO.java rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/pay/dal/dataobject/order/PayRefundDO.java (82%) create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/package-info.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayAppCoreMapper.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/order/PayOrderCoreMapper.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeConstants.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/order/PayOrderStatusEnum.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/package-info.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/PayAppCoreService.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/impl/PayAppCoreServiceImpl.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreService.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderCreateReqDTO.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitReqDTO.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitRespDTO.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/merchant/package-info.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/package-info.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/pay/package-info.java delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/refund/package-info.java diff --git a/yudao-admin-server/pom.xml b/yudao-admin-server/pom.xml index 120d3e926f..9200eb7710 100644 --- a/yudao-admin-server/pom.xml +++ b/yudao-admin-server/pom.xml @@ -122,11 +122,11 @@ screw-core - + + com.xkcoding.justauth justauth-spring-boot-starter - 1.4.0 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/package-info.java deleted file mode 100644 index b89b77f7e1..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject; diff --git a/yudao-core-service/pom.xml b/yudao-core-service/pom.xml index 3ce350b549..278c33fc75 100644 --- a/yudao-core-service/pom.xml +++ b/yudao-core-service/pom.xml @@ -32,6 +32,10 @@ cn.iocoder.boot yudao-spring-boot-starter-biz-sms + + cn.iocoder.boot + yudao-spring-boot-starter-biz-pay + diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java index 5955fe18c3..c8d58196ee 100644 --- a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java @@ -11,7 +11,7 @@ import lombok.ToString; /** * å‚æ•°é…置表 * - * @author ruoyi + * @author 芋é“æºç  */ @TableName("inf_config") @Data diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/order/PayOrderCoreServiceConvert.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/order/PayOrderCoreServiceConvert.java new file mode 100644 index 0000000000..dd6084b117 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/order/PayOrderCoreServiceConvert.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.coreservice.modules.pay.convert.order; + +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderCreateReqDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface PayOrderCoreServiceConvert { + + PayOrderCoreServiceConvert INSTANCE = Mappers.getMapper(PayOrderCoreServiceConvert.class); + + PayOrderDO convert(PayOrderCreateReqDTO bean); + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/package-info.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/package-info.java new file mode 100644 index 0000000000..b10c090290 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/package-info.java @@ -0,0 +1,6 @@ +/** + * æä¾› POJO ç±»çš„å®žä½“è½¬æ¢ + * + * ç›®å‰ä½¿ç”¨ MapStruct 框架 + */ +package cn.iocoder.yudao.coreservice.modules.pay.convert; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/ã€ŠèŠ‹é“ Spring Boot å¯¹è±¡è½¬æ¢ MapStruct 入门》.md b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/ã€ŠèŠ‹é“ Spring Boot å¯¹è±¡è½¬æ¢ MapStruct 入门》.md new file mode 100644 index 0000000000..8153487b72 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/convert/ã€ŠèŠ‹é“ Spring Boot å¯¹è±¡è½¬æ¢ MapStruct 入门》.md @@ -0,0 +1 @@ + diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayAppDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayAppDO.java similarity index 82% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayAppDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayAppDO.java index eefdca6827..859e490a51 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayAppDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayAppDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant; +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @@ -22,11 +22,6 @@ public class PayAppDO extends BaseDO { */ @TableId private Long id; - /** - * åº”ç”¨å· - * 例如说,60cc81e0e4b06afc4d3f0cfq - */ - private String no; /** * 应用å */ @@ -46,6 +41,14 @@ public class PayAppDO extends BaseDO { * TODO 芋艿:用途 */ private String secret; + /** + * æ”¯ä»˜ç»“æžœçš„å›žè°ƒåœ°å€ + */ + private String payNotifyUrl; + /** + * é€€æ¬¾ç»“æžœçš„å›žè°ƒåœ°å€ + */ + private String refundNotifyUrl; /** * å•†æˆ·ç¼–å· diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayChannelDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java similarity index 87% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayChannelDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java index 190debdab9..0fa8666968 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayChannelDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDO.java @@ -1,6 +1,6 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant; +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant; -import cn.iocoder.yudao.adminserver.modules.pay.enums.PayChannelCodeEnum; +import cn.iocoder.yudao.coreservice.modules.pay.enums.merchant.PayChannelCodeEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import lombok.Data; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayMerchantDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayMerchantDO.java similarity index 93% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayMerchantDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayMerchantDO.java index 0d64d4c3af..81a3710d5d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/merchant/PayMerchantDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayMerchantDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant; +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayNotifyDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayNotifyDO.java similarity index 85% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayNotifyDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayNotifyDO.java index 110e1a0824..b9e948f5e2 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayNotifyDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayNotifyDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.order; +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import lombok.Data; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayOrderDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java similarity index 76% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayOrderDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java index 88c0012a98..273078ac17 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayOrderDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderDO.java @@ -1,11 +1,15 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.order; +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order; -import cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.adminserver.modules.pay.enums.PayChannelCodeEnum; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; +import cn.iocoder.yudao.coreservice.modules.pay.enums.merchant.PayChannelCodeEnum; +import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import java.util.Date; @@ -14,19 +18,22 @@ import java.util.Date; * * @author 芋é“æºç  */ +@TableName("pay_order") @Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) public class PayOrderDO extends BaseDO { /** * 订å•ç¼–å·ï¼Œæ•°æ®åº“自增 */ private Long id; - /** - * 订å•å·ï¼Œæ ¹æ®è§„åˆ™ç”Ÿæˆ - * - * 例如说,P202110132239124200055 - */ - private String no; +// /** +// * 订å•å·ï¼Œæ ¹æ®è§„åˆ™ç”Ÿæˆ +// * +// * 例如说,P202110132239124200055 +// */ +// private String no; /** * å•†æˆ·ç¼–å· * @@ -42,7 +49,7 @@ public class PayOrderDO extends BaseDO { /** * 渠é“ç¼–å· * - * å…³è” {@link PayChannelDO#getMerchantId()} + * å…³è” {@link PayChannelDO#getId()} */ private Long channelId; /** @@ -55,10 +62,10 @@ public class PayOrderDO extends BaseDO { // ========== 商户相关字段 ========== /** - * 商户订å•å· + * 商户订å•ç¼–å· * 例如说,内部系统 A 的订å•å·ã€‚需è¦ä¿è¯æ¯ä¸ª PayMerchantDO 唯一 TODO 芋艿:需è¦åœ¨æµ‹è¯•ä¸‹ */ - private String merchantOrderNo; + private String merchantOrderId; /** * 商å“标题 */ @@ -71,11 +78,6 @@ public class PayOrderDO extends BaseDO { * 商户拓展å‚æ•° */ private String merchantExtra; - /** - * é€šçŸ¥å•†æˆ·æ”¯ä»˜ç»“æžœçš„å›žè°ƒçŠ¶æ€ - * TODO 芋艿:0 未å‘é€ 1 å·²å‘é€ - */ - private Integer notifyStatus; // ========== 订å•ç›¸å…³å­—段 ========== @@ -96,9 +98,14 @@ public class PayOrderDO extends BaseDO { /** * æ”¯ä»˜çŠ¶æ€ * - * TODO 芋艿:状æ€æžšä¸¾ + * 枚举 {@link PayOrderStatusEnum} */ private Integer status; + /** + * é€šçŸ¥å•†æˆ·æ”¯ä»˜ç»“æžœçš„å›žè°ƒçŠ¶æ€ + * TODO 芋艿:0 未å‘é€ 1 å·²å‘é€ + */ + private Integer notifyStatus; /** * 客户端 IP */ @@ -110,7 +117,7 @@ public class PayOrderDO extends BaseDO { /** * 订å•å¤±æ•ˆæ—¶é—´ */ - private Date expiredTime; + private Date expireTime; /** * 支付渠é“çš„é¢å¤–å‚æ•° * diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderExtensionDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderExtensionDO.java new file mode 100644 index 0000000000..6dce032c8a --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayOrderExtensionDO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 交易扩展表 + */ +@TableName("pay_transaction_extension") +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class PayOrderExtensionDO extends BaseDO { + + /** + * ç¼–å·ï¼Œè‡ªå¢ž + */ + private Integer id; + /** + * äº¤æ˜“ç¼–å· {@link PayTransactionDO#getId()} + */ + private Integer transactionId; + /** + * é€‰æ‹©çš„æ”¯ä»˜æ¸ é“ + */ + private Integer payChannel; + /** + * 生æˆä¼ è¾“给第三方的订å•å· + * + * 唯一索引 + */ + private String transactionCode; + /** + * 扩展内容 + * + * å¼‚æ­¥é€šçŸ¥çš„æ—¶å€™å¡«å……å›žè°ƒçš„æ•°æ® + */ + private String extensionData; + /** + * å‘起交易的 IP + */ + private String createIp; + /** + * çŠ¶æ€ + * + * @see cn.iocoder.mall.payservice.enums.transaction.PayTransactionStatusEnum + * 注æ„,åªåŒ…å«ä¸Šè¿°æžšä¸¾çš„ WAITING å’Œ SUCCESS + */ + private Integer status; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayRefundDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java similarity index 82% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayRefundDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java index 375fee5b44..6f9ce70608 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/pay/dal/dataobject/order/PayRefundDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayRefundDO.java @@ -1,9 +1,9 @@ -package cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.order; +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order; -import cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.adminserver.modules.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.adminserver.modules.pay.enums.PayChannelCodeEnum; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO; +import cn.iocoder.yudao.coreservice.modules.pay.enums.merchant.PayChannelCodeEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import lombok.Data; @@ -45,7 +45,7 @@ public class PayRefundDO extends BaseDO { /** * 渠é“ç¼–å· * - * å…³è” {@link PayChannelDO#getMerchantId()} + * å…³è” {@link PayChannelDO#getId()} */ private Long channelId; /** @@ -79,6 +79,11 @@ public class PayRefundDO extends BaseDO { * TODO 芋艿:状æ€æžšä¸¾ */ private Integer status; + /** + * é€šçŸ¥å•†æˆ·é€€æ¬¾ç»“æžœçš„å›žè°ƒçŠ¶æ€ + * TODO 芋艿:0 未å‘é€ 1 å·²å‘é€ + */ + private Integer notifyStatus; /** * 客户端 IP */ @@ -98,7 +103,7 @@ public class PayRefundDO extends BaseDO { /** * 退款失效时间 */ - private Date expiredTime; + private Date expireTime; /** * 支付渠é“çš„é¢å¤–å‚æ•° * diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/package-info.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/package-info.java new file mode 100644 index 0000000000..8fe90e379c --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayAppCoreMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayAppCoreMapper.java new file mode 100644 index 0000000000..603ff4609c --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayAppCoreMapper.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.merchant; + +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PayAppCoreMapper extends BaseMapperX { +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/order/PayOrderCoreMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/order/PayOrderCoreMapper.java new file mode 100644 index 0000000000..a2879741b1 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/order/PayOrderCoreMapper.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.order; + +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PayOrderCoreMapper extends BaseMapperX { + + default PayOrderDO selectByAppIdAndMerchantOrderId(Long appId, String merchantOrderId) { + return selectOne(new QueryWrapper().eq("app_id", appId) + .eq("merchant_order_id", merchantOrderId)); + } + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeConstants.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeConstants.java new file mode 100644 index 0000000000..affb3ddeb6 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/PayErrorCodeConstants.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.coreservice.modules.pay.enums; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; + +/** + * Pay 错误ç æžšä¸¾ç±» + * + * pay 系统,使用 1-007-000-000 段 + */ +public interface PayErrorCodeConstants { + + // ========== APP æ¨¡å— 1-007-000-000 ========== + ErrorCode PAY_APP_NOT_FOUND = new ErrorCode(1007000000, "App ä¸å­˜åœ¨"); + ErrorCode PAY_APP_IS_DISABLE = new ErrorCode(1007000002, "App å·²ç»è¢«ç¦ç”¨"); + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java new file mode 100644 index 0000000000..9e8f7eba18 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/merchant/PayChannelCodeEnum.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.coreservice.modules.pay.enums.merchant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 支付渠é“çš„ç¼–ç çš„枚举 + * + * @author 芋é“æºç  + */ +@Getter +@AllArgsConstructor +public enum PayChannelCodeEnum { + + wx_pub("wx_pub", "微信 JSAPI 支付"); + + /** + * ç¼–ç  + * + * å‚考 https://www.pingxx.com/api/支付渠é“属性值.html + */ + private String code; + /** + * åå­— + */ + private String name; + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/order/PayOrderStatusEnum.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/order/PayOrderStatusEnum.java new file mode 100644 index 0000000000..b61c0400ce --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/order/PayOrderStatusEnum.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.coreservice.modules.pay.enums.order; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 支付订å•çš„状æ€æžšä¸¾ + * + * @author 芋é“æºç  + */ +@Getter +@AllArgsConstructor +public enum PayOrderStatusEnum implements IntArrayValuable { + + WAITING(0, "未支付"), + SUCCESS(10, "支付æˆåŠŸ"), + CLOSED(20, "支付关闭"), // 未付款交易超时关闭,或支付完æˆåŽå…¨é¢é€€æ¬¾ TODO 芋艿:需è¦ä¼˜åŒ–下 + ; + + private final Integer status; + private final String name; + + @Override + public int[] array() { + return new int[0]; + } + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/package-info.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/package-info.java new file mode 100644 index 0000000000..8f5ba6ac30 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/package-info.java @@ -0,0 +1,7 @@ +/** + * pay 包下,我们放支付业务,æ供业务的支付能力。 + * 例如说:商户ã€åº”用ã€æ”¯ä»˜ã€é€€æ¬¾ç­‰ç­‰ + * + * 缩写:pay + */ +package cn.iocoder.yudao.coreservice.modules.pay; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/PayAppCoreService.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/PayAppCoreService.java new file mode 100644 index 0000000000..ab6f3f27f0 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/PayAppCoreService.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.merchant; + +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.framework.common.exception.ServiceException; + +/** + * 支付应用 Core Service æŽ¥å£ + * + * @author 芋é“æºç  + */ +public interface PayAppCoreService { + + /** + * 支付应用的åˆæ³•æ€§ + * + * 如果ä¸åˆæ³•ï¼ŒæŠ›å‡º {@link ServiceException} 业务异常 + * + * @param id åº”ç”¨ç¼–å· + * @return åº”ç”¨ä¿¡æ¯ + */ + PayAppDO validPayApp(Long id); + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/impl/PayAppCoreServiceImpl.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/impl/PayAppCoreServiceImpl.java new file mode 100644 index 0000000000..784a213a35 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/impl/PayAppCoreServiceImpl.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.merchant.impl; + +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.merchant.PayAppCoreMapper; +import cn.iocoder.yudao.coreservice.modules.pay.service.merchant.PayAppCoreService; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.validation.Valid; + +import static cn.iocoder.yudao.coreservice.modules.pay.enums.PayErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; + +/** + * 支付应用 Core Service 实现类 + * + * @author 芋é“æºç  + */ +@Service +@Valid +@Slf4j +public class PayAppCoreServiceImpl implements PayAppCoreService { + + @Resource + private PayAppCoreMapper payAppCoreMapper; + + @Override + public PayAppDO validPayApp(Long id) { + PayAppDO app = payAppCoreMapper.selectById(id); + // 校验是å¦å­˜åœ¨ + if (app == null) { + throw exception(PAY_APP_NOT_FOUND); + } + // 校验是å¦ç¦ç”¨ + if (CommonStatusEnum.DISABLE.getStatus().equals(app.getStatus())) { + throw exception(PAY_APP_IS_DISABLE); + } + return app; + } + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreService.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreService.java new file mode 100644 index 0000000000..329f28babf --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreService.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.order; + +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderCreateReqDTO; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitReqDTO; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitRespDTO; + +import javax.validation.Valid; + +/** + * æ”¯ä»˜è®¢å• Core Service + * + * @author 芋é“æºç  + */ +public interface PayOrderCoreService { + + /** + * åˆ›å»ºæ”¯ä»˜å• + * + * @param reqDTO 创建请求 + * @return 支付å•ç¼–å· + */ + Long createPayOrder(@Valid PayOrderCreateReqDTO reqDTO); + + /** + * æ交支付 + * 此时,会å‘起支付渠é“的调用 + * + * @param reqDTO æ交请求 + * @return æ交结果 + */ + PayOrderSubmitRespDTO submitPayOrder(PayOrderSubmitReqDTO reqDTO); + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderCreateReqDTO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderCreateReqDTO.java new file mode 100644 index 0000000000..17a27fcfa1 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderCreateReqDTO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.order.dto; + +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 支付å•åˆ›å»º Request DTO + */ +@Data +public class PayOrderCreateReqDTO implements Serializable { + + /** + * åº”ç”¨ç¼–å· + */ + @NotEmpty(message = "应用编å·ä¸èƒ½ä¸ºç©º") + private Long appId; + /** + * 客户端 IP + */ + @NotEmpty(message = "客户端 IP ä¸èƒ½ä¸ºç©º") + private String clientIp; + + // ========== 商户相关字段 ========== + + /** + * 商户订å•ç¼–å· + */ + @NotEmpty(message = "商户订å•ç¼–å·ä¸èƒ½ä¸ºç©º") + private String merchantOrderId; + /** + * 商å“标题 + */ + @NotEmpty(message = "商å“标题ä¸èƒ½ä¸ºç©º") + @Length(max = 32, message = "商å“标题ä¸èƒ½è¶…过 32") + private String subject; + /** + * 商å“æè¿°ä¿¡æ¯ + */ + @NotEmpty(message = "商å“æè¿°ä¿¡æ¯ä¸èƒ½ä¸ºç©º") + @Length(max = 128, message = "商å“æè¿°ä¿¡æ¯é•¿åº¦ä¸èƒ½è¶…过128") + private String body; + + // ========== 订å•ç›¸å…³å­—段 ========== + + /** + * 支付金é¢ï¼Œå•ä½ï¼šåˆ† + */ + @NotNull(message = "支付金é¢ä¸èƒ½ä¸ºç©º") + @DecimalMin(value = "0", inclusive = false, message = "支付金é¢å¿…须大于零") + private Integer amount; + + /** + * 支付过期时间 + */ + @NotNull(message = "支付过期时间ä¸èƒ½ä¸ºç©º") + private Date expireTime; + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitReqDTO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitReqDTO.java new file mode 100644 index 0000000000..c2d1558653 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitReqDTO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.order.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 支付å•æ交 Request DTO + */ +@Data +@Accessors(chain = true) +public class PayOrderSubmitReqDTO implements Serializable { + + /** + * åº”ç”¨ç¼–å· + */ + @NotEmpty(message = "应用编å·ä¸èƒ½ä¸ºç©º") + private String appId; + + /** + * 支付å•ç¼–å· + */ + @NotNull(message = "支付å•ç¼–å·ä¸èƒ½ä¸ºç©º") + private Long id; + + /** + * æ”¯ä»˜æ¸ é“ + */ + @NotNull(message = "支付渠é“") + private String channelCode; + + /** + * 客户端 IP + */ + @NotEmpty(message = "客户端 IP ä¸èƒ½ä¸ºç©º") + private String clientIp; + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitRespDTO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitRespDTO.java new file mode 100644 index 0000000000..b1a5d2e108 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/dto/PayOrderSubmitRespDTO.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.order.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 支付å•æ交 Response DTO + */ +@Data +public class PayOrderSubmitRespDTO implements Serializable { + + /** + * 支付拓展å•çš„ç¼–å· + */ + private Long extensionId; + + /** + * 调用支付渠é“çš„å“应结果 + */ + private String invokeResponse; + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java new file mode 100644 index 0000000000..60b2877a8f --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java @@ -0,0 +1,89 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service.order.impl; + +import cn.iocoder.yudao.coreservice.modules.pay.convert.order.PayOrderCoreServiceConvert; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO; +import cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.order.PayOrderCoreMapper; +import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum; +import cn.iocoder.yudao.coreservice.modules.pay.service.merchant.PayAppCoreService; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.PayOrderCoreService; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderCreateReqDTO; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitReqDTO; +import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitRespDTO; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.validation.Valid; + +/** + * æ”¯ä»˜è®¢å• Core Service 实现类 + */ +@Service +@Valid +@Slf4j +public class PayOrderCoreServiceImpl implements PayOrderCoreService { + + @Resource + private PayAppCoreService payAppCoreService; + + @Resource + private PayOrderCoreMapper payOrderCoreMapper; + + @Override + public Long createPayOrder(PayOrderCreateReqDTO reqDTO) { + // 校验 App + PayAppDO app = payAppCoreService.validPayApp(reqDTO.getAppId()); + + // 查询对应的支付交易å•æ˜¯å¦å·²ç»å­˜åœ¨ã€‚如果是,则直接返回 + PayOrderDO order = payOrderCoreMapper.selectByAppIdAndMerchantOrderId( + reqDTO.getAppId(), reqDTO.getMerchantOrderId()); + if (order != null) { + log.warn("[createPayOrder][appId({}) merchantOrderId({}) å·²ç»å­˜åœ¨å¯¹åº”的支付å•({})]", order.getAppId(), + order.getMerchantOrderId(), JsonUtils.toJsonString(order)); // ç†è®ºæ¥è¯´ï¼Œä¸ä¼šå‡ºçŽ°è¿™ä¸ªæƒ…况 + return app.getId(); + } + + // åˆ›å»ºæ”¯ä»˜äº¤æ˜“å• + order = PayOrderCoreServiceConvert.INSTANCE.convert(reqDTO) + .setStatus(PayOrderStatusEnum.WAITING.getStatus()) + .setNotifyUrl(app.getPayNotifyUrl()); + payOrderCoreMapper.insert(order); + // 最终返回 + return order.getId(); + } + + @Override + public PayOrderSubmitRespDTO submitPayOrder(PayOrderSubmitReqDTO reqDTO) { + // 校验 App + PayAppDO app = payAppCoreService.validPayApp(reqDTO.getId()); + // TODO 校验支付渠é“是å¦æœ‰æ•ˆ + + // 获得 PayOrderDO ,并校验其是å¦å­˜åœ¨ + PayOrderDO order = payOrderCoreMapper.selectById(reqDTO.getId()); + if (order == null) { // 是å¦å­˜åœ¨ + throw exception(PAY_TRANSACTION_NOT_FOUND); + } + if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状æ€ï¼Œå¿…须是待支付 + throw exception(PAY_TRANSACTION_STATUS_IS_NOT_WAITING); + } + + // æ’å…¥ PayTransactionExtensionDO + PayTransactionExtensionDO payTransactionExtensionDO = PayTransactionConvert.INSTANCE.convert(submitReqDTO) + .setTransactionId(payTransaction.getId()).setTransactionCode(generateTransactionCode()) + .setStatus(PayTransactionStatusEnum.WAITING.getStatus()); + 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()); + } + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java new file mode 100644 index 0000000000..13b4863a5b --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.coreservice.modules.pay.service; diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 125d3bdafc..43dfea757c 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -52,6 +52,7 @@ 4.5.25 2.1.0 1.2.7 + 1.4.0 @@ -92,6 +93,11 @@ yudao-spring-boot-starter-biz-sms ${revision} + + cn.iocoder.boot + yudao-spring-boot-starter-biz-pay + ${revision} + @@ -421,6 +427,13 @@ ${aliyun-java-sdk-dysmsapi.version} + + + com.xkcoding.justauth + justauth-spring-boot-starter + ${justauth.version} + + diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml index 606a435d72..4cc0eed0b3 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/pom.xml @@ -11,23 +11,24 @@ yudao-spring-boot-starter-biz-pay ${artifactId} - 支付核心业务 + 支付拓展,基于 IJPay 简å•å°è£…,支æŒå¾®ä¿¡ã€æ”¯ä»˜å®ç­‰å¸¸è§æ”¯ä»˜æ¸ é“ - - cn.iocoder.boot - yudao-spring-boot-starter-extension - ${revision} - - cn.iocoder.boot yudao-common + - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog + com.github.javen205 + IJPay-AliPay + 2.7.8 + + + com.github.javen205 + IJPay-WxPay + 2.7.8 - \ No newline at end of file + diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/merchant/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/merchant/package-info.java deleted file mode 100644 index fb2b3a848a..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/merchant/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-10-12 10:42 - * @class cn.iocoder.yudao.framework.pay.core.domain.merchant.package-info.java - */ -package cn.iocoder.yudao.framework.pay.core.domain.merchant; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/package-info.java deleted file mode 100644 index d01b48c17c..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-09-29 14:44 - * @class cn.iocoder.yudao.framework.pay.core.domain.package-info.java - */ -package cn.iocoder.yudao.framework.pay.core.domain; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/pay/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/pay/package-info.java deleted file mode 100644 index f0b0ee10cb..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/pay/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-10-12 10:42 - * @class cn.iocoder.yudao.framework.pay.core.domain.pay.package-info.java - */ -package cn.iocoder.yudao.framework.pay.core.domain.pay; \ No newline at end of file diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/refund/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/refund/package-info.java deleted file mode 100644 index 860421c4c8..0000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/domain/refund/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @description - * @author Qingchen - * @version 1.0.0 - * @date 2021-10-12 10:42 - * @class cn.iocoder.yudao.framework.pay.core.domain.refund.package-info.java - */ -package cn.iocoder.yudao.framework.pay.core.domain.refund; \ No newline at end of file diff --git a/更新日志.md b/更新日志.md index 206599b25d..4b631772a6 100644 --- a/更新日志.md +++ b/更新日志.md @@ -7,10 +7,13 @@ * å·¥ä½œæµ +## [v1.1.2] 待定 + +* 用户å‰å°çš„社交登陆 + ## [v1.1.1] 待定 * 支付 -* 用户å‰å°çš„社交登陆 ## [v1.1.0] 进行中