Commit 3a24d05bdcea2ca846a54324121e85e4be02b2da

Authored by YunaiV
1 parent 6aea461e

mall + pay:

1. 修复单元测试的报错
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 <!-- <module>yudao-module-bpm</module>--> 20 <!-- <module>yudao-module-bpm</module>-->
21 <!-- <module>yudao-module-report</module>--> 21 <!-- <module>yudao-module-report</module>-->
22 <!-- <module>yudao-module-mp</module>--> 22 <!-- <module>yudao-module-mp</module>-->
23 - <module>yudao-module-mall</module> 23 +<!-- <module>yudao-module-mall</module>-->
24 <!-- 示例项目 --> 24 <!-- 示例项目 -->
25 <module>yudao-example</module> 25 <module>yudao-example</module>
26 </modules> 26 </modules>
yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java
@@ -8,7 +8,6 @@ import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration @@ -8,7 +8,6 @@ import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration
8 import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; 8 import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
9 import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; 9 import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
10 import org.redisson.spring.starter.RedissonAutoConfiguration; 10 import org.redisson.spring.starter.RedissonAutoConfiguration;
11 -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;  
12 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 11 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
13 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; 12 import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
14 import org.springframework.boot.test.context.SpringBootTest; 13 import org.springframework.boot.test.context.SpringBootTest;
@@ -41,7 +40,6 @@ public class BaseDbAndRedisUnitTest { @@ -41,7 +40,6 @@ public class BaseDbAndRedisUnitTest {
41 40
42 // Redis 配置类 41 // Redis 配置类
43 RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer 42 RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer
44 - RedisAutoConfiguration.class, // Spring Redis 自动配置类  
45 YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 43 YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
46 RedissonAutoConfiguration.class, // Redisson 自动高配置类 44 RedissonAutoConfiguration.class, // Redisson 自动高配置类
47 }) 45 })
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java
@@ -39,7 +39,7 @@ public class MemberAddressDO extends BaseDO { @@ -39,7 +39,7 @@ public class MemberAddressDO extends BaseDO {
39 /** 39 /**
40 * 地区编号 40 * 地区编号
41 */ 41 */
42 - private Integer areaId; 42 + private Long areaId;
43 /** 43 /**
44 * 收件详细地址 44 * 收件详细地址
45 */ 45 */
yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql
@@ -23,9 +23,8 @@ CREATE TABLE IF NOT EXISTS &quot;member_address&quot; ( @@ -23,9 +23,8 @@ CREATE TABLE IF NOT EXISTS &quot;member_address&quot; (
23 "name" varchar(10) NOT NULL, 23 "name" varchar(10) NOT NULL,
24 "mobile" varchar(20) NOT NULL, 24 "mobile" varchar(20) NOT NULL,
25 "area_id" bigint(20) NOT NULL, 25 "area_id" bigint(20) NOT NULL,
26 - "post_code" varchar(16) NOT NULL,  
27 "detail_address" varchar(250) NOT NULL, 26 "detail_address" varchar(250) NOT NULL,
28 - "defaulted" bit NOT NULL, 27 + "default_status" bit NOT NULL,
29 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 28 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
30 "creator" varchar(64) DEFAULT '', 29 "creator" varchar(64) DEFAULT '',
31 "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 30 "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java
@@ -20,9 +20,11 @@ import org.springframework.context.annotation.Import; @@ -20,9 +20,11 @@ import org.springframework.context.annotation.Import;
20 import javax.annotation.Resource; 20 import javax.annotation.Resource;
21 import javax.validation.Validator; 21 import javax.validation.Validator;
22 22
  23 +import java.time.Duration;
23 import java.util.Collections; 24 import java.util.Collections;
24 import java.util.List; 25 import java.util.List;
25 26
  27 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
26 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; 28 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
27 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; 29 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
28 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; 30 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
@@ -68,7 +70,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { @@ -68,7 +70,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest {
68 public void testRefreshLocalCache() { 70 public void testRefreshLocalCache() {
69 // mock 数据 01 71 // mock 数据 01
70 PayChannelDO dbChannel = randomPojo(PayChannelDO.class, 72 PayChannelDO dbChannel = randomPojo(PayChannelDO.class,
71 - o -> o.setConfig(randomWxPayClientConfig())); 73 + o -> o.setConfig(randomWxPayClientConfig()).setUpdateTime(addTime(Duration.ofMinutes(-2))));
72 channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 74 channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据
73 channelService.initLocalCache(); 75 channelService.initLocalCache();
74 // mock 数据 02 76 // mock 数据 02
yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql
@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS &quot;pay_app&quot; ( @@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS &quot;pay_app&quot; (
3 "name" varchar(64) NOT NULL, 3 "name" varchar(64) NOT NULL,
4 "status" tinyint NOT NULL, 4 "status" tinyint NOT NULL,
5 "remark" varchar(255) DEFAULT NULL, 5 "remark" varchar(255) DEFAULT NULL,
6 - `pay_notify_url` varchar(1024) NOT NULL, 6 + `order_notify_url` varchar(1024) NOT NULL,
7 `refund_notify_url` varchar(1024) NOT NULL, 7 `refund_notify_url` varchar(1024) NOT NULL,
8 "creator" varchar(64) DEFAULT '', 8 "creator" varchar(64) DEFAULT '',
9 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 9 "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java
@@ -84,6 +84,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -84,6 +84,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
84 o.setParams(Lists.newArrayList("code", "op")); 84 o.setParams(Lists.newArrayList("code", "op"));
85 }); 85 });
86 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); 86 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
  87 + String title = RandomUtils.randomString();
  88 + when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
  89 + .thenReturn(title);
87 String content = RandomUtils.randomString(); 90 String content = RandomUtils.randomString();
88 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) 91 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
89 .thenReturn(content); 92 .thenReturn(content);
@@ -101,7 +104,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -101,7 +104,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
101 assertEquals(mailLogId, resultMailLogId); 104 assertEquals(mailLogId, resultMailLogId);
102 // 断言调用 105 // 断言调用
103 verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(user.getEmail()), 106 verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(user.getEmail()),
104 - eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content)); 107 + eq(account.getId()), eq(template.getNickname()), eq(title), eq(content));
105 } 108 }
106 109
107 @Test 110 @Test
@@ -122,6 +125,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -122,6 +125,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
122 o.setParams(Lists.newArrayList("code", "op")); 125 o.setParams(Lists.newArrayList("code", "op"));
123 }); 126 });
124 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); 127 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
  128 + String title = RandomUtils.randomString();
  129 + when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
  130 + .thenReturn(title);
