From d45213fe2a4ba290be3c27c9d4bf55cc3e3d2740 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 31 Jan 2022 22:14:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A8=A1=E5=9D=97=E9=87=8D=E6=9E=84?= =?UTF-8?q?=207=EF=BC=9Apay=20=E6=A8=A1=E5=9D=97=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 3 +- yudao-core-service/pom.xml | 106 ---------------- .../modules/pay/service/package-info.java | 1 - .../src/test/resources/sql/create_tables.sql | 18 ++- .../test/resources/application-unit-test.yaml | 4 + .../dataobject/merchant/PayChannelDOTest.java | 2 +- .../PayChannelMapperIntegrationTest.java | 16 +-- .../order/PayOrderServiceIntegrationTest.java | 25 ++-- .../module/pay/service/package-info.java | 1 + .../test}/BaseDbAndRedisIntegrationTest.java | 2 +- .../pay/test}/BaseDbIntegrationTest.java | 2 +- .../pay/test}/BaseRedisIntegrationTest.java | 2 +- .../application-integration-test.yaml | 1 + .../service/merchant/PayAppServiceTest.java | 6 +- .../merchant/PayChannelServiceTest.java | 8 ++ .../service/order/PayOrderServiceTest.java | 19 ++- .../service/refund/PayRefundServiceTest.java | 25 +++- .../test/resources/application-unit-test.yaml | 54 ++++++++ .../src/test/resources/logback-spring.xml | 4 + .../src/test/resources/sql/clean.sql | 5 + .../src/test/resources/sql/create_tables.sql | 115 ++++++++++++++++++ 21 files changed, 271 insertions(+), 148 deletions(-) delete mode 100644 yudao-core-service/pom.xml delete mode 100644 yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java rename {yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules => yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module}/pay/dal/dataobject/merchant/PayChannelDOTest.java (92%) rename yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayChannelCoreMapperTest.java => yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java (89%) rename yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreServiceTest.java => yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java (55%) create mode 100644 yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java rename {yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice => yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test}/BaseDbAndRedisIntegrationTest.java (98%) rename {yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice => yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test}/BaseDbIntegrationTest.java (97%) rename {yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice => yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test}/BaseRedisIntegrationTest.java (95%) rename {yudao-core-service => yudao-module-pay/yudao-module-pay-impl}/src/test-integration/resources/application-integration-test.yaml (98%) create mode 100644 yudao-module-pay/yudao-module-pay-impl/src/test/resources/application-unit-test.yaml create mode 100644 yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback-spring.xml create mode 100644 yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/clean.sql create mode 100644 yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/create_tables.sql diff --git a/pom.xml b/pom.xml index e5294f7d8..dac70439b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,9 +10,10 @@ yudao-dependencies yudao-framework + yudao-admin-server yudao-user-server - yudao-core-service + yudao-module-member yudao-module-system diff --git a/yudao-core-service/pom.xml b/yudao-core-service/pom.xml deleted file mode 100644 index ccb1e1600..000000000 --- a/yudao-core-service/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - cn.iocoder.boot - yudao - ${revision} - - 4.0.0 - - yudao-core-service - jar - - yudao-core-service - - 公共服务,通过 jar 包的方式,被 yudao-admin-server、yudao-user-service 使用。例如说: - 1. 日志相关:访问日志、登录日志、异常日志等等 - 2. 认证相关:在线 Session - 3. 短信相关:短信模板、短信日志 - 等等 - - https://github.com/YunaiV/ruoyi-vue-pro - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-dict - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-sms - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-pay - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.boot - yudao-spring-boot-starter-redis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-config - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mq - - - - - cn.iocoder.boot - yudao-spring-boot-starter-protection - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - - - - com.google.guava - guava - - - - - diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java b/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java deleted file mode 100644 index 13b4863a5..000000000 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.coreservice.modules.pay.service; diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql index 8b6433e69..54e6ab622 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql @@ -1,5 +1,3 @@ --- bpm 开头的 DB - CREATE TABLE IF NOT EXISTS "bpm_form" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" varchar(63) NOT NULL, @@ -13,4 +11,18 @@ CREATE TABLE IF NOT EXISTS "bpm_form" ( "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") -) COMMENT '动态表单'; + ) COMMENT '动态表单'; + +CREATE TABLE IF NOT EXISTS "bpm_user_group" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar(63) NOT NULL, + "description" varchar(255) NOT NULL, + "status" tinyint NOT NULL, + "member_user_ids" varchar(255) NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") + ) COMMENT '用户组'; diff --git a/yudao-module-infra/yudao-module-infra-impl/src/test/resources/application-unit-test.yaml b/yudao-module-infra/yudao-module-infra-impl/src/test/resources/application-unit-test.yaml index 42e5e356d..e8e47b445 100644 --- a/yudao-module-infra/yudao-module-infra-impl/src/test/resources/application-unit-test.yaml +++ b/yudao-module-infra/yudao-module-infra-impl/src/test/resources/application-unit-test.yaml @@ -48,3 +48,7 @@ yudao: base-package2: cn.iocoder.yudao.module core-service: base-package: cn.iocoder.yudao.module.member.dal.mysql # TODO 芋艿:要清理掉 + pay: + pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify + pay-return-url: http://niubi.natapp1.cc/api/pay/order/return + refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDOTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java similarity index 92% rename from yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDOTest.java rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java index c0fb7d5bd..2818cb12d 100644 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/merchant/PayChannelDOTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant; +package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayChannelCoreMapperTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java similarity index 89% rename from yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayChannelCoreMapperTest.java rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java index 18445a4ec..b869163a2 100644 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/merchant/PayChannelCoreMapperTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java @@ -1,12 +1,12 @@ -package cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.merchant; +package cn.iocoder.yudao.module.pay.dal.mysql.merchant; import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.coreservice.BaseDbAndRedisIntegrationTest; -import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; import org.junit.jupiter.api.Test; import javax.annotation.Resource; @@ -15,10 +15,10 @@ import java.io.FileNotFoundException; import java.util.List; @Resource -public class PayChannelCoreMapperTest extends BaseDbAndRedisIntegrationTest { +public class PayChannelMapperIntegrationTest extends BaseDbIntegrationTest { @Resource - private PayChannelCoreMapper payChannelCoreMapper; + private PayChannelMapper payChannelMapper; /** * 插入 {@link PayChannelEnum#WX_PUB} 初始配置 @@ -42,7 +42,7 @@ public class PayChannelCoreMapperTest extends BaseDbAndRedisIntegrationTest { config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); payChannelDO.setConfig(config); // 执行插入 - payChannelCoreMapper.insert(payChannelDO); + payChannelMapper.insert(payChannelDO); } // TODO @ouyang:Zfb 改成 AlipayQr @@ -67,7 +67,7 @@ public class PayChannelCoreMapperTest extends BaseDbAndRedisIntegrationTest { // 创建客户端 payChannelDO.setConfig(config); // 执行插入 - payChannelCoreMapper.insert(payChannelDO); + payChannelMapper.insert(payChannelDO); } /** @@ -75,7 +75,7 @@ public class PayChannelCoreMapperTest extends BaseDbAndRedisIntegrationTest { */ @Test public void testSelectList() { - List payChannels = payChannelCoreMapper.selectList(); + List payChannels = payChannelMapper.selectList(); System.out.println(payChannels.size()); } diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreServiceTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java similarity index 55% rename from yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreServiceTest.java rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java index 2a5e13741..f6f953635 100644 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/PayOrderCoreServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java @@ -1,11 +1,10 @@ -package cn.iocoder.yudao.coreservice.modules.pay.service.order; +package cn.iocoder.yudao.module.pay.service.order; -import cn.iocoder.yudao.coreservice.BaseDbIntegrationTest; -import cn.iocoder.yudao.coreservice.modules.pay.service.merchant.impl.PayAppCoreServiceImpl; -import cn.iocoder.yudao.coreservice.modules.pay.service.merchant.impl.PayChannelCoreServiceImpl; -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.impl.PayOrderCoreServiceImpl; +import cn.iocoder.yudao.module.pay.service.merchant.PayAppServiceImpl; +import cn.iocoder.yudao.module.pay.service.merchant.PayChannelServiceImpl; +import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderCreateReqDTO; +import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderSubmitReqDTO; +import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; @@ -15,12 +14,12 @@ import org.springframework.context.annotation.Import; import javax.annotation.Resource; import java.time.Duration; -@Import({PayOrderCoreServiceImpl.class, PayAppCoreServiceImpl.class, - PayChannelCoreServiceImpl.class, YudaoPayAutoConfiguration.class}) -public class PayOrderCoreServiceTest extends BaseDbIntegrationTest { +@Import({PayOrderServiceImpl.class, PayAppServiceImpl.class, + PayChannelServiceImpl.class, YudaoPayAutoConfiguration.class}) +public class PayOrderServiceIntegrationTest extends BaseDbIntegrationTest { @Resource - private PayOrderCoreService payOrderCoreService; + private PayOrderService payOrderService; @Test public void testCreatePayOrder() { @@ -34,7 +33,7 @@ public class PayOrderCoreServiceTest extends BaseDbIntegrationTest { reqDTO.setAmount(100); reqDTO.setExpireTime(DateUtils.addTime(Duration.ofDays(1))); // 发起请求 - payOrderCoreService.createPayOrder(reqDTO); + payOrderService.createPayOrder(reqDTO); } @Test @@ -46,7 +45,7 @@ public class PayOrderCoreServiceTest extends BaseDbIntegrationTest { reqDTO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); reqDTO.setUserIp("127.0.0.1"); // 发起请求 - payOrderCoreService.submitPayOrder(reqDTO); + payOrderService.submitPayOrder(reqDTO); } } diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java new file mode 100644 index 000000000..2cad91eba --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.pay.service; diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseDbAndRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java similarity index 98% rename from yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseDbAndRedisIntegrationTest.java rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java index dc1580894..2ee19ebf9 100644 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseDbAndRedisIntegrationTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.coreservice; +package cn.iocoder.yudao.module.pay.test; import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseDbIntegrationTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java similarity index 97% rename from yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseDbIntegrationTest.java rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java index c0ebe9873..380efa3f4 100644 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseDbIntegrationTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.coreservice; +package cn.iocoder.yudao.module.pay.test; import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; diff --git a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java similarity index 95% rename from yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseRedisIntegrationTest.java rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java index 16b5e98f1..d01353d72 100644 --- a/yudao-core-service/src/test-integration/java/cn/iocoder/yudao/coreservice/BaseRedisIntegrationTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.coreservice; +package cn.iocoder.yudao.module.pay.test; import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; import org.redisson.spring.starter.RedissonAutoConfiguration; diff --git a/yudao-core-service/src/test-integration/resources/application-integration-test.yaml b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/resources/application-integration-test.yaml similarity index 98% rename from yudao-core-service/src/test-integration/resources/application-integration-test.yaml rename to yudao-module-pay/yudao-module-pay-impl/src/test-integration/resources/application-integration-test.yaml index 9f87b5ca7..658ebd932 100644 --- a/yudao-core-service/src/test-integration/resources/application-integration-test.yaml +++ b/yudao-module-pay/yudao-module-pay-impl/src/test-integration/resources/application-integration-test.yaml @@ -88,6 +88,7 @@ yudao: info: version: 1.0.0 base-package: cn.iocoder.yudao.adminserver + base-package2: cn.iocoder.yudao.module core-service: base-package: cn.iocoder.yudao.coreservice pay: diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java index 0939ade8b..a0da136bc 100644 --- a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.pay.service.merchant; import cn.hutool.core.util.RandomUtil; +import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppCreateReqVO; import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppPageReqVO; @@ -30,11 +31,6 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; import static org.junit.jupiter.api.Assertions.*; -/** - * {@link PayAppServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ @Import(PayAppServiceImpl.class) public class PayAppServiceTest extends BaseDbUnitTest { diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java index 6397bb413..f6335d091 100644 --- a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.service.merchant; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; @@ -14,9 +15,11 @@ import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayChannelMapper; import cn.iocoder.yudao.module.pay.test.BaseDbUnitTest; import com.alibaba.fastjson.JSON; import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; +import javax.validation.Validator; import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; @@ -37,6 +40,11 @@ public class PayChannelServiceTest extends BaseDbUnitTest { @Resource private PayChannelMapper channelMapper; + @MockBean + private PayClientFactory payClientFactory; + @MockBean + private Validator validator; + @Test public void testCreateWechatVersion2Channel_success() { // 准备参数 diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java index e3ac7394c..cacee1681 100755 --- a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java @@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.framework.pay.config.PayProperties; +import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; @@ -12,8 +14,12 @@ import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; +import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; +import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; +import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; import cn.iocoder.yudao.module.pay.test.BaseDbUnitTest; import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; @@ -30,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; * * @author 芋艿 */ -@Import(PayOrderServiceImpl.class) +@Import({PayOrderServiceImpl.class}) public class PayOrderServiceTest extends BaseDbUnitTest { @Resource @@ -39,6 +45,17 @@ public class PayOrderServiceTest extends BaseDbUnitTest { @Resource private PayOrderMapper orderMapper; + @MockBean + private PayClientFactory payClientFactory; + @MockBean + private PayProperties properties; + @MockBean + private PayAppService appService; + @MockBean + private PayChannelService channelService; + @MockBean + private PayNotifyService notifyService; + public String generateNo() { return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999); } diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java index 1d9173217..844c0ca00 100755 --- a/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.service.refund; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; @@ -10,8 +11,14 @@ import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; +import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; +import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; +import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; +import cn.iocoder.yudao.module.pay.service.order.PayOrderExtensionService; +import cn.iocoder.yudao.module.pay.service.order.PayOrderService; import cn.iocoder.yudao.module.pay.test.BaseDbUnitTest; import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; @@ -22,12 +29,6 @@ import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEq import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author aquan - */ @Import(PayRefundServiceImpl.class) public class PayRefundServiceTest extends BaseDbUnitTest { @@ -37,6 +38,18 @@ public class PayRefundServiceTest extends BaseDbUnitTest { @Resource private PayRefundMapper refundMapper; + @MockBean + private PayClientFactory payClientFactory; + @MockBean + private PayOrderService orderService; + @MockBean + private PayOrderExtensionService orderExtensionService; + @MockBean + private PayAppService appService; + @MockBean + private PayChannelService channelService; + @MockBean + private PayNotifyService notifyService; @Test public void testGetRefundPage() { diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/resources/application-unit-test.yaml b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/application-unit-test.yaml new file mode 100644 index 000000000..6f83b473a --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/application-unit-test.yaml @@ -0,0 +1,54 @@ +spring: + main: + lazy-initialization: true # 开启懒加载,加快速度 + banner-mode: off # 单元测试,禁用 Banner + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + datasource: + name: ruoyi-vue-pro + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 + driver-class-name: org.h2.Driver + username: sa + password: + schema: classpath:sql/create_tables.sql # MySQL 转 H2 的语句,使用 https://www.jooq.org/translate/ 工具 + druid: + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 + initial-size: 1 # 单元测试,配置为 1,提升启动速度 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 16379 # 端口(单元测试,使用 16379 端口) + database: 0 # 数据库索引 + +mybatis: + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项(单元测试,禁用 Lock4j) + +# Resilience4j 配置项 + +--- #################### 监控相关配置 #################### + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + info: + base-package: cn.iocoder.yudao.module.member.dal.mysql + base-package2: cn.iocoder.yudao.module + core-service: + base-package: cn.iocoder.yudao.module.member.dal.mysql # TODO 芋艿:要清理掉 + captcha: + timeout: 5m + width: 160 + height: 60 diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback-spring.xml b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback-spring.xml new file mode 100644 index 000000000..daf756bff --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback-spring.xml @@ -0,0 +1,4 @@ + + + + diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/clean.sql b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/clean.sql new file mode 100644 index 000000000..7430b6bfe --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/clean.sql @@ -0,0 +1,5 @@ +DELETE FROM pay_merchant; +DELETE FROM pay_app; +DELETE FROM pay_channel; +DELETE FROM pay_order; +DELETE FROM pay_refund; diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/create_tables.sql b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/create_tables.sql new file mode 100644 index 000000000..e4a141e9f --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/sql/create_tables.sql @@ -0,0 +1,115 @@ +CREATE TABLE IF NOT EXISTS "pay_merchant" +( + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "no" varchar(32) NOT NULL, + "name" varchar(64) NOT NULL, + "short_name" varchar(64) NOT NULL, + "status" tinyint NOT NULL, + "remark" varchar(255) DEFAULT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit(1) NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '支付商户信息'; + +CREATE TABLE IF NOT EXISTS "pay_app" ( + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar(64) NOT NULL, + "status" tinyint NOT NULL, + "remark" varchar(255) DEFAULT NULL, + `pay_notify_url` varchar(1024) NOT NULL, + `refund_notify_url` varchar(1024) NOT NULL, + `merchant_id` bigint(20) NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit(1) NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT = '支付应用信息'; + +CREATE TABLE IF NOT EXISTS "pay_channel" ( + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "code" varchar(32) NOT NULL, + "status" tinyint(4) NOT NULL, + "remark" varchar(255) DEFAULT NULL, + "fee_rate" double NOT NULL DEFAULT 0, + "merchant_id" bigint(20) NOT NULL, + "app_id" bigint(20) NOT NULL, + "config" varchar(10240) NOT NULL, + "creator" varchar(64) NULL DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) NULL DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit(1) NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT = '支付渠道'; + +CREATE TABLE IF NOT EXISTS `pay_order` ( + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, + `merchant_id` bigint(20) NOT NULL, + `app_id` bigint(20) NOT NULL, + `channel_id` bigint(20) DEFAULT NULL, + `channel_code` varchar(32) DEFAULT NULL, + `merchant_order_id` varchar(64) NOT NULL, + `subject` varchar(32) NOT NULL, + `body` varchar(128) NOT NULL, + `notify_url` varchar(1024) NOT NULL, + `notify_status` tinyint(4) NOT NULL, + `amount` bigint(20) NOT NULL, + `channel_fee_rate` double DEFAULT 0, + `channel_fee_amount` bigint(20) DEFAULT 0, + `status` tinyint(4) NOT NULL, + `user_ip` varchar(50) NOT NULL, + `expire_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, + `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, + `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, + `success_extension_id` bigint(20) DEFAULT NULL COMMENT '支付成功的订单拓展单编号', + `refund_status` tinyint(4) NOT NULL, + `refund_times` tinyint(4) NOT NULL, + `refund_amount` bigint(20) NOT NULL, + `channel_user_id` varchar(255) DEFAULT NULL, + `channel_order_no` varchar(64) DEFAULT NULL, + `creator` varchar(64) DEFAULT '', + `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updater` varchar(64) DEFAULT '', + `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `deleted` bit(1) NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT = '支付订单'; + +CREATE TABLE IF NOT EXISTS `pay_refund` ( + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, + `merchant_id` bigint(20) NOT NULL, + `app_id` bigint(20) NOT NULL, + `channel_id` bigint(20) NOT NULL, + `channel_code` varchar(32) NOT NULL, + `order_id` bigint(20) NOT NULL, + `trade_no` varchar(64) NOT NULL, + `merchant_order_id` varchar(64) NOT NULL, + `merchant_refund_no` varchar(64) NOT NULL, + `notify_url` varchar(1024) NOT NULL, + `notify_status` tinyint(4) NOT NULL, + `status` tinyint(4) NOT NULL, + `type` tinyint(4) NOT NULL, + `pay_amount` bigint(20) NOT NULL, + `refund_amount` bigint(20) NOT NULL, + `reason` varchar(256) NOT NULL, + `user_ip` varchar(50) NULL DEFAULT NULL, + `channel_order_no` varchar(64) NOT NULL, + `channel_refund_no` varchar(64) NULL DEFAULT NULL, + `channel_error_code` varchar(128) NULL DEFAULT NULL, + `channel_error_msg` varchar(256) NULL DEFAULT NULL, + `channel_extras` varchar(1024) NULL DEFAULT NULL, + `expire_time` datetime(0) NULL DEFAULT NULL, + `success_time` datetime(0) NULL DEFAULT NULL, + `notify_time` datetime(0) NULL DEFAULT NULL, + `creator` varchar(64) NULL DEFAULT '', + `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updater` varchar(64) NULL DEFAULT '', + `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `deleted` bit(1) NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT = '退款订单';