125 String content = RandomUtils.randomString(); 131 String content = RandomUtils.randomString();
126 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) 132 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
127 .thenReturn(content); 133 .thenReturn(content);
@@ -139,7 +145,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -139,7 +145,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
139 assertEquals(mailLogId, resultMailLogId); 145 assertEquals(mailLogId, resultMailLogId);
140 // 断言调用 146 // 断言调用
141 verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail), 147 verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail),
142 - eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content)); 148 + eq(account.getId()), eq(template.getNickname()), eq(title), eq(content));
143 } 149 }
144 150
145 /** 151 /**
@@ -161,6 +167,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -161,6 +167,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
161 o.setParams(Lists.newArrayList("code", "op")); 167 o.setParams(Lists.newArrayList("code", "op"));
162 }); 168 });
163 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); 169 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
  170 + String title = RandomUtils.randomString();
  171 + when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
  172 + .thenReturn(title);
164 String content = RandomUtils.randomString(); 173 String content = RandomUtils.randomString();
165 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) 174 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
166 .thenReturn(content); 175 .thenReturn(content);
@@ -178,7 +187,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -178,7 +187,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
178 assertEquals(mailLogId, resultMailLogId); 187 assertEquals(mailLogId, resultMailLogId);
179 // 断言调用 188 // 断言调用
180 verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail), 189 verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail),
181 - eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content)); 190 + eq(account.getId()), eq(template.getNickname()), eq(title), eq(content));
182 } 191 }
183 192
184 /** 193 /**
@@ -200,6 +209,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -200,6 +209,9 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
200 o.setParams(Lists.newArrayList("code", "op")); 209 o.setParams(Lists.newArrayList("code", "op"));
201 }); 210 });
202 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); 211 when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
  212 + String title = RandomUtils.randomString();
  213 + when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams)))
  214 + .thenReturn(title);
203 String content = RandomUtils.randomString(); 215 String content = RandomUtils.randomString();
204 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) 216 when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
205 .thenReturn(content); 217 .thenReturn(content);
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java
@@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.social; @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.social;
2 2
3 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; 3 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
4 import cn.iocoder.yudao.framework.social.core.YudaoAuthRequestFactory; 4 import cn.iocoder.yudao.framework.social.core.YudaoAuthRequestFactory;
5 -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; 5 +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
6 import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; 6 import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
7 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO; 7 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO;
8 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; 8 import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
@@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; @@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
35 import static org.mockito.Mockito.*; 35 import static org.mockito.Mockito.*;
36 36
37 @Import(SocialUserServiceImpl.class) 37 @Import(SocialUserServiceImpl.class)
38 -public class SocialUserServiceImplTest extends BaseDbAndRedisUnitTest { 38 +public class SocialUserServiceImplTest extends BaseDbUnitTest {
39 39
40 @Resource 40 @Resource
41 private SocialUserServiceImpl socialUserService; 41 private SocialUserServiceImpl socialUserService;
yudao-server/pom.xml
@@ -68,21 +68,21 @@ @@ -68,21 +68,21 @@
68 <!-- </dependency>--> 68 <!-- </dependency>-->
69 69
70 <!-- 商城相关模块。默认注释,保证编译速度 --> 70 <!-- 商城相关模块。默认注释,保证编译速度 -->
71 - <dependency>  
72 - <groupId>cn.iocoder.boot</groupId>  
73 - <artifactId>yudao-module-promotion-biz</artifactId>  
74 - <version>${revision}</version>  
75 - </dependency>  
76 - <dependency>  
77 - <groupId>cn.iocoder.boot</groupId>  
78 - <artifactId>yudao-module-product-biz</artifactId>  
79 - <version>${revision}</version>  
80 - </dependency>  
81 - <dependency>  
82 - <groupId>cn.iocoder.boot</groupId>  
83 - <artifactId>yudao-module-trade-biz</artifactId>  
84 - <version>${revision}</version>  
85 - </dependency> 71 +<!-- <dependency>-->
  72 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  73 +<!-- <artifactId>yudao-module-promotion-biz</artifactId>-->
  74 +<!-- <version>${revision}</version>-->
  75 +<!-- </dependency>-->
  76 +<!-- <dependency>-->
  77 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  78 +<!-- <artifactId>yudao-module-product-biz</artifactId>-->
  79 +<!-- <version>${revision}</version>-->
  80 +<!-- </dependency>-->
  81 +<!-- <dependency>-->
  82 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  83 +<!-- <artifactId>yudao-module-trade-biz</artifactId>-->
  84 +<!-- <version>${revision}</version>-->
  85 +<!-- </dependency>-->
86 86
87 <!-- spring boot 配置所需依赖 --> 87 <!-- spring boot 配置所需依赖 -->
88 <dependency> 88 <dependency>
yudao-ui-admin/src/views/pay/app/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
3 - 3 + <doc-alert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
4 <!-- 搜索工作栏 --> 4 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6 <el-form-item label="应用名" prop="name"> 6 <el-form-item label="应用名" prop="name">
yudao-ui-admin/src/views/pay/demo/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="支付宝支付接入" url="https://doc.iocoder.cn/pay/alipay-pay-demo/" />
  4 + <doc-alert title="支付宝、微信退款接入" url="https://doc.iocoder.cn/pay/refund-demo/" />
  5 + <doc-alert title="微信公众号支付接入" url="https://doc.iocoder.cn/pay/wx-pub-pay-demo/" />
  6 + <doc-alert title="微信小程序支付接入" url="https://doc.iocoder.cn/pay/wx-lite-pay-demo/" />
  7 +
3 <!-- 操作工具栏 --> 8 <!-- 操作工具栏 -->
4 <el-row :gutter="10" class="mb8"> 9 <el-row :gutter="10" class="mb8">
5 <el-col :span="1.5"> 10 <el-col :span="1.5">
yudao-ui-admin/src/views/pay/notify/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
3 4
4 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
yudao-ui-admin/src/views/pay/order/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="支付宝支付接入" url="https://doc.iocoder.cn/pay/alipay-pay-demo/" />
  4 + <doc-alert title="微信公众号支付接入" url="https://doc.iocoder.cn/pay/wx-pub-pay-demo/" />
  5 + <doc-alert title="微信小程序支付接入" url="https://doc.iocoder.cn/pay/wx-lite-pay-demo/" />
3 6
4 <!-- 搜索工作栏 --> 7 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px"> 8 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
yudao-ui-admin/src/views/pay/refund/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="支付宝、微信退款接入" url="https://doc.iocoder.cn/pay/refund-demo/" />
  4 +
3 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
5 <el-form-item label="应用编号" prop="appId"> 7 <el-form-item label="应用编号" prop="appId">