diff --git a/pom.xml b/pom.xml index f32b152b5..067356826 100644 --- a/pom.xml +++ b/pom.xml @@ -14,14 +14,14 @@ yudao-module-system yudao-module-infra - yudao-module-member - yudao-module-bpm - yudao-module-pay - yudao-module-report - yudao-module-mp - yudao-module-mall - yudao-module-erp - yudao-module-crm + + + + + + + + ${project.artifactId} diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index ce24458cc..afa9bd18d 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -383,14 +383,6 @@ ${spring-boot-admin.version} - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - ${revision} - test - - org.mockito mockito-inline diff --git a/yudao-framework/pom.xml b/yudao-framework/pom.xml index 732364068..56ef86c69 100644 --- a/yudao-framework/pom.xml +++ b/yudao-framework/pom.xml @@ -26,7 +26,6 @@ yudao-spring-boot-starter-rpc yudao-spring-boot-starter-excel - yudao-spring-boot-starter-test yudao-spring-boot-starter-biz-tenant yudao-spring-boot-starter-biz-data-permission diff --git a/yudao-framework/yudao-common/src/test/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtilsTest.java b/yudao-framework/yudao-common/src/test/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtilsTest.java deleted file mode 100644 index 0e44645bc..000000000 --- a/yudao-framework/yudao-common/src/test/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtilsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.framework.common.util.collection; - -import lombok.AllArgsConstructor; -import lombok.Data; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.function.BiFunction; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link CollectionUtils} 的单元测试 - */ -public class CollectionUtilsTest { - - @Data - @AllArgsConstructor - private static class Dog { - - private Integer id; - private String name; - private String code; - - } - - @Test - public void testDiffList() { - // 准备参数 - Collection oldList = Arrays.asList( - new Dog(1, "花花", "hh"), - new Dog(2, "旺财", "wc") - ); - Collection newList = Arrays.asList( - new Dog(null, "花花2", "hh"), - new Dog(null, "小白", "xb") - ); - BiFunction sameFunc = (oldObj, newObj) -> { - boolean same = oldObj.getCode().equals(newObj.getCode()); - // 如果相等的情况下,需要设置下 id,后续好更新 - if (same) { - newObj.setId(oldObj.getId()); - } - return same; - }; - - // 调用 - List> result = CollectionUtils.diffList(oldList, newList, sameFunc); - // 断言 - assertEquals(result.size(), 3); - // 断言 create - assertEquals(result.get(0).size(), 1); - assertEquals(result.get(0).get(0), new Dog(null, "小白", "xb")); - // 断言 update - assertEquals(result.get(1).size(), 1); - assertEquals(result.get(1).get(0), new Dog(1, "花花2", "hh")); - // 断言 delete - assertEquals(result.get(2).size(), 1); - assertEquals(result.get(2).get(0), new Dog(2, "旺财", "wc")); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml index c80191e55..b75258cb7 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/pom.xml @@ -40,13 +40,6 @@ yudao-module-system-api ${revision} - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionAnnotationInterceptorTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionAnnotationInterceptorTest.java deleted file mode 100644 index ba97ede2f..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionAnnotationInterceptorTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.aop; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import org.aopalliance.intercept.MethodInvocation; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.lang.reflect.Method; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.when; - -/** - * {@link DataPermissionAnnotationInterceptor} 的单元测试 - * - * @author 芋道源码 - */ -public class DataPermissionAnnotationInterceptorTest extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionAnnotationInterceptor interceptor; - - @Mock - private MethodInvocation methodInvocation; - - @BeforeEach - public void setUp() { - interceptor.getDataPermissionCache().clear(); - } - - @Test // 无 @DataPermission 注解 - public void testInvoke_none() throws Throwable { - // 参数 - mockMethodInvocation(TestNone.class); - - // 调用 - Object result = interceptor.invoke(methodInvocation); - // 断言 - assertEquals("none", result); - assertEquals(1, interceptor.getDataPermissionCache().size()); - assertTrue(CollUtil.getFirst(interceptor.getDataPermissionCache().values()).enable()); - } - - @Test // 在 Method 上有 @DataPermission 注解 - public void testInvoke_method() throws Throwable { - // 参数 - mockMethodInvocation(TestMethod.class); - - // 调用 - Object result = interceptor.invoke(methodInvocation); - // 断言 - assertEquals("method", result); - assertEquals(1, interceptor.getDataPermissionCache().size()); - assertFalse(CollUtil.getFirst(interceptor.getDataPermissionCache().values()).enable()); - } - - @Test // 在 Class 上有 @DataPermission 注解 - public void testInvoke_class() throws Throwable { - // 参数 - mockMethodInvocation(TestClass.class); - - // 调用 - Object result = interceptor.invoke(methodInvocation); - // 断言 - assertEquals("class", result); - assertEquals(1, interceptor.getDataPermissionCache().size()); - assertFalse(CollUtil.getFirst(interceptor.getDataPermissionCache().values()).enable()); - } - - private void mockMethodInvocation(Class clazz) throws Throwable { - Object targetObject = clazz.newInstance(); - Method method = targetObject.getClass().getMethod("echo"); - when(methodInvocation.getThis()).thenReturn(targetObject); - when(methodInvocation.getMethod()).thenReturn(method); - when(methodInvocation.proceed()).then(invocationOnMock -> method.invoke(targetObject)); - } - - static class TestMethod { - - @DataPermission(enable = false) - public String echo() { - return "method"; - } - - } - - @DataPermission(enable = false) - static class TestClass { - - public String echo() { - return "class"; - } - - } - - static class TestNone { - - public String echo() { - return "none"; - } - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionContextHolderTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionContextHolderTest.java deleted file mode 100644 index 688b92d9f..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/aop/DataPermissionContextHolderTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.aop; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.mockito.Mockito.mock; - -/** - * {@link DataPermissionContextHolder} 的单元测试 - * - * @author 芋道源码 - */ -class DataPermissionContextHolderTest { - - @BeforeEach - public void setUp() { - DataPermissionContextHolder.clear(); - } - - @Test - public void testGet() { - // mock 方法 - DataPermission dataPermission01 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission01); - DataPermission dataPermission02 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission02); - - // 调用 - DataPermission result = DataPermissionContextHolder.get(); - // 断言 - assertSame(result, dataPermission02); - } - - @Test - public void testPush() { - // 调用 - DataPermission dataPermission01 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission01); - DataPermission dataPermission02 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission02); - // 断言 - DataPermission first = DataPermissionContextHolder.getAll().get(0); - DataPermission second = DataPermissionContextHolder.getAll().get(1); - assertSame(dataPermission01, first); - assertSame(dataPermission02, second); - } - - @Test - public void testRemove() { - // mock 方法 - DataPermission dataPermission01 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission01); - DataPermission dataPermission02 = mock(DataPermission.class); - DataPermissionContextHolder.add(dataPermission02); - - // 调用 - DataPermission result = DataPermissionContextHolder.remove(); - // 断言 - assertSame(result, dataPermission02); - assertEquals(1, DataPermissionContextHolder.getAll().size()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java deleted file mode 100644 index 145360789..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.db; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRuleFactory; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.baomidou.mybatisplus.core.toolkit.PluginUtils; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.operators.relational.EqualsTo; -import net.sf.jsqlparser.schema.Column; -import org.apache.ibatis.executor.Executor; -import org.apache.ibatis.executor.statement.StatementHandler; -import org.apache.ibatis.mapping.BoundSql; -import org.apache.ibatis.mapping.MappedStatement; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; - -import java.sql.Connection; -import java.util.*; - -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link DataPermissionDatabaseInterceptor} 的单元测试 - * 主要测试 {@link DataPermissionDatabaseInterceptor#beforePrepare(StatementHandler, Connection, Integer)} - * 和 {@link DataPermissionDatabaseInterceptor#beforeUpdate(Executor, MappedStatement, Object)} - * 以及在这个过程中,ContextHolder 和 MappedStatementCache - * - * @author 芋道源码 - */ -public class DataPermissionDatabaseInterceptorTest extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionDatabaseInterceptor interceptor; - - @Mock - private DataPermissionRuleFactory ruleFactory; - - @BeforeEach - public void setUp() { - // 清理上下文 - DataPermissionDatabaseInterceptor.ContextHolder.clear(); - // 清空缓存 - interceptor.getMappedStatementCache().clear(); - } - - @Test // 不存在规则,且不匹配 - public void testBeforeQuery_withoutRule() { - try (MockedStatic pluginUtilsMock = mockStatic(PluginUtils.class)) { - // 准备参数 - MappedStatement mappedStatement = mock(MappedStatement.class); - BoundSql boundSql = mock(BoundSql.class); - - // 调用 - interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); - // 断言 - pluginUtilsMock.verify(() -> PluginUtils.mpBoundSql(boundSql), never()); - } - } - - @Test // 存在规则,且不匹配 - public void testBeforeQuery_withMatchRule() { - try (MockedStatic pluginUtilsMock = mockStatic(PluginUtils.class)) { - // 准备参数 - MappedStatement mappedStatement = mock(MappedStatement.class); - BoundSql boundSql = mock(BoundSql.class); - // mock 方法(数据权限) - when(ruleFactory.getDataPermissionRule(same(mappedStatement.getId()))) - .thenReturn(singletonList(new DeptDataPermissionRule())); - // mock 方法(MPBoundSql) - PluginUtils.MPBoundSql mpBs = mock(PluginUtils.MPBoundSql.class); - pluginUtilsMock.when(() -> PluginUtils.mpBoundSql(same(boundSql))).thenReturn(mpBs); - // mock 方法(SQL) - String sql = "select * from t_user where id = 1"; - when(mpBs.sql()).thenReturn(sql); - // 针对 ContextHolder 和 MappedStatementCache 暂时不 mock,主要想校验过程中,数据是否正确 - - // 调用 - interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); - // 断言 - verify(mpBs, times(1)).sql( - eq("SELECT * FROM t_user WHERE id = 1 AND t_user.dept_id = 100")); - // 断言缓存 - assertTrue(interceptor.getMappedStatementCache().getNoRewritableMappedStatements().isEmpty()); - } - } - - @Test // 存在规则,但不匹配 - public void testBeforeQuery_withoutMatchRule() { - try (MockedStatic pluginUtilsMock = mockStatic(PluginUtils.class)) { - // 准备参数 - MappedStatement mappedStatement = mock(MappedStatement.class); - BoundSql boundSql = mock(BoundSql.class); - // mock 方法(数据权限) - when(ruleFactory.getDataPermissionRule(same(mappedStatement.getId()))) - .thenReturn(singletonList(new DeptDataPermissionRule())); - // mock 方法(MPBoundSql) - PluginUtils.MPBoundSql mpBs = mock(PluginUtils.MPBoundSql.class); - pluginUtilsMock.when(() -> PluginUtils.mpBoundSql(same(boundSql))).thenReturn(mpBs); - // mock 方法(SQL) - String sql = "select * from t_role where id = 1"; - when(mpBs.sql()).thenReturn(sql); - // 针对 ContextHolder 和 MappedStatementCache 暂时不 mock,主要想校验过程中,数据是否正确 - - // 调用 - interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql); - // 断言 - verify(mpBs, times(1)).sql( - eq("SELECT * FROM t_role WHERE id = 1")); - // 断言缓存 - assertFalse(interceptor.getMappedStatementCache().getNoRewritableMappedStatements().isEmpty()); - } - } - - @Test - public void testAddNoRewritable() { - // 准备参数 - MappedStatement ms = mock(MappedStatement.class); - List rules = singletonList(new DeptDataPermissionRule()); - // mock 方法 - when(ms.getId()).thenReturn("selectById"); - - // 调用 - interceptor.getMappedStatementCache().addNoRewritable(ms, rules); - // 断言 - Map, Set> noRewritableMappedStatements = - interceptor.getMappedStatementCache().getNoRewritableMappedStatements(); - assertEquals(1, noRewritableMappedStatements.size()); - assertEquals(SetUtils.asSet("selectById"), noRewritableMappedStatements.get(DeptDataPermissionRule.class)); - } - - @Test - public void testNoRewritable() { - // 准备参数 - MappedStatement ms = mock(MappedStatement.class); - // mock 方法 - when(ms.getId()).thenReturn("selectById"); - // mock 数据 - List rules = singletonList(new DeptDataPermissionRule()); - interceptor.getMappedStatementCache().addNoRewritable(ms, rules); - - // 场景一,rules 为空 - assertTrue(interceptor.getMappedStatementCache().noRewritable(ms, null)); - // 场景二,rules 非空,可重写 - assertFalse(interceptor.getMappedStatementCache().noRewritable(ms, singletonList(new EmptyDataPermissionRule()))); - // 场景三,rule 非空,不可重写 - assertTrue(interceptor.getMappedStatementCache().noRewritable(ms, rules)); - } - - private static class DeptDataPermissionRule implements DataPermissionRule { - - private static final String COLUMN = "dept_id"; - - @Override - public Set getTableNames() { - return SetUtils.asSet("t_user"); - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - LongValue value = new LongValue(100L); - return new EqualsTo(column, value); - } - - } - - private static class EmptyDataPermissionRule implements DataPermissionRule { - - @Override - public Set getTableNames() { - return Collections.emptySet(); - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - return null; - } - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java deleted file mode 100644 index b8cad13cf..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java +++ /dev/null @@ -1,533 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.db; - -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; -import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRuleFactory; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.operators.relational.EqualsTo; -import net.sf.jsqlparser.expression.operators.relational.ExpressionList; -import net.sf.jsqlparser.expression.operators.relational.InExpression; -import net.sf.jsqlparser.schema.Column; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Arrays; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link DataPermissionDatabaseInterceptor} 的单元测试 - * 主要复用了 MyBatis Plus 的 TenantLineInnerInterceptorTest 的单元测试 - * 不过它的单元测试不是很规范,考虑到是复用的,所以暂时不进行修改~ - * - * @author 芋道源码 - */ -public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionDatabaseInterceptor interceptor; - - @Mock - private DataPermissionRuleFactory ruleFactory; - - @BeforeEach - public void setUp() { - // 租户的数据权限规则 - DataPermissionRule tenantRule = new DataPermissionRule() { - - private static final String COLUMN = "tenant_id"; - - @Override - public Set getTableNames() { - return asSet("entity", "entity1", "entity2", "entity3", "t1", "t2", "sys_dict_item", // 支持 MyBatis Plus 的单元测试 - "t_user", "t_role"); // 满足自己的单元测试 - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - LongValue value = new LongValue(1L); - return new EqualsTo(column, value); - } - - }; - // 部门的数据权限规则 - DataPermissionRule deptRule = new DataPermissionRule() { - - private static final String COLUMN = "dept_id"; - - @Override - public Set getTableNames() { - return asSet("t_user"); // 满足自己的单元测试 - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - ExpressionList values = new ExpressionList(new LongValue(10L), - new LongValue(20L)); - return new InExpression(column, values); - } - - }; - // 设置到上下文,保证 - DataPermissionDatabaseInterceptor.ContextHolder.init(Arrays.asList(tenantRule, deptRule)); - } - - @Test - void delete() { - assertSql("delete from entity where id = ?", - "DELETE FROM entity WHERE id = ? AND entity.tenant_id = 1"); - } - - @Test - void update() { - assertSql("update entity set name = ? where id = ?", - "UPDATE entity SET name = ? WHERE id = ? AND entity.tenant_id = 1"); - } - - @Test - void selectSingle() { - // 单表 - assertSql("select * from entity where id = ?", - "SELECT * FROM entity WHERE id = ? AND entity.tenant_id = 1"); - - assertSql("select * from entity where id = ? or name = ?", - "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); - - assertSql("SELECT * FROM entity WHERE (id = ? OR name = ?)", - "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); - - /* not */ - assertSql("SELECT * FROM entity WHERE not (id = ? OR name = ?)", - "SELECT * FROM entity WHERE NOT (id = ? OR name = ?) AND entity.tenant_id = 1"); - } - - @Test - void selectSubSelectIn() { - /* in */ - assertSql("SELECT * FROM entity e WHERE e.id IN (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id IN (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - // 在最前 - assertSql("SELECT * FROM entity e WHERE e.id IN " + - "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", - "SELECT * FROM entity e WHERE e.id IN " + - "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); - // 在最后 - assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + - "(select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + - "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - // 在中间 - assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + - "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", - "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + - "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); - } - - @Test - void selectSubSelectEq() { - /* = */ - assertSql("SELECT * FROM entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - } - - @Test - void selectSubSelectInnerNotEq() { - /* inner not = */ - assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?))", - "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1)) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?) and e.id = ?)", - "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ?) AND e.tenant_id = 1"); - } - - @Test - void selectSubSelectExists() { - /* EXISTS */ - assertSql("SELECT * FROM entity e WHERE EXISTS (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - - - /* NOT EXISTS */ - assertSql("SELECT * FROM entity e WHERE NOT EXISTS (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE NOT EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - } - - @Test - void selectSubSelect() { - /* >= */ - assertSql("SELECT * FROM entity e WHERE e.id >= (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id >= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - - - /* <= */ - assertSql("SELECT * FROM entity e WHERE e.id <= (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id <= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - - - /* <> */ - assertSql("SELECT * FROM entity e WHERE e.id <> (select e1.id from entity1 e1 where e1.id = ?)", - "SELECT * FROM entity e WHERE e.id <> (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); - } - - @Test - void selectFromSelect() { - assertSql("SELECT * FROM (select e.id from entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?))", - "SELECT * FROM (SELECT e.id FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1)"); - } - - @Test - void selectBodySubSelect() { - assertSql("select t1.col1,(select t2.col2 from t2 t2 where t1.col1=t2.col1) from t1 t1", - "SELECT t1.col1, (SELECT t2.col2 FROM t2 t2 WHERE t1.col1 = t2.col1 AND t2.tenant_id = 1) FROM t1 t1 WHERE t1.tenant_id = 1"); - } - - @Test - void selectLeftJoin() { - // left join - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "left join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + - "WHERE e.tenant_id = 1"); - } - - @Test - void selectRightJoin() { - // right join - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "WHERE e1.tenant_id = 1"); - - assertSql("SELECT * FROM with_as_1 e " + - "right join entity1 e1 on e1.id = e.id", - "SELECT * FROM with_as_1 e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id " + - "WHERE e1.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id " + - "right join entity2 e2 on e1.id = e2.id ", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + - "WHERE e2.tenant_id = 1"); - } - - @Test - void selectMixJoin() { - assertSql("SELECT * FROM entity e " + - "right join entity1 e1 on e1.id = e.id " + - "left join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + - "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + - "WHERE e1.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "right join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + - "WHERE e2.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "left join entity1 e1 on e1.id = e.id " + - "inner join entity2 e2 on e1.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "INNER JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 AND e2.tenant_id = 1"); - } - - - @Test - void selectJoinSubSelect() { - assertSql("select * from (select * from entity) e1 " + - "left join entity2 e2 on e1.id = e2.id", - "SELECT * FROM (SELECT * FROM entity WHERE entity.tenant_id = 1) e1 " + - "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1"); - - assertSql("select * from entity1 e1 " + - "left join (select * from entity2) e2 " + - "on e1.id = e2.id", - "SELECT * FROM entity1 e1 " + - "LEFT JOIN (SELECT * FROM entity2 WHERE entity2.tenant_id = 1) e2 " + - "ON e1.id = e2.id " + - "WHERE e1.tenant_id = 1"); - } - - @Test - void selectSubJoin() { - - assertSql("select * FROM " + - "(entity1 e1 right JOIN entity2 e2 ON e1.id = e2.id)", - "SELECT * FROM " + - "(entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + - "WHERE e2.tenant_id = 1"); - - assertSql("select * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id)", - "SELECT * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "WHERE e1.tenant_id = 1"); - - - assertSql("select * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id) " + - "right join entity3 e3 on e1.id = e3.id", - "SELECT * FROM " + - "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "RIGHT JOIN entity3 e3 ON e1.id = e3.id AND e1.tenant_id = 1 " + - "WHERE e3.tenant_id = 1"); - - - assertSql("select * FROM entity e " + - "LEFT JOIN (entity1 e1 right join entity2 e2 ON e1.id = e2.id) " + - "on e.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN (entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + - "ON e.id = e2.id AND e2.tenant_id = 1 " + - "WHERE e.tenant_id = 1"); - - assertSql("select * FROM entity e " + - "LEFT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + - "on e.id = e2.id", - "SELECT * FROM entity e " + - "LEFT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "ON e.id = e2.id AND e1.tenant_id = 1 " + - "WHERE e.tenant_id = 1"); - - assertSql("select * FROM entity e " + - "RIGHT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + - "on e.id = e2.id", - "SELECT * FROM entity e " + - "RIGHT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + - "ON e.id = e2.id AND e.tenant_id = 1 " + - "WHERE e1.tenant_id = 1"); - } - - - @Test - void selectLeftJoinMultipleTrailingOn() { - // 多个 on 尾缀的 - assertSql("SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN entity2 e2 ON e2.id = e1.id " + - "ON e1.id = e.id " + - "WHERE (e.id = ? OR e.NAME = ?)", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN entity2 e2 ON e2.id = e1.id AND e2.tenant_id = 1 " + - "ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); - - assertSql("SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + - "ON e1.id = e.id " + - "WHERE (e.id = ? OR e.NAME = ?)", - "SELECT * FROM entity e " + - "LEFT JOIN entity1 e1 " + - "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + - "ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); - } - - @Test - void selectInnerJoin() { - // inner join - assertSql("SELECT * FROM entity e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM entity e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + - "WHERE e.id = ? OR e.name = ?"); - - assertSql("SELECT * FROM entity e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM entity e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?)"); - - // 隐式内连接 - assertSql("SELECT * FROM entity,entity1 " + - "WHERE entity.id = entity1.id", - "SELECT * FROM entity, entity1 " + - "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - - // 隐式内连接 - assertSql("SELECT * FROM entity a, with_as_entity1 b " + - "WHERE a.id = b.id", - "SELECT * FROM entity a, with_as_entity1 b " + - "WHERE a.id = b.id AND a.tenant_id = 1"); - - assertSql("SELECT * FROM with_as_entity a, with_as_entity1 b " + - "WHERE a.id = b.id", - "SELECT * FROM with_as_entity a, with_as_entity1 b " + - "WHERE a.id = b.id"); - - // SubJoin with 隐式内连接 - assertSql("SELECT * FROM (entity,entity1) " + - "WHERE entity.id = entity1.id", - "SELECT * FROM (entity, entity1) " + - "WHERE entity.id = entity1.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - - assertSql("SELECT * FROM ((entity,entity1),entity2) " + - "WHERE entity.id = entity1.id and entity.id = entity2.id", - "SELECT * FROM ((entity, entity1), entity2) " + - "WHERE entity.id = entity1.id AND entity.id = entity2.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); - - assertSql("SELECT * FROM (entity,(entity1,entity2)) " + - "WHERE entity.id = entity1.id and entity.id = entity2.id", - "SELECT * FROM (entity, (entity1, entity2)) " + - "WHERE entity.id = entity1.id AND entity.id = entity2.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); - - // 沙雕的括号写法 - assertSql("SELECT * FROM (((entity,entity1))) " + - "WHERE entity.id = entity1.id", - "SELECT * FROM (((entity, entity1))) " + - "WHERE entity.id = entity1.id " + - "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - - } - - - @Test - void selectWithAs() { - assertSql("with with_as_A as (select * from entity) select * from with_as_A", - "WITH with_as_A AS (SELECT * FROM entity WHERE entity.tenant_id = 1) SELECT * FROM with_as_A"); - } - - - @Test - void selectIgnoreTable() { - assertSql(" SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)", - "SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id AND item.tenant_id = 1 WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)"); - } - - private void assertSql(String sql, String targetSql) { - assertEquals(targetSql, interceptor.parserSingle(sql, null)); - } - - - // ========== 额外的测试 ========== - - @Test - public void testSelectSingle() { - // 单表 - assertSql("select * from t_user where id = ?", - "SELECT * FROM t_user WHERE id = ? AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - - assertSql("select * from t_user where id = ? or name = ?", - "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - - assertSql("SELECT * FROM t_user WHERE (id = ? OR name = ?)", - "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - - /* not */ - assertSql("SELECT * FROM t_user WHERE not (id = ? OR name = ?)", - "SELECT * FROM t_user WHERE NOT (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); - } - - @Test - public void testSelectLeftJoin() { - // left join - assertSql("SELECT * FROM t_user e " + - "left join t_role e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM t_user e " + - "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); - - // 条件 e.id = ? OR e.name = ? 带括号 - assertSql("SELECT * FROM t_user e " + - "left join t_role e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM t_user e " + - "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); - } - - @Test - public void testSelectRightJoin() { - // right join - assertSql("SELECT * FROM t_user e " + - "right join t_role e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM t_user e " + - "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + - "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); - - // 条件 e.id = ? OR e.name = ? 带括号 - assertSql("SELECT * FROM t_user e " + - "right join t_role e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM t_user e " + - "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + - "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); - } - - @Test - public void testSelectInnerJoin() { - // inner join - assertSql("SELECT * FROM t_user e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE e.id = ? OR e.name = ?", - "SELECT * FROM t_user e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + - "WHERE e.id = ? OR e.name = ?"); - - // 条件 e.id = ? OR e.name = ? 带括号 - assertSql("SELECT * FROM t_user e " + - "inner join entity1 e1 on e1.id = e.id " + - "WHERE (e.id = ? OR e.name = ?)", - "SELECT * FROM t_user e " + - "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + - "WHERE (e.id = ? OR e.name = ?)"); - - // 没有 On 的 inner join - assertSql("SELECT * FROM entity,entity1 " + - "WHERE entity.id = entity1.id", - "SELECT * FROM entity, entity1 " + - "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/DataPermissionRuleFactoryImplTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/DataPermissionRuleFactoryImplTest.java deleted file mode 100644 index 17dddc929..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/DataPermissionRuleFactoryImplTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.rule; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.framework.datapermission.core.aop.DataPermissionContextHolder; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.springframework.core.annotation.AnnotationUtils; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DataPermissionRuleFactoryImpl} 单元测试 - * - * @author 芋道源码 - */ -class DataPermissionRuleFactoryImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private DataPermissionRuleFactoryImpl dataPermissionRuleFactory; - - @Spy - private List rules = Arrays.asList(new DataPermissionRule01(), - new DataPermissionRule02()); - - @BeforeEach - public void setUp() { - DataPermissionContextHolder.clear(); - } - - @Test - public void testGetDataPermissionRule_02() { - // 准备参数 - String mappedStatementId = randomString(); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertSame(rules, result); - } - - @Test - public void testGetDataPermissionRule_03() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass03.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertTrue(result.isEmpty()); - } - - @Test - public void testGetDataPermissionRule_04() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass04.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertEquals(1, result.size()); - assertEquals(DataPermissionRule01.class, result.get(0).getClass()); - } - - @Test - public void testGetDataPermissionRule_05() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass05.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertEquals(1, result.size()); - assertEquals(DataPermissionRule02.class, result.get(0).getClass()); - } - - @Test - public void testGetDataPermissionRule_06() { - // 准备参数 - String mappedStatementId = randomString(); - // mock 方法 - DataPermissionContextHolder.add(AnnotationUtils.findAnnotation(TestClass06.class, DataPermission.class)); - - // 调用 - List result = dataPermissionRuleFactory.getDataPermissionRule(mappedStatementId); - // 断言 - assertSame(rules, result); - } - - @DataPermission(enable = false) - static class TestClass03 {} - - @DataPermission(includeRules = DataPermissionRule01.class) - static class TestClass04 {} - - @DataPermission(excludeRules = DataPermissionRule01.class) - static class TestClass05 {} - - @DataPermission - static class TestClass06 {} - - static class DataPermissionRule01 implements DataPermissionRule { - - @Override - public Set getTableNames() { - return null; - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - return null; - } - - } - - static class DataPermissionRule02 implements DataPermissionRule { - - @Override - public Set getTableNames() { - return null; - } - - @Override - public Expression getExpression(String tableName, Alias tableAlias) { - return null; - } - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRuleTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRuleTest.java deleted file mode 100644 index aecaf63d3..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRuleTest.java +++ /dev/null @@ -1,239 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.rule.dept; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.security.core.LoginUser; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule.EXPRESSION_NULL; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.same; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -/** - * {@link DeptDataPermissionRule} 的单元测试 - * - * @author 芋道源码 - */ -class DeptDataPermissionRuleTest extends BaseMockitoUnitTest { - - @InjectMocks - private DeptDataPermissionRule rule; - - @Mock - private PermissionApi permissionApi; - - @BeforeEach - @SuppressWarnings("unchecked") - public void setUp() { - // 清空 rule - rule.getTableNames().clear(); - ((Map) ReflectUtil.getFieldValue(rule, "deptColumns")).clear(); - ((Map) ReflectUtil.getFieldValue(rule, "deptColumns")).clear(); - } - - @Test // 无 LoginUser - public void testGetExpression_noLoginUser() { - // 准备参数 - String tableName = randomString(); - Alias tableAlias = new Alias(randomString()); - // mock 方法 - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertNull(expression); - } - - @Test // 无数据权限时 - public void testGetExpression_noDeptDataPermission() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法 - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(permissionApi 返回 null) - when(permissionApi.getDeptDataPermission(eq(loginUser.getId()))).thenReturn(success(null)); - - // 调用 - NullPointerException exception = assertThrows(NullPointerException.class, - () -> rule.getExpression(tableName, tableAlias)); - // 断言 - assertEquals("LoginUser(1) Table(t_user/u) 未返回数据权限", exception.getMessage()); - } - } - - @Test // 全部数据权限 - public void testGetExpression_allDeptDataPermission() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO().setAll(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission)); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertNull(expression); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 即不能查看部门,又不能查看自己,则说明 100% 无权限 - public void testGetExpression_noDept_noSelf() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO(); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission)); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("null = null", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(字段都不符合) - public void testGetExpression_noDeptColumn_noSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setDeptIds(SetUtils.asSet(10L, 20L)).setSelf(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission)); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertSame(EXPRESSION_NULL, expression); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(self 符合) - public void testGetExpression_noDeptColumn_yesSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setSelf(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission)); - // 添加 user 字段配置 - rule.addUserColumn("t_user", "id"); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("u.id = 1", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(dept 符合) - public void testGetExpression_yesDeptColumn_noSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setDeptIds(CollUtil.newLinkedHashSet(10L, 20L)); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission)); - // 添加 dept 字段配置 - rule.addDeptColumn("t_user", "dept_id"); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("u.dept_id IN (10, 20)", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - - @Test // 拼接 Dept 和 User 的条件(dept + self 符合) - public void testGetExpression_yesDeptColumn_yesSelfColumn() { - try (MockedStatic securityFrameworkUtilsMock - = mockStatic(SecurityFrameworkUtils.class)) { - // 准备参数 - String tableName = "t_user"; - Alias tableAlias = new Alias("u"); - // mock 方法(LoginUser) - LoginUser loginUser = randomPojo(LoginUser.class, o -> o.setId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser); - // mock 方法(DeptDataPermissionRespDTO) - DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO() - .setDeptIds(CollUtil.newLinkedHashSet(10L, 20L)).setSelf(true); - when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission)); - // 添加 user 字段配置 - rule.addUserColumn("t_user", "id"); - // 添加 dept 字段配置 - rule.addDeptColumn("t_user", "dept_id"); - - // 调用 - Expression expression = rule.getExpression(tableName, tableAlias); - // 断言 - assertEquals("(u.dept_id IN (10, 20) OR u.id = 1)", expression.toString()); - assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class)); - } - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/util/DataPermissionUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/util/DataPermissionUtilsTest.java deleted file mode 100644 index 1cc57c258..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/util/DataPermissionUtilsTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.framework.datapermission.core.util; - -import cn.iocoder.yudao.framework.datapermission.core.aop.DataPermissionContextHolder; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class DataPermissionUtilsTest { - - @Test - public void testExecuteIgnore() { - DataPermissionUtils.executeIgnore(() -> assertFalse(DataPermissionContextHolder.get().enable())); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml index 1d8f23b50..245e5cf9b 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-ip/pom.xml @@ -42,13 +42,6 @@ slf4j-api provided - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java deleted file mode 100644 index 8f5646b33..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/AreaUtilsTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.framework.ip.core.utils; - - -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link AreaUtils} 的单元测试 - * - * @author 芋道源码 - */ -public class AreaUtilsTest { - - @Test - public void testGetArea() { - // 调用:北京 - Area area = AreaUtils.getArea(110100); - // 断言 - assertEquals(area.getId(), 110100); - assertEquals(area.getName(), "北京市"); - assertEquals(area.getType(), AreaTypeEnum.CITY.getType()); - assertEquals(area.getParent().getId(), 110000); - assertEquals(area.getChildren().size(), 16); - } - - @Test - public void testFormat() { - assertEquals(AreaUtils.format(110105), "北京 北京市 朝阳区"); - assertEquals(AreaUtils.format(1), "中国"); - assertEquals(AreaUtils.format(2), "蒙古"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtilsTest.java deleted file mode 100644 index 761a1aa63..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-ip/src/test/java/cn/iocoder/yudao/framework/ip/core/utils/IPUtilsTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.framework.ip.core.utils; - -import cn.iocoder.yudao.framework.ip.core.Area; -import org.junit.jupiter.api.Test; -import org.lionsoul.ip2region.xdb.Searcher; - - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link IPUtils} 的单元测试 - * - * @author wanglhup - */ -public class IPUtilsTest { - - @Test - public void testGetAreaId_string() { - // 120.202.4.0|120.202.4.255|420600 - Integer areaId = IPUtils.getAreaId("120.202.4.50"); - assertEquals(420600, areaId); - } - - @Test - public void testGetAreaId_long() throws Exception { - // 120.203.123.0|120.203.133.255|360900 - long ip = Searcher.checkIP("120.203.123.250"); - Integer areaId = IPUtils.getAreaId(ip); - assertEquals(360900, areaId); - } - - @Test - public void testGetArea_string() { - // 120.202.4.0|120.202.4.255|420600 - Area area = IPUtils.getArea("120.202.4.50"); - assertEquals("襄阳市", area.getName()); - } - - @Test - public void testGetArea_long() throws Exception { - // 120.203.123.0|120.203.133.255|360900 - long ip = Searcher.checkIP("120.203.123.252"); - Area area = IPUtils.getArea(ip); - assertEquals("宜春市", area.getName()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-excel/pom.xml b/yudao-framework/yudao-spring-boot-starter-excel/pom.xml index feb7b9ac2..9fc1961c2 100644 --- a/yudao-framework/yudao-spring-boot-starter-excel/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-excel/pom.xml @@ -70,13 +70,6 @@ yudao-spring-boot-starter-biz-ip true - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java b/yudao-framework/yudao-spring-boot-starter-excel/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java deleted file mode 100644 index 1409860ae..000000000 --- a/yudao-framework/yudao-spring-boot-starter-excel/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.framework.dict.core.util; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; -import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.when; - -/** - * {@link DictFrameworkUtils} 的单元测试 - */ -public class DictFrameworkUtilsTest extends BaseMockitoUnitTest { - - @Mock - private DictDataApi dictDataApi; - - @BeforeEach - public void setUp() { - DictFrameworkUtils.init(dictDataApi); - } - - @Test - public void testGetDictDataLabel() { - // mock 数据 - DictDataRespDTO dataRespDTO = randomPojo(DictDataRespDTO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - // mock 方法 - when(dictDataApi.getDictData(dataRespDTO.getDictType(), dataRespDTO.getValue())).thenReturn(success(dataRespDTO)); - - // 断言返回值 - assertEquals(dataRespDTO.getLabel(), DictFrameworkUtils.getDictDataLabel(dataRespDTO.getDictType(), dataRespDTO.getValue())); - } - - @Test - public void testParseDictDataValue() { - // mock 数据 - DictDataRespDTO resp = randomPojo(DictDataRespDTO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - // mock 方法 - when(dictDataApi.parseDictData(resp.getDictType(), resp.getLabel())).thenReturn(success(resp)); - // 断言返回值 - assertEquals(resp.getValue(), DictFrameworkUtils.parseDictDataValue(resp.getDictType(), resp.getLabel())); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/pom.xml b/yudao-framework/yudao-spring-boot-starter-test/pom.xml deleted file mode 100644 index 05e5c6813..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - cn.iocoder.cloud - yudao-framework - ${revision} - - 4.0.0 - yudao-spring-boot-starter-test - jar - - ${project.artifactId} - 测试组件,用于单元测试、集成测试 - https://github.com/YunaiV/ruoyi-vue-pro - - - - cn.iocoder.cloud - yudao-common - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - org.mockito - mockito-inline - - - org.springframework.boot - spring-boot-starter-test - - - - com.h2database - h2 - - - - com.github.fppt - jedis-mock - - - - uk.co.jemos.podam - podam - - - diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/RedisTestConfiguration.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/RedisTestConfiguration.java deleted file mode 100644 index 46222911e..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/RedisTestConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.framework.test.config; - -import com.github.fppt.jedismock.RedisServer; -import org.springframework.boot.autoconfigure.data.redis.RedisProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; - -import java.io.IOException; - -/** - * Redis 测试 Configuration,主要实现内嵌 Redis 的启动 - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@Lazy(false) // 禁止延迟加载 -@EnableConfigurationProperties(RedisProperties.class) -public class RedisTestConfiguration { - - /** - * 创建模拟的 Redis Server 服务器 - */ - @Bean - public RedisServer redisServer(RedisProperties properties) throws IOException { - RedisServer redisServer = new RedisServer(properties.getPort()); - // 一次执行多个单元测试时,貌似创建多个 spring 容器,导致不进行 stop。这样,就导致端口被占用,无法启动。。。 - try { - redisServer.start(); - } catch (Exception ignore) {} - return redisServer; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/SqlInitializationTestConfiguration.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/SqlInitializationTestConfiguration.java deleted file mode 100644 index abaec9d84..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/config/SqlInitializationTestConfiguration.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.framework.test.config; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; -import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer; -import org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer; -import org.springframework.boot.sql.init.DatabaseInitializationSettings; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; - -import javax.sql.DataSource; - -/** - * SQL 初始化的测试 Configuration - * - * 为什么不使用 org.springframework.boot.autoconfigure.sql.init.DataSourceInitializationConfiguration 呢? - * 因为我们在单元测试会使用 spring.main.lazy-initialization 为 true,开启延迟加载。此时,会导致 DataSourceInitializationConfiguration 初始化 - * 不过呢,当前类的实现代码,基本是复制 DataSourceInitializationConfiguration 的哈! - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnMissingBean(AbstractScriptDatabaseInitializer.class) -@ConditionalOnSingleCandidate(DataSource.class) -@ConditionalOnClass(name = "org.springframework.jdbc.datasource.init.DatabasePopulator") -@Lazy(value = false) // 禁止延迟加载 -@EnableConfigurationProperties(SqlInitializationProperties.class) -public class SqlInitializationTestConfiguration { - - @Bean - public DataSourceScriptDatabaseInitializer dataSourceScriptDatabaseInitializer(DataSource dataSource, - SqlInitializationProperties initializationProperties) { - DatabaseInitializationSettings settings = createFrom(initializationProperties); - return new DataSourceScriptDatabaseInitializer(dataSource, settings); - } - - static DatabaseInitializationSettings createFrom(SqlInitializationProperties properties) { - DatabaseInitializationSettings settings = new DatabaseInitializationSettings(); - settings.setSchemaLocations(properties.getSchemaLocations()); - settings.setDataLocations(properties.getDataLocations()); - settings.setContinueOnError(properties.isContinueOnError()); - settings.setSeparator(properties.getSeparator()); - settings.setEncoding(properties.getEncoding()); - settings.setMode(properties.getMode()); - return settings; - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java deleted file mode 100644 index c4c0157f3..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; -import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration; -import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; - -/** - * 依赖内存 DB + Redis 的单元测试 - * - * 相比 {@link BaseDbUnitTest} 来说,额外增加了内存 Redis - * - * @author 芋道源码 - */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisUnitTest.Application.class) -@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 -@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB -public class BaseDbAndRedisUnitTest { - - @Import({ - // DB 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - DruidDataSourceAutoConfigure.class, // Druid 自动配置类 - SqlInitializationTestConfiguration.class, // SQL 初始化 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - - // Redis 配置类 - RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - RedissonAutoConfiguration.class, // Redisson 自动配置类 - }) - public static class Application { - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java deleted file mode 100644 index 316c4d52f..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbUnitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration; -import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import com.github.yulichang.autoconfigure.MybatisPlusJoinAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; - -/** - * 依赖内存 DB 的单元测试 - * - * 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法 - * - * @author 芋道源码 - */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class) -@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 -@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB -public class BaseDbUnitTest { - - @Import({ - // DB 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - DruidDataSourceAutoConfigure.class, // Druid 自动配置类 - SqlInitializationTestConfiguration.class, // SQL 初始化 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - MybatisPlusJoinAutoConfiguration.class, // MyBatis 的Join配置类 - }) - public static class Application { - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseMockitoUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseMockitoUnitTest.java deleted file mode 100644 index 26048695c..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseMockitoUnitTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -/** - * 纯 Mockito 的单元测试 - * - * @author 芋道源码 - */ -@ExtendWith(MockitoExtension.class) -public class BaseMockitoUnitTest { -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java deleted file mode 100644 index 7b84003d1..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.ut; - -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -/** - * 依赖内存 Redis 的单元测试 - * - * 相比 {@link BaseDbUnitTest} 来说,从内存 DB 改成了内存 Redis - * - * @author 芋道源码 - */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisUnitTest.Application.class) -@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 -public class BaseRedisUnitTest { - - @Import({ - // Redis 配置类 - RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动配置类 - }) - public static class Application { - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/package-info.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/package-info.java deleted file mode 100644 index bda7aad25..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 提供单元测试 Unit Test 的基类 - */ -package cn.iocoder.yudao.framework.test.core.ut; diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/AssertUtils.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/AssertUtils.java deleted file mode 100644 index e98f4980f..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/AssertUtils.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.util; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.function.Executable; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * 单元测试,assert 断言工具类 - * - * @author 芋道源码 - */ -public class AssertUtils { - - /** - * 比对两个对象的属性是否一致 - * - * 注意,如果 expected 存在的属性,actual 不存在的时候,会进行忽略 - * - * @param expected 期望对象 - * @param actual 实际对象 - * @param ignoreFields 忽略的属性数组 - */ - public static void assertPojoEquals(Object expected, Object actual, String... ignoreFields) { - Field[] expectedFields = ReflectUtil.getFields(expected.getClass()); - Arrays.stream(expectedFields).forEach(expectedField -> { - // 忽略 jacoco 自动生成的 $jacocoData 属性的情况 - if (expectedField.isSynthetic()) { - return; - } - // 如果是忽略的属性,则不进行比对 - if (ArrayUtil.contains(ignoreFields, expectedField.getName())) { - return; - } - // 忽略不存在的属性 - Field actualField = ReflectUtil.getField(actual.getClass(), expectedField.getName()); - if (actualField == null) { - return; - } - // 比对 - Assertions.assertEquals( - ReflectUtil.getFieldValue(expected, expectedField), - ReflectUtil.getFieldValue(actual, actualField), - String.format("Field(%s) 不匹配", expectedField.getName()) - ); - }); - } - - /** - * 比对两个对象的属性是否一致 - * - * 注意,如果 expected 存在的属性,actual 不存在的时候,会进行忽略 - * - * @param expected 期望对象 - * @param actual 实际对象 - * @param ignoreFields 忽略的属性数组 - * @return 是否一致 - */ - public static boolean isPojoEquals(Object expected, Object actual, String... ignoreFields) { - Field[] expectedFields = ReflectUtil.getFields(expected.getClass()); - return Arrays.stream(expectedFields).allMatch(expectedField -> { - // 如果是忽略的属性,则不进行比对 - if (ArrayUtil.contains(ignoreFields, expectedField.getName())) { - return true; - } - // 忽略不存在的属性 - Field actualField = ReflectUtil.getField(actual.getClass(), expectedField.getName()); - if (actualField == null) { - return true; - } - return Objects.equals(ReflectUtil.getFieldValue(expected, expectedField), - ReflectUtil.getFieldValue(actual, actualField)); - }); - } - - /** - * 执行方法,校验抛出的 Service 是否符合条件 - * - * @param executable 业务异常 - * @param errorCode 错误码对象 - * @param messageParams 消息参数 - */ - public static void assertServiceException(Executable executable, ErrorCode errorCode, Object... messageParams) { - // 调用方法 - ServiceException serviceException = assertThrows(ServiceException.class, executable); - // 校验错误码 - Assertions.assertEquals(errorCode.getCode(), serviceException.getCode(), "错误码不匹配"); - String message = ServiceExceptionUtil.doFormat(errorCode.getCode(), errorCode.getMsg(), messageParams); - Assertions.assertEquals(message, serviceException.getMessage(), "错误提示不匹配"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java deleted file mode 100644 index 66d15c5bf..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/util/RandomUtils.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.framework.test.core.util; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import uk.co.jemos.podam.api.PodamFactory; -import uk.co.jemos.podam.api.PodamFactoryImpl; - -import java.lang.reflect.Type; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * 随机工具类 - * - * @author 芋道源码 - */ -public class RandomUtils { - - private static final int RANDOM_STRING_LENGTH = 10; - - private static final int TINYINT_MAX = 127; - - private static final int RANDOM_DATE_MAX = 30; - - private static final int RANDOM_COLLECTION_LENGTH = 5; - - private static final PodamFactory PODAM_FACTORY = new PodamFactoryImpl(); - - static { - // 字符串 - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(String.class, - (dataProviderStrategy, attributeMetadata, map) -> randomString()); - // Integer - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(Integer.class, (dataProviderStrategy, attributeMetadata, map) -> { - // 如果是 status 的字段,返回 0 或 1 - if ("status".equals(attributeMetadata.getAttributeName())) { - return RandomUtil.randomEle(CommonStatusEnum.values()).getStatus(); - } - // 如果是 type、status 结尾的字段,返回 tinyint 范围 - if (StrUtil.endWithAnyIgnoreCase(attributeMetadata.getAttributeName(), - "type", "status", "category", "scope", "result")) { - return RandomUtil.randomInt(0, TINYINT_MAX + 1); - } - return RandomUtil.randomInt(); - }); - // LocalDateTime - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(LocalDateTime.class, - (dataProviderStrategy, attributeMetadata, map) -> randomLocalDateTime()); - // Boolean - PODAM_FACTORY.getStrategy().addOrReplaceTypeManufacturer(Boolean.class, (dataProviderStrategy, attributeMetadata, map) -> { - // 如果是 deleted 的字段,返回非删除 - if ("deleted".equals(attributeMetadata.getAttributeName())) { - return false; - } - return RandomUtil.randomBoolean(); - }); - } - - public static String randomString() { - return RandomUtil.randomString(RANDOM_STRING_LENGTH); - } - - public static Long randomLongId() { - return RandomUtil.randomLong(0, Long.MAX_VALUE); - } - - public static Integer randomInteger() { - return RandomUtil.randomInt(0, Integer.MAX_VALUE); - } - - public static Date randomDate() { - return RandomUtil.randomDay(0, RANDOM_DATE_MAX); - } - - public static LocalDateTime randomLocalDateTime() { - // 设置 Nano 为零的原因,避免 MySQL、H2 存储不到时间戳 - return LocalDateTimeUtil.of(randomDate()).withNano(0); - } - - public static Short randomShort() { - return (short) RandomUtil.randomInt(0, Short.MAX_VALUE); - } - - public static Set randomSet(Class clazz) { - return Stream.iterate(0, i -> i).limit(RandomUtil.randomInt(1, RANDOM_COLLECTION_LENGTH)) - .map(i -> randomPojo(clazz)).collect(Collectors.toSet()); - } - - public static Integer randomCommonStatus() { - return RandomUtil.randomEle(CommonStatusEnum.values()).getStatus(); - } - - public static String randomEmail() { - return randomString() + "@qq.com"; - } - - public static String randomURL() { - return "https://www.iocoder.cn/" + randomString(); - } - - @SafeVarargs - public static T randomPojo(Class clazz, Consumer... consumers) { - T pojo = PODAM_FACTORY.manufacturePojo(clazz); - // 非空时,回调逻辑。通过它,可以实现 Pojo 的进一步处理 - if (ArrayUtil.isNotEmpty(consumers)) { - Arrays.stream(consumers).forEach(consumer -> consumer.accept(pojo)); - } - return pojo; - } - - @SafeVarargs - public static T randomPojo(Class clazz, Type type, Consumer... consumers) { - T pojo = PODAM_FACTORY.manufacturePojo(clazz, type); - // 非空时,回调逻辑。通过它,可以实现 Pojo 的进一步处理 - if (ArrayUtil.isNotEmpty(consumers)) { - Arrays.stream(consumers).forEach(consumer -> consumer.accept(pojo)); - } - return pojo; - } - - @SafeVarargs - public static List randomPojoList(Class clazz, Consumer... consumers) { - int size = RandomUtil.randomInt(1, RANDOM_COLLECTION_LENGTH); - return Stream.iterate(0, i -> i).limit(size).map(o -> randomPojo(clazz, consumers)) - .collect(Collectors.toList()); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/package-info.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/package-info.java deleted file mode 100644 index 3a17f5190..000000000 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 测试组件,用于单元测试、集成测试等等 - */ -package cn.iocoder.yudao.framework.test; diff --git "a/yudao-framework/yudao-spring-boot-starter-test/\343\200\212\350\212\213\351\201\223 Spring Boot \345\215\225\345\205\203\346\265\213\350\257\225 Test \345\205\245\351\227\250\343\200\213.md" "b/yudao-framework/yudao-spring-boot-starter-test/\343\200\212\350\212\213\351\201\223 Spring Boot \345\215\225\345\205\203\346\265\213\350\257\225 Test \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index c6d0e9a90..000000000 --- "a/yudao-framework/yudao-spring-boot-starter-test/\343\200\212\350\212\213\351\201\223 Spring Boot \345\215\225\345\205\203\346\265\213\350\257\225 Test \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/DesensitizeTest.java b/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/DesensitizeTest.java deleted file mode 100644 index c2a107f54..000000000 --- a/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/DesensitizeTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.framework.desensitize.core; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.desensitize.core.regex.annotation.EmailDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.regex.annotation.RegexDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.annotation.Address; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.BankCardDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.CarLicenseDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.ChineseNameDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.FixedPhoneDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.IdCardDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.PasswordDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.MobileDesensitize; -import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.SliderDesensitize; -import lombok.Data; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DesensitizeTest} 的单元测试 - */ -@ExtendWith(MockitoExtension.class) -public class DesensitizeTest { - - @Test - public void test() { - // 准备参数 - DesensitizeDemo desensitizeDemo = new DesensitizeDemo(); - desensitizeDemo.setNickname("芋道源码"); - desensitizeDemo.setBankCard("9988002866797031"); - desensitizeDemo.setCarLicense("粤A66666"); - desensitizeDemo.setFixedPhone("01086551122"); - desensitizeDemo.setIdCard("530321199204074611"); - desensitizeDemo.setPassword("123456"); - desensitizeDemo.setPhoneNumber("13248765917"); - desensitizeDemo.setSlider1("ABCDEFG"); - desensitizeDemo.setSlider2("ABCDEFG"); - desensitizeDemo.setSlider3("ABCDEFG"); - desensitizeDemo.setEmail("1@email.com"); - desensitizeDemo.setRegex("你好,我是芋道源码"); - desensitizeDemo.setAddress("北京市海淀区上地十街10号"); - desensitizeDemo.setOrigin("芋道源码"); - - // 调用 - DesensitizeDemo d = JsonUtils.parseObject(JsonUtils.toJsonString(desensitizeDemo), DesensitizeDemo.class); - // 断言 - assertNotNull(d); - assertEquals("芋***", d.getNickname()); - assertEquals("998800********31", d.getBankCard()); - assertEquals("粤A6***6", d.getCarLicense()); - assertEquals("0108*****22", d.getFixedPhone()); - assertEquals("530321**********11", d.getIdCard()); - assertEquals("******", d.getPassword()); - assertEquals("132****5917", d.getPhoneNumber()); - assertEquals("#######", d.getSlider1()); - assertEquals("ABC*EFG", d.getSlider2()); - assertEquals("*******", d.getSlider3()); - assertEquals("1****@email.com", d.getEmail()); - assertEquals("你好,我是*", d.getRegex()); - assertEquals("北京市海淀区上地十街10号*", d.getAddress()); - assertEquals("芋道源码", d.getOrigin()); - } - - @Data - public static class DesensitizeDemo { - - @ChineseNameDesensitize - private String nickname; - @BankCardDesensitize - private String bankCard; - @CarLicenseDesensitize - private String carLicense; - @FixedPhoneDesensitize - private String fixedPhone; - @IdCardDesensitize - private String idCard; - @PasswordDesensitize - private String password; - @MobileDesensitize - private String phoneNumber; - @SliderDesensitize(prefixKeep = 6, suffixKeep = 1, replacer = "#") - private String slider1; - @SliderDesensitize(prefixKeep = 3, suffixKeep = 3) - private String slider2; - @SliderDesensitize(prefixKeep = 10) - private String slider3; - @EmailDesensitize - private String email; - @RegexDesensitize(regex = "芋道源码", replacer = "*") - private String regex; - @Address - private String address; - private String origin; - - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/annotation/Address.java b/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/annotation/Address.java deleted file mode 100644 index 735d25b34..000000000 --- a/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/annotation/Address.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.framework.desensitize.core.annotation; - -import cn.iocoder.yudao.framework.desensitize.core.DesensitizeTest; -import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy; -import cn.iocoder.yudao.framework.desensitize.core.handler.AddressHandler; -import com.fasterxml.jackson.annotation.JacksonAnnotationsInside; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 地址 - * - * 用于 {@link DesensitizeTest} 测试使用 - * - * @author gaibu - */ -@Documented -@Target({ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -@JacksonAnnotationsInside -@DesensitizeBy(handler = AddressHandler.class) -public @interface Address { - - String replacer() default "*"; - -} diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/handler/AddressHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/handler/AddressHandler.java deleted file mode 100644 index 7a8455f8d..000000000 --- a/yudao-framework/yudao-spring-boot-starter-web/src/test/java/cn/iocoder/yudao/framework/desensitize/core/handler/AddressHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.framework.desensitize.core.handler; - -import cn.iocoder.yudao.framework.desensitize.core.DesensitizeTest; -import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler; -import cn.iocoder.yudao.framework.desensitize.core.annotation.Address; - -/** - * {@link Address} 的脱敏处理器 - * - * 用于 {@link DesensitizeTest} 测试使用 - */ -public class AddressHandler implements DesensitizationHandler
{ - - @Override - public String desensitize(String origin, Address annotation) { - return origin + annotation.replacer(); - } - -} diff --git a/yudao-module-bpm/pom.xml b/yudao-module-bpm/pom.xml deleted file mode 100644 index 432b97ae4..000000000 --- a/yudao-module-bpm/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - - yudao-module-bpm-api - yudao-module-bpm-biz - - yudao-module-bpm - pom - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - bpm 解释:https://baike.baidu.com/item/BPM/1933 - - 工作流基于 Flowable 6 实现,分成流程定义、流程表单、流程实例、流程任务等功能模块。 - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/pom.xml b/yudao-module-bpm/yudao-module-bpm-api/pom.xml deleted file mode 100644 index 470b4b533..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-api - jar - - ${project.artifactId} - - bpm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 37a92219f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java deleted file mode 100644 index e22152ee5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 流程实例") -public interface BpmProcessInstanceApi { - - String PREFIX = ApiConstants.PREFIX + "/process-instance"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建流程实例(提供给内部),返回实例编号") - @Parameter(name = "userId", description = "用户编号", required = true, example = "1") - CommonResult createProcessInstance(@RequestParam("userId") Long userId, - @Valid @RequestBody BpmProcessInstanceCreateReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java deleted file mode 100644 index 033e75d6b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Map; - -@Schema(description = "RPC 服务 - 流程实例的创建 Request DTO") -@Data -public class BpmProcessInstanceCreateReqDTO { - - @Schema(description = "流程定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "leave") - @NotEmpty(message = "流程定义的标识不能为空") - private String processDefinitionKey; - - @Schema(description = "变量实例", requiredMode = Schema.RequiredMode.REQUIRED) - private Map variables; - - @Schema(description = "业务的唯一标识", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "业务的唯一标识不能为空") - private String businessKey; // 例如说,请假申请的编号。通过它,可以查询到对应的实例 - - /** - * 发起人自选审批人 Map - * - * key:taskKey 任务编码 - * value:审批人的数组 - * 例如:{ taskKey1 :[1, 2] },则表示 taskKey1 这个任务,提前设定了,由 userId 为 1,2 的用户进行审批 - */ - @Schema(description = "发起人自选审批人 Map") - private Map> startUserSelectAssignees; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ApiConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ApiConstants.java deleted file mode 100644 index b7c7de9fc..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "bpm-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/bpm"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java deleted file mode 100644 index 7abb3e1db..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -/** - * BPM 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String TASK_ASSIGN_RULE_TYPE = "bpm_task_assign_rule_type"; // 任务分配规则类型 - String TASK_ASSIGN_SCRIPT = "bpm_task_assign_script"; // 任务分配自定义脚本 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java deleted file mode 100644 index ec167719c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Bpm 错误码枚举类 - *

- * bpm 系统,使用 1-009-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 通用流程处理 模块 1-009-000-000 ========== - - // ========== OA 流程模块 1-009-001-000 ========== - ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1_009_001_001, "请假申请不存在"); - - // ========== 流程模型 1-009-002-000 ========== - ErrorCode MODEL_KEY_EXISTS = new ErrorCode(1_009_002_000, "已经存在流程标识为【{}】的流程"); - ErrorCode MODEL_NOT_EXISTS = new ErrorCode(1_009_002_001, "流程模型不存在"); - ErrorCode MODEL_KEY_VALID = new ErrorCode(1_009_002_002, "流程标识格式不正确,需要以字母或下划线开头,后接任意字母、数字、中划线、下划线、句点!"); - ErrorCode MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG = new ErrorCode(1_009_002_003, "部署流程失败,原因:流程表单未配置,请点击【修改流程】按钮进行配置"); - ErrorCode MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG = new ErrorCode(1_009_002_004, "部署流程失败," + - "原因:用户任务({})未配置审批人,请点击【流程设计】按钮,选择该它的【任务(审批人)】进行配置"); - ErrorCode MODEL_DEPLOY_FAIL_BPMN_START_EVENT_NOT_EXISTS = new ErrorCode(1_009_002_005, "部署流程失败,原因:BPMN 流程图中,没有开始事件"); - ErrorCode MODEL_DEPLOY_FAIL_BPMN_USER_TASK_NAME_NOT_EXISTS = new ErrorCode(1_009_002_006, "部署流程失败,原因:BPMN 流程图中,用户任务({})的名字不存在"); - - // ========== 流程定义 1-009-003-000 ========== - ErrorCode PROCESS_DEFINITION_KEY_NOT_MATCH = new ErrorCode(1_009_003_000, "流程定义的标识期望是({}),当前是({}),请修改 BPMN 流程图"); - ErrorCode PROCESS_DEFINITION_NAME_NOT_MATCH = new ErrorCode(1_009_003_001, "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图"); - ErrorCode PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1_009_003_002, "流程定义不存在"); - ErrorCode PROCESS_DEFINITION_IS_SUSPENDED = new ErrorCode(1_009_003_003, "流程定义处于挂起状态"); - - // ========== 流程实例 1-009-004-000 ========== - ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1_009_004_000, "流程实例不存在"); - ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1_009_004_001, "流程取消失败,流程不处于运行中"); - ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1_009_004_002, "流程取消失败,该流程不是你发起的"); - ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_003, "审批任务({})的审批人未配置"); - ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS = new ErrorCode(1_009_004_004, "审批任务({})的审批人({})不存在"); - - // ========== 流程任务 1-009-005-000 ========== - ErrorCode TASK_OPERATE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "操作失败,原因:该任务的审批人不是你"); - ErrorCode TASK_NOT_EXISTS = new ErrorCode(1_009_005_002, "流程任务不存在"); - ErrorCode TASK_IS_PENDING = new ErrorCode(1_009_005_003, "当前任务处于挂起状态,不能操作"); - ErrorCode TASK_TARGET_NODE_NOT_EXISTS = new ErrorCode(1_009_005_004, " 目标节点不存在"); - ErrorCode TASK_RETURN_FAIL_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_006, "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转"); - ErrorCode TASK_DELEGATE_FAIL_USER_REPEAT = new ErrorCode(1_009_005_007, "任务委派失败,委派人和当前审批人为同一人"); - ErrorCode TASK_DELEGATE_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_008, "任务委派失败,被委派人不存在"); - ErrorCode TASK_SIGN_CREATE_USER_NOT_EXIST = new ErrorCode(1_009_005_009, "任务加签:选择的用户不存在"); - ErrorCode TASK_SIGN_CREATE_TYPE_ERROR = new ErrorCode(1_009_005_010, "任务加签:当前任务已经{},不能{}"); - ErrorCode TASK_SIGN_CREATE_USER_REPEAT = new ErrorCode(1_009_005_011, "任务加签失败,加签人与现有审批人[{}]重复"); - ErrorCode TASK_SIGN_DELETE_NO_PARENT = new ErrorCode(1_009_005_012, "任务减签失败,被减签的任务必须是通过加签生成的任务"); - ErrorCode TASK_TRANSFER_FAIL_USER_REPEAT = new ErrorCode(1_009_005_013, "任务转办失败,转办人和当前审批人为同一人"); - ErrorCode TASK_TRANSFER_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_014, "任务转办失败,转办人不存在"); - ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1_009_006_003, "操作失败,原因:找不到任务的审批人!"); - - // ========== 动态表单模块 1-009-010-000 ========== - ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在"); - ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1_009_010_001, "表单项({}) 和 ({}) 使用了相同的字段名({})"); - - // ========== 用户组模块 1-009-011-000 ========== - ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1_009_011_000, "用户分组不存在"); - ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1_009_011_001, "名字为【{}】的用户分组已被禁用"); - - // ========== 用户组模块 1-009-012-000 ========== - ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1_009_012_000, "流程分类不存在"); - ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(1_009_012_001, "流程分类名字【{}】重复"); - ErrorCode CATEGORY_CODE_DUPLICATE = new ErrorCode(1_009_012_002, "流程分类编码【{}】重复"); - - // ========== BPM 流程监听器 1-009-013-000 ========== - ErrorCode PROCESS_LISTENER_NOT_EXISTS = new ErrorCode(1_009_013_000, "流程监听器不存在"); - ErrorCode PROCESS_LISTENER_CLASS_NOT_FOUND = new ErrorCode(1_009_013_001, "流程监听器类({})不存在"); - ErrorCode PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR = new ErrorCode(1_009_013_002, "流程监听器类({})没有实现接口({})"); - ErrorCode PROCESS_LISTENER_EXPRESSION_INVALID = new ErrorCode(1_009_013_003, "流程监听器表达式({})不合法"); - - // ========== BPM 流程表达式 1-009-014-000 ========== - ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在"); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java deleted file mode 100644 index 3bca6c82b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * BPM 模型的表单类型的枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmModelFormTypeEnum implements IntArrayValuable { - - NORMAL(10, "流程表单"), // 对应 BpmFormDO - CUSTOM(20, "业务表单") // 业务自己定义的表单,自己进行数据的存储 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmModelFormTypeEnum::getType).toArray(); - - private final Integer type; - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerType.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerType.java deleted file mode 100644 index 3dde5dfb5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerType.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 流程监听器的类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessListenerType { - - EXECUTION("execution", "执行监听器"), - TASK("task", "任务执行器"); - - private final String type; - private final String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerValueType.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerValueType.java deleted file mode 100644 index 63e23af23..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerValueType.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 流程监听器的值类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessListenerValueType { - - CLASS("class", "Java 类"), - DELEGATE_EXPRESSION("delegateExpression", "代理表达式"), - EXPRESSION("expression", "表达式"); - - private final String type; - private final String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java deleted file mode 100644 index 79001fccd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * Bpm 消息的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum BpmMessageEnum { - - PROCESS_INSTANCE_APPROVE("bpm_process_instance_approve"), // 流程任务被审批通过时,发送给申请人 - PROCESS_INSTANCE_REJECT("bpm_process_instance_reject"), // 流程任务被审批不通过时,发送给申请人 - TASK_ASSIGNED("bpm_task_assigned"); // 任务被分配时,发送给审批人 - - /** - * 短信模板的标识 - * - * 关联 SmsTemplateDO 的 code 属性 - */ - private final String smsTemplateCode; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java deleted file mode 100644 index 8b7b7ce11..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.StrUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务的 Comment 评论类型枚举 - * - * @author kehaiyou - */ -@Getter -@AllArgsConstructor -public enum BpmCommentTypeEnum { - - APPROVE("1", "审批通过", "审批通过,原因是:{}"), - REJECT("2", "不通过", "审批不通过:原因是:{}"), - CANCEL("3", "已取消", "系统自动取消,原因是:{}"), - RETURN("4", "退回", "任务被退回,原因是:{}"), - DELEGATE_START("5", "委派发起", "[{}]将任务委派给[{}],委派理由为:{}"), - DELEGATE_END("6", "委派完成", "[{}]完成委派任务,任务重新回到[{}]手中,审批建议为:{}"), - TRANSFER("7", "转派", "[{}]将任务转派给[{}],转派理由为:{}"), - ADD_SIGN("8", "加签", "[{}]{}给了[{}],理由为:{}"), - SUB_SIGN("9", "减签", "[{}]操作了【减签】,审批人[{}]的任务被取消"), - ; - - /** - * 操作类型 - * - * 由于 BPM Comment 类型为 String,所以这里就不使用 Integer - */ - private final String type; - /** - * 操作名字 - */ - private final String name; - /** - * 操作描述 - */ - private final String comment; - - public String formatComment(Object... params) { - return StrUtil.format(comment, params); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmDeleteReasonEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmDeleteReasonEnum.java deleted file mode 100644 index 802b9d890..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmDeleteReasonEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.StrUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程实例/任务的删除原因枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmDeleteReasonEnum { - - // ========== 流程实例的独有原因 ========== - - REJECT_TASK("审批不通过任务,原因:{}"), // 场景:用户审批不通过任务。修改文案时,需要注意 isRejectReason 方法 - CANCEL_PROCESS_INSTANCE_BY_START_USER("用户主动取消流程,原因:{}"), // 场景:用户主动取消流程 - CANCEL_PROCESS_INSTANCE_BY_ADMIN("管理员【{}】取消流程,原因:{}"), // 场景:管理员取消流程 - - // ========== 流程任务的独有原因 ========== - - CANCEL_BY_SYSTEM("系统自动取消"), // 场景:非常多,比如说:1)多任务审批已经满足条件,无需审批该任务;2)流程实例被取消,无需审批该任务;等等 - ; - - private final String reason; - - /** - * 格式化理由 - * - * @param args 参数 - * @return 理由 - */ - public String format(Object... args) { - return StrUtil.format(reason, args); - } - - // ========== 逻辑 ========== - - public static boolean isRejectReason(String reason) { - return StrUtil.startWith(reason, "审批不通过任务,原因:"); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java deleted file mode 100644 index 82a4119b5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 流程实例 ProcessInstance 的状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessInstanceStatusEnum implements IntArrayValuable { - - RUNNING(1, "审批中"), - APPROVE(2, "审批通过"), - REJECT(3, "审批不通过"), - CANCEL(4, "已取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmProcessInstanceStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 描述 - */ - private final String desc; - - @Override - public int[] array() { - return new int[0]; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskSignTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskSignTypeEnum.java deleted file mode 100644 index b01153d79..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskSignTypeEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.ArrayUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务的加签类型枚举 - * - * @author kehaiyou - */ -@Getter -@AllArgsConstructor -public enum BpmTaskSignTypeEnum { - - /** - * 向前加签,需要前置任务审批完成,才回到原审批人 - */ - BEFORE("before", "向前加签"), - /** - * 向后加签,需要后置任务全部审批完,才会通过原审批人节点 - */ - AFTER("after", "向后加签"); - - /** - * 类型 - */ - private final String type; - /** - * 名字 - */ - private final String name; - - public static String nameOfType(String type) { - for (BpmTaskSignTypeEnum value : values()) { - if (value.type.equals(type)) { - return value.name; - } - } - return null; - } - - public static BpmTaskSignTypeEnum of(String type) { - return ArrayUtil.firstMatch(value -> value.getType().equals(type), values()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java deleted file mode 100644 index 40a385a58..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务 Task 的状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum BpmTaskStatusEnum { - - RUNNING(1, "审批中"), - APPROVE(2, "审批通过"), - REJECT(3, "审批不通过"), - CANCEL(4, "已取消"), - - RETURN(5, "已退回"), - DELEGATE(6, "委派中"), - - /** - * 使用场景: - * 1. 任务被向后【加签】时,它在审批通过后,会变成 APPROVING 这个状态,然后等到【加签】出来的任务都被审批后,才会变成 APPROVE 审批通过 - */ - APPROVING(7, "审批通过中"), - /** - * 使用场景: - * 1. 任务被向前【加签】时,它会变成 WAIT 状态,需要等待【加签】出来的任务被审批后,它才能继续变为 RUNNING 继续审批 - * 2. 任务被向后【加签】时,【加签】出来的任务处于 WAIT 状态,它们需要等待该任务被审批后,它们才能继续变为 RUNNING 继续审批 - */ - WAIT(0, "待审批"); - - /** - * 状态 - *

- * 如果新增时,注意 {@link #isEndStatus(Integer)} 是否需要变更 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - /** - * 判断该状态是否已经处于 End 最终状态 - *

- * 主要用于一些状态更新的逻辑,如果已经是最终状态,就不再进行更新 - * - * @param status 状态 - * @return 是否 - */ - public static boolean isEndStatus(Integer status) { - return ObjectUtils.equalsAny(status, - APPROVE.getStatus(), REJECT.getStatus(), CANCEL.getStatus(), - RETURN.getStatus(), APPROVING.getStatus()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEvent.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEvent.java deleted file mode 100644 index 474a8657d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.event; - -import lombok.Data; -import org.springframework.context.ApplicationEvent; - -import javax.validation.constraints.NotNull; - -/** - * 流程实例的状态(结果)发生变化的 Event - * - * @author 芋道源码 - */ -@SuppressWarnings("ALL") -@Data -public class BpmProcessInstanceStatusEvent extends ApplicationEvent { - - /** - * 流程实例的编号 - */ - @NotNull(message = "流程实例的编号不能为空") - private String id; - /** - * 流程实例的 key - */ - @NotNull(message = "流程实例的 key 不能为空") - private String processDefinitionKey; - /** - * 流程实例的结果 - */ - @NotNull(message = "流程实例的状态不能为空") - private Integer status; - /** - * 流程实例对应的业务标识 - * 例如说,请假 - */ - private String businessKey; - - public BpmProcessInstanceStatusEvent(Object source) { - super(source); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEventListener.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEventListener.java deleted file mode 100644 index f8b1863c6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEventListener.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.event; - -import cn.hutool.core.util.StrUtil; -import org.springframework.context.ApplicationListener; - -/** - * {@link BpmProcessInstanceStatusEvent} 的监听器 - * - * @author 芋道源码 - */ -public abstract class BpmProcessInstanceStatusEventListener - implements ApplicationListener { - - @Override - public final void onApplicationEvent(BpmProcessInstanceStatusEvent event) { - if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) { - return; - } - onEvent(event); - } - - /** - * @return 返回监听的流程定义 Key - */ - protected abstract String getProcessDefinitionKey(); - - /** - * 处理事件 - * - * @param event 事件 - */ - protected abstract void onEvent(BpmProcessInstanceStatusEvent event); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/Dockerfile b/yudao-module-bpm/yudao-module-bpm-biz/Dockerfile deleted file mode 100644 index 4febef856..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-bpm-biz -WORKDIR /yudao-module-bpm-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-bpm-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48083 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml deleted file mode 100644 index 9a54ae6a5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-biz - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 Flowable 6 版本实现。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-module-bpm-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-data-permission - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - - - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - org.flowable - flowable-spring-boot-starter-process - - - org.flowable - flowable-spring-boot-starter-actuator - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java deleted file mode 100644 index d86a045a2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class BpmServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(BpmServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 2137e2203..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java deleted file mode 100644 index 01bf397fd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * Flowable 流程实例 Api 实现类 - * - * @author 芋道源码 - * @author jason - */ -@RestController -@Validated -public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi { - - @Resource - private BpmProcessInstanceService processInstanceService; - - @Override - public CommonResult createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) { - return success(processInstanceService.createProcessInstance(userId, reqDTO)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmCategoryController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmCategoryController.java deleted file mode 100644 index a78790554..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmCategoryController.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - BPM 流程分类") -@RestController -@RequestMapping("/bpm/category") -@Validated -public class BpmCategoryController { - - @Resource - private BpmCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建流程分类") - @PreAuthorize("@ss.hasPermission('bpm:category:create')") - public CommonResult createCategory(@Valid @RequestBody BpmCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新流程分类") - @PreAuthorize("@ss.hasPermission('bpm:category:update')") - public CommonResult updateCategory(@Valid @RequestBody BpmCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除流程分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得流程分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - BpmCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, BpmCategoryRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得流程分类分页") - @PreAuthorize("@ss.hasPermission('bpm:category:query')") - public CommonResult> getCategoryPage(@Valid BpmCategoryPageReqVO pageReqVO) { - PageResult pageResult = categoryService.getCategoryPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, BpmCategoryRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获取流程分类的精简信息列表", description = "只包含被开启的分类,主要用于前端的下拉选项") - public CommonResult> getCategorySimpleList() { - List list = categoryService.getCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); - list.sort(Comparator.comparingInt(BpmCategoryDO::getSort)); - return success(convertList(list, category -> new BpmCategoryRespVO().setId(category.getId()) - .setName(category.getName()).setCode(category.getCode()))); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java deleted file mode 100644 index 4ec377610..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 动态表单") -@RestController -@RequestMapping("/bpm/form") -@Validated -public class BpmFormController { - - @Resource - private BpmFormService formService; - - @PostMapping("/create") - @Operation(summary = "创建动态表单") - @PreAuthorize("@ss.hasPermission('bpm:form:create')") - public CommonResult createForm(@Valid @RequestBody BpmFormSaveReqVO createReqVO) { - return success(formService.createForm(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新动态表单") - @PreAuthorize("@ss.hasPermission('bpm:form:update')") - public CommonResult updateForm(@Valid @RequestBody BpmFormSaveReqVO updateReqVO) { - formService.updateForm(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除动态表单") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:form:delete')") - public CommonResult deleteForm(@RequestParam("id") Long id) { - formService.deleteForm(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得动态表单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:form:query')") - public CommonResult getForm(@RequestParam("id") Long id) { - BpmFormDO form = formService.getForm(id); - return success(BeanUtils.toBean(form, BpmFormRespVO.class)); - } - - @GetMapping({"/list-all-simple", "/simple-list"}) - @Operation(summary = "获得动态表单的精简列表", description = "用于表单下拉框") - public CommonResult> getFormSimpleList() { - List list = formService.getFormList(); - return success(convertList(list, formDO -> // 只返回 id、name 字段 - new BpmFormRespVO().setId(formDO.getId()).setName(formDO.getName()))); - } - - @GetMapping("/page") - @Operation(summary = "获得动态表单分页") - @PreAuthorize("@ss.hasPermission('bpm:form:query')") - public CommonResult> getFormPage(@Valid BpmFormPageReqVO pageVO) { - PageResult pageResult = formService.getFormPage(pageVO); - return success(BeanUtils.toBean(pageResult, BpmFormRespVO.class)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java deleted file mode 100644 index 409545023..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.io.IoUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 流程模型") -@RestController -@RequestMapping("/bpm/model") -@Validated -public class BpmModelController { - - @Resource - private BpmModelService modelService; - @Resource - private BpmFormService formService; - @Resource - private BpmCategoryService categoryService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - - @GetMapping("/page") - @Operation(summary = "获得模型分页") - public CommonResult> getModelPage(BpmModelPageReqVO pageVO) { - PageResult pageResult = modelService.getModelPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - // 获得 Form 表单 - Set formIds = convertSet(pageResult.getList(), model -> { - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - return metaInfo != null ? metaInfo.getFormId() : null; - }); - Map formMap = formService.getFormMap(formIds); - // 获得 Category Map - Map categoryMap = categoryService.getCategoryMap( - convertSet(pageResult.getList(), Model::getCategory)); - // 获得 Deployment Map - Set deploymentIds = new HashSet<>(); - pageResult.getList().forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); - Map deploymentMap = processDefinitionService.getDeploymentMap(deploymentIds); - // 获得 ProcessDefinition Map - List processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds); - Map processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); - return success(BpmModelConvert.INSTANCE.buildModelPage(pageResult, formMap, categoryMap, deploymentMap, processDefinitionMap)); - } - - @GetMapping("/get") - @Operation(summary = "获得模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:query')") - public CommonResult getModel(@RequestParam("id") String id) { - Model model = modelService.getModel(id); - if (model == null) { - return null; - } - byte[] bpmnBytes = modelService.getModelBpmnXML(id); - return success(BpmModelConvert.INSTANCE.buildModel(model, bpmnBytes)); - } - - @PostMapping("/create") - @Operation(summary = "新建模型") - @PreAuthorize("@ss.hasPermission('bpm:model:create')") - public CommonResult createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) { - return success(modelService.createModel(createRetVO, null)); - } - - @PutMapping("/update") - @Operation(summary = "修改模型") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) { - modelService.updateModel(modelVO); - return success(true); - } - - @PostMapping("/import") - @Operation(summary = "导入模型") - @PreAuthorize("@ss.hasPermission('bpm:model:import')") - public CommonResult importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException { - BpmModelCreateReqVO createReqVO = BeanUtils.toBean(importReqVO, BpmModelCreateReqVO.class); - // 读取文件 - String bpmnXml = IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false); - return success(modelService.createModel(createReqVO, bpmnXml)); - } - - @PostMapping("/deploy") - @Operation(summary = "部署模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:deploy')") - public CommonResult deployModel(@RequestParam("id") String id) { - modelService.deployModel(id); - return success(true); - } - - @PutMapping("/update-state") - @Operation(summary = "修改模型的状态", description = "实际更新的部署的流程定义的状态") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) { - modelService.updateModelState(reqVO.getId(), reqVO.getState()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:delete')") - public CommonResult deleteModel(@RequestParam("id") String id) { - modelService.deleteModel(id); - return success(true); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java deleted file mode 100644 index ee23c63e8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmProcessDefinitionConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.BpmTaskCandidateStartUserSelectStrategy; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 流程定义") -@RestController -@RequestMapping("/bpm/process-definition") -@Validated -public class BpmProcessDefinitionController { - - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmFormService formService; - @Resource - private BpmCategoryService categoryService; - - @GetMapping("/page") - @Operation(summary = "获得流程定义分页") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult> getProcessDefinitionPage( - BpmProcessDefinitionPageReqVO pageReqVO) { - PageResult pageResult = processDefinitionService.getProcessDefinitionPage(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 获得 Category Map - Map categoryMap = categoryService.getCategoryMap( - convertSet(pageResult.getList(), ProcessDefinition::getCategory)); - // 获得 Deployment Map - Map deploymentMap = processDefinitionService.getDeploymentMap( - convertSet(pageResult.getList(), ProcessDefinition::getDeploymentId)); - // 获得 BpmProcessDefinitionInfoDO Map - Map processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap( - convertSet(pageResult.getList(), ProcessDefinition::getId)); - // 获得 Form Map - Map formMap = formService.getFormMap( - convertSet(processDefinitionMap.values(), BpmProcessDefinitionInfoDO::getFormId)); - return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionPage( - pageResult, deploymentMap, processDefinitionMap, formMap, categoryMap)); - } - - @GetMapping ("/list") - @Operation(summary = "获得流程定义列表") - @Parameter(name = "suspensionState", description = "挂起状态", required = true, example = "1") // 参见 Flowable SuspensionState 枚举 - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult> getProcessDefinitionList( - @RequestParam("suspensionState") Integer suspensionState) { - List list = processDefinitionService.getProcessDefinitionListBySuspensionState(suspensionState); - if (CollUtil.isEmpty(list)) { - return success(Collections.emptyList()); - } - - // 获得 BpmProcessDefinitionInfoDO Map - Map processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap( - convertSet(list, ProcessDefinition::getId)); - return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionList( - list, null, processDefinitionMap, null, null)); - } - - @GetMapping ("/get") - @Operation(summary = "获得流程定义") - @Parameter(name = "id", description = "流程编号", required = true, example = "1024") - @Parameter(name = "key", description = "流程定义标识", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult getProcessDefinition( - @RequestParam(value = "id", required = false) String id, - @RequestParam(value = "key", required = false) String key) { - ProcessDefinition processDefinition = id != null ? processDefinitionService.getProcessDefinition(id) - : processDefinitionService.getActiveProcessDefinition(key); - if (processDefinition == null) { - return success(null); - } - BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(processDefinition.getId()); - List userTaskList = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectUserTaskList(bpmnModel); - return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinition( - processDefinition, null, null, null, null, bpmnModel, userTaskList)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessExpressionController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessExpressionController.java deleted file mode 100644 index a6e11a03c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessExpressionController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessExpressionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - BPM 流程表达式") -@RestController -@RequestMapping("/bpm/process-expression") -@Validated -public class BpmProcessExpressionController { - - @Resource - private BpmProcessExpressionService processExpressionService; - - @PostMapping("/create") - @Operation(summary = "创建流程表达式") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:create')") - public CommonResult createProcessExpression(@Valid @RequestBody BpmProcessExpressionSaveReqVO createReqVO) { - return success(processExpressionService.createProcessExpression(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新流程表达式") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:update')") - public CommonResult updateProcessExpression(@Valid @RequestBody BpmProcessExpressionSaveReqVO updateReqVO) { - processExpressionService.updateProcessExpression(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除流程表达式") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-expression:delete')") - public CommonResult deleteProcessExpression(@RequestParam("id") Long id) { - processExpressionService.deleteProcessExpression(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得流程表达式") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:query')") - public CommonResult getProcessExpression(@RequestParam("id") Long id) { - BpmProcessExpressionDO processExpression = processExpressionService.getProcessExpression(id); - return success(BeanUtils.toBean(processExpression, BpmProcessExpressionRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得流程表达式分页") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:query')") - public CommonResult> getProcessExpressionPage( - @Valid BpmProcessExpressionPageReqVO pageReqVO) { - PageResult pageResult = processExpressionService.getProcessExpressionPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, BpmProcessExpressionRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessListenerController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessListenerController.java deleted file mode 100644 index c6cc391c3..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessListenerController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessListenerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - BPM 流程监听器") -@RestController -@RequestMapping("/bpm/process-listener") -@Validated -public class BpmProcessListenerController { - - @Resource - private BpmProcessListenerService processListenerService; - - @PostMapping("/create") - @Operation(summary = "创建流程监听器") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:create')") - public CommonResult createProcessListener(@Valid @RequestBody BpmProcessListenerSaveReqVO createReqVO) { - return success(processListenerService.createProcessListener(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新流程监听器") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:update')") - public CommonResult updateProcessListener(@Valid @RequestBody BpmProcessListenerSaveReqVO updateReqVO) { - processListenerService.updateProcessListener(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除流程监听器") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-listener:delete')") - public CommonResult deleteProcessListener(@RequestParam("id") Long id) { - processListenerService.deleteProcessListener(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得流程监听器") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:query')") - public CommonResult getProcessListener(@RequestParam("id") Long id) { - BpmProcessListenerDO processListener = processListenerService.getProcessListener(id); - return success(BeanUtils.toBean(processListener, BpmProcessListenerRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得流程监听器分页") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:query')") - public CommonResult> getProcessListenerPage( - @Valid BpmProcessListenerPageReqVO pageReqVO) { - PageResult pageResult = processListenerService.getProcessListenerPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, BpmProcessListenerRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java deleted file mode 100644 index fca7d5b0f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 用户组") -@RestController -@RequestMapping("/bpm/user-group") -@Validated -public class BpmUserGroupController { - - @Resource - private BpmUserGroupService userGroupService; - - @PostMapping("/create") - @Operation(summary = "创建用户组") - @PreAuthorize("@ss.hasPermission('bpm:user-group:create')") - public CommonResult createUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO createReqVO) { - return success(userGroupService.createUserGroup(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户组") - @PreAuthorize("@ss.hasPermission('bpm:user-group:update')") - public CommonResult updateUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO updateReqVO) { - userGroupService.updateUserGroup(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户组") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:user-group:delete')") - public CommonResult deleteUserGroup(@RequestParam("id") Long id) { - userGroupService.deleteUserGroup(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户组") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") - public CommonResult getUserGroup(@RequestParam("id") Long id) { - BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); - return success(BeanUtils.toBean(userGroup, BpmUserGroupRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得用户组分页") - @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") - public CommonResult> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { - PageResult pageResult = userGroupService.getUserGroupPage(pageVO); - return success(BeanUtils.toBean(pageResult, BpmUserGroupRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获取用户组精简信息列表", description = "只包含被开启的用户组,主要用于前端的下拉选项") - public CommonResult> getUserGroupSimpleList() { - List list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, group -> new BpmUserGroupRespVO().setId(group.getId()).setName(group.getName()))); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryPageReqVO.java deleted file mode 100644 index dba816c87..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryPageReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - BPM 流程分类分页 Request VO") -@Data -public class BpmCategoryPageReqVO extends PageParam { - - @Schema(description = "分类名", example = "王五") - private String name; - - @Schema(description = "分类标志", example = "OA") - private String code; - - @Schema(description = "分类状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryRespVO.java deleted file mode 100644 index 7ada55a1d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - BPM 流程分类 Response VO") -@Data -public class BpmCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "分类名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "分类标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "OA") - private String code; - - @Schema(description = "分类描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String description; - - @Schema(description = "分类状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED) - private Integer sort; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategorySaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategorySaveReqVO.java deleted file mode 100644 index d4865e7f6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategorySaveReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - BPM 流程分类新增/修改 Request VO") -@Data -public class BpmCategorySaveReqVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "分类名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "分类名不能为空") - private String name; - - @Schema(description = "分类描述", example = "你猜") - private String description; - - @Schema(description = "分类标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "OA") - @NotEmpty(message = "分类标志不能为空") - private String code; - - @Schema(description = "分类状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "分类状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "分类排序不能为空") - private Integer sort; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionPageReqVO.java deleted file mode 100644 index 37b02f0d9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - BPM 流程表达式分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessExpressionPageReqVO extends PageParam { - - @Schema(description = "表达式名字", example = "李四") - private String name; - - @Schema(description = "表达式状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionRespVO.java deleted file mode 100644 index d877f60a8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - BPM 流程表达式 Response VO") -@Data -public class BpmProcessExpressionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3870") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "表达式名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("表达式名字") - private String name; - - @Schema(description = "表达式状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "表达式", requiredMode = Schema.RequiredMode.REQUIRED) - private String expression; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionSaveReqVO.java deleted file mode 100644 index 2755bf80e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionSaveReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - BPM 流程表达式新增/修改 Request VO") -@Data -public class BpmProcessExpressionSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3870") - private Long id; - - @Schema(description = "表达式名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "表达式名字不能为空") - private String name; - - @Schema(description = "表达式状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表达式状态不能为空") - private Integer status; - - @Schema(description = "表达式", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "表达式不能为空") - private String expression; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java deleted file mode 100644 index a5f508f61..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 动态表单分页 Request VO") -@Data -public class BpmFormPageReqVO extends PageParam { - - @Schema(description = "表单名称", example = "芋道") - private String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java deleted file mode 100644 index 832d4d40f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单 Response VO") -@Data -public class BpmFormRespVO { - - @Schema(description = "表单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "表单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "表单名称不能为空") - private String name; - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - - @Schema(description = "表单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表单状态不能为空") - private Integer status; // 参见 CommonStatusEnum 枚举 - - @Schema(description = "备注", example = "我是备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSaveReqVO.java deleted file mode 100644 index c89085970..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSaveReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单创建/更新 Request VO") -@Data -public class BpmFormSaveReqVO { - - @Schema(description = "表单编号", example = "1024") - private Long id; - - @Schema(description = "表单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "表单名称不能为空") - private String name; - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - - @Schema(description = "表单状态-参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表单状态不能为空") - private Integer status; - - @Schema(description = "备注", example = "我是备注") - private String remark; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java deleted file mode 100644 index c3a0a860f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户组分页 Request VO") -@Data -public class BpmUserGroupPageReqVO extends PageParam { - - @Schema(description = "编号", example = "1024") - private Long id; - - @Schema(description = "组名", example = "芋道") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java deleted file mode 100644 index f20722a8d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - 用户组 Response VO") -@Data -public class BpmUserGroupRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String description; - - @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") - private Set userIds; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java deleted file mode 100644 index 470eb0e53..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.Set; - -@Schema(description = "管理后台 - 用户组创建/修改 Request VO") -@Data -public class BpmUserGroupSaveReqVO { - - @Schema(description = "编号", example = "1024") - private Long id; - - @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "组名不能为空") - private String name; - - @Schema(description = "描述", example = "芋道源码") - private String description; - - @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") - @NotNull(message = "成员编号数组不能为空") - private Set userIds; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerPageReqVO.java deleted file mode 100644 index d3b974672..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - BPM 流程监听器分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessListenerPageReqVO extends PageParam { - - @Schema(description = "监听器名字", example = "赵六") - private String name; - - @Schema(description = "监听器类型", example = "execution") - private String type; - - @Schema(description = "监听事件", example = "start") - private String event; - - @Schema(description = "状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerRespVO.java deleted file mode 100644 index f7a484254..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - BPM 流程监听器 Response VO") -@Data -public class BpmProcessListenerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13089") - private Long id; - - @Schema(description = "监听器名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String name; - - @Schema(description = "监听器类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "execution") - private String type; - - @Schema(description = "监听器状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "监听事件", requiredMode = Schema.RequiredMode.REQUIRED, example = "start") - private String event; - - @Schema(description = "监听器值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "class") - private String valueType; - - @Schema(description = "监听器值", requiredMode = Schema.RequiredMode.REQUIRED) - private String value; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerSaveReqVO.java deleted file mode 100644 index ef022b86c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerSaveReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - BPM 流程监听器新增/修改 Request VO") -@Data -public class BpmProcessListenerSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13089") - private Long id; - - @Schema(description = "监听器名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotEmpty(message = "监听器名字不能为空") - private String name; - - @Schema(description = "监听器类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "execution") - @NotEmpty(message = "监听器类型不能为空") - private String type; - - @Schema(description = "监听器状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "监听器状态不能为空") - private Integer status; - - @Schema(description = "监听事件", requiredMode = Schema.RequiredMode.REQUIRED, example = "start") - @NotEmpty(message = "监听事件不能为空") - private String event; - - @Schema(description = "监听器值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "class") - @NotEmpty(message = "监听器值类型不能为空") - private String valueType; - - @Schema(description = "监听器值", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "监听器值不能为空") - private String value; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java deleted file mode 100644 index 91d7d7d00..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程模型的导入 Request VO 相比流程模型的新建来说,只是多了一个 bpmnFile 文件") -@Data -public class BpmModeImportReqVO extends BpmModelCreateReqVO { - - @Schema(description = "BPMN 文件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "BPMN 文件不能为空") - private MultipartFile bpmnFile; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java deleted file mode 100644 index 9ff845579..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程模型的创建 Request VO") -@Data -public class BpmModelCreateReqVO { - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") - @NotEmpty(message = "流程标识不能为空") - private String key; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotEmpty(message = "流程名称不能为空") - private String name; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java deleted file mode 100644 index d2767c17f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - - -@Schema(description = "管理后台 - 流程模型分页 Request VO") -@Data -public class BpmModelPageReqVO extends PageParam { - - @Schema(description = "标识,精准匹配", example = "process1641042089407") - private String key; - - @Schema(description = "名字,模糊匹配", example = "芋道") - private String name; - - @Schema(description = "流程分类", example = "1") - private String category; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java deleted file mode 100644 index aad2015c7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程模型 Response VO") -@Data -public class BpmModelRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") - private String key; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类编码", example = "1") - private String category; - @Schema(description = "流程分类名字", example = "请假") - private String categoryName; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - - @Schema(description = "表单编号", example = "1024") - private Long formId; // 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空 - @Schema(description = "表单名字", example = "请假表单") - private String formName; - - @Schema(description = "自定义表单的提交路径", example = "/bpm/oa/leave/create") - private String formCustomCreatePath; // 使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空 - @Schema(description = "自定义表单的查看路径", example = "/bpm/oa/leave/view") - private String formCustomViewPath; // ,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空 - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - /** - * 最新部署的流程定义 - */ - private BpmProcessDefinitionRespVO processDefinition; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java deleted file mode 100644 index 231ead168..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程模型的更新 Request VO") -@Data -public class BpmModelUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "编号不能为空") - private String id; - - @Schema(description = "流程名称", example = "芋道") - private String name; - - @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "流程图标格式不正确") - private String icon; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类", example = "1") - private String category; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - @InEnum(BpmModelFormTypeEnum.class) - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java deleted file mode 100644 index 6ef20c3c7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程模型更新状态 Request VO") -@Data -public class BpmModelUpdateStateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private String id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer state; // 参见 Flowable SuspensionState 枚举 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java deleted file mode 100644 index 923c4a429..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 流程定义分页 Request VO") -@Data -public class BpmProcessDefinitionPageReqVO extends PageParam { - - @Schema(description = "标识-精准匹配", example = "process1641042089407") - private String key; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java deleted file mode 100644 index 2fb8dd4dc..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 流程定义 Response VO") -@Data -public class BpmProcessDefinitionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer version; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") - private String key; - - @Schema(description = "流程图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类", example = "1") - private String category; - @Schema(description = "流程分类名字", example = "请假") - private String categoryName; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "表单名字", example = "请假表单") - private String formName; - @Schema(description = "表单的配置-JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private String formConf; - @Schema(description = "表单项的数组-JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private List formFields; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - - @Schema(description = "中断状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer suspensionState; // 参见 SuspensionState 枚举 - - @Schema(description = "部署时间") - private LocalDateTime deploymentTime; // 需要从对应的 Deployment 读取,非必须返回 - - @Schema(description = "BPMN XML") - private String bpmnXml; // 需要从对应的 BpmnModel 读取,非必须返回 - - @Schema(description = "发起用户需要选择审批人的任务数组") - private List startUserSelectTasks; // 需要从对应的 BpmnModel 读取,非必须返回 - - @Schema(description = "BPMN UserTask 用户任务") - @Data - public static class UserTask { - - @Schema(description = "任务标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "sudo") - private String id; - - @Schema(description = "任务名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http deleted file mode 100644 index 96bbf964d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http +++ /dev/null @@ -1,12 +0,0 @@ -### 请求 /bpm/oa/leave/create 接口 => 成功 -POST {{baseUrl}}/bpm/oa/leave/create -Content-Type: application/json -tenant-id: 1 -Authorization: Bearer {{token}} - -{ - "startTime": "2022-03-01", - "endTime": "2022-03-05", - "type": 1, - "reason": "我要请假啦啦啦!" -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java deleted file mode 100644 index 47a72800e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * OA 请假申请 Controller,用于演示自己存储数据,接入工作流的例子 - * - * @author jason - * @author 芋道源码 - */ -@Tag(name = "管理后台 - OA 请假申请") -@RestController -@RequestMapping("/bpm/oa/leave") -@Validated -public class BpmOALeaveController { - - @Resource - private BpmOALeaveService leaveService; - - @PostMapping("/create") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:create')") - @Operation(summary = "创建请求申请") - public CommonResult createLeave(@Valid @RequestBody BpmOALeaveCreateReqVO createReqVO) { - return success(leaveService.createLeave(getLoginUserId(), createReqVO)); - } - - @GetMapping("/get") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')") - @Operation(summary = "获得请假申请") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getLeave(@RequestParam("id") Long id) { - BpmOALeaveDO leave = leaveService.getLeave(id); - return success(BeanUtils.toBean(leave, BpmOALeaveRespVO.class)); - } - - @GetMapping("/page") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')") - @Operation(summary = "获得请假申请分页") - public CommonResult> getLeavePage(@Valid BpmOALeavePageReqVO pageVO) { - PageResult pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO); - return success(BeanUtils.toBean(pageResult, BpmOALeaveRespVO.class)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java deleted file mode 100644 index 7028708b1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * OA 示例,用于演示外部业务接入 BPM 工作流的示例 - * 一般的接入方式,只需要调用 接口,后续 Admin 用户在管理后台的【待办事务】进行审批 - */ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java deleted file mode 100644 index f843059a1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 请假申请创建 Request VO") -@Data -public class BpmOALeaveCreateReqVO { - - @Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "请假类型-参见 bpm_oa_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码") - private String reason; - - @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}") - private Map> startUserSelectAssignees; - - @AssertTrue(message = "结束时间,需要在开始时间之后") - public boolean isEndTimeValid() { - return !getEndTime().isBefore(getStartTime()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java deleted file mode 100644 index f801e6908..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 请假申请分页 Request VO") -@Data -public class BpmOALeavePageReqVO extends PageParam { - - @Schema(description = "状态", example = "1") - private Integer status; // 参见 BpmProcessInstanceResultEnum 枚举 - - @Schema(description = "请假类型,参见 bpm_oa_type", example = "1") - private Integer type; - - @Schema(description = "原因,模糊匹配", example = "阅读芋道源码") - private String reason; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "申请时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java deleted file mode 100644 index dbfe9d90f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 请假申请 Response VO") -@Data -public class BpmOALeaveRespVO { - - @Schema(description = "请假表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "请假类型,参见 bpm_oa_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码") - private String reason; - - @Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "流程编号") - private String processInstanceId; - - @Schema(description = "审批结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; // 参见 BpmProcessInstanceStatusEnum 枚举 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java deleted file mode 100644 index e74bc626f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 流程活动实例") -@RestController -@RequestMapping("/bpm/activity") -@Validated -public class BpmActivityController { - - @Resource - private BpmActivityService activityService; - - @GetMapping("/list") - @Operation(summary = "生成指定流程实例的高亮流程图", - description = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成") - @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getActivityList( - @RequestParam("processInstanceId") String processInstanceId) { - return success(activityService.getActivityListByProcessInstanceId(processInstanceId)); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java deleted file mode 100644 index 309c372e0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.task.api.Task; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程实例") // 流程实例,通过流程定义创建的一次“申请” -@RestController -@RequestMapping("/bpm/process-instance") -@Validated -public class BpmProcessInstanceController { - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmTaskService taskService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmCategoryService categoryService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @GetMapping("/my-page") - @Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult> getProcessInstanceMyPage( - @Valid BpmProcessInstancePageReqVO pageReqVO) { - PageResult pageResult = processInstanceService.getProcessInstancePage( - getLoginUserId(), pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - Map> taskMap = taskService.getTaskMapByProcessInstanceIds( - convertList(pageResult.getList(), HistoricProcessInstance::getId)); - Map processDefinitionMap = processDefinitionService.getProcessDefinitionMap( - convertSet(pageResult.getList(), HistoricProcessInstance::getProcessDefinitionId)); - Map categoryMap = categoryService.getCategoryMap( - convertSet(processDefinitionMap.values(), ProcessDefinition::getCategory)); - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstancePage(pageResult, - processDefinitionMap, categoryMap, taskMap, null, null)); - } - - @GetMapping("/manager-page") - @Operation(summary = "获得管理流程实例的分页列表", description = "在【流程实例】菜单中,进行调用") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:manager-query')") - public CommonResult> getProcessInstanceManagerPage( - @Valid BpmProcessInstancePageReqVO pageReqVO) { - PageResult pageResult = processInstanceService.getProcessInstancePage( - null, pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - Map> taskMap = taskService.getTaskMapByProcessInstanceIds( - convertList(pageResult.getList(), HistoricProcessInstance::getId)); - Map processDefinitionMap = processDefinitionService.getProcessDefinitionMap( - convertSet(pageResult.getList(), HistoricProcessInstance::getProcessDefinitionId)); - Map categoryMap = categoryService.getCategoryMap( - convertSet(processDefinitionMap.values(), ProcessDefinition::getCategory)); - // 发起人信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), processInstance -> NumberUtils.parseLong(processInstance.getStartUserId()))); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstancePage(pageResult, - processDefinitionMap, categoryMap, taskMap, userMap, deptMap)); - } - - @PostMapping("/create") - @Operation(summary = "新建流程实例") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult createProcessInstance(@Valid @RequestBody BpmProcessInstanceCreateReqVO createReqVO) { - return success(processInstanceService.createProcessInstance(getLoginUserId(), createReqVO)); - } - - @GetMapping("/get") - @Operation(summary = "获得指定流程实例", description = "在【流程详细】界面中,进行调用") - @Parameter(name = "id", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult getProcessInstance(@RequestParam("id") String id) { - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(id); - if (processInstance == null) { - return success(null); - } - - // 拼接返回 - ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition( - processInstance.getProcessDefinitionId()); - BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService.getProcessDefinitionInfo( - processInstance.getProcessDefinitionId()); - String bpmnXml = BpmnModelUtils.getBpmnXml( - processDefinitionService.getProcessDefinitionBpmnModel(processInstance.getProcessDefinitionId())); - AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())).getCheckedData(); - DeptRespDTO dept = null; - if (startUser != null) { - dept = deptApi.getDept(startUser.getDeptId()).getCheckedData(); - } - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstance(processInstance, - processDefinition, processDefinitionInfo, bpmnXml, startUser, dept)); - } - - @DeleteMapping("/cancel-by-start-user") - @Operation(summary = "用户取消流程实例", description = "取消发起的流程") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')") - public CommonResult cancelProcessInstanceByStartUser( - @Valid @RequestBody BpmProcessInstanceCancelReqVO cancelReqVO) { - processInstanceService.cancelProcessInstanceByStartUser(getLoginUserId(), cancelReqVO); - return success(true); - } - - @DeleteMapping("/cancel-by-admin") - @Operation(summary = "管理员取消流程实例", description = "管理员撤回流程") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel-by-admin')") - public CommonResult cancelProcessInstanceByManager( - @Valid @RequestBody BpmProcessInstanceCancelReqVO cancelReqVO) { - processInstanceService.cancelProcessInstanceByAdmin(getLoginUserId(), cancelReqVO); - return success(true); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java deleted file mode 100644 index cfd2f963d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc.BpmProcessInstanceCopyRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceCopyService; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.engine.history.HistoricProcessInstance; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程实例抄送") -@RestController -@RequestMapping("/bpm/process-instance/copy") -@Validated -public class BpmProcessInstanceCopyController { - - @Resource - private BpmProcessInstanceCopyService processInstanceCopyService; - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmTaskService taskService; - - @Resource - private AdminUserApi adminUserApi; - - @GetMapping("/page") - @Operation(summary = "获得抄送流程分页列表") - @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')") - public CommonResult> getProcessInstanceCopyPage( - @Valid BpmProcessInstanceCopyPageReqVO pageReqVO) { - PageResult pageResult = processInstanceCopyService.getProcessInstanceCopyPage( - getLoginUserId(), pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 拼接返回 - Map taskNameMap = taskService.getTaskNameByTaskIds( - convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getTaskId)); - Map processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId)); - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), - copy -> Stream.of(copy.getStartUserId(), Long.parseLong(copy.getCreator())))); - return success(BeanUtils.toBean(pageResult, BpmProcessInstanceCopyRespVO.class, copyVO -> { - MapUtils.findAndThen(userMap, Long.valueOf(copyVO.getCreator()), user -> copyVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, copyVO.getStartUserId(), user -> copyVO.setStartUserName(user.getNickname())); - MapUtils.findAndThen(taskNameMap, copyVO.getTaskId(), copyVO::setTaskName); - MapUtils.findAndThen(processInstanceMap, copyVO.getProcessInstanceId(), - processInstance -> copyVO.setProcessInstanceStartTime(DateUtils.of(processInstance.getStartTime()))); - })); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java deleted file mode 100644 index d299fd6eb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java +++ /dev/null @@ -1,224 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程任务实例") -@RestController -@RequestMapping("/bpm/task") -@Validated -public class BpmTaskController { - - @Resource - private BpmTaskService taskService; - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmFormService formService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @GetMapping("todo-page") - @Operation(summary = "获取 Todo 待办任务分页") - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskTodoPage(@Valid BpmTaskPageReqVO pageVO) { - PageResult pageResult = taskService.getTaskTodoPage(getLoginUserId(), pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 拼接数据 - Map processInstanceMap = processInstanceService.getProcessInstanceMap( - convertSet(pageResult.getList(), Task::getProcessInstanceId)); - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - return success(BpmTaskConvert.INSTANCE.buildTodoTaskPage(pageResult, processInstanceMap, userMap)); - } - - @GetMapping("done-page") - @Operation(summary = "获取 Done 已办任务分页") - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskDonePage(@Valid BpmTaskPageReqVO pageVO) { - PageResult pageResult = taskService.getTaskDonePage(getLoginUserId(), pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 拼接数据 - Map processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(pageResult.getList(), HistoricTaskInstance::getProcessInstanceId)); - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - return success(BpmTaskConvert.INSTANCE.buildTaskPage(pageResult, processInstanceMap, userMap, null)); - } - - @GetMapping("manager-page") - @Operation(summary = "获取全部任务的分页", description = "用于【流程任务】菜单") - @PreAuthorize("@ss.hasPermission('bpm:task:mananger-query')") - public CommonResult> getTaskManagerPage(@Valid BpmTaskPageReqVO pageVO) { - PageResult pageResult = taskService.getTaskPage(getLoginUserId(), pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 拼接数据 - Map processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(pageResult.getList(), HistoricTaskInstance::getProcessInstanceId)); - // 获得 User 和 Dept Map - Set userIds = convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())); - userIds.addAll(convertSet(pageResult.getList(), task -> NumberUtils.parseLong(task.getAssignee()))); - Map userMap = adminUserApi.getUserMap(userIds); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(BpmTaskConvert.INSTANCE.buildTaskPage(pageResult, processInstanceMap, userMap, deptMap)); - } - - @GetMapping("/list-by-process-instance-id") - @Operation(summary = "获得指定流程实例的任务列表", description = "包括完成的、未完成的") - @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskListByProcessInstanceId( - @RequestParam("processInstanceId") String processInstanceId) { - List taskList = taskService.getTaskListByProcessInstanceId(processInstanceId); - if (CollUtil.isEmpty(taskList)) { - return success(Collections.emptyList()); - } - - // 拼接数据 - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); - // 获得 User 和 Dept Map - Set userIds = convertSetByFlatMap(taskList, task -> - Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner()))); - userIds.add(NumberUtils.parseLong(processInstance.getStartUserId())); - Map userMap = adminUserApi.getUserMap(userIds); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 获得 Form Map - Map formMap = formService.getFormMap( - convertSet(taskList, task -> NumberUtils.parseLong(task.getFormKey()))); - return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, processInstance, - formMap, userMap, deptMap)); - } - - @PutMapping("/approve") - @Operation(summary = "通过任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) { - taskService.approveTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/reject") - @Operation(summary = "不通过任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) { - taskService.rejectTask(getLoginUserId(), reqVO); - return success(true); - } - - @GetMapping("/list-by-return") - @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮") - @Parameter(name = "taskId", description = "当前任务ID", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult> getTaskListByReturn(@RequestParam("id") String id) { - List userTaskList = taskService.getUserTaskListByReturn(id); - return success(convertList(userTaskList, userTask -> // 只返回 id 和 name - new BpmTaskRespVO().setName(userTask.getName()).setTaskDefinitionKey(userTask.getId()))); - } - - @PutMapping("/return") - @Operation(summary = "回退任务", description = "用于【流程详情】的【回退】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult returnTask(@Valid @RequestBody BpmTaskReturnReqVO reqVO) { - taskService.returnTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/delegate") - @Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) { - taskService.delegateTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/transfer") - @Operation(summary = "转派任务", description = "用于【流程详情】的【转派】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult transferTask(@Valid @RequestBody BpmTaskTransferReqVO reqVO) { - taskService.transferTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/create-sign") - @Operation(summary = "加签", description = "before 前加签,after 后加签") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult createSignTask(@Valid @RequestBody BpmTaskSignCreateReqVO reqVO) { - taskService.createSignTask(getLoginUserId(), reqVO); - return success(true); - } - - @DeleteMapping("/delete-sign") - @Operation(summary = "减签") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult deleteSignTask(@Valid @RequestBody BpmTaskSignDeleteReqVO reqVO) { - taskService.deleteSignTask(getLoginUserId(), reqVO); - return success(true); - } - - @GetMapping("/list-by-parent-task-id") - @Operation(summary = "获得指定父级任务的子任务列表") // 目前用于,减签的时候,获得子任务列表 - @Parameter(name = "parentTaskId", description = "父级任务编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskListByParentTaskId(@RequestParam("parentTaskId") String parentTaskId) { - List taskList = taskService.getTaskListByParentTaskId(parentTaskId); - if (CollUtil.isEmpty(taskList)) { - return success(Collections.emptyList()); - } - // 拼接数据 - Map userMap = adminUserApi.getUserMap(convertSetByFlatMap(taskList, - user -> Stream.of(NumberUtils.parseLong(user.getAssignee()), NumberUtils.parseLong(user.getOwner())))); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(BpmTaskConvert.INSTANCE.buildTaskListByParentTaskId(taskList, userMap, deptMap)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java deleted file mode 100644 index 8f959e093..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程活动的 Response VO") -@Data -public class BpmActivityRespVO { - - @Schema(description = "流程活动的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String key; - @Schema(description = "流程活动的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent") - private String type; - - @Schema(description = "流程活动的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - @Schema(description = "流程活动的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "关联的流程任务的编号", example = "2048") - private String taskId; // 关联的流程任务,只有 UserTask 等类型才有 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java deleted file mode 100644 index 4b397fc1c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO") -@Data -public class BpmProcessInstanceCopyRespVO { - - @Schema(description = "抄送主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "发起人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long startUserId; - @Schema(description = "发起人昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String startUserName; - - @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "A233") - private String processInstanceId; - @Schema(description = "流程实例的名称") - private String processInstanceName; - @Schema(description = "流程实例的发起时间") - private LocalDateTime processInstanceStartTime; - - @Schema(description = "发起抄送的任务编号") - private String taskId; - @Schema(description = "发起抄送的任务名称") - private String taskName; - - @Schema(description = "抄送人") - private String creator; - @Schema(description = "抄送人昵称") - private String creatorName; - - @Schema(description = "抄送时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java deleted file mode 100644 index 496c72c61..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程实例的取消 Request VO") -@Data -public class BpmProcessInstanceCancelReqVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程实例的编号不能为空") - private String id; - - @Schema(description = "取消原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不请假了!") - @NotEmpty(message = "取消原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCopyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCopyPageReqVO.java deleted file mode 100644 index b702afd2b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCopyPageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO") -@Data -public class BpmProcessInstanceCopyPageReqVO extends PageParam { - - @Schema(description = "流程名称", example = "芋道") - private String processInstanceName; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java deleted file mode 100644 index 207daeeff..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程实例的创建 Request VO") -@Data -public class BpmProcessInstanceCreateReqVO { - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程定义编号不能为空") - private String processDefinitionId; - - @Schema(description = "变量实例(动态表单)") - private Map variables; - - @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}") - private Map> startUserSelectAssignees; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageReqVO.java deleted file mode 100644 index bc658eb87..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程实例分页 Request VO") -@Data -public class BpmProcessInstancePageReqVO extends PageParam { - - @Schema(description = "流程名称", example = "芋道") - private String name; - - @Schema(description = "流程定义的编号", example = "2048") - private String processDefinitionId; - - @Schema(description = "流程实例的状态", example = "1") - @InEnum(BpmProcessInstanceStatusEnum.class) - private Integer status; - - @Schema(description = "流程分类", example = "1") - private String category; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "发起用户编号", example = "1024") - private Long startUserId; // 注意,只有在【流程实例】菜单,才使用该参数 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java deleted file mode 100644 index ac6b90c7e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程实例的 Response VO") -@Data -public class BpmProcessInstanceRespVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String category; - @Schema(description = "流程分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "请假") - private String categoryName; - - @Schema(description = "流程实例的状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; // 参见 BpmProcessInstanceStatusEnum 枚举 - - @Schema(description = "发起时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "持续时间", example = "1000") - private Long durationInMillis; - - @Schema(description = "提交的表单值", requiredMode = Schema.RequiredMode.REQUIRED) - private Map formVariables; - - @Schema(description = "业务的唯一标识-例如说,请假申请的编号", example = "1") - private String businessKey; - - /** - * 发起流程的用户 - */ - private User startUser; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String processDefinitionId; - /** - * 流程定义 - */ - private BpmProcessDefinitionRespVO processDefinition; - - /** - * 当前审批中的任务 - */ - private List tasks; // 仅在流程实例分页才返回 - - @Schema(description = "用户信息") - @Data - public static class User { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long deptId; - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - } - - @Schema(description = "流程任务") - @Data - public static class Task { - - @Schema(description = "流程任务的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java deleted file mode 100644 index 5d35a0e81..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.Collection; -import java.util.Map; - -@Schema(description = "管理后台 - 通过流程任务的 Request VO") -@Data -public class BpmTaskApproveReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") - @NotEmpty(message = "审批意见不能为空") - private String reason; - - @Schema(description = "抄送的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2") - private Collection copyUserIds; - - @Schema(description = "变量实例(动态表单)", requiredMode = Schema.RequiredMode.REQUIRED) - private Map variables; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java deleted file mode 100644 index 96c42deb8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 委派流程任务的 Request VO") -@Data -public class BpmTaskDelegateReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "被委派人 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "被委派人 ID 不能为空") - private Long delegateUserId; - - @Schema(description = "委派原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "做不了决定,需要你先帮忙瞅瞅") - @NotEmpty(message = "委派原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java deleted file mode 100644 index b03b265f1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程任务的的分页 Request VO") // 待办、已办,都使用该分页 -@Data -public class BpmTaskPageReqVO extends PageParam { - - @Schema(description = "流程任务名", example = "芋道") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java deleted file mode 100644 index ebbc0fdaa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 不通过流程任务的 Request VO") -@Data -public class BpmTaskRejectReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") - @NotEmpty(message = "审批意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java deleted file mode 100644 index 7f5177b94..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程任务 Response VO") -@Data -public class BpmTaskRespVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "任务名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "持续时间", example = "1000") - private Long durationInMillis; - - @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer status; // 参见 BpmTaskStatusEnum 枚举 - - @Schema(description = "审批理由", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private String reason; - - /** - * 负责人的用户信息 - */ - private BpmProcessInstanceRespVO.User ownerUser; - /** - * 审核的用户信息 - */ - private BpmProcessInstanceRespVO.User assigneeUser; - - @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one") - private String taskDefinitionKey; - - @Schema(description = "所属流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8888") - private String processInstanceId; - /** - * 所属流程实例 - */ - private ProcessInstance processInstance; - - @Schema(description = "父任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String parentTaskId; - @Schema(description = "子任务列表(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask") - private List children; - - @Schema(description = "表单编号", example = "1024") - private Long formId; - @Schema(description = "表单名字", example = "请假表单") - private String formName; - @Schema(description = "表单的配置-JSON 字符串") - private String formConf; - @Schema(description = "表单项的数组") - private List formFields; - @Schema(description = "提交的表单值", requiredMode = Schema.RequiredMode.REQUIRED) - private Map formVariables; - - @Data - @Schema(description = "流程实例") - public static class ProcessInstance { - - @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "提交时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String processDefinitionId; - - /** - * 发起人的用户信息 - */ - private BpmProcessInstanceRespVO.User startUser; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java deleted file mode 100644 index 49a2316ca..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 回退流程任务的 Request VO") -@Data -public class BpmTaskReturnReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "回退到的任务 Key", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "回退到的任务 Key 不能为空") - private String targetTaskDefinitionKey; - - @Schema(description = "回退意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "我就是想驳回") - @NotEmpty(message = "回退意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignCreateReqVO.java deleted file mode 100644 index e2a153239..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignCreateReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.Set; - -@Schema(description = "管理后台 - 加签任务的创建(加签) Request VO") -@Data -public class BpmTaskSignCreateReqVO { - - @Schema(description = "需要加签的任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "加签的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotEmpty(message = "加签用户不能为空") - private Set userIds; - - @Schema(description = "加签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "before") - @NotEmpty(message = "加签类型不能为空") - private String type; // 参见 BpmTaskSignTypeEnum 枚举 - - @Schema(description = "加签原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "需要加签") - @NotEmpty(message = "加签原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignDeleteReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignDeleteReqVO.java deleted file mode 100644 index 721968cc6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignDeleteReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 加签任务的删除(减签) Request VO") -@Data -public class BpmTaskSignDeleteReqVO { - - @Schema(description = "被减签的任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "加签原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "需要减签") - @NotEmpty(message = "加签原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTransferReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTransferReqVO.java deleted file mode 100644 index 79f0af456..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTransferReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程任务的转办 Request VO") -@Data -public class BpmTaskTransferReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "新审批人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "新审批人的用户编号不能为空") - private Long assigneeUserId; - - @Schema(description = "转办原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "做不了决定,需要你先帮忙瞅瞅") - @NotEmpty(message = "转办原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java deleted file mode 100644 index e8d285e35..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.controller.app; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java deleted file mode 100644 index d1930bd6a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.bpm.controller; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java deleted file mode 100644 index 3fe5cc068..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * 流程模型 Convert - * - * @author yunlongn - */ -@Mapper -public interface BpmModelConvert { - - BpmModelConvert INSTANCE = Mappers.getMapper(BpmModelConvert.class); - - default PageResult buildModelPage(PageResult pageResult, - Map formMap, - Map categoryMap, Map deploymentMap, - Map processDefinitionMap) { - List list = CollectionUtils.convertList(pageResult.getList(), model -> { - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); - BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; - BpmCategoryDO category = categoryMap.get(model.getCategory()); - Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; - ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; - return buildModel0(model, metaInfo, form, category, deployment, processDefinition); - }); - return new PageResult<>(list, pageResult.getTotal()); - } - - default BpmModelRespVO buildModel(Model model, - byte[] bpmnBytes) { - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); - BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null); - if (ArrayUtil.isNotEmpty(bpmnBytes)) { - modelVO.setBpmnXml(new String(bpmnBytes)); - } - return modelVO; - } - - default BpmModelRespVO buildModel0(Model model, - BpmModelMetaInfoRespDTO metaInfo, BpmFormDO form, BpmCategoryDO category, - Deployment deployment, ProcessDefinition processDefinition) { - BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName()) - .setKey(model.getKey()).setCategory(model.getCategory()) - .setCreateTime(DateUtils.of(model.getCreateTime())); - // Form - if (metaInfo != null) { - modelRespVO.setFormType(metaInfo.getFormType()).setFormId(metaInfo.getFormId()) - .setFormCustomCreatePath(metaInfo.getFormCustomCreatePath()) - .setFormCustomViewPath(metaInfo.getFormCustomViewPath()); - modelRespVO.setIcon(metaInfo.getIcon()).setDescription(metaInfo.getDescription()); - } - if (form != null) { - modelRespVO.setFormId(form.getId()).setFormName(form.getName()); - } - // Category - if (category != null) { - modelRespVO.setCategoryName(category.getName()); - } - // ProcessDefinition - if (processDefinition != null) { - modelRespVO.setProcessDefinition(BeanUtils.toBean(processDefinition, BpmProcessDefinitionRespVO.class)); - modelRespVO.getProcessDefinition().setSuspensionState(processDefinition.isSuspended() ? - SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); - if (deployment != null) { - modelRespVO.getProcessDefinition().setDeploymentTime(DateUtils.of(deployment.getDeploymentTime())); - } - } - return modelRespVO; - } - - default void copyToCreateModel(Model model, BpmModelCreateReqVO bean) { - model.setName(bean.getName()); - model.setKey(bean.getKey()); - model.setMetaInfo(buildMetaInfoStr(null, - null, bean.getDescription(), - null, null, null, null)); - } - - default void copyToUpdateModel(Model model, BpmModelUpdateReqVO bean) { - model.setName(bean.getName()); - model.setCategory(bean.getCategory()); - model.setMetaInfo(buildMetaInfoStr(buildMetaInfo(model), - bean.getIcon(), bean.getDescription(), - bean.getFormType(), bean.getFormId(), bean.getFormCustomCreatePath(), bean.getFormCustomViewPath())); - } - - default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo, - String icon, String description, - Integer formType, Long formId, String formCustomCreatePath, String formCustomViewPath) { - if (metaInfo == null) { - metaInfo = new BpmModelMetaInfoRespDTO(); - } - // 只有非空,才进行设置,避免更新时的覆盖 - if (StrUtil.isNotEmpty(icon)) { - metaInfo.setIcon(icon); - } - if (StrUtil.isNotEmpty(description)) { - metaInfo.setDescription(description); - } - if (Objects.nonNull(formType)) { - metaInfo.setFormType(formType); - metaInfo.setFormId(formId); - metaInfo.setFormCustomCreatePath(formCustomCreatePath); - metaInfo.setFormCustomViewPath(formCustomViewPath); - } - return JsonUtils.toJsonString(metaInfo); - } - - default BpmModelMetaInfoRespDTO buildMetaInfo(Model model) { - return JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java deleted file mode 100644 index 0e767d787..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * Bpm 流程定义的 Convert - * - * @author yunlong.li - */ -@Mapper -public interface BpmProcessDefinitionConvert { - - BpmProcessDefinitionConvert INSTANCE = Mappers.getMapper(BpmProcessDefinitionConvert.class); - - default PageResult buildProcessDefinitionPage(PageResult page, - Map deploymentMap, - Map processDefinitionInfoMap, - Map formMap, - Map categoryMap) { - List list = buildProcessDefinitionList(page.getList(), deploymentMap, processDefinitionInfoMap, formMap, categoryMap); - return new PageResult<>(list, page.getTotal()); - } - - default List buildProcessDefinitionList(List list, - Map deploymentMap, - Map processDefinitionInfoMap, - Map formMap, - Map categoryMap) { - return CollectionUtils.convertList(list, definition -> { - Deployment deployment = MapUtil.get(deploymentMap, definition.getDeploymentId(), Deployment.class); - BpmProcessDefinitionInfoDO processDefinitionInfo = MapUtil.get(processDefinitionInfoMap, definition.getId(), BpmProcessDefinitionInfoDO.class); - BpmFormDO form = null; - if (processDefinitionInfo != null) { - form = MapUtil.get(formMap, processDefinitionInfo.getFormId(), BpmFormDO.class); - } - BpmCategoryDO category = MapUtil.get(categoryMap, definition.getCategory(), BpmCategoryDO.class); - return buildProcessDefinition(definition, deployment, processDefinitionInfo, form, category, null, null); - }); - } - - default BpmProcessDefinitionRespVO buildProcessDefinition(ProcessDefinition definition, - Deployment deployment, - BpmProcessDefinitionInfoDO processDefinitionInfo, - BpmFormDO form, - BpmCategoryDO category, - BpmnModel bpmnModel, - List startUserSelectUserTaskList) { - BpmProcessDefinitionRespVO respVO = BeanUtils.toBean(definition, BpmProcessDefinitionRespVO.class); - respVO.setSuspensionState(definition.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); - // Deployment - if (deployment != null) { - respVO.setDeploymentTime(LocalDateTimeUtil.of(deployment.getDeploymentTime())); - } - // BpmProcessDefinitionInfoDO - if (processDefinitionInfo != null) { - copyTo(processDefinitionInfo, respVO); - // Form - if (form != null) { - respVO.setFormName(form.getName()); - } - } - // Category - if (category != null) { - respVO.setCategoryName(category.getName()); - } - // BpmnModel - if (bpmnModel != null) { - respVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnModel)); - respVO.setStartUserSelectTasks(BeanUtils.toBean(startUserSelectUserTaskList, BpmProcessDefinitionRespVO.UserTask.class)); - } - return respVO; - } - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessDefinitionInfoDO from, @MappingTarget BpmProcessDefinitionRespVO to); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java deleted file mode 100644 index 99b7bebf2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.message; - -import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.Map; - -@Mapper -public interface BpmMessageConvert { - - BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class); - - @Mapping(target = "mobile", ignore = true) - @Mapping(source = "userId", target = "userId") - @Mapping(source = "templateCode", target = "templateCode") - @Mapping(source = "templateParams", target = "templateParams") - SmsSendSingleToUserReqDTO convert(Long userId, String templateCode, Map templateParams); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java deleted file mode 100644 index 6db6ebc46..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.bpm.convert; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java deleted file mode 100644 index 3cb674c1c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.flowable.engine.history.HistoricActivityInstance; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * BPM 活动 Convert - * - * @author 芋道源码 - */ -@Mapper(uses = DateUtils.class) -public interface BpmActivityConvert { - - BpmActivityConvert INSTANCE = Mappers.getMapper(BpmActivityConvert.class); - - List convertList(List list); - - @Mappings({ - @Mapping(source = "activityId", target = "key"), - @Mapping(source = "activityType", target = "type") - }) - BpmActivityRespVO convert(HistoricActivityInstance bean); -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java deleted file mode 100644 index 0d4a63244..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 流程实例 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmProcessInstanceConvert { - - BpmProcessInstanceConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceConvert.class); - - default PageResult buildProcessInstancePage(PageResult pageResult, - Map processDefinitionMap, - Map categoryMap, - Map> taskMap, - Map userMap, - Map deptMap) { - PageResult vpPageResult = BeanUtils.toBean(pageResult, BpmProcessInstanceRespVO.class); - for (int i = 0; i < pageResult.getList().size(); i++) { - BpmProcessInstanceRespVO respVO = vpPageResult.getList().get(i); - respVO.setStatus(FlowableUtils.getProcessInstanceStatus(pageResult.getList().get(i))); - MapUtils.findAndThen(processDefinitionMap, respVO.getProcessDefinitionId(), - processDefinition -> respVO.setCategory(processDefinition.getCategory())); - MapUtils.findAndThen(categoryMap, respVO.getCategory(), category -> respVO.setCategoryName(category.getName())); - respVO.setTasks(BeanUtils.toBean(taskMap.get(respVO.getId()), BpmProcessInstanceRespVO.Task.class)); - // user - if (userMap != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(pageResult.getList().get(i).getStartUserId())); - if (startUser != null) { - respVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - MapUtils.findAndThen(deptMap, startUser.getDeptId(), dept -> respVO.getStartUser().setDeptName(dept.getName())); - } - } - } - return vpPageResult; - } - - default BpmProcessInstanceRespVO buildProcessInstance(HistoricProcessInstance processInstance, - ProcessDefinition processDefinition, - BpmProcessDefinitionInfoDO processDefinitionExt, - String bpmnXml, - AdminUserRespDTO startUser, - DeptRespDTO dept) { - BpmProcessInstanceRespVO respVO = BeanUtils.toBean(processInstance, BpmProcessInstanceRespVO.class); - respVO.setStatus(FlowableUtils.getProcessInstanceStatus(processInstance)); - respVO.setFormVariables(FlowableUtils.getProcessInstanceFormVariable(processInstance)); - // definition - respVO.setProcessDefinition(BeanUtils.toBean(processDefinition, BpmProcessDefinitionRespVO.class)); - copyTo(processDefinitionExt, respVO.getProcessDefinition()); - respVO.getProcessDefinition().setBpmnXml(bpmnXml); - // user - if (startUser != null) { - respVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - if (dept != null) { - respVO.getStartUser().setDeptName(dept.getName()); - } - } - return respVO; - } - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessDefinitionInfoDO from, @MappingTarget BpmProcessDefinitionRespVO to); - - default BpmProcessInstanceStatusEvent buildProcessInstanceStatusEvent(Object source, HistoricProcessInstance instance, Integer status) { - return new BpmProcessInstanceStatusEvent(source).setId(instance.getId()).setStatus(status) - .setProcessDefinitionKey(instance.getProcessDefinitionKey()).setBusinessKey(instance.getBusinessKey()); - } - - default BpmProcessInstanceStatusEvent buildProcessInstanceStatusEvent(Object source, ProcessInstance instance, Integer status) {; - return new BpmProcessInstanceStatusEvent(source).setId(instance.getId()).setStatus(status) - .setProcessDefinitionKey(instance.getProcessDefinitionKey()).setBusinessKey(instance.getBusinessKey()); - } - - default BpmMessageSendWhenProcessInstanceApproveReqDTO buildProcessInstanceApproveMessage(ProcessInstance instance) { - return new BpmMessageSendWhenProcessInstanceApproveReqDTO() - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())) - .setProcessInstanceId(instance.getId()) - .setProcessInstanceName(instance.getName()); - } - - default BpmMessageSendWhenProcessInstanceRejectReqDTO buildProcessInstanceRejectMessage(ProcessInstance instance, String reason) { - return new BpmMessageSendWhenProcessInstanceRejectReqDTO() - .setProcessInstanceName(instance.getName()) - .setProcessInstanceId(instance.getId()) - .setReason(reason) - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java deleted file mode 100644 index 5f4e915d3..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java +++ /dev/null @@ -1,176 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * Bpm 任务 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmTaskConvert { - - BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - - default PageResult buildTodoTaskPage(PageResult pageResult, - Map processInstanceMap, - Map userMap) { - return BeanUtils.toBean(pageResult, BpmTaskRespVO.class, taskVO -> { - ProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId()); - if (processInstance == null) { - return; - } - taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class)); - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - taskVO.getProcessInstance().setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - }); - } - - default PageResult buildTaskPage(PageResult pageResult, - Map processInstanceMap, - Map userMap, - Map deptMap) { - List taskVOList = CollectionUtils.convertList(pageResult.getList(), task -> { - BpmTaskRespVO taskVO = BeanUtils.toBean(task, BpmTaskRespVO.class); - taskVO.setStatus(FlowableUtils.getTaskStatus(task)).setReason(FlowableUtils.getTaskReason(task)); - // 用户信息 - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, assignUser.getDeptId(), dept -> taskVO.getAssigneeUser().setDeptName(dept.getName())); - } - // 流程实例 - HistoricProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId()); - if (processInstance != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class)); - taskVO.getProcessInstance().setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - } - return taskVO; - }); - return new PageResult<>(taskVOList, pageResult.getTotal()); - } - - default List buildTaskListByProcessInstanceId(List taskList, - HistoricProcessInstance processInstance, - Map formMap, - Map userMap, - Map deptMap) { - List taskVOList = CollectionUtils.convertList(taskList, task -> { - BpmTaskRespVO taskVO = BeanUtils.toBean(task, BpmTaskRespVO.class); - taskVO.setStatus(FlowableUtils.getTaskStatus(task)).setReason(FlowableUtils.getTaskReason(task)); - // 流程实例 - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class)); - taskVO.getProcessInstance().setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - // 表单信息 - BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class); - if (form != null) { - taskVO.setFormId(form.getId()).setFormName(form.getName()).setFormConf(form.getConf()) - .setFormFields(form.getFields()).setFormVariables(FlowableUtils.getTaskFormVariable(task)); - } - // 用户信息 - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, assignUser.getDeptId(), dept -> taskVO.getAssigneeUser().setDeptName(dept.getName())); - } - AdminUserRespDTO ownerUser = userMap.get(NumberUtils.parseLong(task.getOwner())); - if (ownerUser != null) { - taskVO.setOwnerUser(BeanUtils.toBean(ownerUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, ownerUser.getDeptId(), dept -> taskVO.getOwnerUser().setDeptName(dept.getName())); - } - return taskVO; - }); - - // 拼接父子关系 - Map> childrenTaskMap = convertMultiMap( - filterList(taskVOList, r -> StrUtil.isNotEmpty(r.getParentTaskId())), - BpmTaskRespVO::getParentTaskId); - for (BpmTaskRespVO taskVO : taskVOList) { - taskVO.setChildren(childrenTaskMap.get(taskVO.getId())); - } - return filterList(taskVOList, r -> StrUtil.isEmpty(r.getParentTaskId())); - } - - default List buildTaskListByParentTaskId(List taskList, - Map userMap, - Map deptMap) { - return convertList(taskList, task -> BeanUtils.toBean(task, BpmTaskRespVO.class, taskVO -> { - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class)); - DeptRespDTO dept = deptMap.get(assignUser.getDeptId()); - if (dept != null) { - taskVO.getAssigneeUser().setDeptName(dept.getName()); - } - } - AdminUserRespDTO ownerUser = userMap.get(NumberUtils.parseLong(task.getOwner())); - if (ownerUser != null) { - taskVO.setOwnerUser(BeanUtils.toBean(ownerUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, ownerUser.getDeptId(), dept -> taskVO.getOwnerUser().setDeptName(dept.getName())); - } - })); - } - - default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser, - Task task) { - BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO(); - reqDTO.setProcessInstanceId(processInstance.getProcessInstanceId()) - .setProcessInstanceName(processInstance.getName()).setStartUserId(startUser.getId()) - .setStartUserNickname(startUser.getNickname()).setTaskId(task.getId()).setTaskName(task.getName()) - .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())); - return reqDTO; - } - - /** - * 将父任务的属性,拷贝到子任务(加签任务) - * - * 为什么不使用 mapstruct 映射?因为 TaskEntityImpl 还有很多其他属性,这里我们只设置我们需要的。 - * 使用 mapstruct 会将里面嵌套的各个属性值都设置进去,会出现意想不到的问题。 - * - * @param parentTask 父任务 - * @param childTask 加签任务 - */ - default void copyTo(TaskEntityImpl parentTask, TaskEntityImpl childTask) { - childTask.setName(parentTask.getName()); - childTask.setDescription(parentTask.getDescription()); - childTask.setCategory(parentTask.getCategory()); - childTask.setParentTaskId(parentTask.getId()); - childTask.setProcessDefinitionId(parentTask.getProcessDefinitionId()); - childTask.setProcessInstanceId(parentTask.getProcessInstanceId()); -// childTask.setExecutionId(parentTask.getExecutionId()); // TODO 芋艿:新加的,不太确定;尴尬,不加时,子任务不通过会失败(报错);加了,子任务审批通过会失败(报错) - childTask.setTaskDefinitionKey(parentTask.getTaskDefinitionKey()); - childTask.setTaskDefinitionId(parentTask.getTaskDefinitionId()); - childTask.setPriority(parentTask.getPriority()); - childTask.setCreateTime(new Date()); - childTask.setTenantId(parentTask.getTenantId()); - } - -} diff --git "a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b7..000000000 --- "a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmCategoryDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmCategoryDO.java deleted file mode 100644 index 01c71ebac..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmCategoryDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * BPM 流程分类 DO - * - * @author 芋道源码 - */ -@TableName("bpm_category") -@KeySequence("bpm_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmCategoryDO extends BaseDO { - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 分类名 - */ - private String name; - /** - * 分类标志 - */ - private String code; - /** - * 分类描述 - */ - private String description; - /** - * 分类状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 分类排序 - */ - private Integer sort; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java deleted file mode 100644 index 1d86d3630..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * BPM 工作流的表单定义 - * 用于工作流的申请表单,需要动态配置的场景 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_form", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmFormDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 表单名 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 表单的配置 - */ - private String conf; - /** - * 表单项的数组 - * - * 目前直接将 https://github.com/JakHuang/form-generator 生成的 JSON 串,直接保存 - * 定义:https://github.com/JakHuang/form-generator/issues/46 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List fields; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java deleted file mode 100644 index d8aa68947..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * BPM 流程定义的拓信息 - * 主要解决 Flowable {@link org.flowable.engine.repository.ProcessDefinition} 不支持拓展字段,所以新建该表 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_process_definition_info", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessDefinitionInfoDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 流程定义的编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - /** - * 流程模型的编号 - * - * 关联 Model 的 id 属性 - */ - private String modelId; - - /** - * 图标 - */ - private String icon; - /** - * 描述 - */ - private String description; - - /** - * 表单类型 - * - * 关联 {@link BpmModelFormTypeEnum} - */ - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 关联 {@link BpmFormDO#getId()} - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 冗余 {@link BpmFormDO#getConf()} - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 冗余 {@link BpmFormDO#getFields()} ()} - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessExpressionDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessExpressionDO.java deleted file mode 100644 index 18494b68d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessExpressionDO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * BPM 流程表达式 DO - * - * @author 芋道源码 - */ -@TableName("bpm_process_expression") -@KeySequence("bpm_process_expression_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessExpressionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 表达式名字 - */ - private String name; - /** - * 表达式状态 - * - * 枚举 {@link TODO common_status 对应的类} - */ - private Integer status; - /** - * 表达式 - */ - private String expression; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessListenerDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessListenerDO.java deleted file mode 100644 index 56be88ff3..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessListenerDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * BPM 流程监听器 DO - * - * 目的:本质上它是流程监听器的模版,用于 BPMN 在设计时,直接选择这些模版 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_process_listener") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessListenerDO extends BaseDO { - - /** - * 主键 ID,自增 - */ - @TableId - private Long id; - /** - * 监听器名字 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 监听类型 - * - * 枚举 {@link cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerType} - * - * 1. execution:ExecutionListener 执行监听器 - * 2. task:TaskListener 任务监听器 - */ - private String type; - /** - * 监听事件 - * - * execution 时:start、end - * task 时:create 创建、assignment 指派、complete 完成、delete 删除、update 更新、timeout 超时 - */ - private String event; - - /** - * 值类型 - * - * 1. class:Java 类,ExecutionListener 需要 {@link org.flowable.engine.delegate.JavaDelegate},TaskListener 需要 {@link org.flowable.engine.delegate.TaskListener} - * 2. delegateExpression:委托表达式,在 class 的基础上,需要注册到 Spring 容器里,后续表达式通过 Spring Bean 名称即可 - * 3. expression:表达式,一个普通类的普通方法,将这个普通类注册到 Spring 容器中,然后表达式中还可以执行这个类中的方法 - */ - private String valueType; - /** - * 值 - */ - private String value; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java deleted file mode 100644 index 0a8da0f9b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.Set; - -/** - * BPM 用户组 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_user_group", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmUserGroupDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 组名 - */ - private String name; - /** - * 描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 成员用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set userIds; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java deleted file mode 100644 index 0bef074bc..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.oa; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -/** - * OA 请假申请 DO - * - * {@link #day} 请假天数,目前先简单做。一般是分成请假上午和下午,可以是 1 整天,可以是 0.5 半天 - * - * @author jason - * @author 芋道源码 - */ -@TableName("bpm_oa_leave") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmOALeaveDO extends BaseDO { - - /** - * 请假表单主键 - */ - @TableId - private Long id; - /** - * 申请人的用户编号 - * - * 关联 AdminUserDO 的 id 属性 - */ - private Long userId; - /** - * 请假类型 - */ - private String type; - /** - * 原因 - */ - private String reason; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 请假天数 - */ - private Long day; - /** - * 审批结果 - * - * 枚举 {@link BpmTaskStatusEnum} - * 考虑到简单,所以直接复用了 BpmProcessInstanceStatusEnum 枚举,也可以自己定义一个枚举哈 - */ - private Integer status; - - /** - * 对应的流程编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java deleted file mode 100644 index a464f58fa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.task; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 流程抄送 DO - * - * @author kyle - * @since 2024-01-22 - */ -@TableName(value = "bpm_process_instance_copy", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessInstanceCopyDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 发起人 Id - * - * 冗余 ProcessInstance 的 startUserId 字段 - */ - private Long startUserId; - /** - * 流程名 - * - * 冗余 ProcessInstance 的 name 字段 - */ - private String processInstanceName; - /** - * 流程实例的编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 流程分类 - * - * 冗余 ProcessInstance 的 category 字段 - */ - private String category; - - /** - * 任务主键 - * - * 关联 Task 的 id 属性 - */ - private String taskId; - /** - * 任务名称 - * - * 冗余 Task 的 name 属性 - */ - private String taskName; - - /** - * 用户编号(被抄送的用户编号) - * - * 关联 system_users 的 id 属性 - */ - private Long userId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/category/BpmCategoryMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/category/BpmCategoryMapper.java deleted file mode 100644 index 5fc8236e8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/category/BpmCategoryMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.category; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * BPM 流程分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmCategoryMapper extends BaseMapperX { - - default PageResult selectPage(BpmCategoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmCategoryDO::getName, reqVO.getName()) - .likeIfPresent(BpmCategoryDO::getCode, reqVO.getCode()) - .eqIfPresent(BpmCategoryDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmCategoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(BpmCategoryDO::getSort)); - } - - default BpmCategoryDO selectByName(String name) { - return selectOne(BpmCategoryDO::getName, name); - } - - default BpmCategoryDO selectByCode(String code) { - return selectOne(BpmCategoryDO::getCode, code); - } - - default List selectListByCode(Collection codes) { - return selectList(BpmCategoryDO::getCode, codes); - } - - default List selectListByStatus(Integer status) { - return selectList(BpmCategoryDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java deleted file mode 100644 index 633bac06f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 动态表单 Mapper - * - * @author 风里雾里 - */ -@Mapper -public interface BpmFormMapper extends BaseMapperX { - - default PageResult selectPage(BpmFormPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .likeIfPresent("name", reqVO.getName()) - .orderByDesc("id")); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionInfoMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionInfoMapper.java deleted file mode 100644 index b868fdce6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionInfoMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface BpmProcessDefinitionInfoMapper extends BaseMapperX { - - default List selectListByProcessDefinitionIds(Collection processDefinitionIds) { - return selectList(BpmProcessDefinitionInfoDO::getProcessDefinitionId, processDefinitionIds); - } - - default BpmProcessDefinitionInfoDO selectByProcessDefinitionId(String processDefinitionId) { - return selectOne(BpmProcessDefinitionInfoDO::getProcessDefinitionId, processDefinitionId); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessExpressionMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessExpressionMapper.java deleted file mode 100644 index 81af6d54a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessExpressionMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * BPM 流程表达式 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmProcessExpressionMapper extends BaseMapperX { - - default PageResult selectPage(BpmProcessExpressionPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmProcessExpressionDO::getName, reqVO.getName()) - .eqIfPresent(BpmProcessExpressionDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmProcessExpressionDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmProcessExpressionDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessListenerMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessListenerMapper.java deleted file mode 100644 index 10ccd2fba..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessListenerMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * BPM 流程监听器 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmProcessListenerMapper extends BaseMapperX { - - default PageResult selectPage(BpmProcessListenerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmProcessListenerDO::getName, reqVO.getName()) - .eqIfPresent(BpmProcessListenerDO::getType, reqVO.getType()) - .eqIfPresent(BpmProcessListenerDO::getEvent, reqVO.getEvent()) - .eqIfPresent(BpmProcessListenerDO::getStatus, reqVO.getStatus()) - .orderByDesc(BpmProcessListenerDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java deleted file mode 100644 index bb8d96c2b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 用户组 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmUserGroupMapper extends BaseMapperX { - - default PageResult selectPage(BpmUserGroupPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmUserGroupDO::getName, reqVO.getName()) - .eqIfPresent(BpmUserGroupDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmUserGroupDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmUserGroupDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BpmUserGroupDO::getStatus, status); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java deleted file mode 100644 index 305ddca86..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.oa; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 请假申请 Mapper - * - * @author jason - * @author 芋道源码 - */ -@Mapper -public interface BpmOALeaveMapper extends BaseMapperX { - - default PageResult selectPage(Long userId, BpmOALeavePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BpmOALeaveDO::getUserId, userId) - .eqIfPresent(BpmOALeaveDO::getStatus, reqVO.getStatus()) - .eqIfPresent(BpmOALeaveDO::getType, reqVO.getType()) - .likeIfPresent(BpmOALeaveDO::getReason, reqVO.getReason()) - .betweenIfPresent(BpmOALeaveDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmOALeaveDO::getId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceCopyMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceCopyMapper.java deleted file mode 100644 index c5ec50f65..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceCopyMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface BpmProcessInstanceCopyMapper extends BaseMapperX { - - default PageResult selectPage(Long loginUserId, BpmProcessInstanceCopyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId) - .likeIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceName, reqVO.getProcessInstanceName()) - .betweenIfPresent(BpmProcessInstanceCopyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmProcessInstanceCopyDO::getId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java deleted file mode 100644 index 8e69fdc75..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.config; - -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmActivityBehaviorFactory; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.event.BpmProcessInstanceEventPublisher; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.flowable.common.engine.api.delegate.event.FlowableEventListener; -import org.flowable.spring.SpringProcessEngineConfiguration; -import org.flowable.spring.boot.EngineConfigurationConfigurer; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.task.AsyncListenableTaskExecutor; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.List; - -/** - * BPM 模块的 Flowable 配置类 - * - * @author jason - */ -@Configuration(proxyBeanMethods = false) -public class BpmFlowableConfiguration { - - /** - * 参考 {@link org.flowable.spring.boot.FlowableJobConfiguration} 类,创建对应的 AsyncListenableTaskExecutor Bean - * - * 如果不创建,会导致项目启动时,Flowable 报错的问题 - */ - @Bean(name = "applicationTaskExecutor") - @ConditionalOnMissingBean(name = "applicationTaskExecutor") - public AsyncListenableTaskExecutor taskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(8); - executor.setMaxPoolSize(8); - executor.setQueueCapacity(100); - executor.setThreadNamePrefix("flowable-task-Executor-"); - executor.setAwaitTerminationSeconds(30); - executor.setWaitForTasksToCompleteOnShutdown(true); - executor.setAllowCoreThreadTimeOut(true); - executor.initialize(); - return executor; - } - - /** - * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类: - * - * 1. 设置各种监听器 - * 2. 设置自定义的 ActivityBehaviorFactory 实现 - */ - @Bean - public EngineConfigurationConfigurer bpmProcessEngineConfigurationConfigurer( - ObjectProvider listeners, - BpmActivityBehaviorFactory bpmActivityBehaviorFactory) { - return configuration -> { - // 注册监听器,例如说 BpmActivityEventListener - configuration.setEventListeners(ListUtil.toList(listeners.iterator())); - // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义 - configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory); - }; - } - - // =========== 审批人相关的 Bean ========== - - @Bean - public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskCandidateInvoker bpmTaskCandidateInvoker) { - BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); - bpmActivityBehaviorFactory.setTaskCandidateInvoker(bpmTaskCandidateInvoker); - return bpmActivityBehaviorFactory; - } - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") // adminUserApi 可以注入成功 - public BpmTaskCandidateInvoker bpmTaskCandidateInvoker(List strategyList, - AdminUserApi adminUserApi) { - return new BpmTaskCandidateInvoker(strategyList, adminUserApi); - } - - // =========== 自己拓展的 Bean ========== - - @Bean - public BpmProcessInstanceEventPublisher processInstanceEventPublisher(ApplicationEventPublisher publisher) { - return new BpmProcessInstanceEventPublisher(publisher); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java deleted file mode 100644 index b5278f5ab..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import lombok.Setter; -import org.flowable.bpmn.model.Activity; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; -import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory; - -/** - * 自定义的 ActivityBehaviorFactory 实现类,目的如下: - * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配 - * - * @author 芋道源码 - */ -@Setter -public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { - - private BpmTaskCandidateInvoker taskCandidateInvoker; - - @Override - public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) { - return new BpmUserTaskActivityBehavior(userTask) - .setTaskCandidateInvoker(taskCandidateInvoker); - } - - @Override - public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior behavior) { - return new BpmParallelMultiInstanceBehavior(activity, behavior) - .setTaskCandidateInvoker(taskCandidateInvoker); - } - - @Override - public SequentialMultiInstanceBehavior createSequentialMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior behavior) { - return new BpmSequentialMultiInstanceBehavior(activity, behavior) - .setTaskCandidateInvoker(taskCandidateInvoker); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java deleted file mode 100644 index 2e1143815..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import lombok.Setter; -import org.flowable.bpmn.model.Activity; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; - -import java.util.Set; - -/** - * 自定义的【并行】的【多个】流程任务的 assignee 负责人的分配 - * 第一步,基于分配规则,计算出分配任务的【多个】候选人们。 - * 第二步,将【多个】任务候选人们,设置到 DelegateExecution 的 collectionVariable 变量中,以便 BpmUserTaskActivityBehavior 使用它 - * - * @author kemengkai - * @since 2022-04-21 16:57 - */ -@Setter -public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehavior { - - private BpmTaskCandidateInvoker taskCandidateInvoker; - - public BpmParallelMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior innerActivityBehavior) { - super(activity, innerActivityBehavior); - } - - /** - * 重写该方法,主要实现两个功能: - * 1. 忽略原有的 collectionVariable、collectionElementVariable 表达式,而是采用自己定义的 - * 2. 获得任务的处理人,并设置到 collectionVariable 中,用于 BpmUserTaskActivityBehavior 从中可以获取任务的处理人 - * - * 注意,多个任务实例,每个任务实例对应一个处理人,所以返回的数量就是任务处理人的数量 - * - * @param execution 执行任务 - * @return 数量 - */ - @Override - protected int resolveNrOfInstances(DelegateExecution execution) { - // 第一步,设置 collectionVariable 和 CollectionVariable - // 从 execution.getVariable() 读取所有任务处理人的 key - super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的 - super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId()); - // 从 execution.getVariable() 读取当前所有任务处理的人的 key - super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId()); - - // 第二步,获取任务的所有处理人 - Set assigneeUserIds = taskCandidateInvoker.calculateUsers(execution); - execution.setVariable(super.collectionVariable, assigneeUserIds); - return assigneeUserIds.size(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java deleted file mode 100644 index 6beb6e7bb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import lombok.Setter; -import org.flowable.bpmn.model.Activity; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; - -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * 自定义的【串行】的【多个】流程任务的 assignee 负责人的分配 - * - * 本质上,实现和 {@link BpmParallelMultiInstanceBehavior} 一样,只是继承的类不一样 - * - * @author 芋道源码 - */ -@Setter -public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceBehavior { - - private BpmTaskCandidateInvoker taskCandidateInvoker; - - public BpmSequentialMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior) { - super(activity, innerActivityBehavior); - } - - /** - * 逻辑和 {@link BpmParallelMultiInstanceBehavior#resolveNrOfInstances(DelegateExecution)} 类似 - * - * 差异的点:是在【第二步】的时候,需要返回 LinkedHashSet 集合!因为它需要有序! - */ - @Override - protected int resolveNrOfInstances(DelegateExecution execution) { - // 第一步,设置 collectionVariable 和 CollectionVariable - // 从 execution.getVariable() 读取所有任务处理人的 key - super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的 - super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId()); - // 从 execution.getVariable() 读取当前所有任务处理的人的 key - super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId()); - - // 第二步,获取任务的所有处理人 - Set assigneeUserIds = new LinkedHashSet<>(taskCandidateInvoker.calculateUsers(execution)); // 保证有序!!! - execution.setVariable(super.collectionVariable, assigneeUserIds); - return assigneeUserIds.size(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java deleted file mode 100644 index c49465273..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.el.ExpressionManager; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.util.TaskHelper; -import org.flowable.task.service.TaskService; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; - -import java.util.List; -import java.util.Set; - -/** - * 自定义的【单个】流程任务的 assignee 负责人的分配 - * 第一步,基于分配规则,计算出分配任务的【单个】候选人。如果找不到,则直接报业务异常,不继续执行后续的流程; - * 第二步,随机选择一个候选人,则选择作为 assignee 负责人。 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior { - - @Setter - private BpmTaskCandidateInvoker taskCandidateInvoker; - - public BpmUserTaskActivityBehavior(UserTask userTask) { - super(userTask); - } - - @Override - protected void handleAssignments(TaskService taskService, String assignee, String owner, - List candidateUsers, List candidateGroups, TaskEntity task, ExpressionManager expressionManager, - DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - // 第一步,获得任务的候选用户 - Long assigneeUserId = calculateTaskCandidateUsers(execution); - Assert.notNull(assigneeUserId, "任务处理人不能为空"); - // 第二步,设置作为负责人 - TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); - } - - private Long calculateTaskCandidateUsers(DelegateExecution execution) { - // 情况一,如果是多实例的任务,例如说会签、或签等情况,则从 Variable 中获取。 - // 顺序审批可见 BpmSequentialMultiInstanceBehavior,并发审批可见 BpmSequentialMultiInstanceBehavior - if (super.multiInstanceActivityBehavior != null) { - return execution.getVariable(super.multiInstanceActivityBehavior.getCollectionElementVariable(), Long.class); - } - - // 情况二,如果非多实例的任务,则计算任务处理人 - // 第一步,先计算可处理该任务的处理人们 - Set candidateUserIds = taskCandidateInvoker.calculateUsers(execution); - // 第二步,后随机选择一个任务的处理人 - // 疑问:为什么一定要选择一个任务处理人? - // 解答:项目对 bpm 的任务是责任到人,所以每个任务有且仅有一个处理人。 - // 如果希望一个任务可以同时被多个人处理,可以考虑使用 BpmParallelMultiInstanceBehavior 实现的会签 or 或签。 - int index = RandomUtil.randomInt(candidateUserIds.size()); - return CollUtil.get(candidateUserIds, index); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java deleted file mode 100644 index c0c7ca0d9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.delegate.DelegateExecution; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER; - -/** - * {@link BpmTaskCandidateStrategy} 的调用者,用于调用对应的策略,实现任务的候选人的计算 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmTaskCandidateInvoker { - - private final Map strategyMap = new HashMap<>(); - - private final AdminUserApi adminUserApi; - - public BpmTaskCandidateInvoker(List strategyList, - AdminUserApi adminUserApi) { - strategyList.forEach(strategy -> { - BpmTaskCandidateStrategy oldStrategy = strategyMap.put(strategy.getStrategy(), strategy); - Assert.isNull(oldStrategy, "策略(%s) 重复", strategy.getStrategy()); - }); - this.adminUserApi = adminUserApi; - } - - /** - * 校验流程模型的任务分配规则全部都配置了 - * 目的:如果有规则未配置,会导致流程任务找不到负责人,进而流程无法进行下去! - * - * @param bpmnBytes BPMN XML - */ - public void validateBpmnConfig(byte[] bpmnBytes) { - BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); - assert bpmnModel != null; - List userTaskList = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class); - // 遍历所有的 UserTask,校验审批人配置 - userTaskList.forEach(userTask -> { - // 1. 非空校验 - Integer strategy = BpmnModelUtils.parseCandidateStrategy(userTask); - String param = BpmnModelUtils.parseCandidateParam(userTask); - if (strategy == null) { - throw exception(MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG, userTask.getName()); - } - BpmTaskCandidateStrategy candidateStrategy = getCandidateStrategy(strategy); - if (candidateStrategy.isParamRequired() && StrUtil.isBlank(param)) { - throw exception(MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG, userTask.getName()); - } - // 2. 具体策略校验 - getCandidateStrategy(strategy).validateParam(param); - }); - } - - /** - * 计算任务的候选人 - * - * @param execution 执行任务 - * @return 用户编号集合 - */ - @DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致找不到候选人 - public Set calculateUsers(DelegateExecution execution) { - Integer strategy = BpmnModelUtils.parseCandidateStrategy(execution.getCurrentFlowElement()); - String param = BpmnModelUtils.parseCandidateParam(execution.getCurrentFlowElement()); - // 1.1 计算任务的候选人 - Set userIds = getCandidateStrategy(strategy).calculateUsers(execution, param); - // 1.2 移除被禁用的用户 - removeDisableUsers(userIds); - - // 2. 校验是否有候选人 - if (CollUtil.isEmpty(userIds)) { - log.error("[calculateUsers][流程任务({}/{}/{}) 任务规则({}/{}) 找不到候选人]", execution.getId(), - execution.getProcessDefinitionId(), execution.getCurrentActivityId(), strategy, param); - throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER); - } - return userIds; - } - - @VisibleForTesting - void removeDisableUsers(Set assigneeUserIds) { - if (CollUtil.isEmpty(assigneeUserIds)) { - return; - } - Map userMap = adminUserApi.getUserMap(assigneeUserIds); - assigneeUserIds.removeIf(id -> { - AdminUserRespDTO user = userMap.get(id); - return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus()); - }); - } - - private BpmTaskCandidateStrategy getCandidateStrategy(Integer strategy) { - BpmTaskCandidateStrategyEnum strategyEnum = BpmTaskCandidateStrategyEnum.valueOf(strategy); - Assert.notNull(strategyEnum, "策略(%s) 不存在", strategy); - BpmTaskCandidateStrategy strategyObj = strategyMap.get(strategyEnum); - Assert.notNull(strategyObj, "策略(%s) 不存在", strategy); - return strategyObj; - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateStrategy.java deleted file mode 100644 index 1534d39c2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateStrategy.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import org.flowable.engine.delegate.DelegateExecution; - -import java.util.Set; - -/** - * BPM 任务的候选人的策略接口 - * - * 例如说:分配审批人 - * - * @author 芋道源码 - */ -public interface BpmTaskCandidateStrategy { - - /** - * 对应策略 - * - * @return 策略 - */ - BpmTaskCandidateStrategyEnum getStrategy(); - - /** - * 校验参数 - * - * @param param 参数 - */ - void validateParam(String param); - - /** - * 基于执行任务,获得任务的候选用户们 - * - * @param execution 执行任务 - * @return 用户编号集合 - */ - Set calculateUsers(DelegateExecution execution, String param); - - /** - * 是否一定要输入参数 - * - * @return 是否 - */ - default boolean isParamRequired() { - return true; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java deleted file mode 100644 index 25482e818..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.expression; - -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; - -import javax.annotation.Resource; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static java.util.Collections.emptySet; - -/** - * 分配给发起人的 Leader 审批的 Expression 流程表达式 - * 目前 Leader 的定义是,发起人所在部门的 Leader - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderExpression { - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Resource - private BpmProcessInstanceService processInstanceService; - - /** - * 计算审批的候选人 - * - * @param execution 流程执行实体 - * @param level 指定级别 - * @return 指定级别的领导 - */ - public Set calculateUsers(DelegateExecution execution, int level) { - Assert.isTrue(level > 0, "level 必须大于 0"); - // 获得发起人 - ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId()); - // 获得对应 leve 的部门 - DeptRespDTO dept = null; - for (int i = 0; i < level; i++) { - // 获得 level 对应的部门 - if (dept == null) { - dept = getStartUserDept(startUserId); - if (dept == null) { // 找不到发起人的部门,所以无法使用该规则 - return emptySet(); - } - } else { - DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()).getCheckedData(); - if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少 - break; - } - dept = parentDept; - } - } - return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet(); - } - - private DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId).getCheckedData(); - if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则 - return null; - } - return deptApi.getDept(startUser.getDeptId()).getCheckedData(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java deleted file mode 100644 index 2c7de5a2b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.expression; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 分配给发起人审批的 Expression 流程表达式 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignStartUserExpression { - - @Resource - private BpmProcessInstanceService processInstanceService; - - /** - * 计算审批的候选人 - * - * @param execution 流程执行实体 - * @return 发起人 - */ - public Set calculateUsers(ExecutionEntityImpl execution) { - ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId()); - return SetUtils.asSet(startUserId); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategy.java deleted file mode 100644 index 30e948c8f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategy.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * 部门的负责人 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateDeptLeaderStrategy implements BpmTaskCandidateStrategy { - - @Resource - private DeptApi deptApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.DEPT_LEADER; - } - - @Override - public void validateParam(String param) { - Set deptIds = StrUtils.splitToLongSet(param); - deptApi.validateDeptList(deptIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set deptIds = StrUtils.splitToLongSet(param); - List depts = deptApi.getDeptList(deptIds).getCheckedData(); - return convertSet(depts, DeptRespDTO::getLeaderUserId); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategy.java deleted file mode 100644 index ad1c57367..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategy.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * 部门的成员 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateDeptMemberStrategy implements BpmTaskCandidateStrategy { - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.DEPT_MEMBER; - } - - @Override - public void validateParam(String param) { - Set deptIds = StrUtils.splitToLongSet(param); - deptApi.validateDeptList(deptIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set deptIds = StrUtils.splitToLongSet(param); - List users = adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(); - return convertSet(users, AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java deleted file mode 100644 index e0f9dabe5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.hutool.core.convert.Convert; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 流程表达式 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrategy { - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.EXPRESSION; - } - - @Override - public void validateParam(String param) { - // do nothing 因为它基本做不了校验 - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Object result = FlowableUtils.getExpressionValue(execution, param); - return Convert.toSet(Long.class, result); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java deleted file mode 100644 index da1aa3944..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; - -/** - * 用户组 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy { - - @Resource - private BpmUserGroupService userGroupService; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.USER_GROUP; - } - - @Override - public void validateParam(String param) { - Set groupIds = StrUtils.splitToLongSet(param); - userGroupService.getUserGroupList(groupIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set groupIds = StrUtils.splitToLongSet(param); - List groups = userGroupService.getUserGroupList(groupIds); - return convertSetByFlatMap(groups, BpmUserGroupDO::getUserIds, Collection::stream); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategy.java deleted file mode 100644 index b23cf5733..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategy.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * 岗位 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidatePostStrategy implements BpmTaskCandidateStrategy { - - @Resource - private PostApi postApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.POST; - } - - @Override - public void validateParam(String param) { - Set postIds = StrUtils.splitToLongSet(param); - postApi.validPostList(postIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set postIds = StrUtils.splitToLongSet(param); - List users = adminUserApi.getUserListByPostIds(postIds).getCheckedData(); - return convertSet(users, AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategy.java deleted file mode 100644 index d44b388f6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategy.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 角色 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateRoleStrategy implements BpmTaskCandidateStrategy { - - @Resource - private RoleApi roleApi; - @Resource - private PermissionApi permissionApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.ROLE; - } - - @Override - public void validateParam(String param) { - Set roleIds = StrUtils.splitToLongSet(param); - roleApi.validRoleList(roleIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set roleIds = StrUtils.splitToLongSet(param); - return permissionApi.getUserRoleIdListByRoleIds(roleIds).getCheckedData(); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserSelectStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserSelectStrategy.java deleted file mode 100644 index 36750effb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserSelectStrategy.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.*; - -/** - * 发起人自选 {@link BpmTaskCandidateUserStrategy} 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidateStrategy { - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmProcessInstanceService processInstanceService; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.START_USER_SELECT; - } - - @Override - public void validateParam(String param) {} - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Assert.notNull(processInstance, "流程实例({})不能为空", execution.getProcessInstanceId()); - Map> startUserSelectAssignees = FlowableUtils.getStartUserSelectAssignees(processInstance); - Assert.notNull(startUserSelectAssignees, "流程实例({}) 的发起人自选审批人不能为空", - execution.getProcessInstanceId()); - // 获得审批人 - List assignees = startUserSelectAssignees.get(execution.getCurrentActivityId()); - return new LinkedHashSet<>(assignees); - } - - @Override - public boolean isParamRequired() { - return false; - } - - /** - * 获得发起人自选审批人的 UserTask 列表 - * - * @param bpmnModel BPMN 模型 - * @return UserTask 列表 - */ - public static List getStartUserSelectUserTaskList(BpmnModel bpmnModel) { - if (bpmnModel == null) { - return null; - } - List userTaskList = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class); - if (CollUtil.isEmpty(userTaskList)) { - return null; - } - userTaskList.removeIf(userTask -> !Objects.equals(BpmnModelUtils.parseCandidateStrategy(userTask), - BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())); - return userTaskList; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategy.java deleted file mode 100644 index a6daec0e0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategy.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 用户 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy { - - @Resource - private AdminUserApi adminUserApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.USER; - } - - @Override - public void validateParam(String param) { - adminUserApi.validateUserList(StrUtils.splitToLongSet(param)); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - return StrUtils.splitToLongSet(param); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmConstants.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmConstants.java deleted file mode 100644 index e965d2281..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; - -import org.flowable.engine.runtime.ProcessInstance; - -/** - * BPM 通用常量 - * - * @author 芋道源码 - */ -public class BpmConstants { - - /** - * 流程实例的变量 - 状态 - * - * @see ProcessInstance#getProcessVariables() - */ - public static final String PROCESS_INSTANCE_VARIABLE_STATUS = "PROCESS_STATUS"; - /** - * 流程实例的变量 - 发起用户选择的审批人 Map - * - * @see ProcessInstance#getProcessVariables() - */ - public static final String PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES = "PROCESS_START_USER_SELECT_ASSIGNEES"; - - /** - * 任务的变量 - 状态 - * - * @see org.flowable.task.api.Task#getTaskLocalVariables() - */ - public static final String TASK_VARIABLE_STATUS = "TASK_STATUS"; - /** - * 任务的变量 - 理由 - * - * 例如说:审批通过、不通过的理由 - * - * @see org.flowable.task.api.Task#getTaskLocalVariables() - */ - public static final String TASK_VARIABLE_REASON = "TASK_REASON"; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java deleted file mode 100644 index a8b538501..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; - -import cn.hutool.core.util.ArrayUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 任务的候选人策略枚举 - * - * 例如说:分配给指定人审批 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmTaskCandidateStrategyEnum { - - ROLE(10, "角色"), - DEPT_MEMBER(20, "部门的成员"), // 包括负责人 - DEPT_LEADER(21, "部门的负责人"), - POST(22, "岗位"), - USER(30, "用户"), - START_USER_SELECT(35, "发起人自选"), // 申请人自己,可在提交申请时选择此节点的审批人 - USER_GROUP(40, "用户组"), - EXPRESSION(60, "流程表达式"), // 表达式 ExpressionManager - ; - - /** - * 类型 - */ - private final Integer strategy; - /** - * 描述 - */ - private final String description; - - public static BpmTaskCandidateStrategyEnum valueOf(Integer strategy) { - return ArrayUtil.firstMatch(o -> o.getStrategy().equals(strategy), values()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java deleted file mode 100644 index 3eb6981ef..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; - -/** - * BPMN XML 常量信息 - * - * @author 芋道源码 - */ -public interface BpmnModelConstants { - - String BPMN_FILE_SUFFIX = ".bpmn"; - - /** - * BPMN 中的命名空间 - */ - String NAMESPACE = "http://flowable.org/bpmn"; - - /** - * BPMN UserTask 的扩展属性,用于标记候选人策略 - */ - String USER_TASK_CANDIDATE_STRATEGY = "candidateStrategy"; - /** - * BPMN UserTask 的扩展属性,用于标记候选人参数 - */ - String USER_TASK_CANDIDATE_PARAM = "candidateParam"; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/event/BpmProcessInstanceEventPublisher.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/event/BpmProcessInstanceEventPublisher.java deleted file mode 100644 index efeda8afa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/event/BpmProcessInstanceEventPublisher.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.event; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import lombok.AllArgsConstructor; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; - -/** - * {@link BpmProcessInstanceStatusEvent} 的生产者 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Validated -public class BpmProcessInstanceEventPublisher { - - private final ApplicationEventPublisher publisher; - - public void sendProcessInstanceResultEvent(@Valid BpmProcessInstanceStatusEvent event) { - publisher.publishEvent(event); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java deleted file mode 100644 index f6d0a28c0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import com.google.common.collect.ImmutableSet; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 监听 {@link ProcessInstance} 的状态变更,更新其对应的 status 状态 - * - * @author jason - */ -@Component -public class BpmProcessInstanceEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy - private BpmProcessInstanceService processInstanceService; - - public static final Set PROCESS_INSTANCE_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.PROCESS_CANCELLED) - .add(FlowableEngineEventType.PROCESS_COMPLETED) - .build(); - - public BpmProcessInstanceEventListener(){ - super(PROCESS_INSTANCE_EVENTS); - } - - @Override - protected void processCancelled(FlowableCancelledEvent event) { - processInstanceService.updateProcessInstanceWhenCancel(event); - } - - @Override - protected void processCompleted(FlowableEngineEntityEvent event) { - processInstanceService.updateProcessInstanceWhenApprove((ProcessInstance)event.getEntity()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java deleted file mode 100644 index 8cb40412c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import com.google.common.collect.ImmutableSet; -import lombok.extern.slf4j.Slf4j; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener; -import org.flowable.engine.delegate.event.FlowableActivityCancelledEvent; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.task.api.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -/** - * 监听 {@link Task} 的开始与完成 - * - * @author jason - */ -@Component -@Slf4j -public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - @Resource - @Lazy // 解决循环依赖 - private BpmActivityService activityService; - - public static final Set TASK_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.TASK_CREATED) - .add(FlowableEngineEventType.TASK_ASSIGNED) -// .add(FlowableEngineEventType.TASK_COMPLETED) // 由于审批通过时,已经记录了 task 的 status 为通过,所以不需要监听了。 - .add(FlowableEngineEventType.ACTIVITY_CANCELLED) - .build(); - - public BpmTaskEventListener(){ - super(TASK_EVENTS); - } - - @Override - protected void taskCreated(FlowableEngineEntityEvent event) { - taskService.updateTaskStatusWhenCreated((Task) event.getEntity()); - } - - @Override - protected void taskAssigned(FlowableEngineEntityEvent event) { - taskService.updateTaskExtAssign((Task)event.getEntity()); - } - - @Override - protected void activityCancelled(FlowableActivityCancelledEvent event) { - List activityList = activityService.getHistoricActivityListByExecutionId(event.getExecutionId()); - if (CollUtil.isEmpty(activityList)) { - log.error("[activityCancelled][使用 executionId({}) 查找不到对应的活动实例]", event.getExecutionId()); - return; - } - // 遍历处理 - activityList.forEach(activity -> { - if (StrUtil.isEmpty(activity.getTaskId())) { - return; - } - taskService.updateTaskStatusWhenCanceled(activity.getTaskId()); - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateClassExecutionListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateClassExecutionListener.java deleted file mode 100644 index 0ce920e3f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateClassExecutionListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.delegate.JavaDelegate; - -/** - * 类型为 class 的 ExecutionListener 监听器示例 - * - * @author 芋道源码 - */ -@Slf4j -public class DemoDelegateClassExecutionListener implements JavaDelegate { - - @Override - public void execute(DelegateExecution execution) { - log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), - execution.getCurrentFlowableListener().getFieldExtensions()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateExpressionExecutionListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateExpressionExecutionListener.java deleted file mode 100644 index 00f3504ac..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateExpressionExecutionListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.delegate.JavaDelegate; -import org.springframework.stereotype.Component; - -/** - * 类型为 delegateExpression 的 ExecutionListener 监听器示例 - * - * 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中 - */ -@Component -@Slf4j -public class DemoDelegateExpressionExecutionListener implements JavaDelegate { - - @Override - public void execute(DelegateExecution execution) { - log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), - execution.getCurrentFlowableListener().getFieldExtensions()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoSpringExpressionExecutionListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoSpringExpressionExecutionListener.java deleted file mode 100644 index 949140fdf..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoSpringExpressionExecutionListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -/** - * 类型为 expression 的 ExecutionListener 监听器示例 - * - * 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中,但不用实现 {@link org.flowable.engine.delegate.JavaDelegate} 接口 - */ -@Component -@Slf4j -public class DemoSpringExpressionExecutionListener { - - public void execute(DelegateExecution execution) { - log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), - execution.getCurrentFlowableListener().getFieldExtensions()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateClassTaskListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateClassTaskListener.java deleted file mode 100644 index dee2b9587..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateClassTaskListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.TaskListener; -import org.flowable.task.service.delegate.DelegateTask; - -/** - * 类型为 class 的 TaskListener 监听器示例 - * - * @author 芋道源码 - */ -@Slf4j -public class DemoDelegateClassTaskListener implements TaskListener { - - @Override - public void notify(DelegateTask delegateTask) { - log.info("[execute][task({}) 被调用]", delegateTask.getId()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateExpressionTaskListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateExpressionTaskListener.java deleted file mode 100644 index e554ff83f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateExpressionTaskListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.TaskListener; -import org.flowable.task.service.delegate.DelegateTask; -import org.springframework.stereotype.Component; - -/** - * 类型为 delegateExpression 的 TaskListener 监听器示例 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class DemoDelegateExpressionTaskListener implements TaskListener { - - @Override - public void notify(DelegateTask delegateTask) { - log.info("[execute][task({}) 被调用]", delegateTask.getId()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoSpringExpressionTaskListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoSpringExpressionTaskListener.java deleted file mode 100644 index 0917abd57..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoSpringExpressionTaskListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.task.service.delegate.DelegateTask; -import org.springframework.stereotype.Component; - -/** - * 类型为 expression 的 TaskListener 监听器示例 - * - * @author 芋道源码 - */ -@Slf4j -@Component -public class DemoSpringExpressionTaskListener { - - public void notify(DelegateTask delegateTask) { - log.info("[execute][task({}) 被调用]", delegateTask.getId()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java deleted file mode 100644 index 3a812eb25..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java +++ /dev/null @@ -1,332 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; -import org.flowable.bpmn.converter.BpmnXMLConverter; -import org.flowable.bpmn.model.Process; -import org.flowable.bpmn.model.*; -import org.flowable.common.engine.impl.util.io.BytesStreamSource; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * 流程模型转操作工具类 - */ -public class BpmnModelUtils { - - public static Integer parseCandidateStrategy(FlowElement userTask) { - return NumberUtils.parseInt(userTask.getAttributeValue( - BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY)); - } - - public static String parseCandidateParam(FlowElement userTask) { - return userTask.getAttributeValue( - BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_PARAM); - } - - /** - * 根据节点,获取入口连线 - * - * @param source 起始节点 - * @return 入口连线列表 - */ - public static List getElementIncomingFlows(FlowElement source) { - if (source instanceof FlowNode) { - return ((FlowNode) source).getIncomingFlows(); - } - return new ArrayList<>(); - } - - /** - * 根据节点,获取出口连线 - * - * @param source 起始节点 - * @return 出口连线列表 - */ - public static List getElementOutgoingFlows(FlowElement source) { - if (source instanceof FlowNode) { - return ((FlowNode) source).getOutgoingFlows(); - } - return new ArrayList<>(); - } - - /** - * 获取流程元素信息 - * - * @param model bpmnModel 对象 - * @param flowElementId 元素 ID - * @return 元素信息 - */ - public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) { - Process process = model.getMainProcess(); - return process.getFlowElement(flowElementId); - } - - /** - * 获得 BPMN 流程中,指定的元素们 - * - * @param model 模型 - * @param clazz 指定元素。例如说,{@link UserTask}、{@link Gateway} 等等 - * @return 元素们 - */ - public static List getBpmnModelElements(BpmnModel model, Class clazz) { - List result = new ArrayList<>(); - model.getProcesses().forEach(process -> { - process.getFlowElements().forEach(flowElement -> { - if (flowElement.getClass().isAssignableFrom(clazz)) { - result.add((T) flowElement); - } - }); - }); - return result; - } - - public static StartEvent getStartEvent(BpmnModel model) { - Process process = model.getMainProcess(); - // 从 initialFlowElement 找 - FlowElement startElement = process.getInitialFlowElement(); - if (startElement instanceof StartEvent) { - return (StartEvent) startElement; - } - // 从 flowElementList 找 - return (StartEvent) CollUtil.findOne(process.getFlowElements(), flowElement -> flowElement instanceof StartEvent); - } - - public static BpmnModel getBpmnModel(byte[] bpmnBytes) { - if (ArrayUtil.isEmpty(bpmnBytes)) { - return null; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - // 补充说明:由于在 Flowable 中自定义了属性,所以 validateSchema 传递 false - return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), false, false); - } - - public static String getBpmnXml(BpmnModel model) { - if (model == null) { - return null; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - return new String(converter.convertToXML(model)); - } - - // ========== 遍历相关的方法 ========== - - /** - * 找到 source 节点之前的所有用户任务节点 - * - * @param source 起始节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 已找到的用户任务节点 - * @return 用户任务节点 数组 - */ - public static List getPreviousUserTaskList(FlowElement source, Set hasSequenceFlow, List userTaskList) { - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 - if (source instanceof StartEvent && source.getSubProcess() != null) { - userTaskList = getPreviousUserTaskList(source.getSubProcess(), hasSequenceFlow, userTaskList); - } - - // 根据类型,获取入口连线 - List sequenceFlows = getElementIncomingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 类型为用户节点,则新增父级节点 - if (sequenceFlow.getSourceFlowElement() instanceof UserTask) { - userTaskList.add((UserTask) sequenceFlow.getSourceFlowElement()); - } - // 类型为子流程,则添加子流程开始节点出口处相连的节点 - if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { - // 获取子流程用户任务节点 - List childUserTaskList = findChildProcessUserTaskList((StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - } - } - // 继续迭代 - userTaskList = getPreviousUserTaskList(sequenceFlow.getSourceFlowElement(), hasSequenceFlow, userTaskList); - } - return userTaskList; - } - - /** - * 迭代获取子流程用户任务节点 - * - * @param source 起始节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 需要撤回的用户任务列表 - * @return 用户任务节点 - */ - public static List findChildProcessUserTaskList(FlowElement source, Set hasSequenceFlow, List userTaskList) { - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - - // 根据类型,获取出口连线 - List sequenceFlows = getElementOutgoingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 - if (sequenceFlow.getTargetFlowElement() instanceof UserTask) { - userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); - continue; - } - // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 - if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { - List childUserTaskList = findChildProcessUserTaskList((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - continue; - } - } - // 继续迭代 - userTaskList = findChildProcessUserTaskList(sequenceFlow.getTargetFlowElement(), hasSequenceFlow, userTaskList); - } - return userTaskList; - } - - - /** - * 迭代从后向前扫描,判断目标节点相对于当前节点是否是串行 - * 不存在直接回退到子流程中的情况,但存在从子流程出去到父流程情况 - * - * @param source 起始节点 - * @param target 目标节点 - * @param visitedElements 已经经过的连线的 ID,用于判断线路是否重复 - * @return 结果 - */ - public static boolean isSequentialReachable(FlowElement source, FlowElement target, Set visitedElements) { - visitedElements = visitedElements == null ? new HashSet<>() : visitedElements; - // 不能是开始事件和子流程 - if (source instanceof StartEvent && isInEventSubprocess(source)) { - return false; - } - - // 根据类型,获取入口连线 - List sequenceFlows = getElementIncomingFlows(source); - if (CollUtil.isEmpty(sequenceFlows)) { - return true; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (visitedElements.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - visitedElements.add(sequenceFlow.getId()); - // 这条线路存在目标节点,这条线路完成,进入下个线路 - FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); - if (target.getId().equals(sourceFlowElement.getId())) { - continue; - } - // 如果目标节点为并行网关,则不继续 - if (sourceFlowElement instanceof ParallelGateway) { - return false; - } - // 否则就继续迭代 - if (!isSequentialReachable(sourceFlowElement, target, visitedElements)) { - return false; - } - } - return true; - } - - /** - * 判断当前节点是否属于不同的子流程 - * - * @param flowElement 被判断的节点 - * @return true 表示属于子流程 - */ - private static boolean isInEventSubprocess(FlowElement flowElement) { - FlowElementsContainer flowElementsContainer = flowElement.getParentContainer(); - while (flowElementsContainer != null) { - if (flowElementsContainer instanceof EventSubProcess) { - return true; - } - - if (flowElementsContainer instanceof FlowElement) { - flowElementsContainer = ((FlowElement) flowElementsContainer).getParentContainer(); - } else { - flowElementsContainer = null; - } - } - return false; - } - - /** - * 根据正在运行的任务节点,迭代获取子级任务节点列表,向后找 - * - * @param source 起始节点 - * @param runTaskKeyList 正在运行的任务 Key,用于校验任务节点是否是正在运行的节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 需要撤回的用户任务列表 - * @return 子级任务节点列表 - */ - public static List iteratorFindChildUserTasks(FlowElement source, List runTaskKeyList, - Set hasSequenceFlow, List userTaskList) { - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 - if (source instanceof StartEvent && source.getSubProcess() != null) { - userTaskList = iteratorFindChildUserTasks(source.getSubProcess(), runTaskKeyList, hasSequenceFlow, userTaskList); - } - - // 根据类型,获取出口连线 - List sequenceFlows = getElementOutgoingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 - if (sequenceFlow.getTargetFlowElement() instanceof UserTask && runTaskKeyList.contains((sequenceFlow.getTargetFlowElement()).getId())) { - userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); - continue; - } - // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 - if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { - List childUserTaskList = iteratorFindChildUserTasks((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), runTaskKeyList, hasSequenceFlow, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - continue; - } - } - // 继续迭代 - userTaskList = iteratorFindChildUserTasks(sequenceFlow.getTargetFlowElement(), runTaskKeyList, hasSequenceFlow, userTaskList); - } - return userTaskList; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java deleted file mode 100644 index a8ee4e7f9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; - -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; -import org.flowable.common.engine.api.delegate.Expression; -import org.flowable.common.engine.api.variable.VariableContainer; -import org.flowable.common.engine.impl.el.ExpressionManager; -import org.flowable.common.engine.impl.identity.Authentication; -import org.flowable.engine.ProcessEngineConfiguration; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.TaskInfo; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Flowable 相关的工具方法 - * - * @author 芋道源码 - */ -public class FlowableUtils { - - // ========== User 相关的工具方法 ========== - - public static void setAuthenticatedUserId(Long userId) { - Authentication.setAuthenticatedUserId(String.valueOf(userId)); - } - - public static void clearAuthenticatedUserId() { - Authentication.setAuthenticatedUserId(null); - } - - public static String getTenantId() { - Long tenantId = TenantContextHolder.getTenantId(); - return tenantId != null ? String.valueOf(tenantId) : ProcessEngineConfiguration.NO_TENANT_ID; - } - - // ========== Execution 相关的工具方法 ========== - - /** - * 格式化多实例(并签、或签)的 collectionVariable 变量(多实例对应的多审批人列表) - * - * @param activityId 活动编号 - * @return collectionVariable 变量 - */ - public static String formatExecutionCollectionVariable(String activityId) { - return activityId + "_assignees"; - } - - /** - * 格式化多实例(并签、或签)的 collectionElementVariable 变量(当前实例对应的一个审批人) - * - * @param activityId 活动编号 - * @return collectionElementVariable 变量 - */ - public static String formatExecutionCollectionElementVariable(String activityId) { - return activityId + "_assignee"; - } - - // ========== ProcessInstance 相关的工具方法 ========== - - public static Integer getProcessInstanceStatus(ProcessInstance processInstance) { - return getProcessInstanceStatus(processInstance.getProcessVariables()); - } - - public static Integer getProcessInstanceStatus(HistoricProcessInstance processInstance) { - return getProcessInstanceStatus(processInstance.getProcessVariables()); - } - - /** - * 获得流程实例的状态 - * - * @param processVariables 流程实例的 variables - * @return 状态 - */ - private static Integer getProcessInstanceStatus(Map processVariables) { - return (Integer) processVariables.get(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS); - } - - /** - * 获得流程实例的表单 - * - * @param processInstance 流程实例 - * @return 表单 - */ - public static Map getProcessInstanceFormVariable(HistoricProcessInstance processInstance) { - Map formVariables = new HashMap<>(processInstance.getProcessVariables()); - filterProcessInstanceFormVariable(formVariables); - return formVariables; - } - - /** - * 过滤流程实例的表单 - * - * 为什么要过滤?目前使用 processVariables 存储所有流程实例的拓展字段,需要过滤掉一部分的系统字段,从而实现表单的展示 - * - * @param processVariables 流程实例的 variables - * @return 过滤后的表单 - */ - public static Map filterProcessInstanceFormVariable(Map processVariables) { - processVariables.remove(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS); - return processVariables; - } - - /** - * 获得流程实例的发起用户选择的审批人 Map - * - * @param processInstance 流程实例 - * @return 发起用户选择的审批人 Map - */ - @SuppressWarnings("unchecked") - public static Map> getStartUserSelectAssignees(ProcessInstance processInstance) { - return (Map>) processInstance.getProcessVariables().get( - BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES); - } - - // ========== Task 相关的工具方法 ========== - - /** - * 获得任务的状态 - * - * @param task 任务 - * @return 状态 - */ - public static Integer getTaskStatus(TaskInfo task) { - return (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - } - - /** - * 获得任务的审批原因 - * - * @param task 任务 - * @return 审批原因 - */ - public static String getTaskReason(TaskInfo task) { - return (String) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_REASON); - } - - /** - * 获得任务的表单 - * - * @param task 任务 - * @return 表单 - */ - public static Map getTaskFormVariable(TaskInfo task) { - Map formVariables = new HashMap<>(task.getTaskLocalVariables()); - filterTaskFormVariable(formVariables); - return formVariables; - } - - /** - * 过滤任务的表单 - * - * 为什么要过滤?目前使用 taskLocalVariables 存储所有任务的拓展字段,需要过滤掉一部分的系统字段,从而实现表单的展示 - * - * @param taskLocalVariables 任务的 taskLocalVariables - * @return 过滤后的表单 - */ - public static Map filterTaskFormVariable(Map taskLocalVariables) { - taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_STATUS); - taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_REASON); - return taskLocalVariables; - } - - // ========== Expression 相关的工具方法 ========== - - public static Object getExpressionValue(VariableContainer variableContainer, String expressionString) { - ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); - assert processEngineConfiguration != null; - ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager(); - assert expressionManager != null; - Expression expression = expressionManager.createExpression(expressionString); - return expression.getValue(variableContainer); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java deleted file mode 100644 index 52fdb7f93..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 bpm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 6459263cb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.rpc.config; - -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java deleted file mode 100644 index d34205cec..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.framework.rpc; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/config/SecurityConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 163886c65..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Bpm 模块的 Security 配置 - */ -@Configuration(proxyBeanMethods = false, value = "bpmSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("bpmAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案 - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - } - - }; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/core/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/core/package-info.java deleted file mode 100644 index 6d9f5a508..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.framework.security.core; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java deleted file mode 100644 index aa730198a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.web.config; - -import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; -import cn.iocoder.yudao.module.bpm.framework.web.core.FlowableWebFilter; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * bpm 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class BpmWebConfiguration { - - /** - * 配置 Flowable Web 过滤器 - */ - @Bean - public FilterRegistrationBean flowableWebFilter() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new FlowableWebFilter()); - registrationBean.setOrder(WebFilterOrderEnum.FLOWABLE_FILTER); - return registrationBean; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/core/FlowableWebFilter.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/core/FlowableWebFilter.java deleted file mode 100644 index 37c95a9f7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/core/FlowableWebFilter.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.web.core; - -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中 - * - * @author jason - */ -public class FlowableWebFilter extends OncePerRequestFilter { - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) - throws ServletException, IOException { - try { - // 设置工作流的用户 - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (userId != null) { - FlowableUtils.setAuthenticatedUserId(userId); - } - // 过滤 - chain.doFilter(request, response); - } finally { - // 清理 - FlowableUtils.clearAuthenticatedUserId(); - } - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java deleted file mode 100644 index c01417081..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm 模块的 web 配置 - */ -package cn.iocoder.yudao.module.bpm.framework.web; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java deleted file mode 100644 index 9d02824f6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 Flowable 6 版本实现。 - * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - * - * bpm 解释:https://baike.baidu.com/item/BPM/1933 - * - * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分 - * - * 注意,由于 Bpm 模块下,容易和其它模块重名,所以类名都加载 Bpm 的前缀~ - */ -package cn.iocoder.yudao.module.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryService.java deleted file mode 100644 index e267d3055..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryService.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * BPM 流程分类 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmCategoryService { - - /** - * 创建流程分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid BpmCategorySaveReqVO createReqVO); - - /** - * 更新流程分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid BpmCategorySaveReqVO updateReqVO); - - /** - * 删除流程分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得流程分类 - * - * @param id 编号 - * @return BPM 流程分类 - */ - BpmCategoryDO getCategory(Long id); - - /** - * 获得流程分类分页 - * - * @param pageReqVO 分页查询 - * @return 流程分类分页 - */ - PageResult getCategoryPage(BpmCategoryPageReqVO pageReqVO); - - /** - * 获得流程分类 Map,基于指定编码 - * - * @param codes 编号数组 - * @return 流程分类 Map - */ - default Map getCategoryMap(Collection codes) { - return convertMap(getCategoryListByCode(codes), BpmCategoryDO::getCode); - } - - /** - * 获得流程分类列表,基于指定编码 - * - * @return 流程分类列表 - */ - List getCategoryListByCode(Collection codes); - - /** - * 获得流程分类列表,基于指定状态 - * - * @param status 状态 - * @return 流程分类列表 - */ - List getCategoryListByStatus(Integer status); - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryServiceImpl.java deleted file mode 100644 index d76eb98e9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.category.BpmCategoryMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * BPM 流程分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmCategoryServiceImpl implements BpmCategoryService { - - @Resource - private BpmCategoryMapper bpmCategoryMapper; - - @Override - public Long createCategory(BpmCategorySaveReqVO createReqVO) { - // 校验唯一 - validateCategoryNameUnique(createReqVO); - validateCategoryCodeUnique(createReqVO); - // 插入 - BpmCategoryDO category = BeanUtils.toBean(createReqVO, BpmCategoryDO.class); - bpmCategoryMapper.insert(category); - return category.getId(); - } - - @Override - public void updateCategory(BpmCategorySaveReqVO updateReqVO) { - // 校验存在 - validateCategoryExists(updateReqVO.getId()); - validateCategoryNameUnique(updateReqVO); - validateCategoryCodeUnique(updateReqVO); - // 更新 - BpmCategoryDO updateObj = BeanUtils.toBean(updateReqVO, BpmCategoryDO.class); - bpmCategoryMapper.updateById(updateObj); - } - - private void validateCategoryNameUnique(BpmCategorySaveReqVO updateReqVO) { - BpmCategoryDO category = bpmCategoryMapper.selectByName(updateReqVO.getName()); - if (category == null - || ObjUtil.equal(category.getId(), updateReqVO.getId())) { - return; - } - throw exception(CATEGORY_NAME_DUPLICATE, updateReqVO.getName()); - } - - private void validateCategoryCodeUnique(BpmCategorySaveReqVO updateReqVO) { - BpmCategoryDO category = bpmCategoryMapper.selectByCode(updateReqVO.getCode()); - if (category == null - || ObjUtil.equal(category.getId(), updateReqVO.getId())) { - return; - } - throw exception(CATEGORY_CODE_DUPLICATE, updateReqVO.getCode()); - } - - @Override - public void deleteCategory(Long id) { - // 校验存在 - validateCategoryExists(id); - // 删除 - bpmCategoryMapper.deleteById(id); - } - - private void validateCategoryExists(Long id) { - if (bpmCategoryMapper.selectById(id) == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - @Override - public BpmCategoryDO getCategory(Long id) { - return bpmCategoryMapper.selectById(id); - } - - @Override - public PageResult getCategoryPage(BpmCategoryPageReqVO pageReqVO) { - return bpmCategoryMapper.selectPage(pageReqVO); - } - - @Override - public List getCategoryListByCode(Collection codes) { - if (CollUtil.isEmpty(codes)) { - return Collections.emptyList(); - } - return bpmCategoryMapper.selectListByCode(codes); - } - - @Override - public List getCategoryListByStatus(Integer status) { - return bpmCategoryMapper.selectListByStatus(status); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java deleted file mode 100644 index cf421e190..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - - -/** - * 动态表单 Service 接口 - * - * @author @风里雾里 - */ -public interface BpmFormService { - - /** - * 创建动态表单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createForm(@Valid BpmFormSaveReqVO createReqVO); - - /** - * 更新动态表单 - * - * @param updateReqVO 更新信息 - */ - void updateForm(@Valid BpmFormSaveReqVO updateReqVO); - - /** - * 删除动态表单 - * - * @param id 编号 - */ - void deleteForm(Long id); - - /** - * 获得动态表单 - * - * @param id 编号 - * @return 动态表单 - */ - BpmFormDO getForm(Long id); - - /** - * 获得动态表单列表 - * - * @return 动态表单列表 - */ - List getFormList(); - - /** - * 获得动态表单列表 - * - * @param ids 编号 - * @return 动态表单列表 - */ - List getFormList(Collection ids); - - /** - * 获得动态表单 Map - * - * @param ids 编号 - * @return 动态表单 Map - */ - default Map getFormMap(Collection ids) { - return CollectionUtils.convertMap(this.getFormList(ids), BpmFormDO::getId); - } - - /** - * 获得动态表单分页 - * - * @param pageReqVO 分页查询 - * @return 动态表单分页 - */ - PageResult getFormPage(BpmFormPageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java deleted file mode 100644 index 51d022dac..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; - -/** - * 动态表单 Service 实现类 - * - * @author 风里雾里 - */ -@Service -@Validated -public class BpmFormServiceImpl implements BpmFormService { - - @Resource - private BpmFormMapper formMapper; - - @Override - public Long createForm(BpmFormSaveReqVO createReqVO) { - this.validateFields(createReqVO.getFields()); - // 插入 - BpmFormDO form = BeanUtils.toBean(createReqVO, BpmFormDO.class); - formMapper.insert(form); - // 返回 - return form.getId(); - } - - @Override - public void updateForm(BpmFormSaveReqVO updateReqVO) { - validateFields(updateReqVO.getFields()); - // 校验存在 - validateFormExists(updateReqVO.getId()); - // 更新 - BpmFormDO updateObj = BeanUtils.toBean(updateReqVO, BpmFormDO.class); - formMapper.updateById(updateObj); - } - - @Override - public void deleteForm(Long id) { - // 校验存在 - this.validateFormExists(id); - // 删除 - formMapper.deleteById(id); - } - - private void validateFormExists(Long id) { - if (formMapper.selectById(id) == null) { - throw exception(ErrorCodeConstants.FORM_NOT_EXISTS); - } - } - - @Override - public BpmFormDO getForm(Long id) { - return formMapper.selectById(id); - } - - @Override - public List getFormList() { - return formMapper.selectList(); - } - - @Override - public List getFormList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return formMapper.selectBatchIds(ids); - } - - @Override - public PageResult getFormPage(BpmFormPageReqVO pageReqVO) { - return formMapper.selectPage(pageReqVO); - } - - /** - * 校验 Field,避免 field 重复 - * - * @param fields field 数组 - */ - private void validateFields(List fields) { - if (true) { // TODO 芋艿:兼容 Vue3 工作流:因为采用了新的表单设计器,所以暂时不校验 - return; - } - Map fieldMap = new HashMap<>(); // key 是 vModel,value 是 label - for (String field : fields) { - BpmFormFieldRespDTO fieldDTO = JsonUtils.parseObject(field, BpmFormFieldRespDTO.class); - Assert.notNull(fieldDTO); - String oldLabel = fieldMap.put(fieldDTO.getVModel(), fieldDTO.getLabel()); - // 如果不存在,则直接返回 - if (oldLabel == null) { - continue; - } - // 如果存在,则报错 - throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java deleted file mode 100644 index ef50bf7f8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.repository.Model; - -import javax.validation.Valid; - -/** - * Flowable流程模型接口 - * - * @author yunlongn - */ -public interface BpmModelService { - - /** - * 获得流程模型分页 - * - * @param pageVO 分页查询 - * @return 流程模型分页 - */ - PageResult getModelPage(BpmModelPageReqVO pageVO); - - /** - * 创建流程模型 - * - * @param modelVO 创建信息 - * @param bpmnXml BPMN XML - * @return 创建的流程模型的编号 - */ - String createModel(@Valid BpmModelCreateReqVO modelVO, String bpmnXml); - - /** - * 获得流程模块 - * - * @param id 编号 - * @return 流程模型 - */ - Model getModel(String id); - - /** - * 获得流程模型的 BPMN XML - * - * @param id 编号 - * @return BPMN XML - */ - byte[] getModelBpmnXML(String id); - - /** - * 修改流程模型 - * - * @param updateReqVO 更新信息 - */ - void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); - - /** - * 将流程模型,部署成一个流程定义 - * - * @param id 编号 - */ - void deployModel(String id); - - /** - * 删除模型 - * - * @param id 编号 - */ - void deleteModel(String id); - - /** - * 修改模型的状态,实际更新的部署的流程定义的状态 - * - * @param id 编号 - * @param state 状态 - */ - void updateModelState(String id, Integer state); - - /** - * 获得流程定义编号对应的 BPMN Model - * - * @param processDefinitionId 流程定义编号 - * @return BPMN Model - */ - BpmnModel getBpmnModelByDefinitionId(String processDefinitionId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java deleted file mode 100644 index 0f20f66c8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java +++ /dev/null @@ -1,278 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.StartEvent; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ModelQuery; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * Flowable流程模型实现 - * 主要进行 Flowable {@link Model} 的维护 - * - * @author yunlongn - * @author 芋道源码 - * @author jason - */ -@Service -@Validated -@Slf4j -public class BpmModelServiceImpl implements BpmModelService { - - @Resource - private RepositoryService repositoryService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmFormService bpmFormService; - - @Resource - private BpmTaskCandidateInvoker taskCandidateInvoker; - - @Override - public PageResult getModelPage(BpmModelPageReqVO pageVO) { - ModelQuery modelQuery = repositoryService.createModelQuery(); - if (StrUtil.isNotBlank(pageVO.getKey())) { - modelQuery.modelKey(pageVO.getKey()); - } - if (StrUtil.isNotBlank(pageVO.getName())) { - modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配 - } - if (StrUtil.isNotBlank(pageVO.getCategory())) { - modelQuery.modelCategory(pageVO.getCategory()); - } - // 执行查询 - long count = modelQuery.count(); - if (count == 0) { - return PageResult.empty(count); - } - List models = modelQuery - .modelTenantId(FlowableUtils.getTenantId()) - .orderByCreateTime().desc() - .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(models, count); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) { - if (!ValidationUtils.isXmlNCName(createReqVO.getKey())) { - throw exception(MODEL_KEY_VALID); - } - // 校验流程标识已经存在 - Model keyModel = getModelByKey(createReqVO.getKey()); - if (keyModel != null) { - throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); - } - - // 创建流程定义 - Model model = repositoryService.newModel(); - BpmModelConvert.INSTANCE.copyToCreateModel(model, createReqVO); - model.setTenantId(FlowableUtils.getTenantId()); - // 保存流程定义 - repositoryService.saveModel(model); - // 保存 BPMN XML - saveModelBpmnXml(model, bpmnXml); - return model.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 - public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) { - // 校验流程模型存在 - Model model = getModel(updateReqVO.getId()); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - - // 修改流程定义 - BpmModelConvert.INSTANCE.copyToUpdateModel(model, updateReqVO); - // 更新模型 - repositoryService.saveModel(model); - // 更新 BPMN XML - saveModelBpmnXml(model, updateReqVO.getBpmnXml()); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 - public void deployModel(String id) { - // 1.1 校验流程模型存在 - Model model = getModel(id); - if (ObjectUtils.isEmpty(model)) { - throw exception(MODEL_NOT_EXISTS); - } - // 1.2 校验流程图 - byte[] bpmnBytes = getModelBpmnXML(model.getId()); - validateBpmnXml(bpmnBytes); - // 1.3 校验表单已配 - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - BpmFormDO form = validateFormConfig(metaInfo); - // 1.4 校验任务分配规则已配置 - taskCandidateInvoker.validateBpmnConfig(bpmnBytes); - - // 2.1 创建流程定义 - String definitionId = processDefinitionService.createProcessDefinition(model, metaInfo, bpmnBytes, form); - - // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 - updateProcessDefinitionSuspended(model.getDeploymentId()); - - // 2.3 更新 model 的 deploymentId,进行关联 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); - model.setDeploymentId(definition.getDeploymentId()); - repositoryService.saveModel(model); - } - - private void validateBpmnXml(byte[] bpmnBytes) { - BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); - if (bpmnModel == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 1. 没有 StartEvent - StartEvent startEvent = BpmnModelUtils.getStartEvent(bpmnModel); - if (startEvent == null) { - throw exception(MODEL_DEPLOY_FAIL_BPMN_START_EVENT_NOT_EXISTS); - } - // 2. 校验 UserTask 的 name 都配置了 - List userTasks = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class); - userTasks.forEach(userTask -> { - if (StrUtil.isEmpty(userTask.getName())) { - throw exception(MODEL_DEPLOY_FAIL_BPMN_USER_TASK_NAME_NOT_EXISTS, userTask.getId()); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteModel(String id) { - // 校验流程模型存在 - Model model = getModel(id); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 执行删除 - repositoryService.deleteModel(id); - // 禁用流程定义 - updateProcessDefinitionSuspended(model.getDeploymentId()); - } - - @Override - public void updateModelState(String id, Integer state) { - // 1.1 校验流程模型存在 - Model model = getModel(id); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 1.2 校验流程定义存在 - ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (definition == null) { - throw exception(PROCESS_DEFINITION_NOT_EXISTS); - } - - // 2. 更新状态 - processDefinitionService.updateProcessDefinitionState(definition.getId(), state); - } - - @Override - public BpmnModel getBpmnModelByDefinitionId(String processDefinitionId) { - return repositoryService.getBpmnModel(processDefinitionId); - } - - /** - * 校验流程表单已配置 - * - * @param metaInfo 流程模型元数据 - * @return 表单配置 - */ - private BpmFormDO validateFormConfig(BpmModelMetaInfoRespDTO metaInfo) { - if (metaInfo == null || metaInfo.getFormType() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - // 校验表单存在 - if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) { - if (metaInfo.getFormId() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - BpmFormDO form = bpmFormService.getForm(metaInfo.getFormId()); - if (form == null) { - throw exception(FORM_NOT_EXISTS); - } - return form; - } else { - if (StrUtil.isEmpty(metaInfo.getFormCustomCreatePath()) || StrUtil.isEmpty(metaInfo.getFormCustomViewPath())) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - return null; - } - } - - private void saveModelBpmnXml(Model model, String bpmnXml) { - if (StrUtil.isEmpty(bpmnXml)) { - return; - } - repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml)); - } - - /** - * 挂起 deploymentId 对应的流程定义 - * - * 注意:这里一个 deploymentId 只关联一个流程定义 - * - * @param deploymentId 流程发布Id - */ - private void updateProcessDefinitionSuspended(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return; - } - ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId); - if (oldDefinition == null) { - return; - } - processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode()); - } - - private Model getModelByKey(String key) { - return repositoryService.createModelQuery().modelKey(key).singleResult(); - } - - @Override - public Model getModel(String id) { - return repositoryService.getModel(id); - } - - @Override - public byte[] getModelBpmnXML(String id) { - return repositoryService.getModelEditorSource(id); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java deleted file mode 100644 index 5e2e2f805..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * Flowable流程定义接口 - * - * @author yunlong.li - * @author ZJQ - * @author 芋道源码 - */ -public interface BpmProcessDefinitionService { - - /** - * 获得流程定义分页 - * - * @param pageReqVO 分页入参 - * @return 流程定义 Page - */ - PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO); - - /** - * 获得流程定义列表 - * - * @param suspensionState 中断状态 - * @return 流程定义列表 - */ - List getProcessDefinitionListBySuspensionState(Integer suspensionState); - - /** - * 基于流程模型,创建流程定义 - * - * @param model 流程模型 - * @param modelMetaInfo 流程模型元信息 - * @param bpmnBytes BPMN XML 字节数组 - * @param form 表单 - * @return 流程编号 - */ - String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, byte[] bpmnBytes, BpmFormDO form); - - /** - * 更新流程定义状态 - * - * @param id 流程定义的编号 - * @param state 状态 - */ - void updateProcessDefinitionState(String id, Integer state); - - /** - * 获得流程定义对应的 BPMN - * - * @param id 流程定义编号 - * @return BPMN - */ - BpmnModel getProcessDefinitionBpmnModel(String id); - - /** - * 获得流程定义的信息 - * - * @param id 流程定义编号 - * @return 流程定义信息 - */ - BpmProcessDefinitionInfoDO getProcessDefinitionInfo(String id); - - /** - * 获得流程定义的信息 List - * - * @param ids 流程定义编号数组 - * @return 流程额定义信息数组 - */ - List getProcessDefinitionInfoList(Collection ids); - - default Map getProcessDefinitionInfoMap(Set ids) { - return convertMap(getProcessDefinitionInfoList(ids), BpmProcessDefinitionInfoDO::getProcessDefinitionId); - } - - /** - * 获得流程定义编号对应的 ProcessDefinition - * - * @param id 流程定义编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinition(String id); - - /** - * 获得 ids 对应的 ProcessDefinition 数组 - * - * @param ids 编号的数组 - * @return 流程定义的数组 - */ - List getProcessDefinitionList(Set ids); - - default Map getProcessDefinitionMap(Set ids) { - return convertMap(getProcessDefinitionList(ids), ProcessDefinition::getId); - } - - /** - * 获得 deploymentId 对应的 ProcessDefinition - * - * @param deploymentId 部署编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId); - - /** - * 获得 deploymentIds 对应的 ProcessDefinition 数组 - * - * @param deploymentIds 部署编号的数组 - * @return 流程定义的数组 - */ - List getProcessDefinitionListByDeploymentIds(Set deploymentIds); - - /** - * 获得流程定义标识对应的激活的流程定义 - * - * @param key 流程定义的标识 - * @return 流程定义 - */ - ProcessDefinition getActiveProcessDefinition(String key); - - /** - * 获得 ids 对应的 Deployment Map - * - * @param ids 部署编号的数组 - * @return 流程部署 Map - */ - default Map getDeploymentMap(Set ids) { - return convertMap(getDeploymentList(ids), Deployment::getId); - } - - /** - * 获得 ids 对应的 Deployment 数组 - * - * @param ids 部署编号的数组 - * @return 流程部署的数组 - */ - List getDeploymentList(Set ids); - - /** - * 获得 id 对应的 Deployment - * - * @param id 部署编号 - * @return 流程部署 - */ - Deployment getDeployment(String id); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java deleted file mode 100644 index fcfc805ce..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.repository.ProcessDefinitionQuery; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.addIfNotNull; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; -import static java.util.Collections.emptyList; - -/** - * 流程定义实现 - * 主要进行 Flowable {@link ProcessDefinition} 和 {@link Deployment} 的维护 - * - * @author yunlongn - * @author ZJQ - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { - - @Resource - private RepositoryService repositoryService; - - @Resource - private BpmProcessDefinitionInfoMapper processDefinitionMapper; - - @Override - public ProcessDefinition getProcessDefinition(String id) { - return repositoryService.getProcessDefinition(id); - } - - @Override - public List getProcessDefinitionList(Set ids) { - return repositoryService.createProcessDefinitionQuery().processDefinitionIds(ids).list(); - } - - @Override - public ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return null; - } - return repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult(); - } - - @Override - public List getProcessDefinitionListByDeploymentIds(Set deploymentIds) { - if (CollUtil.isEmpty(deploymentIds)) { - return emptyList(); - } - return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); - } - - @Override - public ProcessDefinition getActiveProcessDefinition(String key) { - return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult(); - } - - @Override - public List getDeploymentList(Set ids) { - if (CollUtil.isEmpty(ids)) { - return emptyList(); - } - List list = new ArrayList<>(ids.size()); - for (String id : ids) { - addIfNotNull(list, getDeployment(id)); - } - return list; - } - - @Override - public Deployment getDeployment(String id) { - if (StrUtil.isEmpty(id)) { - return null; - } - return repositoryService.createDeploymentQuery().deploymentId(id).singleResult(); - } - - @Override - public String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, - byte[] bpmnBytes, BpmFormDO form) { - // 创建 Deployment 部署 - Deployment deploy = repositoryService.createDeployment() - .key(model.getKey()).name(model.getName()).category(model.getCategory()) - .addBytes(model.getKey() + BpmnModelConstants.BPMN_FILE_SUFFIX, bpmnBytes) - .tenantId(FlowableUtils.getTenantId()) - .disableSchemaValidation() // 禁用 XML Schema 验证,因为有自定义的属性 - .deploy(); - - // 设置 ProcessDefinition 的 category 分类 - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() - .deploymentId(deploy.getId()).singleResult(); - repositoryService.setProcessDefinitionCategory(definition.getId(), model.getCategory()); - // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 的 id 和 name 决定 - // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。 - // 否则,会导致 ProcessDefinition 的分页无法查询到。 - if (!Objects.equals(definition.getKey(), model.getKey())) { - throw exception(PROCESS_DEFINITION_KEY_NOT_MATCH, model.getKey(), definition.getKey()); - } - if (!Objects.equals(definition.getName(), model.getName())) { - throw exception(PROCESS_DEFINITION_NAME_NOT_MATCH, model.getName(), definition.getName()); - } - - // 插入拓展表 - BpmProcessDefinitionInfoDO definitionDO = BeanUtils.toBean(modelMetaInfo, BpmProcessDefinitionInfoDO.class) - .setModelId(model.getId()).setProcessDefinitionId(definition.getId()); - if (form != null) { - definitionDO.setFormFields(form.getFields()).setFormConf(form.getConf()); - } - processDefinitionMapper.insert(definitionDO); - return definition.getId(); - } - - @Override - public void updateProcessDefinitionState(String id, Integer state) { - // 激活 - if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) { - repositoryService.activateProcessDefinitionById(id, false, null); - return; - } - // 挂起 - if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), state)) { - // suspendProcessInstances = false,进行中的任务,不进行挂起。 - // 原因:只要新的流程不允许发起即可,老流程继续可以执行。 - repositoryService.suspendProcessDefinitionById(id, false, null); - return; - } - log.error("[updateProcessDefinitionState][流程定义({}) 修改未知状态({})]", id, state); - } - - @Override - public BpmnModel getProcessDefinitionBpmnModel(String id) { - return repositoryService.getBpmnModel(id); - } - - @Override - public BpmProcessDefinitionInfoDO getProcessDefinitionInfo(String id) { - return processDefinitionMapper.selectByProcessDefinitionId(id); - } - - @Override - public List getProcessDefinitionInfoList(Collection ids) { - return processDefinitionMapper.selectListByProcessDefinitionIds(ids); - } - - @Override - public PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) { - ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); - if (StrUtil.isNotBlank(pageVO.getKey())) { - query.processDefinitionKey(pageVO.getKey()); - } - // 执行查询 - long count = query.count(); - if (count == 0) { - return PageResult.empty(count); - } - List list = query.orderByProcessDefinitionVersion().desc() - .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(list, count); - } - - @Override - public List getProcessDefinitionListBySuspensionState(Integer suspensionState) { - // 拼接查询条件 - ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); - if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), suspensionState)) { - query.suspended(); - } else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), suspensionState)) { - query.active(); - } - // 执行查询 - query.processDefinitionTenantId(FlowableUtils.getTenantId()); - return query.list(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionService.java deleted file mode 100644 index 0d8a99e07..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionService.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; - -import javax.validation.Valid; - -/** - * BPM 流程表达式 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessExpressionService { - - /** - * 创建流程表达式 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProcessExpression(@Valid BpmProcessExpressionSaveReqVO createReqVO); - - /** - * 更新流程表达式 - * - * @param updateReqVO 更新信息 - */ - void updateProcessExpression(@Valid BpmProcessExpressionSaveReqVO updateReqVO); - - /** - * 删除流程表达式 - * - * @param id 编号 - */ - void deleteProcessExpression(Long id); - - /** - * 获得流程表达式 - * - * @param id 编号 - * @return 流程表达式 - */ - BpmProcessExpressionDO getProcessExpression(Long id); - - /** - * 获得流程表达式分页 - * - * @param pageReqVO 分页查询 - * @return 流程表达式分页 - */ - PageResult getProcessExpressionPage(BpmProcessExpressionPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionServiceImpl.java deleted file mode 100644 index f379bfdf7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessExpressionMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_EXPRESSION_NOT_EXISTS; - -/** - * BPM 流程表达式 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmProcessExpressionServiceImpl implements BpmProcessExpressionService { - - @Resource - private BpmProcessExpressionMapper processExpressionMapper; - - @Override - public Long createProcessExpression(BpmProcessExpressionSaveReqVO createReqVO) { - // 插入 - BpmProcessExpressionDO processExpression = BeanUtils.toBean(createReqVO, BpmProcessExpressionDO.class); - processExpressionMapper.insert(processExpression); - // 返回 - return processExpression.getId(); - } - - @Override - public void updateProcessExpression(BpmProcessExpressionSaveReqVO updateReqVO) { - // 校验存在 - validateProcessExpressionExists(updateReqVO.getId()); - // 更新 - BpmProcessExpressionDO updateObj = BeanUtils.toBean(updateReqVO, BpmProcessExpressionDO.class); - processExpressionMapper.updateById(updateObj); - } - - @Override - public void deleteProcessExpression(Long id) { - // 校验存在 - validateProcessExpressionExists(id); - // 删除 - processExpressionMapper.deleteById(id); - } - - private void validateProcessExpressionExists(Long id) { - if (processExpressionMapper.selectById(id) == null) { - throw exception(PROCESS_EXPRESSION_NOT_EXISTS); - } - } - - @Override - public BpmProcessExpressionDO getProcessExpression(Long id) { - return processExpressionMapper.selectById(id); - } - - @Override - public PageResult getProcessExpressionPage(BpmProcessExpressionPageReqVO pageReqVO) { - return processExpressionMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerService.java deleted file mode 100644 index f9f1020e0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerService.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; - -import javax.validation.Valid; - -/** - * BPM 流程监听器 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessListenerService { - - /** - * 创建流程监听器 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProcessListener(@Valid BpmProcessListenerSaveReqVO createReqVO); - - /** - * 更新流程监听器 - * - * @param updateReqVO 更新信息 - */ - void updateProcessListener(@Valid BpmProcessListenerSaveReqVO updateReqVO); - - /** - * 删除流程监听器 - * - * @param id 编号 - */ - void deleteProcessListener(Long id); - - /** - * 获得流程监听器 - * - * @param id 编号 - * @return 流程监听器 - */ - BpmProcessListenerDO getProcessListener(Long id); - - /** - * 获得流程监听器分页 - * - * @param pageReqVO 分页查询 - * @return 流程监听器分页 - */ - PageResult getProcessListenerPage(BpmProcessListenerPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerServiceImpl.java deleted file mode 100644 index e5f47b90b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerServiceImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessListenerMapper; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerType; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerValueType; -import org.flowable.engine.delegate.JavaDelegate; -import org.flowable.engine.delegate.TaskListener; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * BPM 流程监听器 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmProcessListenerServiceImpl implements BpmProcessListenerService { - - @Resource - private BpmProcessListenerMapper processListenerMapper; - - @Override - public Long createProcessListener(BpmProcessListenerSaveReqVO createReqVO) { - // 校验 - validateCreateProcessListenerValue(createReqVO); - // 插入 - BpmProcessListenerDO processListener = BeanUtils.toBean(createReqVO, BpmProcessListenerDO.class); - processListenerMapper.insert(processListener); - return processListener.getId(); - } - - @Override - public void updateProcessListener(BpmProcessListenerSaveReqVO updateReqVO) { - // 校验存在 - validateProcessListenerExists(updateReqVO.getId()); - validateCreateProcessListenerValue(updateReqVO); - // 更新 - BpmProcessListenerDO updateObj = BeanUtils.toBean(updateReqVO, BpmProcessListenerDO.class); - processListenerMapper.updateById(updateObj); - } - - private void validateCreateProcessListenerValue(BpmProcessListenerSaveReqVO createReqVO) { - // class 类型 - if (createReqVO.getValueType().equals(BpmProcessListenerValueType.CLASS.getType())) { - try { - Class clazz = Class.forName(createReqVO.getValue()); - if (createReqVO.getType().equals(BpmProcessListenerType.EXECUTION.getType()) - && !JavaDelegate.class.isAssignableFrom(clazz)) { - throw exception(PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR, createReqVO.getValue(), - JavaDelegate.class.getName()); - } else if (createReqVO.getType().equals(BpmProcessListenerType.TASK.getType()) - && !TaskListener.class.isAssignableFrom(clazz)) { - throw exception(PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR, createReqVO.getValue(), - TaskListener.class.getName()); - } - } catch (ClassNotFoundException e) { - throw exception(PROCESS_LISTENER_CLASS_NOT_FOUND, createReqVO.getValue()); - } - return; - } - // 表达式 - if (!StrUtil.startWith(createReqVO.getValue(), "${") || !StrUtil.endWith(createReqVO.getValue(), "}")) { - throw exception(PROCESS_LISTENER_EXPRESSION_INVALID, createReqVO.getValue()); - } - } - - @Override - public void deleteProcessListener(Long id) { - // 校验存在 - validateProcessListenerExists(id); - // 删除 - processListenerMapper.deleteById(id); - } - - private void validateProcessListenerExists(Long id) { - if (processListenerMapper.selectById(id) == null) { - throw exception(PROCESS_LISTENER_NOT_EXISTS); - } - } - - @Override - public BpmProcessListenerDO getProcessListener(Long id) { - return processListenerMapper.selectById(id); - } - - @Override - public PageResult getProcessListenerPage(BpmProcessListenerPageReqVO pageReqVO) { - return processListenerMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java deleted file mode 100644 index 967f6e104..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 用户组 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmUserGroupService { - - /** - * 创建用户组 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createUserGroup(@Valid BpmUserGroupSaveReqVO createReqVO); - - /** - * 更新用户组 - * - * @param updateReqVO 更新信息 - */ - void updateUserGroup(@Valid BpmUserGroupSaveReqVO updateReqVO); - - /** - * 删除用户组 - * - * @param id 编号 - */ - void deleteUserGroup(Long id); - - /** - * 获得用户组 - * - * @param id 编号 - * @return 用户组 - */ - BpmUserGroupDO getUserGroup(Long id); - - /** - * 获得用户组列表 - * - * @param ids 编号 - * @return 用户组列表 - */ - List getUserGroupList(Collection ids); - - /** - * 获得指定状态的用户组列表 - * - * @param status 状态 - * @return 用户组列表 - */ - List getUserGroupListByStatus(Integer status); - - /** - * 获得用户组分页 - * - * @param pageReqVO 分页查询 - * @return 用户组分页 - */ - PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO); - - /** - * 校验用户组们是否有效。如下情况,视为无效: - * 1. 用户组编号不存在 - * 2. 用户组被禁用 - * - * @param ids 用户组编号数组 - */ - void validUserGroups(Collection ids); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java deleted file mode 100644 index 3d60dea7c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_IS_DISABLE; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; - -/** - * 用户组 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmUserGroupServiceImpl implements BpmUserGroupService { - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Override - public Long createUserGroup(BpmUserGroupSaveReqVO createReqVO) { - BpmUserGroupDO userGroup = BeanUtils.toBean(createReqVO, BpmUserGroupDO.class); - userGroupMapper.insert(userGroup); - return userGroup.getId(); - } - - @Override - public void updateUserGroup(BpmUserGroupSaveReqVO updateReqVO) { - // 校验存在 - validateUserGroupExists(updateReqVO.getId()); - // 更新 - BpmUserGroupDO updateObj = BeanUtils.toBean(updateReqVO, BpmUserGroupDO.class); - userGroupMapper.updateById(updateObj); - } - - @Override - public void deleteUserGroup(Long id) { - // 校验存在 - this.validateUserGroupExists(id); - // 删除 - userGroupMapper.deleteById(id); - } - - private void validateUserGroupExists(Long id) { - if (userGroupMapper.selectById(id) == null) { - throw exception(USER_GROUP_NOT_EXISTS); - } - } - - @Override - public BpmUserGroupDO getUserGroup(Long id) { - return userGroupMapper.selectById(id); - } - - @Override - public List getUserGroupList(Collection ids) { - return userGroupMapper.selectBatchIds(ids); - } - - - @Override - public List getUserGroupListByStatus(Integer status) { - return userGroupMapper.selectListByStatus(status); - } - - @Override - public PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO) { - return userGroupMapper.selectPage(pageReqVO); - } - - @Override - public void validUserGroups(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得用户组信息 - List userGroups = userGroupMapper.selectBatchIds(ids); - Map userGroupMap = convertMap(userGroups, BpmUserGroupDO::getId); - // 校验 - ids.forEach(id -> { - BpmUserGroupDO userGroup = userGroupMap.get(id); - if (userGroup == null) { - throw exception(USER_GROUP_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { - throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); - } - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java deleted file mode 100644 index 1606192ce..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * Bpm 表单的 Field 表单项 Response DTO - * 字段的定义,可见 https://github.com/JakHuang/form-generator/issues/46 文档 - * - * @author 芋道源码 - */ -@Data -public class BpmFormFieldRespDTO { - - /** - * 表单标题 - */ - private String label; - /** - * 表单字段的属性名,可自定义 - */ - @JsonProperty(value = "vModel") - private String vModel; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java deleted file mode 100644 index 8ec9dc64b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -/** - * BPM 流程 MetaInfo Response DTO - * 主要用于 { Model#setMetaInfo(String)} 的存储 - * - * 最终,它的字段和 {@link cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO} 是一致的 - * - * @author 芋道源码 - */ -@Data -public class BpmModelMetaInfoRespDTO { - - /** - * 流程图标 - */ - private String icon; - /** - * 流程描述 - */ - private String description; - - /** - * 表单类型 - */ - private Integer formType; - /** - * 表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java deleted file mode 100644 index e7b84c998..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 流程定义创建 Request DTO - */ -@Data -public class BpmProcessDefinitionCreateReqDTO { - - // ========== 模型相关 ========== - - /** - * 流程模型的编号 - */ - @NotEmpty(message = "流程模型编号不能为空") - private String modelId; - /** - * 流程标识 - */ - @NotEmpty(message = "流程标识不能为空") - private String key; - /** - * 流程名称 - */ - @NotEmpty(message = "流程名称不能为空") - private String name; - /** - * 流程描述 - */ - private String description; - /** - * 流程分类 - */ - @NotEmpty(message = "流程分类不能为空") - private String category; - /** - * BPMN XML - */ - @NotEmpty(message = "BPMN XML 不能为空") - private byte[] bpmnBytes; - - // ========== 表单相关 ========== - - /** - * 表单类型 - */ - @NotNull(message = "表单类型不能为空") - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java deleted file mode 100644 index ff51ae306..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; - -import javax.validation.Valid; - -/** - * BPM 消息 Service 接口 - * - * TODO 芋艿:未来支持消息的可配置;不同的流程,在什么场景下,需要发送什么消息,消息的内容是什么; - * - * @author 芋道源码 - */ -public interface BpmMessageService { - - /** - * 发送流程实例被通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceApprove(@Valid BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO); - - /** - * 发送流程实例被不通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceReject(@Valid BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO); - - /** - * 发送任务被分配的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenTaskAssigned(@Valid BpmMessageSendWhenTaskCreatedReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java deleted file mode 100644 index 032370158..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.framework.web.config.WebProperties; -import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert; -import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * BPM 消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmMessageServiceImpl implements BpmMessageService { - - @Resource - private SmsSendApi smsSendApi; - - @Resource - private WebProperties webProperties; - - @Override - public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("reason", reqDTO.getReason()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("taskName", reqDTO.getTaskName()); - templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), - BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); - } - - private String getProcessInstanceDetailUrl(String taskId) { - return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java deleted file mode 100644 index 7c37734f9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceApproveReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java deleted file mode 100644 index 69a266b68..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被不通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceRejectReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - - /** - * 不通过理由 - */ - @NotEmpty(message = "不通过理由不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java deleted file mode 100644 index 7cb0e3d70..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送任务被分配 Request DTO - */ -@Data -public class BpmMessageSendWhenTaskCreatedReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - @NotEmpty(message = "发起人的昵称") - private String startUserNickname; - - /** - * 流程任务的编号 - */ - @NotEmpty(message = "流程任务的编号不能为空") - private String taskId; - /** - * 流程任务的名字 - */ - @NotEmpty(message = "流程任务的名字不能为空") - private String taskName; - - /** - * 审批人的用户编号 - */ - @NotNull(message = "审批人的用户编号不能为空") - private Long assigneeUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java deleted file mode 100644 index b255e0888..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; - -import javax.validation.Valid; - -/** - * 请假申请 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmOALeaveService { - - /** - * 创建请假申请 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO); - - /** - * 更新请假申请的状态 - * - * @param id 编号 - * @param status 结果 - */ - void updateLeaveStatus(Long id, Integer status); - - /** - * 获得请假申请 - * - * @param id 编号 - * @return 请假申请 - */ - BpmOALeaveDO getLeave(Long id); - - /** - * 获得请假申请分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页查询 - * @return 请假申请分页 - */ - PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java deleted file mode 100644 index a8601e546..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALeaveMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_LEAVE_NOT_EXISTS; - -/** - * OA 请假申请 Service 实现类 - * - * @author jason - * @author 芋道源码 - */ -@Service -@Validated -public class BpmOALeaveServiceImpl implements BpmOALeaveService { - - /** - * OA 请假对应的流程定义 KEY - */ - public static final String PROCESS_KEY = "oa_leave"; - - @Resource - private BpmOALeaveMapper leaveMapper; - - @Resource - private BpmProcessInstanceApi processInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) { - // 插入 OA 请假单 - long day = LocalDateTimeUtil.between(createReqVO.getStartTime(), createReqVO.getEndTime()).toDays(); - BpmOALeaveDO leave = BeanUtils.toBean(createReqVO, BpmOALeaveDO.class) - .setUserId(userId).setDay(day).setStatus(BpmTaskStatusEnum.RUNNING.getStatus()); - leaveMapper.insert(leave); - - // 发起 BPM 流程 - Map processInstanceVariables = new HashMap<>(); - processInstanceVariables.put("day", day); - String processInstanceId = processInstanceApi.createProcessInstance(userId, - new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) - .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId())) - .setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees())).getCheckedData(); - - // 将工作流的编号,更新到 OA 请假单中 - leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId)); - return leave.getId(); - } - - @Override - public void updateLeaveStatus(Long id, Integer status) { - validateLeaveExists(id); - leaveMapper.updateById(new BpmOALeaveDO().setId(id).setStatus(status)); - } - - private void validateLeaveExists(Long id) { - if (leaveMapper.selectById(id) == null) { - throw exception(OA_LEAVE_NOT_EXISTS); - } - } - - @Override - public BpmOALeaveDO getLeave(Long id) { - return leaveMapper.selectById(id); - } - - @Override - public PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) { - return leaveMapper.selectPage(userId, pageReqVO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveStatusListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveStatusListener.java deleted file mode 100644 index 912479aaf..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveStatusListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa.listener; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * OA 请假单的结果的监听器实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmOALeaveStatusListener extends BpmProcessInstanceStatusEventListener { - - @Resource - private BpmOALeaveService leaveService; - - @Override - protected String getProcessDefinitionKey() { - return BpmOALeaveServiceImpl.PROCESS_KEY; - } - - @Override - protected void onEvent(BpmProcessInstanceStatusEvent event) { - leaveService.updateLeaveStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java deleted file mode 100644 index 4bed16413..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.flowable.engine.history.HistoricActivityInstance; - -import java.util.List; - -/** - * BPM 活动实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmActivityService { - - /** - * 获得指定流程实例的活动实例列表 - * - * @param processInstanceId 流程实例的编号 - * @return 活动实例列表 - */ - List getActivityListByProcessInstanceId(String processInstanceId); - - /** - * 获得执行编号对应的活动实例 - * - * @param executionId 执行编号 - * @return 活动实例 - */ - List getHistoricActivityListByExecutionId(String executionId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java deleted file mode 100644 index c06445efa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.convert.task.BpmActivityConvert; -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.HistoryService; -import org.flowable.engine.history.HistoricActivityInstance; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - - -/** - * BPM 活动实例 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Slf4j -@Validated -public class BpmActivityServiceImpl implements BpmActivityService { - - @Resource - private HistoryService historyService; - - @Override - public List getActivityListByProcessInstanceId(String processInstanceId) { - List activityList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId).list(); - return BpmActivityConvert.INSTANCE.convertList(activityList); - } - - @Override - public List getHistoricActivityListByExecutionId(String executionId) { - return historyService.createHistoricActivityInstanceQuery().executionId(executionId).list(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java deleted file mode 100644 index bd84490e8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; - -import java.util.Collection; - -/** - * 流程抄送 Service 接口 - * - * 现在是在审批的时候进行流程抄送 - */ -public interface BpmProcessInstanceCopyService { - - /** - * 流程实例的抄送 - * - * @param userIds 抄送的用户编号 - * @param taskId 流程任务编号 - */ - void createProcessInstanceCopy(Collection userIds, String taskId); - - /** - * 获得抄送的流程的分页 - * - * @param userId 当前登录用户 - * @param pageReqVO 分页请求 - * @return 抄送的分页结果 - */ - PageResult getProcessInstanceCopyPage(Long userId, - BpmProcessInstanceCopyPageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java deleted file mode 100644 index 5d7347001..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceCopyMapper; -import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * 流程抄送 Service 实现类 - * - * @author kyle - */ -@Service -@Validated -@Slf4j -public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService { - - @Resource - private BpmProcessInstanceCopyMapper processInstanceCopyMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmTaskService taskService; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmProcessInstanceService processInstanceService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmProcessDefinitionService processDefinitionService; - - @Override - public void createProcessInstanceCopy(Collection userIds, String taskId) { - // 1.1 校验任务存在 - Task task = taskService.getTask(taskId); - if (ObjectUtil.isNull(task)) { - throw exception(ErrorCodeConstants.TASK_NOT_EXISTS); - } - // 1.2 校验流程实例存在 - String processInstanceId = task.getProcessInstanceId(); - ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId); - if (processInstance == null) { - throw exception(ErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS); - } - // 1.3 校验流程定义存在 - ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition( - processInstance.getProcessDefinitionId()); - if (processDefinition == null) { - throw exception(ErrorCodeConstants.PROCESS_DEFINITION_NOT_EXISTS); - } - - // 2. 创建抄送流程 - List copyList = convertList(userIds, userId -> new BpmProcessInstanceCopyDO() - .setUserId(userId).setStartUserId(Long.valueOf(processInstance.getStartUserId())) - .setProcessInstanceId(processInstanceId).setProcessInstanceName(processInstance.getName()) - .setCategory(processDefinition.getCategory()).setTaskId(taskId).setTaskName(task.getName())); - processInstanceCopyMapper.insertBatch(copyList); - } - - @Override - public PageResult getProcessInstanceCopyPage(Long userId, - BpmProcessInstanceCopyPageReqVO pageReqVO) { - return processInstanceCopyMapper.selectPage(userId, pageReqVO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java deleted file mode 100644 index 43e44aa5c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageReqVO; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 流程实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessInstanceService { - - /** - * 获得流程实例 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - ProcessInstance getProcessInstance(String id); - - /** - * 获得流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 - */ - List getProcessInstances(Set ids); - - /** - * 获得流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 Map - */ - default Map getProcessInstanceMap(Set ids) { - return convertMap(getProcessInstances(ids), ProcessInstance::getProcessInstanceId); - } - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - HistoricProcessInstance getHistoricProcessInstance(String id); - - /** - * 获得历史的流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 - */ - List getHistoricProcessInstances(Set ids); - - /** - * 获得历史的流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 Map - */ - default Map getHistoricProcessInstanceMap(Set ids) { - return convertMap(getHistoricProcessInstances(ids), HistoricProcessInstance::getId); - } - - /** - * 获得流程实例的分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程实例的分页 - */ - PageResult getProcessInstancePage(Long userId, - @Valid BpmProcessInstancePageReqVO pageReqVO); - - /** - * 创建流程实例(提供给前端) - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO); - - /** - * 创建流程实例(提供给内部) - * - * @param userId 用户编号 - * @param createReqDTO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO); - - /** - * 发起人取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstanceByStartUser(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 管理员取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstanceByAdmin(Long userId, BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 更新 ProcessInstance 拓展记录为取消 - * - * @param event 流程取消事件 - */ - void updateProcessInstanceWhenCancel(FlowableCancelledEvent event); - - /** - * 更新 ProcessInstance 拓展记录为完成 - * - * @param instance 流程任务 - */ - void updateProcessInstanceWhenApprove(ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为不通过 - * - * @param id 流程编号 - * @param reason 理由。例如说,审批不通过时,需要传递该值 - */ - void updateProcessInstanceReject(String id, String reason); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java deleted file mode 100644 index 443236c6a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.common.util.object.PageUtils; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCancelReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageReqVO; import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; import cn.iocoder.yudao.module.bpm.enums.task.BpmDeleteReasonEnum; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.BpmTaskCandidateStartUserSelectStrategy; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; import cn.iocoder.yudao.module.bpm.framework.flowable.core.event.BpmProcessInstanceEventPublisher; import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import lombok.extern.slf4j.Slf4j; import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.UserTask; import org.flowable.engine.HistoryService; import org.flowable.engine.RuntimeService; import org.flowable.engine.delegate.event.FlowableCancelledEvent; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstanceQuery; import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.runtime.ProcessInstance; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import javax.validation.Valid; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; /** * 流程实例 Service 实现类 * * ProcessDefinition & ProcessInstance & Execution & Task 的关系: * 1. * * HistoricProcessInstance & ProcessInstance 的关系: * 1. * * 简单来说,前者 = 历史 + 运行中的流程实例,后者仅是运行中的流程实例 * * @author 芋道源码 */ @Service @Validated @Slf4j public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService { @Resource private RuntimeService runtimeService; @Resource private HistoryService historyService; @Resource private BpmProcessDefinitionService processDefinitionService; @Resource private BpmMessageService messageService; @Resource private AdminUserApi adminUserApi; @Resource private BpmProcessInstanceEventPublisher processInstanceEventPublisher; @Override public ProcessInstance getProcessInstance(String id) { return runtimeService.createProcessInstanceQuery() .includeProcessVariables() .processInstanceId(id) .singleResult(); } @Override public List getProcessInstances(Set ids) { return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list(); } @Override public HistoricProcessInstance getHistoricProcessInstance(String id) { return historyService.createHistoricProcessInstanceQuery().processInstanceId(id).includeProcessVariables().singleResult(); } @Override public List getHistoricProcessInstances(Set ids) { return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list(); } @Override public PageResult getProcessInstancePage(Long userId, BpmProcessInstancePageReqVO pageReqVO) { // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery() .includeProcessVariables() .processInstanceTenantId(FlowableUtils.getTenantId()) .orderByProcessInstanceStartTime().desc(); if (userId != null) { // 【我的流程】菜单时,需要传递该字段 processInstanceQuery.startedBy(String.valueOf(userId)); } else if (pageReqVO.getStartUserId() != null) { // 【管理流程】菜单时,才会传递该字段 processInstanceQuery.startedBy(String.valueOf(pageReqVO.getStartUserId())); } if (StrUtil.isNotEmpty(pageReqVO.getName())) { processInstanceQuery.processInstanceNameLike("%" + pageReqVO.getName() + "%"); } if (StrUtil.isNotEmpty(pageReqVO.getProcessDefinitionId())) { processInstanceQuery.processDefinitionId("%" + pageReqVO.getProcessDefinitionId() + "%"); } if (StrUtil.isNotEmpty(pageReqVO.getCategory())) { processInstanceQuery.processDefinitionCategory(pageReqVO.getCategory()); } if (pageReqVO.getStatus() != null) { processInstanceQuery.variableValueEquals(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, pageReqVO.getStatus()); } if (ArrayUtil.isNotEmpty(pageReqVO.getCreateTime())) { processInstanceQuery.startedAfter(DateUtils.of(pageReqVO.getCreateTime()[0])); processInstanceQuery.startedBefore(DateUtils.of(pageReqVO.getCreateTime()[1])); } // 查询数量 long processInstanceCount = processInstanceQuery.count(); if (processInstanceCount == 0) { return PageResult.empty(processInstanceCount); } // 查询列表 List processInstanceList = processInstanceQuery.listPage(PageUtils.getStart(pageReqVO), pageReqVO.getPageSize()); return new PageResult<>(processInstanceList, processInstanceCount); } @Override @Transactional(rollbackFor = Exception.class) public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getProcessDefinition(createReqVO.getProcessDefinitionId()); // 发起流程 return createProcessInstance0(userId, definition, createReqVO.getVariables(), null, createReqVO.getStartUserSelectAssignees()); } @Override public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(createReqDTO.getProcessDefinitionKey()); // 发起流程 return createProcessInstance0(userId, definition, createReqDTO.getVariables(), createReqDTO.getBusinessKey(), createReqDTO.getStartUserSelectAssignees()); } private String createProcessInstance0(Long userId, ProcessDefinition definition, Map variables, String businessKey, Map> startUserSelectAssignees) { // 1.1 校验流程定义 if (definition == null) { throw exception(PROCESS_DEFINITION_NOT_EXISTS); } if (definition.isSuspended()) { throw exception(PROCESS_DEFINITION_IS_SUSPENDED); } // 1.2 校验发起人自选审批人 validateStartUserSelectAssignees(definition, startUserSelectAssignees); // 2. 创建流程实例 if (variables == null) { variables = new HashMap<>(); } FlowableUtils.filterProcessInstanceFormVariable(variables); // 过滤一下,避免 ProcessInstance 系统级的变量被占用 variables.put(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, // 流程实例状态:审批中 BpmProcessInstanceStatusEnum.RUNNING.getStatus()); if (CollUtil.isNotEmpty(startUserSelectAssignees)) { variables.put(BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, startUserSelectAssignees); } ProcessInstance instance = runtimeService.createProcessInstanceBuilder() .processDefinitionId(definition.getId()) .businessKey(businessKey) .name(definition.getName().trim()) .variables(variables) .start(); return instance.getId(); } private void validateStartUserSelectAssignees(ProcessDefinition definition, Map> startUserSelectAssignees) { // 1. 获得发起人自选审批人的 UserTask 列表 BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(definition.getId()); List userTaskList = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectUserTaskList(bpmnModel); if (CollUtil.isEmpty(userTaskList)) { return; } // 2. 校验发起人自选审批人的 UserTask 是否都配置了 userTaskList.forEach(userTask -> { List assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(userTask.getId()) : null; if (CollUtil.isEmpty(assignees)) { throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, userTask.getName()); } Map userMap = adminUserApi.getUserMap(assignees); assignees.forEach(assignee -> { if (userMap.get(assignee) == null) { throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS, userTask.getName(), assignee); } }); }); } @Override public void cancelProcessInstanceByStartUser(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO) { // 1.1 校验流程实例存在 ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } // 1.2 只能取消自己的 if (!Objects.equals(instance.getStartUserId(), String.valueOf(userId))) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF); } // 2. 通过删除流程实例,实现流程实例的取消, // 删除流程实例,正则执行任务 ACT_RU_TASK. 任务会被删除。 deleteProcessInstance(cancelReqVO.getId(), BpmDeleteReasonEnum.CANCEL_PROCESS_INSTANCE_BY_START_USER.format(cancelReqVO.getReason())); // 3. 进一步的处理,交给 updateProcessInstanceCancel 方法 } @Override public void cancelProcessInstanceByAdmin(Long userId, BpmProcessInstanceCancelReqVO cancelReqVO) { // 1.1 校验流程实例存在 ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } // 1.2 管理员取消,不用校验是否为自己的 AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); // 2. 通过删除流程实例,实现流程实例的取消, // 删除流程实例,正则执行任务 ACT_RU_TASK. 任务会被删除。 deleteProcessInstance(cancelReqVO.getId(), BpmDeleteReasonEnum.CANCEL_PROCESS_INSTANCE_BY_ADMIN.format(user.getNickname(), cancelReqVO.getReason())); // 3. 进一步的处理,交给 updateProcessInstanceCancel 方法 } @Override public void updateProcessInstanceWhenCancel(FlowableCancelledEvent event) { // 1. 判断是否为 Reject 不通过。如果是,则不进行更新. // 因为,updateProcessInstanceReject 方法(审批不通过),已经进行更新了 if (BpmDeleteReasonEnum.isRejectReason((String) event.getCause())) { return; } // 2. 更新流程实例 status runtimeService.setVariable(event.getProcessInstanceId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.CANCEL.getStatus()); // 3. 发送流程实例的状态事件 // 注意:此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance HistoricProcessInstance processInstance = getHistoricProcessInstance(event.getProcessInstanceId()); // 发送流程实例的状态事件 processInstanceEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.CANCEL.getStatus())); } @Override public void updateProcessInstanceWhenApprove(ProcessInstance instance) { // 1. 更新流程实例 status runtimeService.setVariable(instance.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.APPROVE.getStatus()); // 2. 发送流程被【通过】的消息 messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceApproveMessage(instance)); // 3. 发送流程实例的状态事件 // 注意:此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); processInstanceEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.APPROVE.getStatus())); } @Override @Transactional(rollbackFor = Exception.class) public void updateProcessInstanceReject(String id, String reason) { // 1. 更新流程实例 status runtimeService.setVariable(id, BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.REJECT.getStatus()); // 2. 删除流程实例,以实现驳回任务时,取消整个审批流程 ProcessInstance processInstance = getProcessInstance(id); deleteProcessInstance(id, StrUtil.format(BpmDeleteReasonEnum.REJECT_TASK.format(reason))); // 3. 发送流程被【不通过】的消息 messageService.sendMessageWhenProcessInstanceReject(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceRejectMessage(processInstance, reason)); // 4. 发送流程实例的状态事件 processInstanceEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.REJECT.getStatus())); } private void deleteProcessInstance(String id, String reason) { runtimeService.deleteProcessInstance(id, reason); } } \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java deleted file mode 100644 index e9a55c0ff..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java +++ /dev/null @@ -1,186 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import org.flowable.bpmn.model.UserTask; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 流程任务实例 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmTaskService { - - /** - * 获得待办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTaskTodoPage(Long userId, BpmTaskPageReqVO pageReqVO); - - /** - * 获得已办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTaskDonePage(Long userId, BpmTaskPageReqVO pageReqVO); - - /** - * 获得全部的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTaskPage(Long userId, BpmTaskPageReqVO pageReqVO); - - /** - * 获得流程任务 Map - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务 Map - */ - default Map> getTaskMapByProcessInstanceIds(List processInstanceIds) { - return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), - Task::getProcessInstanceId); - } - - /** - * 获得流程任务列表 - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务列表 - */ - List getTasksByProcessInstanceIds(List processInstanceIds); - - /** - * 获得指定流程实例的流程任务列表,包括所有状态的 - * - * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 - */ - List getTaskListByProcessInstanceId(String processInstanceId); - - /** - * 通过任务 - * - * @param userId 用户编号 - * @param reqVO 通过请求 - */ - void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO); - - /** - * 不通过任务 - * - * @param userId 用户编号 - * @param reqVO 不通过请求 - */ - void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param userId 用户编号 - * @param reqVO 分配请求 - */ - void transferTask(Long userId, BpmTaskTransferReqVO reqVO); - - /** - * 更新 Task 状态,在创建时 - * - * @param task 任务实体 - */ - void updateTaskStatusWhenCreated(Task task); - - /** - * 更新 Task 状态,在取消时 - * - * @param taskId 任务的编号 - */ - void updateTaskStatusWhenCanceled(String taskId); - - /** - * 更新 Task 拓展记录,并发送通知 - * - * @param task 任务实体 - */ - void updateTaskExtAssign(Task task); - - /** - * 获取任务 - * - * @param id 任务编号 - * @return 任务 - */ - Task getTask(String id); - - /** - * 获取当前任务的可回退的 UserTask 集合 - * - * @param id 当前的任务 ID - * @return 可以回退的节点列表 - */ - List getUserTaskListByReturn(String id); - - /** - * 将任务回退到指定的 targetDefinitionKey 位置 - * - * @param userId 用户编号 - * @param reqVO 回退的任务key和当前所在的任务ID - */ - void returnTask(Long userId, BpmTaskReturnReqVO reqVO); - - /** - * 将指定任务委派给其他人处理,等接收人处理后再回到原审批人手中审批 - * - * @param userId 用户编号 - * @param reqVO 被委派人和被委派的任务编号理由参数 - */ - void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO); - - /** - * 任务加签 - * - * @param userId 被加签的用户和任务 ID,加签类型 - * @param reqVO 当前用户 ID - */ - void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO); - - /** - * 任务减签 - * - * @param userId 当前用户ID - * @param reqVO 被减签的任务 ID,理由 - */ - void deleteSignTask(Long userId, BpmTaskSignDeleteReqVO reqVO); - - /** - * 获取指定任务的子任务列表 - * - * @param parentTaskId 父任务ID - * @return 子任务列表 - */ - List getTaskListByParentTaskId(String parentTaskId); - - /** - * 通过任务 ID,查询任务名 Map - * - * @param taskIds 任务 ID - * @return 任务 ID 与名字的 Map - */ - Map getTaskNameByTaskIds(Collection taskIds); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java deleted file mode 100644 index 411b7fa8e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ /dev/null @@ -1,822 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmDeleteReasonEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskSignTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; -import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.FlowElement; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.HistoryService; -import org.flowable.engine.ManagementService; -import org.flowable.engine.RuntimeService; -import org.flowable.engine.TaskService; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.DelegationState; -import org.flowable.task.api.Task; -import org.flowable.task.api.TaskQuery; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskInstanceQuery; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.Assert; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.*; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 流程任务实例 Service 实现类 - * - * @author 芋道源码 - * @author jason - */ -@Slf4j -@Service -public class BpmTaskServiceImpl implements BpmTaskService { - - @Resource - private TaskService taskService; - @Resource - private HistoryService historyService; - @Resource - private RuntimeService runtimeService; - @Resource - private ManagementService managementService; - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmProcessInstanceCopyService processInstanceCopyService; - @Resource - private BpmModelService bpmModelService; - @Resource - private BpmMessageService messageService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - public PageResult getTaskTodoPage(Long userId, BpmTaskPageReqVO pageVO) { - TaskQuery taskQuery = taskService.createTaskQuery() - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .active() - .includeProcessVariables() - .orderByTaskCreateTime().desc(); // 创建时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); - } - long count = taskQuery.count(); - if (count == 0) { - return PageResult.empty(); - } - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(tasks, count); - } - - @Override - public PageResult getTaskDonePage(Long userId, BpmTaskPageReqVO pageVO) { - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery() - .finished() // 已完成 - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .includeTaskLocalVariables() - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); - } - // 执行查询 - long count = taskQuery.count(); - if (count == 0) { - return PageResult.empty(); - } - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(tasks, count); - } - - @Override - public PageResult getTaskPage(Long userId, BpmTaskPageReqVO pageVO) { - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery() - .includeTaskLocalVariables() - .taskTenantId(FlowableUtils.getTenantId()) - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); - } - // 执行查询 - long count = taskQuery.count(); - if (count == 0) { - return PageResult.empty(); - } - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(tasks, count); - } - - @Override - public List getTasksByProcessInstanceIds(List processInstanceIds) { - if (CollUtil.isEmpty(processInstanceIds)) { - return Collections.emptyList(); - } - return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list(); - } - - @Override - public List getTaskListByProcessInstanceId(String processInstanceId) { - List tasks = historyService.createHistoricTaskInstanceQuery() - .includeTaskLocalVariables() - .processInstanceId(processInstanceId) - .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序 - .list(); - if (CollUtil.isEmpty(tasks)) { - return Collections.emptyList(); - } - return tasks; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO) { - // 1.1 校验任务存在 - Task task = validateTask(userId, reqVO.getId()); - // 1.2 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 2. 抄送用户 - if (CollUtil.isNotEmpty(reqVO.getCopyUserIds())) { - processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), reqVO.getId()); - } - - // 情况一:被委派的任务,不调用 complete 去完成任务 - if (DelegationState.PENDING.equals(task.getDelegationState())) { - approveDelegateTask(reqVO, task); - return; - } - - // 情况二:审批有【后】加签的任务 - if (BpmTaskSignTypeEnum.AFTER.getType().equals(task.getScopeType())) { - approveAfterSignTask(task, reqVO); - return; - } - - // 情况三:审批普通的任务。大多数情况下,都是这样 - // 3.1 更新 task 状态、原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVE.getStatus(), reqVO.getReason()); - // 3.2 添加评论 - taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(), - BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason())); - // 3.3 调用 BPM complete 去完成任务 - // 其中,variables 是存储动态表单到 local 任务级别。过滤一下,避免 ProcessInstance 系统级的变量被占用 - if (CollUtil.isNotEmpty(reqVO.getVariables())) { - Map variables = FlowableUtils.filterTaskFormVariable(reqVO.getVariables()); - taskService.complete(task.getId(), variables, true); - } else { - taskService.complete(task.getId()); - } - - // 【加签专属】处理加签任务 - handleParentTaskIfSign(task.getParentTaskId()); - } - - /** - * 审批通过存在“后加签”的任务。 - *

- * 注意:该任务不能马上完成,需要一个中间状态(APPROVING),并激活剩余所有子任务(PROCESS)为可审批处理 - * 如果马上完成,则会触发下一个任务,甚至如果没有下一个任务则流程实例就直接结束了! - * - * @param task 当前任务 - * @param reqVO 前端请求参数 - */ - private void approveAfterSignTask(Task task, BpmTaskApproveReqVO reqVO) { - // 更新父 task 状态 + 原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVING.getStatus(), reqVO.getReason()); - - // 2. 激活子任务 - List childrenTaskList = getTaskListByParentTaskId(task.getId()); - for (Task childrenTask : childrenTaskList) { - taskService.resolveTask(childrenTask.getId()); - // 更新子 task 状态 - updateTaskStatus(childrenTask.getId(), BpmTaskStatusEnum.RUNNING.getStatus()); - } - } - - /** - * 如果父任务是有前后【加签】的任务,如果它【加签】出来的子任务都被处理,需要处理父任务: - * - * 1. 如果是【向前】加签,则需要重新激活父任务,让它可以被审批 - * 2. 如果是【向后】加签,则需要完成父任务,让它完成审批 - * - * @param parentTaskId 父任务编号 - */ - private void handleParentTaskIfSign(String parentTaskId) { - if (StrUtil.isBlank(parentTaskId)) { - return; - } - // 1.1 判断是否还有子任务。如果没有,就不处理 - Long childrenTaskCount = getTaskCountByParentTaskId(parentTaskId); - if (childrenTaskCount > 0) { - return; - } - // 1.2 只处理加签的父任务 - Task parentTask = validateTaskExist(parentTaskId); - String scopeType = parentTask.getScopeType(); - if (BpmTaskSignTypeEnum.of(scopeType) == null) { - return; - } - - // 2. 子任务已处理完成,清空 scopeType 字段,修改 parentTask 信息,方便后续可以继续向前后向后加签 - TaskEntityImpl parentTaskImpl = (TaskEntityImpl) parentTask; - parentTaskImpl.setScopeType(null); - taskService.saveTask(parentTaskImpl); - - // 3.1 情况一:处理向【向前】加签 - if (BpmTaskSignTypeEnum.BEFORE.getType().equals(scopeType)) { - // 3.1.1 owner 重新赋值给父任务的 assignee,这样它就可以被审批 - taskService.resolveTask(parentTaskId); - // 3.1.2 更新流程任务 status - updateTaskStatus(parentTaskId, BpmTaskStatusEnum.RUNNING.getStatus()); - // 3.2 情况二:处理向【向后】加签 - } else if (BpmTaskSignTypeEnum.AFTER.getType().equals(scopeType)) { - // 只有 parentTask 处于 APPROVING 的情况下,才可以继续 complete 完成 - // 否则,一个未审批的 parentTask 任务,在加签出来的任务都被减签的情况下,就直接完成审批,这样会存在问题 - Integer status = (Integer) parentTask.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - if (ObjectUtil.notEqual(status, BpmTaskStatusEnum.APPROVING.getStatus())) { - return; - } - // 3.2.2 完成自己(因为它已经没有子任务,所以也可以完成) - updateTaskStatus(parentTaskId, BpmTaskStatusEnum.APPROVE.getStatus()); - taskService.complete(parentTaskId); - } - - // 4. 递归处理父任务 - handleParentTaskIfSign(parentTask.getParentTaskId()); - } - - /** - * 审批被委派的任务 - * - * @param reqVO 前端请求参数,包含当前任务ID,审批意见等 - * @param task 当前被审批的任务 - */ - private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) { - // 1. 添加审批意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()).getCheckedData(); - AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); // 发起委托的用户 - Assert.notNull(ownerUser, "委派任务找不到原审批人,需要检查数据"); - taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_END.getType(), - BpmCommentTypeEnum.DELEGATE_END.formatComment(currentUser.getNickname(), ownerUser.getNickname(), reqVO.getReason())); - - // 2.1 调用 resolveTask 完成任务。 - // 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()):将 owner 设置为 assignee - taskService.resolveTask(task.getId()); - // 2.2 更新 task 状态 + 原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus(), reqVO.getReason()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) { - // 1.1 校验任务存在 - Task task = validateTask(userId, reqVO.getId()); - // 1.2 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 2.1 更新流程实例为不通过 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.REJECT.getStatus(), reqVO.getReason()); - // 2.2 添加评论 - taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.REJECT.getType(), - BpmCommentTypeEnum.REJECT.formatComment(reqVO.getReason())); - - // 3. 更新流程实例,审批不通过! - processInstanceService.updateProcessInstanceReject(instance.getProcessInstanceId(), reqVO.getReason()); - } - - /** - * 更新流程任务的 status 状态 - * - * @param id 任务编号 - * @param status 状态 - */ - private void updateTaskStatus(String id, Integer status) { - taskService.setVariableLocal(id, BpmConstants.TASK_VARIABLE_STATUS, status); - } - - /** - * 更新流程任务的 status 状态、reason 理由 - * - * @param id 任务编号 - * @param status 状态 - * @param reason 理由(审批通过、审批不通过的理由) - */ - private void updateTaskStatusAndReason(String id, Integer status, String reason) { - updateTaskStatus(id, status); - taskService.setVariableLocal(id, BpmConstants.TASK_VARIABLE_REASON, reason); - } - - /** - * 校验任务是否存在,并且是否是分配给自己的任务 - * - * @param userId 用户 id - * @param taskId task id - */ - private Task validateTask(Long userId, String taskId) { - Task task = validateTaskExist(taskId); - if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) { - throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF); - } - return task; - } - - @Override - public void updateTaskStatusWhenCreated(Task task) { - Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - if (status != null) { - log.error("[updateTaskStatusWhenCreated][taskId({}) 已经有状态({})]", task.getId(), status); - return; - } - updateTaskStatus(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus()); - } - - @Override - public void updateTaskStatusWhenCanceled(String taskId) { - Task task = getTask(taskId); - // 1. 可能只是活动,不是任务,所以查询不到 - if (task == null) { - log.error("[updateTaskStatusWhenCanceled][taskId({}) 任务不存在]", taskId); - return; - } - - // 2. 更新 task 状态 + 原因 - Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - if (BpmTaskStatusEnum.isEndStatus(status)) { - log.error("[updateTaskStatusWhenCanceled][taskId({}) 处于结果({}),无需进行更新]", taskId, status); - return; - } - updateTaskStatusAndReason(taskId, BpmTaskStatusEnum.CANCEL.getStatus(), BpmDeleteReasonEnum.CANCEL_BY_SYSTEM.getReason()); - // 补充说明:由于 Task 被删除成 HistoricTask 后,无法通过 taskService.addComment 添加理由,所以无法存储具体的取消理由 - } - - @Override - public void updateTaskExtAssign(Task task) { - // 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - if (StrUtil.isEmpty(task.getAssignee())) { - return; - } - ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData(); - messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); - } - - }); - } - - private Task validateTaskExist(String id) { - Task task = getTask(id); - if (task == null) { - throw exception(TASK_NOT_EXISTS); - } - return task; - } - - @Override - public Task getTask(String id) { - return taskService.createTaskQuery().taskId(id).includeTaskLocalVariables().singleResult(); - } - - private HistoricTaskInstance getHistoricTask(String id) { - return historyService.createHistoricTaskInstanceQuery().taskId(id).includeTaskLocalVariables().singleResult(); - } - - @Override - public List getUserTaskListByReturn(String id) { - // 1.1 校验当前任务 task 存在 - Task task = validateTaskExist(id); - // 1.2 根据流程定义获取流程模型信息 - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); - FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); - if (source == null) { - throw exception(TASK_NOT_EXISTS); - } - - // 2.1 查询该任务的前置任务节点的 key 集合 - List previousUserList = BpmnModelUtils.getPreviousUserTaskList(source, null, null); - if (CollUtil.isEmpty(previousUserList)) { - return Collections.emptyList(); - } - // 2.2 过滤:只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 - previousUserList.removeIf(userTask -> !BpmnModelUtils.isSequentialReachable(source, userTask, null)); - return previousUserList; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void returnTask(Long userId, BpmTaskReturnReqVO reqVO) { - // 1.1 当前任务 task - Task task = validateTask(userId, reqVO.getId()); - if (task.isSuspended()) { - throw exception(TASK_IS_PENDING); - } - // 1.2 校验源头和目标节点的关系,并返回目标元素 - FlowElement targetElement = validateTargetTaskCanReturn(task.getTaskDefinitionKey(), - reqVO.getTargetTaskDefinitionKey(), task.getProcessDefinitionId()); - - // 2. 调用 Flowable 框架的回退逻辑 - returnTask(task, targetElement, reqVO); - } - - /** - * 回退流程节点时,校验目标任务节点是否可回退 - * - * @param sourceKey 当前任务节点 Key - * @param targetKey 目标任务节点 key - * @param processDefinitionId 当前流程定义 ID - * @return 目标任务节点元素 - */ - private FlowElement validateTargetTaskCanReturn(String sourceKey, String targetKey, String processDefinitionId) { - // 1.1 获取流程模型信息 - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(processDefinitionId); - // 1.3 获取当前任务节点元素 - FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, sourceKey); - // 1.3 获取跳转的节点元素 - FlowElement target = BpmnModelUtils.getFlowElementById(bpmnModel, targetKey); - if (target == null) { - throw exception(TASK_TARGET_NODE_NOT_EXISTS); - } - - // 2.2 只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 - if (!BpmnModelUtils.isSequentialReachable(source, target, null)) { - throw exception(TASK_RETURN_FAIL_SOURCE_TARGET_ERROR); - } - return target; - } - - /** - * 执行回退逻辑 - * - * @param currentTask 当前回退的任务 - * @param targetElement 需要回退到的目标任务 - * @param reqVO 前端参数封装 - */ - public void returnTask(Task currentTask, FlowElement targetElement, BpmTaskReturnReqVO reqVO) { - // 1. 获得所有需要回撤的任务 taskDefinitionKey,用于稍后的 moveActivityIdsToSingleActivityId 回撤 - // 1.1 获取所有正常进行的任务节点 Key - List taskList = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).list(); - List runTaskKeyList = convertList(taskList, Task::getTaskDefinitionKey); - // 1.2 通过 targetElement 的出口连线,计算在 runTaskKeyList 有哪些 key 需要被撤回 - // 为什么不直接使用 runTaskKeyList 呢?因为可能存在多个审批分支,例如说:A -> B -> C 和 D -> F,而只要 C 撤回到 A,需要排除掉 F - List returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null); - List returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId); - - // 2. 给当前要被回退的 task 数组,设置回退意见 - taskList.forEach(task -> { - // 需要排除掉,不需要设置回退意见的任务 - if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) { - return; - } - // 2.1 添加评论 - taskService.addComment(task.getId(), currentTask.getProcessInstanceId(), BpmCommentTypeEnum.RETURN.getType(), - BpmCommentTypeEnum.RETURN.formatComment(reqVO.getReason())); - // 2.2 更新 task 状态 + 原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RETURN.getStatus(), reqVO.getReason()); - }); - - // 3. 执行驳回 - runtimeService.createChangeActivityStateBuilder() - .processInstanceId(currentTask.getProcessInstanceId()) - .moveActivityIdsToSingleActivityId(returnTaskKeyList, // 当前要跳转的节点列表( 1 或多) - reqVO.getTargetTaskDefinitionKey()) // targetKey 跳转到的节点(1) - .changeState(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO) { - String taskId = reqVO.getId(); - // 1.1 校验任务 - Task task = validateTask(userId, reqVO.getId()); - if (task.getAssignee().equals(reqVO.getDelegateUserId().toString())) { // 校验当前审批人和被委派人不是同一人 - throw exception(TASK_DELEGATE_FAIL_USER_REPEAT); - } - // 1.2 校验目标用户存在 - AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()).getCheckedData(); - if (delegateUser == null) { - throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS); - } - - // 2. 添加委托意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); - taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_START.getType(), - BpmCommentTypeEnum.DELEGATE_START.formatComment(currentUser.getNickname(), delegateUser.getNickname(), reqVO.getReason())); - - // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) - taskService.setOwner(taskId, task.getAssignee()); - // 3.2 执行委派,将任务委派给 delegateUser - taskService.delegateTask(taskId, reqVO.getDelegateUserId().toString()); - // 3.3 更新 task 状态。 - // 为什么不更新原因?因为原因目前主要给审批通过、不通过时使用 - updateTaskStatus(taskId, BpmTaskStatusEnum.DELEGATE.getStatus()); - } - - @Override - public void transferTask(Long userId, BpmTaskTransferReqVO reqVO) { - String taskId = reqVO.getId(); - // 1.1 校验任务 - Task task = validateTask(userId, reqVO.getId()); - if (task.getAssignee().equals(reqVO.getAssigneeUserId().toString())) { // 校验当前审批人和被转派人不是同一人 - throw exception(TASK_TRANSFER_FAIL_USER_REPEAT); - } - // 1.2 校验目标用户存在 - AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId()).getCheckedData(); - if (assigneeUser == null) { - throw exception(TASK_TRANSFER_FAIL_USER_NOT_EXISTS); - } - - // 2. 添加委托意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); - taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.TRANSFER.getType(), - BpmCommentTypeEnum.TRANSFER.formatComment(currentUser.getNickname(), assigneeUser.getNickname(), reqVO.getReason())); - - // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) - taskService.setOwner(taskId, task.getAssignee()); - // 3.2 执行转派(审批人),将任务转派给 assigneeUser - // 委托( delegate)和转派(transfer)的差别,就在这块的调用!!!! - taskService.setAssignee(taskId, reqVO.getAssigneeUserId().toString()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO) { - // 1. 获取和校验任务 - TaskEntityImpl taskEntity = validateTaskCanCreateSign(userId, reqVO); - List userList = adminUserApi.getUserList(reqVO.getUserIds()).getCheckedData(); - if (CollUtil.isEmpty(userList)) { - throw exception(TASK_SIGN_CREATE_USER_NOT_EXIST); - } - - // 2. 处理当前任务 - // 2.1 开启计数功能,主要用于为了让表 ACT_RU_TASK 中的 SUB_TASK_COUNT_ 字段记录下总共有多少子任务,后续可能有用 - taskEntity.setCountEnabled(true); - // 2.2 向前加签,设置 owner,置空 assign。等子任务都完成后,再调用 resolveTask 重新将 owner 设置为 assign - // 原因是:不能和向前加签的子任务一起审批,需要等前面的子任务都完成才能审批 - if (reqVO.getType().equals(BpmTaskSignTypeEnum.BEFORE.getType())) { - taskEntity.setOwner(taskEntity.getAssignee()); - taskEntity.setAssignee(null); - } - // 2.4 记录加签方式,完成任务时需要用到判断 - taskEntity.setScopeType(reqVO.getType()); - // 2.5 保存当前任务修改后的值 - taskService.saveTask(taskEntity); - // 2.6 更新 task 状态为 WAIT,只有在向前加签的时候 - if (reqVO.getType().equals(BpmTaskSignTypeEnum.BEFORE.getType())) { - updateTaskStatus(taskEntity.getId(), BpmTaskStatusEnum.WAIT.getStatus()); - } - - // 3. 创建加签任务 - createSignTaskList(convertList(reqVO.getUserIds(), String::valueOf), taskEntity); - - // 4. 记录加签的评论到 task 任务 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); - String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(), - currentUser.getNickname(), BpmTaskSignTypeEnum.nameOfType(reqVO.getType()), - String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason()); - taskService.addComment(reqVO.getId(), taskEntity.getProcessInstanceId(), BpmCommentTypeEnum.ADD_SIGN.getType(), comment); - } - - /** - * 校验任务是否可以加签,主要校验加签类型是否一致: - *

- * 1. 如果存在“向前加签”的任务,则不能“向后加签” - * 2. 如果存在“向后加签”的任务,则不能“向前加签” - * - * @param userId 当前用户 ID - * @param reqVO 请求参数,包含任务 ID 和加签类型 - * @return 当前任务 - */ - private TaskEntityImpl validateTaskCanCreateSign(Long userId, BpmTaskSignCreateReqVO reqVO) { - TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId()); - // 向前加签和向后加签不能同时存在 - if (taskEntity.getScopeType() != null - && ObjectUtil.notEqual(taskEntity.getScopeType(), reqVO.getType())) { - throw exception(TASK_SIGN_CREATE_TYPE_ERROR, - BpmTaskSignTypeEnum.nameOfType(taskEntity.getScopeType()), BpmTaskSignTypeEnum.nameOfType(reqVO.getType())); - } - - // 同一个 key 的任务,审批人不重复 - List taskList = taskService.createTaskQuery().processInstanceId(taskEntity.getProcessInstanceId()) - .taskDefinitionKey(taskEntity.getTaskDefinitionKey()).list(); - List currentAssigneeList = convertListByFlatMap(taskList, task -> // 需要考虑 owner 的情况,因为向后加签时,它暂时没 assignee 而是 owner - Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner()))); - if (CollUtil.containsAny(currentAssigneeList, reqVO.getUserIds())) { - List userList = adminUserApi.getUserList( CollUtil.intersection(currentAssigneeList, reqVO.getUserIds())).getCheckedData(); - throw exception(TASK_SIGN_CREATE_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname))); - } - return taskEntity; - } - - /** - * 创建加签子任务 - * - * @param userIds 被加签的用户 ID - * @param taskEntity 被加签的任务 - */ - private void createSignTaskList(List userIds, TaskEntityImpl taskEntity) { - if (CollUtil.isEmpty(userIds)) { - return; - } - // 创建加签人的新任务,全部基于 taskEntity 为父任务来创建 - for (String addSignId : userIds) { - if (StrUtil.isBlank(addSignId)) { - continue; - } - createSignTask(taskEntity, addSignId); - } - } - - /** - * 创建加签子任务 - * - * @param parentTask 父任务 - * @param assignee 子任务的执行人 - */ - private void createSignTask(TaskEntityImpl parentTask, String assignee) { - // 1. 生成子任务 - TaskEntityImpl task = (TaskEntityImpl) taskService.newTask(IdUtil.fastSimpleUUID()); - BpmTaskConvert.INSTANCE.copyTo(parentTask, task); - - // 2.1 向前加签,设置审批人 - if (BpmTaskSignTypeEnum.BEFORE.getType().equals(parentTask.getScopeType())) { - task.setAssignee(assignee); - // 2.2 向后加签,设置 owner 不设置 assignee 是因为不能同时审批,需要等父任务完成 - } else { - task.setOwner(assignee); - } - // 2.3 保存子任务 - taskService.saveTask(task); - - // 3. 向后前签,设置子任务的状态为 WAIT,因为需要等父任务审批完 - if (BpmTaskSignTypeEnum.AFTER.getType().equals(parentTask.getScopeType())) { - updateTaskStatus(task.getId(), BpmTaskStatusEnum.WAIT.getStatus()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSignTask(Long userId, BpmTaskSignDeleteReqVO reqVO) { - // 1.1 校验 task 可以被减签 - Task task = validateTaskCanSignDelete(reqVO.getId()); - // 1.2 校验取消人存在 - AdminUserRespDTO cancelUser = null; - if (StrUtil.isNotBlank(task.getAssignee())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())).getCheckedData(); - } - if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); - } - Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误"); - - // 2.1 获得子任务列表,包括子任务的子任务 - List childTaskList = getAllChildTaskList(task); - childTaskList.add(task); - // 2.2 更新子任务为已取消 - String cancelReason = StrUtil.format("任务被取消,原因:由于[{}]操作[减签],", cancelUser.getNickname()); - childTaskList.forEach(childTask -> updateTaskStatusAndReason(childTask.getId(), BpmTaskStatusEnum.CANCEL.getStatus(), cancelReason)); - // 2.3 删除任务和所有子任务 - taskService.deleteTasks(convertList(childTaskList, Task::getId)); - - // 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录 - AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); - taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), BpmCommentTypeEnum.SUB_SIGN.getType(), - StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname())); - - // 4. 处理当前任务的父任务 - handleParentTaskIfSign(task.getParentTaskId()); - } - - /** - * 校验任务是否能被减签 - * - * @param id 任务编号 - * @return 任务信息 - */ - private Task validateTaskCanSignDelete(String id) { - Task task = validateTaskExist(id); - if (task.getParentTaskId() == null) { - throw exception(TASK_SIGN_DELETE_NO_PARENT); - } - Task parentTask = getTask(task.getParentTaskId()); - if (parentTask == null) { - throw exception(TASK_SIGN_DELETE_NO_PARENT); - } - if (BpmTaskSignTypeEnum.of(parentTask.getScopeType()) == null) { - throw exception(TASK_SIGN_DELETE_NO_PARENT); - } - return task; - } - - /** - * 获得所有子任务列表 - * - * @param parentTask 父任务 - * @return 所有子任务列表 - */ - private List getAllChildTaskList(Task parentTask) { - List result = new ArrayList<>(); - // 1. 递归获取子级 - Stack stack = new Stack<>(); - stack.push(parentTask); - // 2. 递归遍历 - for (int i = 0; i < Short.MAX_VALUE; i++) { - if (stack.isEmpty()) { - break; - } - // 2.1 获取子任务们 - Task task = stack.pop(); - List childTaskList = getTaskListByParentTaskId(task.getId()); - // 2.2 如果非空,则添加到 stack 进一步递归 - if (CollUtil.isNotEmpty(childTaskList)) { - stack.addAll(childTaskList); - result.addAll(childTaskList); - } - } - return result; - } - - @Override - public List getTaskListByParentTaskId(String parentTaskId) { - String tableName = managementService.getTableName(TaskEntity.class); - // taskService.createTaskQuery() 没有 parentId 参数,所以写 sql 查询 - String sql = "select ID_,NAME_,OWNER_,ASSIGNEE_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}"; - return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list(); - } - - /** - * 获取子任务个数 - * - * @param parentTaskId 父任务 ID - * @return 剩余子任务个数 - */ - private Long getTaskCountByParentTaskId(String parentTaskId) { - String tableName = managementService.getTableName(TaskEntity.class); - String sql = "SELECT COUNT(1) from " + tableName + " WHERE PARENT_TASK_ID_=#{parentTaskId}"; - return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count(); - } - - @Override - public Map getTaskNameByTaskIds(Collection taskIds) { - if (CollUtil.isEmpty(taskIds)) { - return Collections.emptyMap(); - } - List tasks = taskService.createTaskQuery().taskIds(taskIds).list(); - return convertMap(tasks, Task::getId, Task::getName); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-dev.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 0753ceeeb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,101 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - demo: true # 开启演示模式 diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-local.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 2d60cea66..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.bpm.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - captcha: - enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml deleted file mode 100644 index bd377f272..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,123 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# 工作流 Flowable 配置 -flowable: - # 1. false: 默认值,Flowable 启动时,对比数据库表中保存的版本,如果不匹配。将抛出异常 - # 2. true: 启动时会对数据库中所有表进行更新操作,如果表存在,不做处理,反之,自动创建表 - # 3. create_drop: 启动时自动创建表,关闭时自动删除表 - # 4. drop_create: 启动时,删除旧表,再创建新表 - database-schema-update: true # 设置为 false,可通过 https://github.com/flowable/flowable-sql 初始化 - db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置 - check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程 - history-level: audit # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数 - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.bpm - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - timeout: 5m - width: 160 - height: 60 - tenant: # 多租户相关配置项 - enable: true - -debug: false diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 0f30e625a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: bpm-server - - profiles: - active: local - -server: - port: 48083 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/logback-spring.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvokerTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvokerTest.java deleted file mode 100644 index 702dce3f1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvokerTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.BpmTaskCandidateUserStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.delegate.DelegateExecution; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * {@link BpmTaskCandidateInvoker} 的单元测试 - * - * @author 芋道源码 - */ -public class BpmTaskCandidateInvokerTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateInvoker taskCandidateInvoker; - - @Mock - private AdminUserApi adminUserApi; - @Spy - private BpmTaskCandidateStrategy strategy = new BpmTaskCandidateUserStrategy(); - @Spy - private List strategyList = Collections.singletonList(strategy); - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - DelegateExecution execution = mock(DelegateExecution.class); - // mock 方法(DelegateExecution) - UserTask userTask = mock(UserTask.class); - when(execution.getCurrentFlowElement()).thenReturn(userTask); - when(userTask.getAttributeValue(eq(BpmnModelConstants.NAMESPACE), eq(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY))) - .thenReturn(BpmTaskCandidateStrategyEnum.USER.getStrategy().toString()); - when(userTask.getAttributeValue(eq(BpmnModelConstants.NAMESPACE), eq(BpmnModelConstants.USER_TASK_CANDIDATE_PARAM))) - .thenReturn(param); - // mock 方法(adminUserApi) - AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - Map userMap = MapUtil.builder(user1.getId(), user1) - .put(user2.getId(), user2).build(); - when(adminUserApi.getUserMap(eq(asSet(1L, 2L)))).thenReturn(userMap); - - // 调用 - Set results = taskCandidateInvoker.calculateUsers(execution); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - - @Test - public void testRemoveDisableUsers() { - // 准备参数. 1L 可以找到;2L 是禁用的;3L 找不到 - Set assigneeUserIds = asSet(1L, 2L, 3L); - // mock 方法 - AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - Map userMap = MapUtil.builder(user1.getId(), user1) - .put(user2.getId(), user2).build(); - when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); - - // 调用 - taskCandidateInvoker.removeDisableUsers(assigneeUserIds); - // 断言 - assertEquals(asSet(1L), assigneeUserIds); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java deleted file mode 100644 index 251af1d9f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.expression; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskAssignLeaderExpressionTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskAssignLeaderExpression expression; - - @Mock - private AdminUserApi adminUserApi; - @Mock - private DeptApi deptApi; - - @Mock - private BpmProcessInstanceService processInstanceService; - - @Test - public void testCalculateUsers_noDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); - // mock 方法(getStartUserDept)没有部门 - when(deptApi.getDept(eq(10L))).thenReturn(success(null)); - - // 调用 - Set result = expression.calculateUsers(execution, 1); - // 断言 - assertEquals(0, result.size()); - } - - @Test - public void testCalculateUsers_noParentDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - // mock 方法(getDept) - when(deptApi.getDept(eq(10L))).thenReturn(success(startUserDept)); - when(deptApi.getDept(eq(100L))).thenReturn(success(null)); - - // 调用 - Set result = expression.calculateUsers(execution, 2); - // 断言 - assertEquals(asSet(20L), result); - } - - @Test - public void testCalculateUsers_existParentDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - when(deptApi.getDept(eq(10L))).thenReturn(success(startUserDept)); - // mock 方法(父 dept) - DeptRespDTO parentDept = randomPojo(DeptRespDTO.class, o -> o.setId(100L).setParentId(1000L) - .setLeaderUserId(200L)); - when(deptApi.getDept(eq(100L))).thenReturn(success(parentDept)); - - // 调用 - Set result = expression.calculateUsers(execution, 2); - // 断言 - assertEquals(asSet(200L), result); - } - - @SuppressWarnings("SameParameterValue") - private DelegateExecution mockDelegateExecution(Long startUserId) { - ExecutionEntityImpl execution = new ExecutionEntityImpl(); - execution.setProcessInstanceId(randomString()); - // mock 返回 startUserId - ExecutionEntityImpl processInstance = new ExecutionEntityImpl(); - processInstance.setStartUserId(String.valueOf(startUserId)); - when(processInstanceService.getProcessInstance(eq(execution.getProcessInstanceId()))) - .thenReturn(processInstance); - return execution; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategyTest.java deleted file mode 100644 index ac74ec5b4..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateDeptLeaderStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateDeptLeaderStrategy strategy; - - @Mock - private DeptApi deptApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); - DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L)); - when(deptApi.getDeptList(eq(asSet(1L, 2L)))).thenReturn(success(asList(dept1, dept2))); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategyTest.java deleted file mode 100644 index 68b0e985a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateDeptMemberStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateDeptMemberStrategy strategy; - - @Mock - private AdminUserApi adminUserApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "11,22"; - // mock 方法 - List users = convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByDeptIds(eq(asSet(11L, 22L)))).thenReturn(success(users)); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategyTest.java deleted file mode 100644 index eaa2ef7b5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategyTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import org.flowable.engine.delegate.DelegateExecution; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.MockedStatic; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -public class BpmTaskCandidateExpressionStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateExpressionStrategy strategy; - - @Test - public void testCalculateUsers() { - try (MockedStatic flowableUtilMockedStatic = mockStatic(FlowableUtils.class)) { - // 准备参数 - String param = "1,2"; - DelegateExecution execution = mock(DelegateExecution.class); - // mock 方法 - flowableUtilMockedStatic.when(() -> FlowableUtils.getExpressionValue(same(execution), eq(param))) - .thenReturn(asSet(1L, 2L)); - - // 调用 - Set results = strategy.calculateUsers(execution, param); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java deleted file mode 100644 index 8bd2c88af..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Arrays; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateGroupStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateGroupStrategy strategy; - - @Mock - private BpmUserGroupService userGroupService; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(11L, 12L))); - BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(21L, 22L))); - when(userGroupService.getUserGroupList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(userGroup1, userGroup2)); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 12L, 21L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategyTest.java deleted file mode 100644 index 5a476ae01..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategyTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidatePostStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidatePostStrategy strategy; - - @Mock - private PostApi postApi; - @Mock - private AdminUserApi adminUserApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - List users = convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByPostIds(eq(asSet(1L, 2L)))).thenReturn(success(users)); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategyTest.java deleted file mode 100644 index 23625f5f4..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategyTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateRoleStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateRoleStrategy strategy; - - @Mock - private RoleApi roleApi; - @Mock - private PermissionApi permissionApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - when(permissionApi.getUserRoleIdListByRoleIds(eq(asSet(1L, 2L)))) - .thenReturn(success(asSet(11L, 22L))); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategyTest.java deleted file mode 100644 index d71ccebfd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategyTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BpmTaskCandidateUserStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateUserStrategy strategy; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/category/BpmCategoryServiceImplTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/category/BpmCategoryServiceImplTest.java deleted file mode 100644 index f5033d7c6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/category/BpmCategoryServiceImplTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.category.BpmCategoryMapper; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryServiceImpl; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.CATEGORY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link BpmCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmCategoryServiceImpl.class) -public class BpmCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private BpmCategoryServiceImpl categoryService; - - @Resource - private BpmCategoryMapper categoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - BpmCategorySaveReqVO createReqVO = randomPojo(BpmCategorySaveReqVO.class).setId(null) - .setStatus(randomCommonStatus()); - - // 调用 - Long categoryId = categoryService.createCategory(createReqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - BpmCategoryDO category = categoryMapper.selectById(categoryId); - assertPojoEquals(createReqVO, category, "id"); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmCategorySaveReqVO updateReqVO = randomPojo(BpmCategorySaveReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - categoryService.updateCategory(updateReqVO); - // 校验是否更新正确 - BpmCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - BpmCategorySaveReqVO updateReqVO = randomPojo(BpmCategorySaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - categoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(categoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - public void testGetCategoryPage() { - // mock 数据 - BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class, o -> { // 等会查询到 - o.setName("芋头"); - o.setCode("xiaodun"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2023, 2, 2)); - }); - categoryMapper.insert(dbCategory); - // 测试 name 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName("小盾"))); - // 测试 code 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setCode("tudou"))); - // 测试 status 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setCreateTime(buildTime(2024, 2, 2)))); - // 准备参数 - BpmCategoryPageReqVO reqVO = new BpmCategoryPageReqVO(); - reqVO.setName("芋"); - reqVO.setCode("xiao"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = categoryService.getCategoryPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCategory, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java deleted file mode 100644 index 3d5d508fd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.FORM_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link BpmFormServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmFormServiceImpl.class) -public class BpmFormServiceTest extends BaseDbUnitTest { - - @Resource - private BpmFormServiceImpl formService; - - @Resource - private BpmFormMapper formMapper; - - @Test - public void testCreateForm_success() { - // 准备参数 - BpmFormSaveReqVO reqVO = randomPojo(BpmFormSaveReqVO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - - // 调用 - Long formId = formService.createForm(reqVO); - // 断言 - assertNotNull(formId); - // 校验记录的属性是否正确 - BpmFormDO form = formMapper.selectById(formId); - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmFormSaveReqVO reqVO = randomPojo(BpmFormSaveReqVO.class, o -> { - o.setId(dbForm.getId()); // 设置更新的 ID - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用 - formService.updateForm(reqVO); - // 校验是否更新正确 - BpmFormDO form = formMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_notExists() { - // 准备参数 - BpmFormSaveReqVO reqVO = randomPojo(BpmFormSaveReqVO.class, o -> { - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> formService.updateForm(reqVO), FORM_NOT_EXISTS); - } - - @Test - public void testDeleteForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbForm.getId(); - - // 调用 - formService.deleteForm(id); - // 校验数据不存在了 - assertNull(formMapper.selectById(id)); - } - - @Test - public void testDeleteForm_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> formService.deleteForm(id), FORM_NOT_EXISTS); - } - - @Test - public void testGetFormPage() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - }); - formMapper.insert(dbForm); - // 测试 name 不匹配 - formMapper.insert(cloneIgnoreId(dbForm, o -> o.setName("源码"))); - // 准备参数 - BpmFormPageReqVO reqVO = new BpmFormPageReqVO(); - reqVO.setName("芋道"); - - // 调用 - PageResult pageResult = formService.getFormPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbForm, pageResult.getList().get(0)); - } - - private List randomFields() { - int size = RandomUtil.randomInt(1, 3); - return Stream.iterate(0, i -> i).limit(size) - .map(i -> JsonUtils.toJsonString(randomPojo(BpmFormFieldRespDTO.class))) - .collect(Collectors.toList()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java deleted file mode 100644 index 759e0f143..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; - -/** - * {@link BpmUserGroupServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmUserGroupServiceImpl.class) -public class BpmUserGroupServiceTest extends BaseDbUnitTest { - - @Resource - private BpmUserGroupServiceImpl userGroupService; - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Test - public void testCreateUserGroup_success() { - // 准备参数 - BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class); - - // 调用 - Long userGroupId = userGroupService.createUserGroup(reqVO); - // 断言 - Assertions.assertNotNull(userGroupId); - // 校验记录的属性是否正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(userGroupId); - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class, o -> { - o.setId(dbUserGroup.getId()); // 设置更新的 ID - }); - - // 调用 - userGroupService.updateUserGroup(reqVO); - // 校验是否更新正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(reqVO.getId()); // 获取最新的 - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_notExists() { - // 准备参数 - BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testDeleteUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbUserGroup.getId(); - - // 调用 - userGroupService.deleteUserGroup(id); - // 校验数据不存在了 - Assertions.assertNull(userGroupMapper.selectById(id)); - } - - @Test - public void testDeleteUserGroup_notExists() { - // 准备参数 - Long id = RandomUtils.randomLongId(); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testGetUserGroupPage() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - userGroupMapper.insert(dbUserGroup); - // 测试 name 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道"))); - // 测试 status 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO(); - reqVO.setName("源码"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)})); - - // 调用 - PageResult pageResult = userGroupService.getUserGroupPage(reqVO); - // 断言 - Assertions.assertEquals(1, pageResult.getTotal()); - Assertions.assertEquals(1, pageResult.getList().size()); - AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 9d37b82c2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,45 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.bpm diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index d4f93bbc2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,3 +0,0 @@ -DELETE FROM "bpm_form"; -DELETE FROM "bpm_user_group"; -DELETE FROM "bpm_category"; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 1034962c7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,43 +0,0 @@ -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, - "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 '用户组'; - -CREATE TABLE IF NOT EXISTS "bpm_category" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "code" varchar(63) NOT NULL, - "description" varchar(255) NOT NULL, - "status" tinyint NOT NULL, - "sort" int 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 '分类'; - -CREATE TABLE IF NOT EXISTS "bpm_form" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "fields" varchar(255) NOT NULL, - "conf" varchar(255) NOT NULL, - "remark" varchar(255), - "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-crm/pom.xml b/yudao-module-crm/pom.xml deleted file mode 100644 index 56921c6fb..000000000 --- a/yudao-module-crm/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - - yudao-module-crm-api - yudao-module-crm-biz - - 4.0.0 - yudao-module-crm - pom - - ${project.artifactId} - - crm 包下,客户关系管理(Customer Relationship Management)。 - 例如说:客户、联系人、商机、合同、回款等等 - 商业智能 BI 模块,包括:报表、图表、数据大屏等等 - - - diff --git a/yudao-module-crm/yudao-module-crm-api/pom.xml b/yudao-module-crm/yudao-module-crm-api/pom.xml deleted file mode 100644 index fc97b6759..000000000 --- a/yudao-module-crm/yudao-module-crm-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-crm - ${revision} - - 4.0.0 - yudao-module-crm-api - jar - - ${project.artifactId} - - crm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java deleted file mode 100644 index c38bde7f5..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ApiConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ApiConstants.java deleted file mode 100644 index 544ebf9f4..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "crm-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/crm"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java deleted file mode 100644 index eee2b32d9..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -/** - * CRM 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业 - String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级 - String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源 - String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态 - String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位 - String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态 - String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // CRM 跟进方式 - String CRM_RECEIVABLE_RETURN_TYPE = "crm_receivable_return_type"; // CRM 回款方式 - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java deleted file mode 100644 index 07a6dad60..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * CRM 错误码枚举类 - *

- * crm 系统,使用 1-020-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 合同管理 1-020-000-000 ========== - ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); - ErrorCode CONTRACT_UPDATE_FAIL_NOT_DRAFT = new ErrorCode(1_020_000_001, "合同更新失败,原因:合同不是草稿状态"); - ErrorCode CONTRACT_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_020_000_002, "合同提交审核失败,原因:合同没处在未提交状态"); - ErrorCode CONTRACT_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_020_000_003, "更新合同审核状态失败,原因:合同不是审核中状态"); - ErrorCode CONTRACT_NO_EXISTS = new ErrorCode(1_020_000_004, "生成合同序列号重复,请重试"); - ErrorCode CONTRACT_DELETE_FAIL = new ErrorCode(1_020_000_005, "删除合同失败,原因:有被回款所使用"); - - // ========== 线索管理 1-020-001-000 ========== - ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); - ErrorCode CLUE_TRANSFORM_FAIL_ALREADY = new ErrorCode(1_020_001_001, "线索已经转化过了,请勿重复转化"); - - // ========== 商机管理 1-020-002-000 ========== - ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); - ErrorCode BUSINESS_DELETE_FAIL_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); - ErrorCode BUSINESS_UPDATE_STATUS_FAIL_END_STATUS = new ErrorCode(1_020_002_002, "更新商机状态失败,原因:已经是结束状态"); - ErrorCode BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS = new ErrorCode(1_020_002_003, "更新商机状态失败,原因:已经是该状态"); - - // ========== 联系人管理 1-020-003-000 ========== - ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode(1_020_003_002, "联系人已关联合同,不能删除"); - ErrorCode CONTACT_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_003_003, "更新联系人负责人失败"); - - // ========== 回款 1-020-004-000 ========== - ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); - ErrorCode RECEIVABLE_UPDATE_FAIL_EDITING_PROHIBITED = new ErrorCode(1_020_004_001, "更新回款失败,原因:禁止编辑"); - ErrorCode RECEIVABLE_DELETE_FAIL = new ErrorCode(1_020_004_002, "删除回款失败,原因: 被回款计划所使用,不允许删除"); - ErrorCode RECEIVABLE_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_020_004_003, "回款提交审核失败,原因:回款没处在未提交状态"); - ErrorCode RECEIVABLE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_020_004_004, "更新回款审核状态失败,原因:回款不是审核中状态"); - ErrorCode RECEIVABLE_NO_EXISTS = new ErrorCode(1_020_004_005, "生成回款序列号重复,请重试"); - ErrorCode RECEIVABLE_CREATE_FAIL_CONTRACT_NOT_APPROVE = new ErrorCode(1_020_004_006, "创建回款失败,原因:合同不是审核通过状态"); - ErrorCode RECEIVABLE_CREATE_FAIL_PRICE_EXCEEDS_LIMIT = new ErrorCode(1_020_004_007, "创建回款失败,原因:回款金额超出合同金额,目前剩余可退:{} 元"); - ErrorCode RECEIVABLE_DELETE_FAIL_IS_APPROVE = new ErrorCode(1_020_004_008, "删除回款失败,原因:回款审批已通过"); - - // ========== 回款计划 1-020-005-000 ========== - ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); - ErrorCode RECEIVABLE_PLAN_UPDATE_FAIL = new ErrorCode(1_020_006_000, "更想回款计划失败,原因:已经有对应的还款"); - ErrorCode RECEIVABLE_PLAN_EXISTS_RECEIVABLE = new ErrorCode(1_020_006_001, "回款计划已经有对应的回款,不能使用"); - - // ========== 客户管理 1_020_006_000 ========== - ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); - ErrorCode CUSTOMER_OWNER_EXISTS = new ErrorCode(1_020_006_001, "客户【{}】已存在所属负责人"); - ErrorCode CUSTOMER_LOCKED = new ErrorCode(1_020_006_002, "客户【{}】状态已锁定"); - ErrorCode CUSTOMER_ALREADY_DEAL = new ErrorCode(1_020_006_003, "客户已交易"); - ErrorCode CUSTOMER_IN_POOL = new ErrorCode(1_020_006_004, "客户【{}】放入公海失败,原因:已经是公海客户"); - ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定"); - ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常"); - ErrorCode CUSTOMER_LOCK_FAIL_IS_LOCK = new ErrorCode(1_020_006_007, "锁定客户失败,它已经处于锁定状态"); - ErrorCode CUSTOMER_UNLOCK_FAIL_IS_UNLOCK = new ErrorCode(1_020_006_008, "解锁客户失败,它已经处于未锁定状态"); - ErrorCode CUSTOMER_LOCK_EXCEED_LIMIT = new ErrorCode(1_020_006_009, "锁定客户失败,超出锁定规则上限"); - ErrorCode CUSTOMER_OWNER_EXCEED_LIMIT = new ErrorCode(1_020_006_010, "操作失败,超出客户数拥有上限"); - ErrorCode CUSTOMER_DELETE_FAIL_HAVE_REFERENCE = new ErrorCode(1_020_006_011, "删除客户失败,有关联{}"); - ErrorCode CUSTOMER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_020_006_012, "导入客户数据不能为空!"); - ErrorCode CUSTOMER_CREATE_NAME_NOT_NULL = new ErrorCode(1_020_006_013, "客户名称不能为空!"); - ErrorCode CUSTOMER_NAME_EXISTS = new ErrorCode(1_020_006_014, "已存在名为【{}】的客户!"); - ErrorCode CUSTOMER_UPDATE_DEAL_STATUS_FAIL = new ErrorCode(1_020_006_015, "更新客户的成交状态失败,原因:已经是该状态,无需更新"); - - // ========== 权限管理 1_020_007_000 ========== - ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); - ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); - ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:转移对象已经是该负责人"); - ErrorCode CRM_PERMISSION_DELETE_FAIL = new ErrorCode(1_020_007_004, "删除数据权限失败,原因:批量删除权限的时候,只能属于同一个 bizId 下"); - ErrorCode CRM_PERMISSION_DELETE_DENIED = new ErrorCode(1_020_007_006, "删除数据权限失败,原因:没有权限"); - ErrorCode CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_007, "删除数据权限失败,原因:不能删除负责人"); - ErrorCode CRM_PERMISSION_CREATE_FAIL = new ErrorCode(1_020_007_008, "创建数据权限失败,原因:所加用户已有权限"); - ErrorCode CRM_PERMISSION_CREATE_FAIL_EXISTS = new ErrorCode(1_020_007_009, "同时添加数据权限失败,原因:用户【{}】已有模块【{}】数据【{}】的【{}】权限"); - - // ========== 产品 1_020_008_000 ========== - ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在"); - ErrorCode PRODUCT_NO_EXISTS = new ErrorCode(1_020_008_001, "产品编号已存在"); - ErrorCode PRODUCT_NOT_ENABLE = new ErrorCode(1_020_008_002, "产品【{}】已禁用"); - - // ========== 产品分类 1_020_009_000 ========== - ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_EXISTS = new ErrorCode(1_020_009_001, "产品分类已存在"); - ErrorCode PRODUCT_CATEGORY_USED = new ErrorCode(1_020_009_002, "产品分类已关联产品"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_020_009_003, "父分类不存在"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_020_009_004, "父分类不能是二级分类"); - ErrorCode PRODUCT_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_020_009_005, "存在子分类,无法删除"); - - // ========== 商机状态 1_020_010_000 ========== - ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态组不存在"); - ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态组的名称已存在"); - ErrorCode BUSINESS_STATUS_UPDATE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行更新"); - ErrorCode BUSINESS_STATUS_DELETE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行删除"); - ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_010_003, "商机状态不存在"); - - // ========== 客户公海规则设置 1_020_012_000 ========== - ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_001, "客户限制配置不存在"); - - // ========== 跟进记录 1_020_013_000 ========== - ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在"); - ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限"); - - // ========== 数据统计 1_020_014_000 ========== - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java deleted file mode 100644 index aeeed316d..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -/** - * CRM 操作日志枚举 - * 目的:统一管理,也减少 Service 里各种“复杂”字符串 - * - * @author HUIHUI - */ -public interface LogRecordConstants { - - // ======================= CRM_CLUE 线索 ======================= - - String CRM_CLUE_TYPE = "CRM 线索"; - String CRM_CLUE_CREATE_SUB_TYPE = "创建线索"; - String CRM_CLUE_CREATE_SUCCESS = "创建了线索{{#clue.name}}"; - String CRM_CLUE_UPDATE_SUB_TYPE = "更新线索"; - String CRM_CLUE_UPDATE_SUCCESS = "更新了线索【{{#clueName}}】: {_DIFF{#updateReq}}"; - String CRM_CLUE_DELETE_SUB_TYPE = "删除线索"; - String CRM_CLUE_DELETE_SUCCESS = "删除了线索【{{#clueName}}】"; - String CRM_CLUE_TRANSFER_SUB_TYPE = "转移线索"; - String CRM_CLUE_TRANSFER_SUCCESS = "将线索【{{#clue.name}}】的负责人从【{getAdminUserById{#clue.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CLUE_TRANSLATE_SUB_TYPE = "线索转化为客户"; - String CRM_CLUE_TRANSLATE_SUCCESS = "将线索【{{#clueName}}】转化为客户"; - String CRM_CLUE_FOLLOW_UP_SUB_TYPE = "线索跟进"; - String CRM_CLUE_FOLLOW_UP_SUCCESS = "线索跟进【{{#clueName}}】"; - - // ======================= CRM_CUSTOMER 客户 ======================= - - String CRM_CUSTOMER_TYPE = "CRM 客户"; - String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户"; - String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}"; - String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户"; - String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}"; - String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户"; - String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】"; - String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户"; - String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#customer.name}}】的负责人从【{getAdminUserById{#customer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#customer.lockStatus ? '解锁客户' : '锁定客户'}}"; - String CRM_CUSTOMER_LOCK_SUCCESS = "{{#customer.lockStatus ? '将客户【' + #customer.name + '】解锁' : '将客户【' + #customer.name + '】锁定'}}"; - String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海"; - String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海"; - String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; - String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}"; - String CRM_CUSTOMER_IMPORT_SUB_TYPE = "{{#isUpdate ? '导入并更新客户' : '导入客户'}}"; - String CRM_CUSTOMER_IMPORT_SUCCESS = "{{#isUpdate ? '导入并更新了客户【'+ #customer.name +'】' : '导入了客户【'+ #customer.name +'】'}}"; - String CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUB_TYPE = "更新客户成交状态"; - String CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUCCESS = "更新了客户【{{#customerName}}】的成交状态为【{{#dealStatus ? '已成交' : '未成交'}}】"; - String CRM_CUSTOMER_FOLLOW_UP_SUB_TYPE = "客户跟进"; - String CRM_CUSTOMER_FOLLOW_UP_SUCCESS = "客户跟进【{{#customerName}}】"; - - // ======================= CRM_CUSTOMER_LIMIT_CONFIG 客户限制配置 ======================= - - String CRM_CUSTOMER_LIMIT_CONFIG_TYPE = "CRM 客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE = "创建客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS = "创建了【{{#limitType}}】类型的客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE = "更新客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS = "更新了客户限制配置: {_DIFF{#updateReqVO}}"; - String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE = "删除客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS = "删除了【{{#limitType}}】类型的客户限制配置"; - - // ======================= CRM_CUSTOMER_POOL_CONFIG 客户公海规则 ======================= - - String CRM_CUSTOMER_POOL_CONFIG_TYPE = "CRM 客户公海规则"; - String CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新客户公海规则' : '创建客户公海规则'}}"; - String CRM_CUSTOMER_POOL_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了客户公海规则' : '创建了客户公海规则'}}"; - - // ======================= CRM_CONTACT 联系人 ======================= - - String CRM_CONTACT_TYPE = "CRM 联系人"; - String CRM_CONTACT_CREATE_SUB_TYPE = "创建联系人"; - String CRM_CONTACT_CREATE_SUCCESS = "创建了联系人{{#contact.name}}"; - String CRM_CONTACT_UPDATE_SUB_TYPE = "更新联系人"; - String CRM_CONTACT_UPDATE_SUCCESS = "更新了联系人【{{#contactName}}】: {_DIFF{#updateReqVO}}"; - String CRM_CONTACT_DELETE_SUB_TYPE = "删除联系人"; - String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】"; - String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人"; - String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CONTACT_FOLLOW_UP_SUB_TYPE = "联系人跟进"; - String CRM_CONTACT_FOLLOW_UP_SUCCESS = "联系人跟进【{{#contactName}}】"; - String CRM_CONTACT_UPDATE_OWNER_USER_SUB_TYPE = "更新联系人负责人"; - String CRM_CONTACT_UPDATE_OWNER_USER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#ownerUserId}}】"; - - // ======================= CRM_BUSINESS 商机 ======================= - - String CRM_BUSINESS_TYPE = "CRM 商机"; - String CRM_BUSINESS_CREATE_SUB_TYPE = "创建商机"; - String CRM_BUSINESS_CREATE_SUCCESS = "创建了商机{{#business.name}}"; - String CRM_BUSINESS_UPDATE_SUB_TYPE = "更新商机"; - String CRM_BUSINESS_UPDATE_SUCCESS = "更新了商机【{{#businessName}}】: {_DIFF{#updateReqVO}}"; - String CRM_BUSINESS_DELETE_SUB_TYPE = "删除商机"; - String CRM_BUSINESS_DELETE_SUCCESS = "删除了商机【{{#businessName}}】"; - String CRM_BUSINESS_TRANSFER_SUB_TYPE = "转移商机"; - String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_BUSINESS_FOLLOW_UP_SUB_TYPE = "商机跟进"; - String CRM_BUSINESS_FOLLOW_UP_SUCCESS = "商机跟进【{{#businessName}}】"; - String CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE = "更新商机状态"; - String CRM_BUSINESS_UPDATE_STATUS_SUCCESS = "更新了商机【{{#businessName}}】的状态从【{{#oldStatusName}}】变更为了【{{#newStatusName}}】"; - - // ======================= CRM_CONTRACT_CONFIG 合同配置 ======================= - - String CRM_CONTRACT_CONFIG_TYPE = "CRM 合同配置"; - String CRM_CONTRACT_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新合同配置' : '创建合同配置'}}"; - String CRM_CONTRACT_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了合同配置' : '创建了合同配置'}}"; - - // ======================= CRM_CONTRACT 合同 ======================= - - String CRM_CONTRACT_TYPE = "CRM 合同"; - String CRM_CONTRACT_CREATE_SUB_TYPE = "创建合同"; - String CRM_CONTRACT_CREATE_SUCCESS = "创建了合同{{#contract.name}}"; - String CRM_CONTRACT_UPDATE_SUB_TYPE = "更新合同"; - String CRM_CONTRACT_UPDATE_SUCCESS = "更新了合同【{{#contractName}}】: {_DIFF{#updateReqVO}}"; - String CRM_CONTRACT_DELETE_SUB_TYPE = "删除合同"; - String CRM_CONTRACT_DELETE_SUCCESS = "删除了合同【{{#contractName}}】"; - String CRM_CONTRACT_TRANSFER_SUB_TYPE = "转移合同"; - String CRM_CONTRACT_TRANSFER_SUCCESS = "将合同【{{#contract.name}}】的负责人从【{getAdminUserById{#contract.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CONTRACT_SUBMIT_SUB_TYPE = "提交合同审批"; - String CRM_CONTRACT_SUBMIT_SUCCESS = "提交合同【{{#contractName}}】审批成功"; - String CRM_CONTRACT_FOLLOW_UP_SUB_TYPE = "合同跟进"; - String CRM_CONTRACT_FOLLOW_UP_SUCCESS = "合同跟进【{{#contractName}}】"; - - // ======================= CRM_PRODUCT 产品 ======================= - - String CRM_PRODUCT_TYPE = "CRM 产品"; - String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品"; - String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】"; - String CRM_PRODUCT_UPDATE_SUB_TYPE = "更新产品"; - String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}"; - String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品"; - String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】"; - - // ======================= CRM_PRODUCT_CATEGORY 产品分类 ======================= - - String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类"; - String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类"; - String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】"; - String CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE = "更新产品分类"; - String CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS = "更新了产品分类【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}"; - String CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE = "删除产品分类"; - String CRM_PRODUCT_CATEGORY_DELETE_SUCCESS = "删除了产品分类【{{#productCategory.name}}】"; - - // ======================= CRM_RECEIVABLE 回款 ======================= - - String CRM_RECEIVABLE_TYPE = "CRM 回款"; - String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款"; - String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款"; - String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款"; - String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款: {_DIFF{#updateReqVO}}"; - String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款"; - String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款"; - String CRM_RECEIVABLE_SUBMIT_SUB_TYPE = "提交回款审批"; - String CRM_RECEIVABLE_SUBMIT_SUCCESS = "提交编号为【{{#receivableNo}}】的回款审批成功"; - - // ======================= CRM_RECEIVABLE_PLAN 回款计划 ======================= - - String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划"; - String CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE = "创建回款计划"; - String CRM_RECEIVABLE_PLAN_CREATE_SUCCESS = "创建了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划"; - String CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE = "更新回款计划"; - String CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划: {_DIFF{#updateReqVO}}"; - String CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE = "删除回款计划"; - String CRM_RECEIVABLE_PLAN_DELETE_SUCCESS = "删除了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划"; - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java deleted file mode 100644 index 4736c01b7..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.business; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 商机的结束状态枚举 - * - * @author lzxhqs - */ -@RequiredArgsConstructor -@Getter -public enum CrmBusinessEndStatusEnum implements IntArrayValuable { - - WIN(1, "赢单"), - LOSE(2, "输单"), - INVALID(3, "无效"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBusinessEndStatusEnum::getStatus).toArray(); - - /** - * 场景类型 - */ - private final Integer status; - /** - * 场景名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static CrmBusinessEndStatusEnum fromStatus(Integer status) { - return Arrays.stream(values()) - .filter(value -> value.getStatus().equals(status)) - .findFirst() - .orElse(null); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java deleted file mode 100644 index 67709e95b..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * CRM 的审批状态 - * - * @author 赤焰 - */ -@RequiredArgsConstructor -@Getter -public enum CrmAuditStatusEnum implements IntArrayValuable { - - DRAFT(0, "未提交"), - PROCESS(10, "审批中"), - APPROVE(20, "审核通过"), - REJECT(30, "审核不通过"), - CANCEL(40, "已取消"); - - private final Integer status; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmAuditStatusEnum::getStatus).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java deleted file mode 100644 index 8402ad288..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * CRM 业务类型枚举 - * - * @author HUIHUI - */ -@RequiredArgsConstructor -@Getter -public enum CrmBizTypeEnum implements IntArrayValuable { - - CRM_CLUE(1, "线索"), - CRM_CUSTOMER(2, "客户"), - CRM_CONTACT(3, "联系人"), - CRM_BUSINESS(4, "商机"), - CRM_CONTRACT(5, "合同"), - CRM_PRODUCT(6, "产品"), - CRM_RECEIVABLE(7, "回款"), - CRM_RECEIVABLE_PLAN(8, "回款计划") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - public static String getNameByType(Integer type) { - CrmBizTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmBizTypeEnum.values()), - item -> ObjUtil.equal(item.type, type)); - return typeEnum == null ? null : typeEnum.getName(); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java deleted file mode 100644 index 945d7c6a3..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 列表检索场景 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmSceneTypeEnum implements IntArrayValuable { - - OWNER(1, "我负责的"), - INVOLVED(2, "我参与的"), - SUBORDINATE(3, "下属负责的"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray(); - - /** - * 场景类型 - */ - private final Integer type; - /** - * 场景名称 - */ - private final String name; - - public static boolean isOwner(Integer type) { - return ObjUtil.equal(OWNER.getType(), type); - } - - public static boolean isInvolved(Integer type) { - return ObjUtil.equal(INVOLVED.getType(), type); - } - - public static boolean isSubordinate(Integer type) { - return ObjUtil.equal(SUBORDINATE.getType(), type); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java deleted file mode 100644 index aa06b05eb..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.customer; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 客户等级 - * - * @author Wanwan - */ -@Getter -@AllArgsConstructor -public enum CrmCustomerLevelEnum implements IntArrayValuable { - - IMPORTANT(1, "A(重点客户)"), - GENERAL(2, "B(普通客户)"), - LOW_PRIORITY(3, "C(非优先客户)"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLevelEnum::getLevel).toArray(); - - /** - * 状态 - */ - private final Integer level; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java deleted file mode 100644 index 2cf8d7811..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 客户限制配置规则类型 - * - * @author Wanwan - */ -@Getter -@AllArgsConstructor -public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable { - - /** - * 拥有客户数限制 - */ - CUSTOMER_OWNER_LIMIT(1, "拥有客户数限制"), - /** - * 锁定客户数限制 - */ - CUSTOMER_LOCK_LIMIT(2, "锁定客户数限制"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getType).toArray(); - - /** - * 状态 - */ - private final Integer type; - /** - * 状态名 - */ - private final String name; - - public static String getNameByType(Integer type) { - CrmCustomerLimitConfigTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmCustomerLimitConfigTypeEnum.values()), - item -> ObjUtil.equal(item.type, type)); - return typeEnum == null ? null : typeEnum.getName(); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java deleted file mode 100644 index f36e8cfff..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 数据权限级别枚举 - * - * OWNER > WRITE > READ - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmPermissionLevelEnum implements IntArrayValuable { - - OWNER(1, "负责人"), - READ(2, "只读"), - WRITE(3, "读写"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmPermissionLevelEnum::getLevel).toArray(); - - /** - * 级别 - */ - private final Integer level; - /** - * 级别名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isOwner(Integer level) { - return ObjUtil.equal(OWNER.level, level); - } - - public static boolean isRead(Integer level) { - return ObjUtil.equal(READ.level, level); - } - - public static boolean isWrite(Integer level) { - return ObjUtil.equal(WRITE.level, level); - } - - public static String getNameByLevel(Integer level) { - CrmPermissionLevelEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmPermissionLevelEnum.values()), - item -> ObjUtil.equal(item.level, level)); - return typeEnum == null ? null : typeEnum.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java deleted file mode 100644 index 9516c35c6..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.product; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 商品状态 - * - * @author ZanGe丶 - * @since 2023-11-30 21:53 - */ -@Getter -@AllArgsConstructor -public enum CrmProductStatusEnum implements IntArrayValuable { - - DISABLE(0, "下架"), - ENABLE(1, "上架"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmProductStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isEnable(Integer status) { - return ObjUtil.equal(ENABLE.status, status); - } - - public static boolean isDisable(Integer status) { - return ObjUtil.equal(DISABLE.status, status); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/receivable/CrmReceivableReturnTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/receivable/CrmReceivableReturnTypeEnum.java deleted file mode 100644 index 3c01fe95c..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/receivable/CrmReceivableReturnTypeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.receivable; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 回款方式枚举 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmReceivableReturnTypeEnum implements IntArrayValuable { - - CHECK(1, "支票"), - CASH(2, "现金"), - POSTAL_REMITTANCE(3, "邮政汇款"), - TELEGRAPHIC_TRANSFER(4, "电汇"), - ONLINE_TRANSFER(5, "网上转账"), - ALIPAY(6, "支付宝"), - WECHAT_PAY(7, "微信支付"), - OTHER(8, "其它"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmReceivableReturnTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/Dockerfile b/yudao-module-crm/yudao-module-crm-biz/Dockerfile deleted file mode 100644 index bdda8ac15..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-crm-biz -WORKDIR /yudao-module-crm-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-crm-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48089 端口 -EXPOSE 48089 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-crm/yudao-module-crm-biz/pom.xml b/yudao-module-crm/yudao-module-crm-biz/pom.xml deleted file mode 100644 index 93e4a8a5c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/pom.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-crm - ${revision} - - 4.0.0 - yudao-module-crm-biz - - ${project.artifactId} - - crm 包下,客户关系管理(Customer Relationship Management)。 - 例如说:客户、联系人、商机、合同、回款等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-crm-api - ${revision} - - - cn.iocoder.cloud - yudao-module-bpm-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/CrmServerApplication.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/CrmServerApplication.java deleted file mode 100644 index 36bc7e8e3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/CrmServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - *

- * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class CrmServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(CrmServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java deleted file mode 100644 index 5c4e2493e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java deleted file mode 100644 index f55bd8974..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ /dev/null @@ -1,222 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; - -@Tag(name = "管理后台 - CRM 商机") -@RestController -@RequestMapping("/crm/business") -@Validated -public class CrmBusinessController { - - @Resource - private CrmBusinessService businessService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmBusinessStatusService businessStatusTypeService; - @Resource - private CrmBusinessStatusService businessStatusService; - @Resource - private CrmProductService productService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建商机") - @PreAuthorize("@ss.hasPermission('crm:business:create')") - public CommonResult createBusiness(@Valid @RequestBody CrmBusinessSaveReqVO createReqVO) { - return success(businessService.createBusiness(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新商机") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult updateBusiness(@Valid @RequestBody CrmBusinessSaveReqVO updateReqVO) { - businessService.updateBusiness(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新商机状态") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult updateBusinessStatus(@Valid @RequestBody CrmBusinessUpdateStatusReqVO updateStatusReqVO) { - businessService.updateBusinessStatus(updateStatusReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商机") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:business:delete')") - public CommonResult deleteBusiness(@RequestParam("id") Long id) { - businessService.deleteBusiness(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商机") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult getBusiness(@RequestParam("id") Long id) { - CrmBusinessDO business = businessService.getBusiness(id); - return success(buildBusinessDetail(business)); - } - - private CrmBusinessRespVO buildBusinessDetail(CrmBusinessDO business) { - if (business == null) { - return null; - } - CrmBusinessRespVO businessVO = buildBusinessDetailList(Collections.singletonList(business)).get(0); - // 拼接产品项 - List businessProducts = businessService.getBusinessProductListByBusinessId(businessVO.getId()); - Map productMap = productService.getProductMap( - convertSet(businessProducts, CrmBusinessProductDO::getProductId)); - businessVO.setProducts(BeanUtils.toBean(businessProducts, CrmBusinessRespVO.Product.class, businessProductVO -> - MapUtils.findAndThen(productMap, businessProductVO.getProductId(), - product -> businessProductVO.setProductName(product.getName()) - .setProductNo(product.getNo()).setProductUnit(product.getUnit())))); - return businessVO; - } - - @GetMapping("/simple-all-list") - @Operation(summary = "获得联系人的精简列表") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getSimpleContactList() { - CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); - reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - PageResult pageResult = businessService.getBusinessPage(reqVO, getLoginUserId()); - return success(convertList(pageResult.getList(), business -> // 只返回 id、name 字段 - new CrmBusinessRespVO().setId(business.getId()).setName(business.getName()) - .setCustomerId(business.getCustomerId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得商机分页") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { - PageResult pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得商机分页,基于指定客户") - public CommonResult> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { - if (pageReqVO.getCustomerId() == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - PageResult pageResult = businessService.getBusinessPageByCustomerId(pageReqVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-contact") - @Operation(summary = "获得联系人的商机分页") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessContactPage(@Valid CrmBusinessPageReqVO pageReqVO) { - PageResult pageResult = businessService.getBusinessPageByContact(pageReqVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出商机 Excel") - @PreAuthorize("@ss.hasPermission('crm:business:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PAGE_SIZE_NONE); - List list = businessService.getBusinessPage(exportReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessRespVO.class, - buildBusinessDetailList(list)); - } - - public List buildBusinessDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(list, CrmBusinessDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(list, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 获得商机状态组 - Map statusTypeMap = businessStatusTypeService.getBusinessStatusTypeMap( - convertSet(list, CrmBusinessDO::getStatusTypeId)); - Map statusMap = businessStatusService.getBusinessStatusMap( - convertSet(list, CrmBusinessDO::getStatusId)); - // 2. 拼接数据 - return BeanUtils.toBean(list, CrmBusinessRespVO.class, businessVO -> { - // 2.1 设置客户名称 - MapUtils.findAndThen(customerMap, businessVO.getCustomerId(), customer -> businessVO.setCustomerName(customer.getName())); - // 2.2 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(businessVO.getCreator()), - user -> businessVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, businessVO.getOwnerUserId(), user -> { - businessVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> businessVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.3 设置商机状态 - MapUtils.findAndThen(statusTypeMap, businessVO.getStatusTypeId(), statusType -> businessVO.setStatusTypeName(statusType.getName())); - MapUtils.findAndThen(statusMap, businessVO.getStatusId(), status -> businessVO.setStatusName( - businessService.getBusinessStatusName(businessVO.getEndStatus(), status))); - }); - } - - @PutMapping("/transfer") - @Operation(summary = "商机转移") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult transferBusiness(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { - businessService.transferBusiness(reqVO, getLoginUserId()); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java deleted file mode 100644 index 016670527..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 商机状态") -@RestController -@RequestMapping("/crm/business-status") -@Validated -public class CrmBusinessStatusController { - - @Resource - private CrmBusinessStatusService businessStatusTypeService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建商机状态") - @PreAuthorize("@ss.hasPermission('crm:business-status:create')") - public CommonResult createBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO createReqVO) { - return success(businessStatusTypeService.createBusinessStatus(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商机状态") - @PreAuthorize("@ss.hasPermission('crm:business-status:update')") - public CommonResult updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO updateReqVO) { - businessStatusTypeService.updateBusinessStatus(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商机状态") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:business-status:delete')") - public CommonResult deleteBusinessStatusType(@RequestParam("id") Long id) { - businessStatusTypeService.deleteBusinessStatusType(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商机状态") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") - public CommonResult getBusinessStatusType(@RequestParam("id") Long id) { - CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id); - if (statusType == null) { - return success(null); - } - List statuses = businessStatusTypeService.getBusinessStatusListByTypeId(id); - return success(BeanUtils.toBean(statusType, CrmBusinessStatusRespVO.class, - statusTypeVO -> statusTypeVO.setStatuses(BeanUtils.toBean(statuses, CrmBusinessStatusRespVO.Status.class)))); - } - - @GetMapping("/page") - @Operation(summary = "获得商机状态分页") - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") - public CommonResult> getBusinessStatusPage(@Valid PageParam pageReqVO) { - // 1. 查询数据 - PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 2. 拼接数据 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), statusType -> Long.parseLong(statusType.getCreator()))); - Map deptMap = deptApi.getDeptMap( - convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds, Collection::stream)); - return success(BeanUtils.toBean(pageResult, CrmBusinessStatusRespVO.class, statusTypeVO -> { - statusTypeVO.setCreator(userMap.get(NumberUtils.parseLong(statusTypeVO.getCreator())).getNickname()); - statusTypeVO.setDeptNames(convertList(statusTypeVO.getDeptIds(), - deptId -> deptMap.containsKey(deptId) ? deptMap.get(deptId).getName() : null)); - })); - } - - @GetMapping("/type-simple-list") - @Operation(summary = "获得商机状态组列表") - public CommonResult> getBusinessStatusTypeSimpleList() { - List list = businessStatusTypeService.getBusinessStatusTypeList(); - // 过滤掉部门不匹配的 - Long deptId = adminUserApi.getUser(getLoginUserId()).getCheckedData().getDeptId(); - list.removeIf(statusType -> CollUtil.isNotEmpty(statusType.getDeptIds()) && !statusType.getDeptIds().contains(deptId)); - return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.class)); - } - - @GetMapping("/status-simple-list") - @Operation(summary = "获得商机状态列表") - @Parameter(name = "typeId", description = "商机状态组", required = true, example = "1024") - public CommonResult> getBusinessStatusSimpleList(@RequestParam("typeId") Long typeId) { - List list = businessStatusTypeService.getBusinessStatusListByTypeId(typeId); - return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.Status.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java deleted file mode 100644 index 0e47bf5be..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商机分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessPageReqVO extends PageParam { - - @Schema(description = "商机名称", example = "李四") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - - @Schema(description = "联系人编号", example = "10795") - private Long contactId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java deleted file mode 100644 index 49cdcb80b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - CRM 商机 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmBusinessRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("商机名称") - private String name; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example ="true") - @ExcelProperty("跟进状态") - private Boolean followUpStatus; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "下次联系时间") - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") - private Long statusTypeId; - @Schema(description = "商机状组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中") - @ExcelProperty("商机状态组") - private String statusTypeName; - - @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") - private Long statusId; - @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中") - @ExcelProperty("商机状态") - private String statusName; - - @Schema - @ExcelProperty("结束状态") - private Integer endStatus; - - @ExcelProperty("结束时的备注") - private String endRemark; - - @Schema(description = "预计成交日期") - @ExcelProperty("预计成交日期") - private LocalDateTime dealTime; - - @Schema(description = "产品总金额", example = "12025") - @ExcelProperty("产品总金额") - private BigDecimal totalProductPrice; - - @Schema(description = "整单折扣") - @ExcelProperty("整单折扣") - private BigDecimal discountPercent; - - @Schema(description = "商机总金额", example = "12371") - @ExcelProperty("商机总金额") - private BigDecimal totalPrice; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Product { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private Long productId; - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private String productNo; - @Schema(description = "产品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private Integer productUnit; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal productPrice; - - @Schema(description = "商机价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal businessPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - private BigDecimal count; - - @Schema(description = "总计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal totalPrice; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java deleted file mode 100644 index 86864dc0f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 商机创建/更新 Request VO") -@Data -public class CrmBusinessSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - private Long id; - - @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @DiffLogField(name = "商机名称") - @NotNull(message = "商机名称不能为空") - private String name; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - @NotNull(message = "客户不能为空") - private Long customerId; - - @Schema(description = "下次联系时间") - @DiffLogField(name = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人用户编号", example = "14334") - @NotNull(message = "负责人不能为空") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - private Long ownerUserId; - - @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") - @DiffLogField(name = "商机状态组") - @NotNull(message = "商机状态组不能为空") - private Long statusTypeId; - - @Schema(description = "预计成交日期") - @DiffLogField(name = "预计成交日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime dealTime; - - @Schema(description = "整单折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "55.00") - @DiffLogField(name = "整单折扣") - @NotNull(message = "整单折扣不能为空") - private BigDecimal discountPercent; - - @Schema(description = "备注", example = "随便") - @DiffLogField(name = "备注") - private String remark; - - @Schema(description = "联系人编号", example = "110") - private Long contactId; // 使用场景,在【联系人详情】添加商机时,如果需要关联两者,需要传递 contactId 字段 - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class BusinessProduct { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "产品单价不能为空") - private BigDecimal productPrice; - - @Schema(description = "商机价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "商机价格不能为空") - private BigDecimal businessPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "产品数量不能为空") - private Integer count; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java deleted file mode 100644 index da3a87fca..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商机转移 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessTransferReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "商机编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java deleted file mode 100644 index 3fe7d9f47..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 商机更新状态 Request VO") -@Data -public class CrmBusinessUpdateStatusReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - @NotNull(message = "商机编号不能为空") - private Long id; - - @Schema(description = "状态编号", example = "1") - private Long statusId; - - @Schema(description = "结束状态", example = "1") - @InEnum(value = CrmBusinessEndStatusEnum.class) - private Integer endStatus; - - @AssertTrue(message = "变更状态不正确") - public boolean isStatusValid() { - return statusId != null || endStatus != null; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java deleted file mode 100644 index a2ee1dfe5..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商机状态 Response VO") -@Data -public class CrmBusinessStatusRespVO { - - @Schema(description = "状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") - private Long id; - - @Schema(description = "状态组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) - private List deptIds; - @Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED) - private List deptNames; - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) - private String creator; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED) - private List statuses; - - @Data - public static class Status { - - @Schema(description = "状态编号", example = "23899") - private Long id; - - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private BigDecimal percent; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java deleted file mode 100644 index 42d6620e9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.util.List; - -@Schema(description = "管理后台 - 商机状态组新增/修改 Request VO") -@Data -public class CrmBusinessStatusSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") - private Long id; - - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "状态类型名不能为空") - private String name; - - @Schema(description = "使用的部门编号") - private List deptIds; - - @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "商机状态集合不能为空") - @Valid - private List statuses; - - @Data - public static class Status { - - @Schema(description = "状态编号", example = "23899") - private Long id; - - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "状态名不能为空") - private String name; - - @Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - @NotNull(message = "赢单率不能为空") - private BigDecimal percent; - - @Schema(description = "排序", hidden = true, example = "1") - private Integer sort; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java deleted file mode 100644 index 166268c2b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java +++ /dev/null @@ -1,173 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - 线索") -@RestController -@RequestMapping("/crm/clue") -@Validated -public class CrmClueController { - - @Resource - private CrmClueService clueService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建线索") - @PreAuthorize("@ss.hasPermission('crm:clue:create')") - public CommonResult createClue(@Valid @RequestBody CrmClueSaveReqVO createReqVO) { - return success(clueService.createClue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新线索") - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult updateClue(@Valid @RequestBody CrmClueSaveReqVO updateReqVO) { - clueService.updateClue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除线索") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:clue:delete')") - public CommonResult deleteClue(@RequestParam("id") Long id) { - clueService.deleteClue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得线索") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult getClue(@RequestParam("id") Long id) { - CrmClueDO clue = clueService.getClue(id); - return success(buildClueDetail(clue)); - } - - private CrmClueRespVO buildClueDetail(CrmClueDO clue) { - if (clue == null) { - return null; - } - return buildClueDetailList(singletonList(clue)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得线索分页") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult> getCluePage(@Valid CrmCluePageReqVO pageVO) { - PageResult pageResult = clueService.getCluePage(pageVO, getLoginUserId()); - return success(new PageResult<>(buildClueDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出线索 Excel") - @PreAuthorize("@ss.hasPermission('crm:clue:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportClueExcel(@Valid CrmCluePageReqVO pageReqVO, HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PAGE_SIZE_NONE); - List list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "线索.xls", "数据", CrmClueRespVO.class, buildClueDetailList(list)); - } - - private List buildClueDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(list, CrmClueDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(list, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 2. 转换成 VO - return BeanUtils.toBean(list, CrmClueRespVO.class, clueVO -> { - clueVO.setAreaName(AreaUtils.format(clueVO.getAreaId())); - // 2.1 设置客户名称 - MapUtils.findAndThen(customerMap, clueVO.getCustomerId(), customer -> clueVO.setCustomerName(customer.getName())); - // 2.2 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(clueVO.getCreator()), - user -> clueVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, clueVO.getOwnerUserId(), user -> { - clueVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> clueVO.setOwnerUserDeptName(dept.getName())); - }); - }); - } - - @PutMapping("/transfer") - @Operation(summary = "线索转移") - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult transferClue(@Valid @RequestBody CrmClueTransferReqVO reqVO) { - clueService.transferClue(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/transform") - @Operation(summary = "线索转化为客户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult transformClue(@RequestParam("id") Long id) { - clueService.transformClue(id, getLoginUserId()); - return success(Boolean.TRUE); - } - - @GetMapping("/follow-count") - @Operation(summary = "获得分配给我的、待跟进的线索数量") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult getFollowClueCount() { - return success(clueService.getFollowClueCount(getLoginUserId())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java deleted file mode 100644 index a63d946e9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 线索分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCluePageReqVO extends PageParam { - - @Schema(description = "线索名称", example = "线索xxx") - private String name; - - @Schema(description = "转化状态", example = "2048") - private Boolean transformStatus; - - @Schema(description = "电话", example = "18000000000") - private String telephone; - - @Schema(description = "手机号", example = "18000000000") - private String mobile; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean pool; // null 则表示为不是公海数据 - - @Schema(description = "所属行业", example = "1") - private Integer industryId; - - @Schema(description = "客户等级", example = "1") - private Integer level; - - @Schema(description = "客户来源", example = "1") - private Integer source; - - @Schema(description = "跟进状态", example = "true") - private Boolean followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java deleted file mode 100644 index 56e5c2561..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 线索 Response VO") -@Data -@ToString(callSuper = true) -@ExcelIgnoreUnannotated -public class CrmClueRespVO { - - @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @ExcelProperty("线索名称") - private String name; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean followUpStatus; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "最后跟进内容", example = "吃饭、睡觉、打逗逗") - @ExcelProperty("最后跟进内容") - private String contactLastContent; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "转化状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean transformStatus; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "客户名称") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "手机号", example = "18000000000") - @ExcelProperty("手机号") - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @ExcelProperty("电话") - private String telephone; - - @Schema(description = "QQ", example = "25682") - @ExcelProperty("QQ") - private String qq; - - @Schema(description = "wechat", example = "25682") - @ExcelProperty("wechat") - private String wechat; - - @Schema(description = "email", example = "25682") - @ExcelProperty("email") - private String email; - - @Schema(description = "地区编号", example = "1024") - @ExcelProperty("地区编号") - private Integer areaId; - @Schema(description = "地区名称", example = "北京市") - @ExcelProperty("地区名称") - private String areaName; - @Schema(description = "详细地址", example = "北京市成华大道") - @ExcelProperty("详细地址") - private String detailAddress; - - @Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL) - private Integer level; - - @Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE) - private Integer source; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java deleted file mode 100644 index aff2ad1eb..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerIndustryParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerLevelParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerSourceParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAreaParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; - -@Schema(description = "管理后台 - CRM 线索创建/更新 Request VO") -@Data -public class CrmClueSaveReqVO { - - @Schema(description = "编号", example = "10969") - private Long id; - - @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @DiffLogField(name = "线索名称") - @NotEmpty(message = "线索名称不能为空") - private String name; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @DiffLogField(name = "最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @DiffLogField(name = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人编号", example = "2048") - @NotNull(message = "负责人编号不能为空") - private Long ownerUserId; - - @Schema(description = "手机号", example = "18000000000") - @DiffLogField(name = "手机号") - @Mobile - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @DiffLogField(name = "电话") - @Telephone - private String telephone; - - @Schema(description = "QQ", example = "123456789") - @DiffLogField(name = "QQ") - @Size(max = 20, message = "QQ长度不能超过 20 个字符") - private String qq; - - @Schema(description = "微信", example = "123456789") - @DiffLogField(name = "微信") - @Size(max = 255, message = "微信长度不能超过 255 个字符") - private String wechat; - - @Schema(description = "邮箱", example = "123456789@qq.com") - @DiffLogField(name = "邮箱") - @Email(message = "邮箱格式不正确") - @Size(max = 255, message = "邮箱长度不能超过 255 个字符") - private String email; - - @Schema(description = "地区编号", example = "20158") - @DiffLogField(name = "地区编号", function = SysAreaParseFunction.NAME) - private Integer areaId; - - @Schema(description = "详细地址", example = "北京市海淀区") - @DiffLogField(name = "详细地址") - private String detailAddress; - - @Schema(description = "所属行业", example = "1") - @DiffLogField(name = "所属行业", function = CrmCustomerIndustryParseFunction.NAME) - @DictFormat(CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", example = "2") - @DiffLogField(name = "客户等级", function = CrmCustomerLevelParseFunction.NAME) - @InEnum(CrmCustomerLevelEnum.class) - private Integer level; - - @Schema(description = "客户来源", example = "3") - @DiffLogField(name = "客户来源", function = CrmCustomerSourceParseFunction.NAME) - private Integer source; - - @Schema(description = "客户描述", example = "任意文字") - @DiffLogField(name = "客户描述") - @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") - private String description; - - @Schema(description = "备注", example = "随便") - @DiffLogField(name = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java deleted file mode 100644 index d1a28694d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - 线索转移 Request VO") -@Data -public class CrmClueTransferReqVO { - - @Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "线索编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(value = CrmPermissionLevelEnum.class) - private Integer oldOwnerPermissionLevel; // 老负责人加入团队后的权限级别。如果 null 说明移除 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java deleted file mode 100644 index a9d2b35ee..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java +++ /dev/null @@ -1,226 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - CRM 联系人") -@RestController -@RequestMapping("/crm/contact") -@Validated -@Slf4j -public class CrmContactController { - - @Resource - private CrmContactService contactService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmContactBusinessService contactBusinessLinkService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建联系人") - @PreAuthorize("@ss.hasPermission('crm:contact:create')") - public CommonResult createContact(@Valid @RequestBody CrmContactSaveReqVO createReqVO) { - return success(contactService.createContact(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新联系人") - @PreAuthorize("@ss.hasPermission('crm:contact:update')") - public CommonResult updateContact(@Valid @RequestBody CrmContactSaveReqVO updateReqVO) { - contactService.updateContact(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contact:delete')") - public CommonResult deleteContact(@RequestParam("id") Long id) { - contactService.deleteContact(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得联系人") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult getContact(@RequestParam("id") Long id) { - CrmContactDO contact = contactService.getContact(id); - return success(buildContactDetail(contact)); - } - - private CrmContactRespVO buildContactDetail(CrmContactDO contact) { - if (contact == null) { - return null; - } - return buildContactDetailList(singletonList(contact)).get(0); - } - - @GetMapping("/simple-all-list") - @Operation(summary = "获得联系人的精简列表") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getSimpleContactList() { - List list = contactService.getContactList(getLoginUserId()); - return success(convertList(list, contact -> // 只返回 id、name 字段 - new CrmContactRespVO().setId(contact.getId()).setName(contact.getName()) - .setCustomerId(contact.getCustomerId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得联系人分页") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getContactPage(@Valid CrmContactPageReqVO pageVO) { - PageResult pageResult = contactService.getContactPage(pageVO, getLoginUserId()); - return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得联系人分页,基于指定客户") - public CommonResult> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { - Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = contactService.getContactPageByCustomerId(pageVO); - return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-business") - @Operation(summary = "获得联系人分页,基于指定商机") - public CommonResult> getContactPageByBusiness(@Valid CrmContactPageReqVO pageVO) { - Assert.notNull(pageVO.getBusinessId(), "商机编号不能为空"); - PageResult pageResult = contactService.getContactPageByBusinessId(pageVO); - return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出联系人 Excel") - @PreAuthorize("@ss.hasPermission('crm:contact:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageNo(PAGE_SIZE_NONE); - List list = contactService.getContactPage(exportReqVO, getLoginUserId()).getList(); - ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class, buildContactDetailList(list)); - } - - private List buildContactDetailList(List contactList) { - if (CollUtil.isEmpty(contactList)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(contactList, CrmContactDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 直属上级 Map - Map parentContactMap = contactService.getContactMap( - convertSet(contactList, CrmContactDO::getParentId)); - // 2. 转换成 VO - return BeanUtils.toBean(contactList, CrmContactRespVO.class, contactVO -> { - contactVO.setAreaName(AreaUtils.format(contactVO.getAreaId())); - // 2.1 设置客户名称 - MapUtils.findAndThen(customerMap, contactVO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); - // 2.2 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(contactVO.getCreator()), - user -> contactVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, contactVO.getOwnerUserId(), user -> { - contactVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> contactVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.3 设置直属上级名称 - findAndThen(parentContactMap, contactVO.getParentId(), contact -> contactVO.setParentName(contact.getName())); - }); - } - - @PutMapping("/transfer") - @Operation(summary = "联系人转移") - @PreAuthorize("@ss.hasPermission('crm:contact:update')") - public CommonResult transferContact(@Valid @RequestBody CrmContactTransferReqVO reqVO) { - contactService.transferContact(reqVO, getLoginUserId()); - return success(true); - } - - // ================== 关联/取关商机 =================== - - @PostMapping("/create-business-list") - @Operation(summary = "创建联系人与商机的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:create-business')") - public CommonResult createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) { - contactBusinessLinkService.createContactBusinessList(createReqVO); - return success(true); - } - - - @PostMapping("/create-business-list2") - @Operation(summary = "创建联系人与商机的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:create-business')") - public CommonResult createContactBusinessList2(@Valid @RequestBody CrmContactBusiness2ReqVO createReqVO) { - contactBusinessLinkService.createContactBusinessList2(createReqVO); - return success(true); - } - - @DeleteMapping("/delete-business-list") - @Operation(summary = "删除联系人与联系人的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:delete-business')") - public CommonResult deleteContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO deleteReqVO) { - contactBusinessLinkService.deleteContactBusinessList(deleteReqVO); - return success(true); - } - - @DeleteMapping("/delete-business-list2") - @Operation(summary = "删除联系人与联系人的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:delete-business')") - public CommonResult deleteContactBusinessList(@Valid @RequestBody CrmContactBusiness2ReqVO deleteReqVO) { - contactBusinessLinkService.deleteContactBusinessList2(deleteReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusiness2ReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusiness2ReqVO.java deleted file mode 100644 index edc07bf96..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusiness2ReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 【商机关联联系人】用于关联,取消关联的操作 -@Data -public class CrmContactBusiness2ReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") - @NotNull(message="商机不能为空") - private Long businessId; - - @Schema(description = "联系人编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") - @NotEmpty(message="联系人数组不能为空") - private List contactIds; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java deleted file mode 100644 index c0be78698..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 【联系人关联商机】用于关联,取消关联的操作 -@Data -public class CrmContactBusinessReqVO { - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") - @NotNull(message="联系人不能为空") - private Long contactId; - - @Schema(description = "商机编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") - @NotEmpty(message="商机不能为空") - private List businessIds; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java deleted file mode 100644 index 6698a3855..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 联系人分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContactPageReqVO extends PageParam { - - @Schema(description = "姓名", example = "芋艿") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - - @Schema(description = "手机号", example = "13898273941") - private String mobile; - - @Schema(description = "电话", example = "021-383773") - private String telephone; - - @Schema(description = "电子邮箱", example = "111@22.com") - private String email; - - @Schema(description = "QQ", example = "3882872") - private Long qq; - - @Schema(description = "微信", example = "zzZ98373") - private String wechat; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "商机编号", example = "10430") - private Long businessId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java deleted file mode 100644 index b2b1e8384..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 联系人 Response VO") -@Data -@ToString(callSuper = true) -@ExcelIgnoreUnannotated -public class CrmContactRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "联系人姓名", example = "芋艿") - @ExcelProperty(value = "联系人姓名", order = 1) - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - @ExcelProperty(value = "客户名称", order = 2) - @Schema(description = "客户名字", example = "test") - private String customerName; - - @Schema(description = "最后跟进时间") - @ExcelProperty(value = "最后跟进时间", order = 6) - private LocalDateTime contactLastTime; - - @Schema(description = "最后跟进内容") - @ExcelProperty(value = "最后跟进内容", order = 6) - private String contactLastContent; - - @Schema(description = "下次联系时间") - @ExcelProperty(value = "下次联系时间", order = 6) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "手机号", example = "1387171766") - @ExcelProperty(value = "手机号", order = 4) - private String mobile; - - @Schema(description = "电话", example = "021-0029922") - @ExcelProperty(value = "电话", order = 4) - private String telephone; - - @Schema(description = "电子邮箱", example = "1111@22.com") - @ExcelProperty(value = "邮箱", order = 4) - private String email; - - @Schema(description = "QQ", example = "197272662") - @ExcelProperty(value = "QQ", order = 4) - private Long qq; - - @Schema(description = "微信", example = "zzz3883") - @ExcelProperty(value = "微信", order = 4) - private String wechat; - - @Schema(description = "地区编号", example = "20158") - private Integer areaId; - @Schema(description = "地区名", example = "上海上海市浦东新区") - @ExcelProperty(value = "地区", order = 5) - private String areaName; - - @Schema(description = "地址") - @ExcelProperty(value = "地址", order = 5) - private String detailAddress; - - @Schema(description = "性别") - @ExcelProperty(value = "性别", converter = DictConvert.class, order = 3) - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX) - private Integer sex; - - @Schema(description = "是否关键决策人") - @ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean master; - - @Schema(description = "职位") - @ExcelProperty(value = "职位", order = 3) - private String post; - - @Schema(description = "直属上级", example = "23457") - private Long parentId; - @Schema(description = "直属上级名", example = "芋头") - @ExcelProperty(value = "直属上级", order = 4) - private String parentName; - - @Schema(description = "备注", example = "你说的对") - @ExcelProperty(value = "备注", order = 6) - private String remark; - - @Schema(description = "创建人", example = "25682") - private String creator; - @Schema(description = "创建人名字", example = "test") - @ExcelProperty(value = "创建人", order = 8) - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java deleted file mode 100644 index dd5f9d86c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.*; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotNull; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO") -@Data -public class CrmContactSaveReqVO { - - @Schema(description = "主键", example = "3167") - private Long id; - - @Schema(description = "姓名", example = "芋艿") - @NotNull(message = "姓名不能为空") - @DiffLogField(name = "姓名") - private String name; - - @Schema(description = "客户编号", example = "10795") - @NotNull(message = "客户编号不能为空") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - private Long customerId; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - @DiffLogField(name = "下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人用户编号", example = "14334") - @NotNull(message = "负责人不能为空") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - private Long ownerUserId; - - @Schema(description = "手机号", example = "1387171766") - @Mobile - @DiffLogField(name = "手机号") - private String mobile; - - @Schema(description = "电话", example = "021-0029922") - @Telephone - @DiffLogField(name = "电话") - private String telephone; - - @Schema(description = "QQ", example = "197272662") - @DiffLogField(name = "QQ") - private Long qq; - - @Schema(description = "微信", example = "zzz3883") - @DiffLogField(name = "微信") - private String wechat; - - @Schema(description = "电子邮箱", example = "1111@22.com") - @DiffLogField(name = "邮箱") - @Email - private String email; - - @Schema(description = "地区编号", example = "20158") - @DiffLogField(name = "所在地", function = SysAreaParseFunction.NAME) - private Integer areaId; - - @Schema(description = "地址") - @DiffLogField(name = "地址") - private String detailAddress; - - @Schema(description = "性别") - @DiffLogField(name = "性别", function = SysSexParseFunction.NAME) - private Integer sex; - - @Schema(description = "是否关键决策人") - @DiffLogField(name = "关键决策人", function = SysBooleanParseFunction.NAME) - private Boolean master; - - @Schema(description = "职位") - @DiffLogField(name = "职位") - private String post; - - @Schema(description = "直属上级", example = "23457") - @DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME) - private Long parentId; - - @Schema(description = "备注", example = "你说的对") - @DiffLogField(name = "备注") - private String remark; - - @Schema(description = "关联商机 ID", example = "122233") - private Long businessId; // 注意:该字段用于在【商机】详情界面「新建联系人」时,自动进行关联 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java deleted file mode 100644 index 4f94ee2ac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 联系人转移 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactTransferReqVO { - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractConfigController.java deleted file mode 100644 index 369260fcb..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 合同配置") -@RestController -@RequestMapping("/crm/contract-config") -@Validated -public class CrmContractConfigController { - - @Resource - private CrmContractConfigService contractConfigService; - - @GetMapping("/get") - @Operation(summary = "获取合同配置") - @PreAuthorize("@ss.hasPermission('crm:contract-config:query')") - public CommonResult getCustomerPoolConfig() { - CrmContractConfigDO config = contractConfigService.getContractConfig(); - return success(BeanUtils.toBean(config, CrmContractConfigRespVO.class)); - } - - @PutMapping("/save") - @Operation(summary = "更新合同配置") - @PreAuthorize("@ss.hasPermission('crm:contract-config:update')") - public CommonResult saveCustomerPoolConfig(@Valid @RequestBody CrmContractConfigSaveReqVO updateReqVO) { - contractConfigService.saveContractConfig(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java deleted file mode 100644 index 225ef13dc..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java +++ /dev/null @@ -1,256 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - CRM 合同") -@RestController -@RequestMapping("/crm/contract") -@Validated -public class CrmContractController { - - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmContactService contactService; - @Resource - private CrmBusinessService businessService; - @Resource - private CrmProductService productService; - @Resource - private CrmReceivableService receivableService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建合同") - @PreAuthorize("@ss.hasPermission('crm:contract:create')") - public CommonResult createContract(@Valid @RequestBody CrmContractSaveReqVO createReqVO) { - return success(contractService.createContract(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新合同") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult updateContract(@Valid @RequestBody CrmContractSaveReqVO updateReqVO) { - contractService.updateContract(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除合同") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contract:delete')") - public CommonResult deleteContract(@RequestParam("id") Long id) { - contractService.deleteContract(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得合同") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getContract(@RequestParam("id") Long id) { - CrmContractDO contract = contractService.getContract(id); - return success(buildContractDetail(contract)); - } - - private CrmContractRespVO buildContractDetail(CrmContractDO contract) { - if (contract == null) { - return null; - } - CrmContractRespVO contractVO = buildContractDetailList(singletonList(contract)).get(0); - // 拼接产品项 - List businessProducts = contractService.getContractProductListByContractId(contractVO.getId()); - Map productMap = productService.getProductMap( - convertSet(businessProducts, CrmContractProductDO::getProductId)); - contractVO.setProducts(BeanUtils.toBean(businessProducts, CrmContractRespVO.Product.class, businessProductVO -> - MapUtils.findAndThen(productMap, businessProductVO.getProductId(), - product -> businessProductVO.setProductName(product.getName()) - .setProductNo(product.getNo()).setProductUnit(product.getUnit())))); - return contractVO; - } - - @GetMapping("/page") - @Operation(summary = "获得合同分页") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractPage(@Valid CrmContractPageReqVO pageVO) { - PageResult pageResult = contractService.getContractPage(pageVO, getLoginUserId()); - return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得合同分页,基于指定客户") - public CommonResult> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { - Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = contractService.getContractPageByCustomerId(pageVO); - return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); - } - - @GetMapping("/page-by-business") - @Operation(summary = "获得合同分页,基于指定商机") - public CommonResult> getContractPageByBusiness(@Valid CrmContractPageReqVO pageVO) { - Assert.notNull(pageVO.getBusinessId(), "商机编号不能为空"); - PageResult pageResult = contractService.getContractPageByBusinessId(pageVO); - return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出合同 Excel") - @PreAuthorize("@ss.hasPermission('crm:contract:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - PageResult pageResult = contractService.getContractPage(exportReqVO, getLoginUserId()); - // 导出 Excel - ExcelUtils.write(response, "合同.xls", "数据", CrmContractRespVO.class, - BeanUtils.toBean(pageResult.getList(), CrmContractRespVO.class)); - } - - @PutMapping("/transfer") - @Operation(summary = "合同转移") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult transferContract(@Valid @RequestBody CrmContractTransferReqVO reqVO) { - contractService.transferContract(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/submit") - @Operation(summary = "提交合同审批") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult submitContract(@RequestParam("id") Long id) { - contractService.submitContract(id, getLoginUserId()); - return success(true); - } - - private List buildContractDetailList(List contractList) { - if (CollUtil.isEmpty(contractList)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(contractList, CrmContractDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contractList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 获取联系人 - Map contactMap = convertMap(contactService.getContactList(convertSet(contractList, - CrmContractDO::getSignContactId)), CrmContactDO::getId); - // 1.4 获取商机 - Map businessMap = businessService.getBusinessMap( - convertSet(contractList, CrmContractDO::getBusinessId)); - // 1.5 获得已回款金额 - Map receivablePriceMap = receivableService.getReceivablePriceMapByContractId( - convertSet(contractList, CrmContractDO::getId)); - // 2. 拼接数据 - return BeanUtils.toBean(contractList, CrmContractRespVO.class, contractVO -> { - // 2.1 设置客户信息 - findAndThen(customerMap, contractVO.getCustomerId(), customer -> contractVO.setCustomerName(customer.getName())); - // 2.2 设置用户信息 - findAndThen(userMap, Long.parseLong(contractVO.getCreator()), user -> contractVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, contractVO.getOwnerUserId(), user -> { - contractVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> contractVO.setOwnerUserDeptName(dept.getName())); - }); - findAndThen(userMap, contractVO.getSignUserId(), user -> contractVO.setSignUserName(user.getNickname())); - // 2.3 设置联系人信息 - findAndThen(contactMap, contractVO.getSignContactId(), contact -> contractVO.setSignContactName(contact.getName())); - // 2.4 设置商机信息 - findAndThen(businessMap, contractVO.getBusinessId(), business -> contractVO.setBusinessName(business.getName())); - // 2.5 设置已回款金额 - contractVO.setTotalReceivablePrice(receivablePriceMap.getOrDefault(contractVO.getId(), BigDecimal.ZERO)); - }); - } - - @GetMapping("/audit-count") - @Operation(summary = "获得待审核合同数量") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getAuditContractCount() { - return success(contractService.getAuditContractCount(getLoginUserId())); - } - - @GetMapping("/remind-count") - @Operation(summary = "获得即将到期(提醒)的合同数量") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getRemindContractCount() { - return success(contractService.getRemindContractCount(getLoginUserId())); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得合同精简列表", description = "只包含的合同,主要用于前端的下拉选项") - @Parameter(name = "customerId", description = "客户编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractSimpleList(@RequestParam("customerId") Long customerId) { - CrmContractPageReqVO pageReqVO = new CrmContractPageReqVO().setCustomerId(customerId); - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); // 不分页 - PageResult pageResult = contractService.getContractPageByCustomerId(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(Collections.emptyList()); - } - // 拼接数据 - Map receivablePriceMap = receivableService.getReceivablePriceMapByContractId( - convertSet(pageResult.getList(), CrmContractDO::getId)); - return success(convertList(pageResult.getList(), contract -> new CrmContractRespVO() // 只返回 id、name 等精简字段 - .setId(contract.getId()).setName(contract.getName()).setAuditStatus(contract.getAuditStatus()) - .setTotalPrice(contract.getTotalPrice()) - .setTotalReceivablePrice(receivablePriceMap.getOrDefault(contract.getId(), BigDecimal.ZERO)))); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigRespVO.java deleted file mode 100644 index c39cf9269..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 合同配置 Response VO") -@Data -public class CrmContractConfigRespVO { - - @Schema(description = "是否开启提前提醒", example = "true") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigSaveReqVO.java deleted file mode 100644 index 2eb79d8e0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigSaveReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config; - -import cn.hutool.core.util.BooleanUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import java.util.Objects; - -@Schema(description = "管理后台 - CRM 合同配置 Request VO") -@Data -public class CrmContractConfigSaveReqVO { - - @Schema(description = "是否开启提前提醒", example = "true") - @DiffLogField(name = "是否开启提前提醒") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - @DiffLogField(name = "提前提醒天数") - private Integer notifyDays; - - @AssertTrue(message = "提前提醒天数不能为空") - @JsonIgnore - public boolean isNotifyDaysValid() { - if (!BooleanUtil.isTrue(getNotifyEnabled())) { - return true; - } - return Objects.nonNull(getNotifyDays()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractPageReqVO.java deleted file mode 100644 index 74f8008b8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractPageReqVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 合同分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContractPageReqVO extends PageParam { - - /** - * 过期类型 - 即将过期 - */ - public static final Integer EXPIRY_TYPE_ABOUT_TO_EXPIRE = 1; - /** - * 过期类型 - 已过期 - */ - public static final Integer EXPIRY_TYPE_EXPIRED = 2; - - @Schema(description = "合同编号", example = "XYZ008") - private String no; - - @Schema(description = "合同名称", example = "王五") - private String name; - - @Schema(description = "客户编号", example = "18336") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - private Long businessId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "审批状态", example = "20") - @InEnum(CrmAuditStatusEnum.class) - private Integer auditStatus; - - @Schema(description = "过期类型", example = "1") - private Integer expiryType; // 过期类型,为 null 时则表示全部 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractRespVO.java deleted file mode 100644 index a01bc110b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractRespVO.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - CRM 合同 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmContractRespVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @ExcelProperty("合同编号") - private Long id; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @ExcelProperty("合同名称") - private String name; - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20230101") - @ExcelProperty("合同编号") - private String no; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") - @ExcelProperty("客户编号") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "商机编号", example = "10864") - @ExcelProperty("商机编号") - private Long businessId; - @Schema(description = "商机名称", example = "10864") - @ExcelProperty("商机名称") - private String businessName; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "工作流编号", example = "1043") - @ExcelProperty("工作流编号") - private String processInstanceId; - - @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @ExcelProperty("审批状态") - private Integer auditStatus; - - @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("下单日期") - private LocalDateTime orderDate; - - @Schema(description = "开始时间") - @ExcelProperty("开始时间") - private LocalDateTime startTime; - - @Schema(description = "结束时间") - @ExcelProperty("结束时间") - private LocalDateTime endTime; - - @Schema(description = "产品总金额", example = "19510") - @ExcelProperty("产品总金额") - private BigDecimal totalProductPrice; - - @Schema(description = "整单折扣") - @ExcelProperty("整单折扣") - private BigDecimal discountPercent; - - @Schema(description = "合同金额", example = "5617") - @ExcelProperty("合同金额") - private BigDecimal totalPrice; - - @Schema(description = "已回款金额", example = "5617") - @ExcelProperty("已回款金额") - private BigDecimal totalReceivablePrice; - - @Schema(description = "客户签约人编号", example = "18546") - private Long signContactId; - @Schema(description = "客户签约人", example = "小豆") - @ExcelProperty("客户签约人") - private String signContactName; - - @Schema(description = "公司签约人", example = "14036") - private Long signUserId; - @Schema(description = "公司签约人", example = "小明") - @ExcelProperty("公司签约人") - private String signUserName; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "创建人", example = "25682") - @ExcelProperty("创建人") - private String creator; - - @Schema(description = "创建人名字", example = "test") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Product { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private Long productId; - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private String productNo; - @Schema(description = "产品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private Integer productUnit; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal productPrice; - - @Schema(description = "合同价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal contractPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - private BigDecimal count; - - @Schema(description = "总计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal totalPrice; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java deleted file mode 100644 index 2f5e8447c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmBusinessParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmContactParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 合同创建/更新 Request VO") -@Data -public class CrmContractSaveReqVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private Long id; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @DiffLogField(name = "合同名称") - @NotNull(message = "合同名称不能为空") - private String name; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - @NotNull(message = "客户编号不能为空") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - @DiffLogField(name = "商机", function = CrmBusinessParseFunction.NAME) - private Long businessId; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17144") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - - @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED) - @DiffLogField(name = "下单日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotNull(message = "下单日期不能为空") - private LocalDateTime orderDate; - - @Schema(description = "开始时间") - @DiffLogField(name = "开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间") - @DiffLogField(name = "结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "整单折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "55.00") - @DiffLogField(name = "整单折扣") - @NotNull(message = "整单折扣不能为空") - private BigDecimal discountPercent; - - @Schema(description = "合同金额", example = "5617") - @DiffLogField(name = "合同金额") - private BigDecimal totalPrice; - - @Schema(description = "客户签约人编号", example = "18546") - @DiffLogField(name = "客户签约人", function = CrmContactParseFunction.NAME) - private Long signContactId; - - @Schema(description = "公司签约人", example = "14036") - @DiffLogField(name = "公司签约人", function = SysAdminUserParseFunction.NAME) - private Long signUserId; - - @Schema(description = "备注", example = "你猜") - @DiffLogField(name = "备注") - private String remark; - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Product { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "产品单价不能为空") - private BigDecimal productPrice; - - @Schema(description = "合同价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "合同价格不能为空") - private BigDecimal contractPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "产品数量不能为空") - private Integer count; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java deleted file mode 100644 index e234a0230..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 合同转移 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractTransferReqVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(value = CrmPermissionLevelEnum.class) - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java deleted file mode 100644 index 68e7a48c1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ /dev/null @@ -1,316 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - CRM 客户") -@RestController -@RequestMapping("/crm/customer") -@Validated -public class CrmCustomerController { - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmCustomerPoolConfigService customerPoolConfigService; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建客户") - @PreAuthorize("@ss.hasPermission('crm:customer:create')") - public CommonResult createCustomer(@Valid @RequestBody CrmCustomerSaveReqVO createReqVO) { - return success(customerService.createCustomer(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult updateCustomer(@Valid @RequestBody CrmCustomerSaveReqVO updateReqVO) { - customerService.updateCustomer(updateReqVO); - return success(true); - } - - @PutMapping("/update-deal-status") - @Operation(summary = "更新客户的成交状态") - @Parameters({ - @Parameter(name = "id", description = "客户编号", required = true), - @Parameter(name = "dealStatus", description = "成交状态", required = true) - }) - public CommonResult updateCustomerDealStatus(@RequestParam("id") Long id, - @RequestParam("dealStatus") Boolean dealStatus) { - customerService.updateCustomerDealStatus(id, dealStatus); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户") - @Parameter(name = "id", description = "客户编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:customer:delete')") - public CommonResult deleteCustomer(@RequestParam("id") Long id) { - customerService.deleteCustomer(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getCustomer(@RequestParam("id") Long id) { - // 1. 获取客户 - CrmCustomerDO customer = customerService.getCustomer(id); - // 2. 拼接数据 - return success(buildCustomerDetail(customer)); - } - - public CrmCustomerRespVO buildCustomerDetail(CrmCustomerDO customer) { - if (customer == null) { - return null; - } - return buildCustomerDetailList(singletonList(customer)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得客户分页") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { - // 1. 查询客户分页 - PageResult pageResult = customerService.getCustomerPage(pageVO, getLoginUserId()); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 2. 拼接数据 - return success(new PageResult<>(buildCustomerDetailList(pageResult.getList()), pageResult.getTotal())); - } - - public List buildCustomerDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return java.util.Collections.emptyList(); - } - // 1.1 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertSetByFlatMap(list, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.2 获取距离进入公海的时间 - Map poolDayMap = getPoolDayMap(list); - // 2. 转换成 VO - return BeanUtils.toBean(list, CrmCustomerRespVO.class, customerVO -> { - customerVO.setAreaName(AreaUtils.format(customerVO.getAreaId())); - // 2.1 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(customerVO.getCreator()), - user -> customerVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, customerVO.getOwnerUserId(), user -> { - customerVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> customerVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.2 设置距离进入公海的时间 - if (customerVO.getOwnerUserId() != null) { - customerVO.setPoolDay(poolDayMap.get(customerVO.getId())); - } - }); - } - - @GetMapping("/put-pool-remind-page") - @Operation(summary = "获得待进入公海客户分页") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult> getPutPoolRemindCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { - // 1. 查询客户分页 - PageResult pageResult = customerService.getPutPoolRemindCustomerPage(pageVO, getLoginUserId()); - // 2. 拼接数据 - return success(new PageResult<>(buildCustomerDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/put-pool-remind-count") - @Operation(summary = "获得待进入公海客户数量") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getPutPoolRemindCustomerCount() { - return success(customerService.getPutPoolRemindCustomerCount(getLoginUserId())); - } - - @GetMapping("/today-contact-count") - @Operation(summary = "获得今日需联系客户数量") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getTodayContactCustomerCount() { - return success(customerService.getTodayContactCustomerCount(getLoginUserId())); - } - - @GetMapping("/follow-count") - @Operation(summary = "获得分配给我、待跟进的线索数量的客户数量") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getFollowCustomerCount() { - return success(customerService.getFollowCustomerCount(getLoginUserId())); - } - - /** - * 获取距离进入公海的时间 Map - * - * @param list 客户列表 - * @return key 客户编号, value 距离进入公海的时间 - */ - private Map getPoolDayMap(List list) { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (poolConfig == null || !poolConfig.getEnabled()) { - return MapUtil.empty(); - } - list = CollectionUtils.filterList(list, customer -> { - // 特殊:如果没负责人,则说明已经在公海,不用计算 - if (customer.getOwnerUserId() == null) { - return false; - } - // 已成交 or 已锁定,不进入公海 - return !customer.getDealStatus() && !customer.getLockStatus(); - }); - return convertMap(list, CrmCustomerDO::getId, customer -> { - // 1.1 未成交放入公海天数 - long dealExpireDay = poolConfig.getDealExpireDays() - LocalDateTimeUtils.between(customer.getOwnerTime()); - // 1.2 未跟进放入公海天数 - LocalDateTime lastTime = customer.getOwnerTime(); - if (customer.getContactLastTime() != null && customer.getContactLastTime().isAfter(lastTime)) { - lastTime = customer.getContactLastTime(); - } - long contactExpireDay = poolConfig.getContactExpireDays() - LocalDateTimeUtils.between(lastTime); - // 2. 返回最小的天数 - long poolDay = Math.min(dealExpireDay, contactExpireDay); - return poolDay > 0 ? poolDay : 0; - }); - } - - @GetMapping(value = "/simple-list") - @Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项") - public CommonResult> getCustomerSimpleList() { - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); - reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - List list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList(); - return success(convertList(list, customer -> // 只返回 id、name 精简字段 - new CrmCustomerRespVO().setId(customer.getId()).setName(customer.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出客户 Excel") - @PreAuthorize("@ss.hasPermission('crm:customer:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportCustomerExcel(@Valid CrmCustomerPageReqVO pageVO, - HttpServletResponse response) throws IOException { - pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - List list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, - buildCustomerDetailList(list)); - } - - @GetMapping("/get-import-template") - @Operation(summary = "获得导入客户模板") - public void importTemplate(HttpServletResponse response) throws IOException { - // 手动创建导出 demo - List list = Arrays.asList( - CrmCustomerImportExcelVO.builder().name("芋道").industryId(1).level(1).source(1) - .mobile("15601691300").telephone("").qq("").wechat("").email("yunai@iocoder.cn") - .areaId(null).detailAddress("").remark("").build(), - CrmCustomerImportExcelVO.builder().name("源码").industryId(1).level(1).source(1) - .mobile("15601691300").telephone("").qq("").wechat("").email("yunai@iocoder.cn") - .areaId(null).detailAddress("").remark("").build() - ); - // 输出 - ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); - } - - @PostMapping("/import") - @Operation(summary = "导入客户") - @PreAuthorize("@ss.hasPermission('crm:customer:import')") - public CommonResult importExcel(@Valid CrmCustomerImportReqVO importReqVO) - throws Exception { - List list = ExcelUtils.read(importReqVO.getFile(), CrmCustomerImportExcelVO.class); - return success(customerService.importCustomerList(list, importReqVO)); - } - - @PutMapping("/transfer") - @Operation(summary = "转移客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult transferCustomer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { - customerService.transferCustomer(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/lock") - @Operation(summary = "锁定/解锁客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) { - customerService.lockCustomer(lockReqVO, getLoginUserId()); - return success(true); - } - - // ==================== 公海相关操作 ==================== - - @PutMapping("/put-pool") - @Operation(summary = "数据放入公海") - @Parameter(name = "id", description = "客户编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult putCustomerPool(@RequestParam("id") Long id) { - customerService.putCustomerPool(id); - return success(true); - } - - @PutMapping("/receive") - @Operation(summary = "领取公海客户") - @Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3") - @PreAuthorize("@ss.hasPermission('crm:customer:receive')") - public CommonResult receiveCustomer(@RequestParam(value = "ids") List ids) { - customerService.receiveCustomer(ids, getLoginUserId(), Boolean.TRUE); - return success(true); - } - - @PutMapping("/distribute") - @Operation(summary = "分配公海给对应负责人") - @PreAuthorize("@ss.hasPermission('crm:customer:distribute')") - public CommonResult distributeCustomer(@Valid @RequestBody CrmCustomerDistributeReqVO distributeReqVO) { - customerService.receiveCustomer(distributeReqVO.getIds(), distributeReqVO.getOwnerUserId(), Boolean.FALSE); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java deleted file mode 100644 index 82a326c05..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; - -@Tag(name = "管理后台 - CRM 客户限制配置") -@RestController -@RequestMapping("/crm/customer-limit-config") -@Validated -public class CrmCustomerLimitConfigController { - - @Resource - private CrmCustomerLimitConfigService customerLimitConfigService; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建客户限制配置") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')") - public CommonResult createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO createReqVO) { - return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新客户限制配置") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')") - public CommonResult updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO updateReqVO) { - customerLimitConfigService.updateCustomerLimitConfig(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户限制配置") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:delete')") - public CommonResult deleteCustomerLimitConfig(@RequestParam("id") Long id) { - customerLimitConfigService.deleteCustomerLimitConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户限制配置") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") - public CommonResult getCustomerLimitConfig(@RequestParam("id") Long id) { - CrmCustomerLimitConfigDO limitConfig = customerLimitConfigService.getCustomerLimitConfig(id); - // 拼接数据 - Map userMap = adminUserApi.getUserMap(limitConfig.getUserIds()); - Map deptMap = deptApi.getDeptMap(limitConfig.getDeptIds()); - return success(BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class, configVO -> { - configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get)); - configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get)); - })); - } - - @GetMapping("/page") - @Operation(summary = "获得客户限制配置分页") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") - public CommonResult> getCustomerLimitConfigPage(@Valid CrmCustomerLimitConfigPageReqVO pageVO) { - PageResult pageResult = customerLimitConfigService.getCustomerLimitConfigPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接数据 - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream)); - Map deptMap = deptApi.getDeptMap( - convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream)); - return success(BeanUtils.toBean(pageResult, CrmCustomerLimitConfigRespVO.class, configVO -> { - configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get)); - configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get)); - })); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java deleted file mode 100644 index 5c566359f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户公海配置") -@RestController -@RequestMapping("/crm/customer-pool-config") -@Validated -public class CrmCustomerPoolConfigController { - - @Resource - private CrmCustomerPoolConfigService customerPoolConfigService; - - @GetMapping("/get") - @Operation(summary = "获取客户公海规则设置") - @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") - public CommonResult getCustomerPoolConfig() { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - return success(BeanUtils.toBean(poolConfig, CrmCustomerPoolConfigRespVO.class)); - } - - @PutMapping("/save") - @Operation(summary = "更新客户公海规则设置") - @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:update')") - public CommonResult saveCustomerPoolConfig(@Valid @RequestBody CrmCustomerPoolConfigSaveReqVO updateReqVO) { - customerPoolConfigService.saveCustomerPoolConfig(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerDistributeReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerDistributeReqVO.java deleted file mode 100644 index fd47f6782..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerDistributeReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - CRM 客户分配公海给对应负责人 Request VO") -@Data -public class CrmCustomerDistributeReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]") - @NotEmpty(message = "客户编号不能为空") - private List ids; - - @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java deleted file mode 100644 index a45e9115f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; -import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.crm.framework.excel.core.AreaExcelColumnSelectFunction; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*; - -/** - * 客户 Excel 导入 VO - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 -public class CrmCustomerImportExcelVO { - - @ExcelProperty("客户名称") - private String name; - - @ExcelProperty("手机") - private String mobile; - - @ExcelProperty("电话") - private String telephone; - - @ExcelProperty("QQ") - private String qq; - - @ExcelProperty("微信") - private String wechat; - - @ExcelProperty("邮箱") - private String email; - - @ExcelProperty(value = "地区", converter = AreaConvert.class) - @ExcelColumnSelect(functionName = AreaExcelColumnSelectFunction.NAME) - private Integer areaId; - - @ExcelProperty("详细地址") - private String detailAddress; - - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(CRM_CUSTOMER_INDUSTRY) - @ExcelColumnSelect(dictType = CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(CRM_CUSTOMER_LEVEL) - @ExcelColumnSelect(dictType = CRM_CUSTOMER_LEVEL) - private Integer level; - - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(CRM_CUSTOMER_SOURCE) - @ExcelColumnSelect(dictType = CRM_CUSTOMER_SOURCE) - private Integer source; - - @ExcelProperty("备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportReqVO.java deleted file mode 100644 index 362bad882..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Builder; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -@Schema(description = "管理后台 - 客户导入 Request VO") -@Data -@Builder -public class CrmCustomerImportReqVO { - - @Schema(description = "Excel 文件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "Excel 文件不能为空") - private MultipartFile file; - - @Schema(description = "是否支持更新", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否支持更新不能为空") - private Boolean updateSupport; - - @Schema(description = "负责人", example = "1") - private Long ownerUserId; // 为 null 则客户进入公海 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportRespVO.java deleted file mode 100644 index dda5bc5d1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Builder; -import lombok.Data; - -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 客户导入 Response VO") -@Data -@Builder -public class CrmCustomerImportRespVO { - - @Schema(description = "创建成功的客户名数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List createCustomerNames; - - @Schema(description = "更新成功的客户名数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List updateCustomerNames; - - @Schema(description = "导入失败的客户集合,key 为客户名,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED) - private Map failureCustomerNames; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerLockReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerLockReqVO.java deleted file mode 100644 index 10bf2e10a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerLockReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户锁定/解锁 Request VO") -@Data -public class CrmCustomerLockReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "客户锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Boolean lockStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerPageReqVO.java deleted file mode 100644 index 73af5d6b1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerPageReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 客户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerPageReqVO extends PageParam { - - /** - * 联系状态 - 今日需联系 - */ - public static final int CONTACT_TODAY = 1; - /** - * 联系状态 - 已逾期 - */ - public static final int CONTACT_EXPIRED = 2; - /** - * 联系状态 - 已联系 - */ - public static final int CONTACT_ALREADY = 3; - - @Schema(description = "客户名称", example = "赵六") - private String name; - - @Schema(description = "手机", example = "18000000000") - private String mobile; - - @Schema(description = "所属行业", example = "1") - private Integer industryId; - - @Schema(description = "客户等级", example = "1") - private Integer level; - - @Schema(description = "客户来源", example = "1") - private Integer source; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean pool; // null 则表示为不是公海数据 - - @Schema(description = "联系状态", example = "1") - private Integer contactStatus; // backlog 查询条件 - - @Schema(description = "跟进状态", example = "true") - private Boolean followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerRespVO.java deleted file mode 100644 index 236129918..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerRespVO.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 客户 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmCustomerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty("客户名称") - private String name; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean followUpStatus; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "最后跟进内容", example = "吃饭、睡觉、打逗逗") - @ExcelProperty("最后跟进内容") - private String contactLastContent; - - @Schema(description = "下次联系时间") - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "锁定状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean lockStatus; - - @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "成交状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean dealStatus; - - @Schema(description = "手机", example = "25682") - @ExcelProperty("手机") - private String mobile; - - @Schema(description = "电话", example = "25682") - @ExcelProperty("电话") - private String telephone; - - @Schema(description = "QQ", example = "25682") - @ExcelProperty("QQ") - private String qq; - - @Schema(description = "wechat", example = "25682") - @ExcelProperty("wechat") - private String wechat; - - @Schema(description = "email", example = "25682") - @ExcelProperty("email") - private String email; - - @Schema(description = "地区编号", example = "1024") - @ExcelProperty("地区编号") - private Integer areaId; - @Schema(description = "地区名称", example = "北京市") - @ExcelProperty("地区名称") - private String areaName; - @Schema(description = "详细地址", example = "北京市成华大道") - @ExcelProperty("详细地址") - private String detailAddress; - - @Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL) - private Integer level; - - @Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE) - private Integer source; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "距离加入公海时间", example = "1") - private Long poolDay; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerSaveReqVO.java deleted file mode 100644 index daedb7830..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerSaveReqVO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerIndustryParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerLevelParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerSourceParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAreaParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; - -@Schema(description = "管理后台 - CRM 客户新增/修改 Request VO") -@Data -public class CrmCustomerSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @DiffLogField(name = "客户名称") - @NotEmpty(message = "客户名称不能为空") - private String name; - - @Schema(description = "下次联系时间") - @DiffLogField(name = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @NotNull(message = "负责人的用户编号不能为空") - private Long ownerUserId; - - @Schema(description = "手机", example = "18000000000") - @DiffLogField(name = "手机") - @Mobile - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @DiffLogField(name = "电话") - @Telephone - private String telephone; - - @Schema(description = "QQ", example = "123456789") - @DiffLogField(name = "QQ") - @Size(max = 20, message = "QQ长度不能超过 20 个字符") - private String qq; - - @Schema(description = "微信", example = "123456789") - @DiffLogField(name = "微信") - @Size(max = 255, message = "微信长度不能超过 255 个字符") - private String wechat; - - @Schema(description = "邮箱", example = "123456789@qq.com") - @DiffLogField(name = "邮箱") - @Email(message = "邮箱格式不正确") - @Size(max = 255, message = "邮箱长度不能超过 255 个字符") - private String email; - - @Schema(description = "地区编号", example = "20158") - @DiffLogField(name = "地区编号", function = SysAreaParseFunction.NAME) - private Integer areaId; - - @Schema(description = "详细地址", example = "北京市海淀区") - @DiffLogField(name = "详细地址") - private String detailAddress; - - @Schema(description = "所属行业", example = "1") - @DiffLogField(name = "所属行业", function = CrmCustomerIndustryParseFunction.NAME) - @DictFormat(CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", example = "2") - @DiffLogField(name = "客户等级", function = CrmCustomerLevelParseFunction.NAME) - @InEnum(CrmCustomerLevelEnum.class) - private Integer level; - - @Schema(description = "客户来源", example = "3") - @DiffLogField(name = "客户来源", function = CrmCustomerSourceParseFunction.NAME) - private Integer source; - - @Schema(description = "备注", example = "随便") - @DiffLogField(name = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java deleted file mode 100644 index 467ac8ad4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - CRM 客户转移 Request VO") -@Data -public class CrmCustomerTransferReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "客户编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - - /** - * 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择。选中时,也一起转移 - */ - @Schema(description = "同时转移", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private List toBizTypes; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java deleted file mode 100644 index 37ce11009..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 客户限制配置分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerLimitConfigPageReqVO extends PageParam { - - @Schema(description = "规则类型", example = "1") - private Integer type; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java deleted file mode 100644 index 8ff03ad66..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 客户限制配置 Response VO") -@Data -public class CrmCustomerLimitConfigRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") - private Long id; - - @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer type; - - @Schema(description = "规则适用人群") - private List userIds; - - @Schema(description = "规则适用部门") - private List deptIds; - - @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - private Integer maxCount; - - @Schema(description = "成交客户是否占有拥有客户数") - private Boolean dealCountEnabled; - - @Schema(description = "规则适用人群名称") - private List users; - - @Schema(description = "规则适用部门名称") - private List depts; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java deleted file mode 100644 index 9a4f25861..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysDeptParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO") -@Data -public class CrmCustomerLimitConfigSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") - private Long id; - - @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "规则类型不能为空") - @DiffLogField(name = "规则类型") - private Integer type; - - @Schema(description = "规则适用人群") - @DiffLogField(name = "规则适用人群", function = SysAdminUserParseFunction.NAME) - private List userIds; - - @Schema(description = "规则适用部门") - @DiffLogField(name = "规则适用部门", function = SysDeptParseFunction.NAME) - private List deptIds; - - @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - @NotNull(message = "数量上限不能为空") - @DiffLogField(name = "数量上限") - private Integer maxCount; - - @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") - @DiffLogField(name = "成交客户是否占有拥有客户数") - private Boolean dealCountEnabled; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java deleted file mode 100644 index 4a5b6b8c0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户公海规则 Response VO") -@Data -public class CrmCustomerPoolConfigRespVO { - - @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用客户公海不能为空") - private Boolean enabled; - - @Schema(description = "未跟进放入公海天数", example = "2") - private Integer contactExpireDays; - - @Schema(description = "未成交放入公海天数", example = "2") - private Integer dealExpireDays; - - @Schema(description = "是否开启提前提醒", example = "true") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java deleted file mode 100644 index 6fa1301c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import cn.hutool.core.util.BooleanUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.Objects; - -@Schema(description = "管理后台 - CRM 客户公海配置的创建/更新 Request VO") -@Data -public class CrmCustomerPoolConfigSaveReqVO { - - @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @DiffLogField(name = "是否启用客户公海") - @NotNull(message = "是否启用客户公海不能为空") - private Boolean enabled; - - @Schema(description = "未跟进放入公海天数", example = "2") - @DiffLogField(name = "未跟进放入公海天数") - private Integer contactExpireDays; - - @Schema(description = "未成交放入公海天数", example = "2") - @DiffLogField(name = "未成交放入公海天数") - private Integer dealExpireDays; - - @Schema(description = "是否开启提前提醒", example = "true") - @DiffLogField(name = "是否开启提前提醒") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - @DiffLogField(name = "提前提醒天数") - private Integer notifyDays; - - @AssertTrue(message = "未成交放入公海天数不能为空") - @JsonIgnore - public boolean isDealExpireDaysValid() { - if (!BooleanUtil.isTrue(getEnabled())) { - return true; - } - return Objects.nonNull(getDealExpireDays()); - } - - @AssertTrue(message = "未跟进放入公海天数不能为空") - @JsonIgnore - public boolean isContactExpireDaysValid() { - if (!BooleanUtil.isTrue(getEnabled())) { - return true; - } - return Objects.nonNull(getContactExpireDays()); - } - - @AssertTrue(message = "提前提醒天数不能为空") - @JsonIgnore - public boolean isNotifyDaysValid() { - if (!BooleanUtil.isTrue(getNotifyEnabled())) { - return true; - } - return Objects.nonNull(getNotifyDays()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java deleted file mode 100644 index 867c4e730..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - - -@Tag(name = "管理后台 - 跟进记录") -@RestController -@RequestMapping("/crm/follow-up-record") -@Validated -public class CrmFollowUpRecordController { - - @Resource - private CrmFollowUpRecordService followUpRecordService; - @Resource - private CrmContactService contactService; - @Resource - private CrmBusinessService businessService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建跟进记录") - public CommonResult createFollowUpRecord(@Valid @RequestBody CrmFollowUpRecordSaveReqVO createReqVO) { - return success(followUpRecordService.createFollowUpRecord(createReqVO)); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除跟进记录") - @Parameter(name = "id", description = "编号", required = true) - public CommonResult deleteFollowUpRecord(@RequestParam("id") Long id) { - followUpRecordService.deleteFollowUpRecord(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得跟进记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getFollowUpRecord(@RequestParam("id") Long id) { - CrmFollowUpRecordDO followUpRecord = followUpRecordService.getFollowUpRecord(id); - return success(BeanUtils.toBean(followUpRecord, CrmFollowUpRecordRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得跟进记录分页") - public CommonResult> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { - PageResult pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO); - // 1.1 查询联系人和商机 - Map contactMap = contactService.getContactMap( - convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())); - Map businessMap = businessService.getBusinessMap( - convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())); - // 1.2 查询用户 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), item -> Long.valueOf(item.getCreator()))); - // 2. 拼接数据 - PageResult voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> { - // 2.1 设置联系人和商机信息 - record.setBusinesses(new ArrayList<>()).setContacts(new ArrayList<>()); - record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id, contact -> - record.getContacts().add(new CrmBusinessRespVO().setId(contact.getId()).setName(contact.getName())))); - record.getBusinessIds().forEach(id -> MapUtils.findAndThen(businessMap, id, business -> - record.getBusinesses().add(new CrmBusinessRespVO().setId(business.getId()).setName(business.getName())))); - // 2.2 设置用户信息 - MapUtils.findAndThen(userMap, Long.valueOf(record.getCreator()), user -> record.setCreatorName(user.getNickname())); - }); - return success(voPageResult); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java deleted file mode 100644 index 78c28a08f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 跟进记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmFollowUpRecordPageReqVO extends PageParam { - - @Schema(description = "数据类型", example = "2") - private Integer bizType; - - @Schema(description = "数据编号", example = "5564") - private Long bizId; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java deleted file mode 100644 index 1ce10b73e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_FOLLOW_UP_TYPE; - -@Schema(description = "管理后台 - 跟进记录 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmFollowUpRecordRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800") - private Long id; - - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer bizType; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564") - private Long bizId; - - @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DictFormat(CRM_FOLLOW_UP_TYPE) - private Integer type; - - @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED) - private String content; - - @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime nextTime; - - @Schema(description = "关联的商机编号数组") - private List businessIds; - @Schema(description = "关联的商机数组") - private List businesses; - - @Schema(description = "关联的联系人编号数组") - private List contactIds; - @Schema(description = "关联的联系人名称数组") - private List contacts; - - @Schema(description = "图片") - private List picUrls; - @Schema(description = "附件") - private List fileUrls; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java deleted file mode 100644 index 0b6291a0e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 跟进记录新增/修改 Request VO") -@Data -public class CrmFollowUpRecordSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800") - private Long id; - - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "数据类型不能为空") - private Integer bizType; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564") - @NotNull(message = "数据编号不能为空") - private Long bizId; - - @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "跟进类型不能为空") - private Integer type; - - @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "跟进内容不能为空") - private String content; - - @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "下次联系时间不能为空") - private LocalDateTime nextTime; - - @Schema(description = "关联的商机编号数组") - private List businessIds; - @Schema(description = "关联的联系人编号数组") - private List contactIds; - - @Schema(description = "图片") - private List picUrls; - @Schema(description = "附件") - private List fileUrls; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java deleted file mode 100644 index 4aa48bd57..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.operatelog; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogRespVO; -import cn.iocoder.yudao.module.crm.enums.LogRecordConstants; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; -import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogPageReqDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -@Tag(name = "管理后台 - CRM 操作日志") -@RestController -@RequestMapping("/crm/operate-log") -@Validated -public class CrmOperateLogController { - - @Resource - private OperateLogApi operateLogApi; - - /** - * {@link CrmBizTypeEnum} 与 {@link LogRecordConstants} 的映射关系 - */ - private static final Map BIZ_TYPE_MAP = new HashMap<>(); - - static { - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CLUE.getType(), CRM_CLUE_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CUSTOMER.getType(), CRM_CUSTOMER_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CONTACT.getType(), CRM_CONTACT_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_BUSINESS.getType(), CRM_BUSINESS_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CONTRACT.getType(), CRM_CONTRACT_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_PRODUCT.getType(), CRM_PRODUCT_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE.getType(), CRM_RECEIVABLE_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), CRM_RECEIVABLE_PLAN_TYPE); - } - - @GetMapping("/page") - @Operation(summary = "获得操作日志") - public CommonResult> getCustomerOperateLog(@Valid CrmOperateLogPageReqVO pageReqVO) { - OperateLogPageReqDTO reqDTO = new OperateLogPageReqDTO(); - reqDTO.setPageSize(PAGE_SIZE_NONE); // 默认不分页,需要分页需注释 - reqDTO.setType(BIZ_TYPE_MAP.get(pageReqVO.getBizType())).setBizId(pageReqVO.getBizId()); - return success(BeanUtils.toBean(operateLogApi.getOperateLogPage(reqDTO).getCheckedData(), CrmOperateLogRespVO.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java deleted file mode 100644 index de3af64b3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 操作日志 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmOperateLogPageReqVO extends PageParam { - - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "数据类型不能为空") - private Integer bizType; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "数据编号不能为空") - private Long bizId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogRespVO.java deleted file mode 100644 index 8e458a8a0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogRespVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 操作日志 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmOperateLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String userName; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer userType; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String type; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "修改客户") - private String subType; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long bizId; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "将什么从什么改为了什么") - private String action; - - @Schema(description = "编号", example = "{orderId: 1}") - private String extra; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-01-01") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http deleted file mode 100644 index 1ef2bc1a1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http +++ /dev/null @@ -1,32 +0,0 @@ -### 请求 /add -POST {{baseUrl}}/crm/permission/create -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 1, - "bizType": 2, - "bizId": 2, - "level": 1 -} - -### 请求 /update -PUT {{baseUrl}}/crm/permission/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 1, - "bizType": 2, - "bizId": 2, - "level": 1, - "id": 1 -} - -### 请求 /delete -DELETE {{baseUrl}}/crm/permission/delete?bizType=2&bizId=1&id=1 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java deleted file mode 100644 index 1a829ad2f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.collect.Multimaps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 数据权限") -@RestController -@RequestMapping("/crm/permission") -@Validated -public class CrmPermissionController { - - @Resource - private CrmPermissionService permissionService; - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - private PostApi postApi; - - @PostMapping("/create") - @Operation(summary = "创建数据权限") - public CommonResult create(@Valid @RequestBody CrmPermissionSaveReqVO reqVO) { - permissionService.createPermission(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/update") - @Operation(summary = "编辑数据权限") - @CrmPermission(bizTypeValue = "#updateReqVO.bizType", bizId = "#updateReqVO.bizId" - , level = CrmPermissionLevelEnum.OWNER) - public CommonResult updatePermission(@Valid @RequestBody CrmPermissionUpdateReqVO updateReqVO) { - permissionService.updatePermission(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除数据权限") - @Parameter(name = "ids", description = "数据权限编号", required = true, example = "1024") - public CommonResult deletePermission(@RequestParam("ids") Collection ids) { - permissionService.deletePermissionBatch(ids, getLoginUserId()); - return success(true); - } - - @DeleteMapping("/delete-self") - @Operation(summary = "删除自己的数据权限") - @Parameter(name = "id", description = "数据权限编号", required = true, example = "1024") - public CommonResult deleteSelfPermission(@RequestParam("id") Long id) { - permissionService.deleteSelfPermission(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获得数据权限列表") - @Parameters({ - @Parameter(name = "bizType", description = "CRM 类型", required = true, example = "2"), - @Parameter(name = "bizId", description = "CRM 类型数据编号", required = true, example = "1024") - }) - public CommonResult> getPermissionList(@RequestParam("bizType") Integer bizType, - @RequestParam("bizId") Long bizId) { - List permissions = permissionService.getPermissionListByBiz(bizType, bizId); - if (CollUtil.isEmpty(permissions)) { - return success(Collections.emptyList()); - } - - // 查询相关数据 - Map userMap = adminUserApi.getUserMap( - convertSet(permissions, CrmPermissionDO::getUserId)); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - Map postMap = postApi.getPostMap( - convertSetByFlatMap(userMap.values(), AdminUserRespDTO::getPostIds, - item -> item != null ? item.stream() : Stream.empty())); - // 拼接数据 - return success(CollectionUtils.convertList(BeanUtils.toBean(permissions, CrmPermissionRespVO.class), item -> { - findAndThen(userMap, item.getUserId(), user -> { - item.setNickname(user.getNickname()); - findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); - if (CollUtil.isEmpty(user.getPostIds())) { - item.setPostNames(Collections.emptySet()); - return; - } - List postList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); - item.setPostNames(CollectionUtils.convertSet(postList, PostRespDTO::getName)); - }); - return item; - })); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java deleted file mode 100644 index 28985aef6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - CRM 数据权限 Response VO") -@Data -public class CrmPermissionRespVO { - - @Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "CRM 类型不能为空") - private Integer bizType; - - @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "CRM 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - @Schema(description = "岗位名称数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[BOOS,经理]") - private Set postNames; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-01-01 00:00:00") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java deleted file mode 100644 index c4d7e9c20..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 数据权限创建/更新 Request VO") -@Data -public class CrmPermissionSaveReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "CRM 类型不能为空") - private Integer bizType; - - @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "CRM 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - - /** - * 添加客户团队成员时,需要额外有【联系人】【商机】【合同】的 checkbox 选择。 - * 选中时,同时添加对应的权限 - */ - @Schema(description = "同时添加", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private List toBizTypes; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java deleted file mode 100644 index d49f5662f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 数据权限更新 Request VO") -@Data -public class CrmPermissionUpdateReqVO { - - @Schema(description = "数据权限编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2]") - @NotNull(message = "数据权限编号列表不能为空") - private List ids; - - @Schema(description = "Crm 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "Crm 类型不能为空") - private Integer bizType; - - @Schema(description = "Crm 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "Crm 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java deleted file mode 100644 index dec0d6241..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryRespVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 产品分类") -@RestController -@RequestMapping("/crm/product-category") -@Validated -public class CrmProductCategoryController { - - @Resource - private CrmProductCategoryService productCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建产品分类") - @PreAuthorize("@ss.hasPermission('crm:product-category:create')") - public CommonResult createProductCategory(@Valid @RequestBody CrmProductCategoryCreateReqVO createReqVO) { - return success(productCategoryService.createProductCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品分类") - @PreAuthorize("@ss.hasPermission('crm:product-category:update')") - public CommonResult updateProductCategory(@Valid @RequestBody CrmProductCategoryCreateReqVO updateReqVO) { - productCategoryService.updateProductCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:product-category:delete')") - public CommonResult deleteProductCategory(@RequestParam("id") Long id) { - productCategoryService.deleteProductCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:product-category:query')") - public CommonResult getProductCategory(@RequestParam("id") Long id) { - CrmProductCategoryDO category = productCategoryService.getProductCategory(id); - return success(BeanUtils.toBean(category, CrmProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得产品分类列表") - @PreAuthorize("@ss.hasPermission('crm:product-category:query')") - public CommonResult> getProductCategoryList(@Valid CrmProductCategoryListReqVO listReqVO) { - List list = productCategoryService.getProductCategoryList(listReqVO); - return success(BeanUtils.toBean(list, CrmProductCategoryRespVO.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java deleted file mode 100644 index 555993b86..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.translate.core.TranslateUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - CRM 产品") -@RestController -@RequestMapping("/crm/product") -@Validated -public class CrmProductController { - - @Resource - private CrmProductService productService; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建产品") - @PreAuthorize("@ss.hasPermission('crm:product:create')") - public CommonResult createProduct(@Valid @RequestBody CrmProductSaveReqVO createReqVO) { - return success(productService.createProduct(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品") - @PreAuthorize("@ss.hasPermission('crm:product:update')") - public CommonResult updateProduct(@Valid @RequestBody CrmProductSaveReqVO updateReqVO) { - productService.updateProduct(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:product:delete')") - public CommonResult deleteProduct(@RequestParam("id") Long id) { - productService.deleteProduct(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:product:query')") - public CommonResult getProduct(@RequestParam("id") Long id) { - CrmProductDO product = productService.getProduct(id); - return success(BeanUtils.toBean(product, CrmProductRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") - public CommonResult> getProductSimpleList() { - List list = productService.getProductListByStatus(CrmProductStatusEnum.ENABLE.getStatus()); - return success(convertList(list, product -> new CrmProductRespVO().setId(product.getId()).setName(product.getName()) - .setUnit(product.getUnit()).setNo(product.getNo()).setPrice(product.getPrice()))); - } - - @GetMapping("/page") - @Operation(summary = "获得产品分页") - @PreAuthorize("@ss.hasPermission('crm:product:query')") - public CommonResult> getProductPage(@Valid CrmProductPageReqVO pageVO) { - PageResult pageResult = productService.getProductPage(pageVO); - return success(BeanUtils.toBean(pageResult, CrmProductRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品 Excel") - @PreAuthorize("@ss.hasPermission('crm:product:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = productService.getProductPage(exportReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class, - TranslateUtils.translate(BeanUtils.toBean(list, CrmProductRespVO.class))); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java deleted file mode 100644 index e1b249c15..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 产品分类创建/更新 Request VO") -@Data -public class CrmProductCategoryCreateReqVO{ - - @Schema(description = "分类编号", example = "23902") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotNull(message = "分类名称不能为空") - @DiffLogField(name = "分类名称") - private String name; - - @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") - @NotNull(message = "父级编号不能为空") - private Long parentId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java deleted file mode 100644 index 6144c95c4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品分类列表 Request VO") -@Data -public class CrmProductCategoryListReqVO { - - @ExcelProperty("名称") - private String name; - - @ExcelProperty("父级 id") - private Long parentId; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java deleted file mode 100644 index 657a32c5b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品分类 Response VO") -@Data -public class CrmProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23902") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String name; - - @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") - private Long parentId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java deleted file mode 100644 index 39b1090f8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 产品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmProductPageReqVO extends PageParam { - - @Schema(description = "产品名称", example = "李四") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java deleted file mode 100644 index 08625b8ca..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import com.fhs.core.trans.anno.Trans; -import com.fhs.core.trans.constant.TransType; -import com.fhs.core.trans.vo.VO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmProductRespVO implements VO { - - @Schema(description = "产品编号", example = "20529") - @ExcelProperty("产品编号") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") - @ExcelProperty("产品名称") - private String name; - - @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") - @ExcelProperty("产品编码") - private String no; - - @Schema(description = "单位", example = "2") - @ExcelProperty(value = "单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CRM_PRODUCT_UNIT) - private Integer unit; - - @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @ExcelProperty("价格,单位:分") - private BigDecimal price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") - @ExcelProperty(value = "单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CRM_PRODUCT_STATUS) - private Integer status; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @Trans(type = TransType.SIMPLE, target = CrmProductCategoryDO.class, fields = "name", ref = "categoryName") - private Long categoryId; - @Schema(description = "产品分类名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "衣服") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "产品描述", example = "你说的对") - @ExcelProperty("产品描述") - private String description; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") - @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, - fields = "nickname", ref = "ownerUserName") - private Long ownerUserId; - @Schema(description = "负责人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("负责人") - private String ownerUserName; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, - fields = "nickname", ref = "creatorName") - private String creator; - @Schema(description = "创建人名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("创建人") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java deleted file mode 100644 index 761242f4f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductStatusParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductUnitParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 产品创建/修改 Request VO") -@Data -public class CrmProductSaveReqVO { - - @Schema(description = "产品编号", example = "20529") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") - @NotNull(message = "产品名称不能为空") - @DiffLogField(name = "产品名称") - private String name; - - @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") - @NotNull(message = "产品编码不能为空") - @DiffLogField(name = "产品编码") - private String no; - - @Schema(description = "单位", example = "2") - @DiffLogField(name = "单位", function = CrmProductUnitParseFunction.NAME) - private Integer unit; - - @Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "价格不能为空") - @DiffLogField(name = "价格") - private BigDecimal price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") - @NotNull(message = "状态不能为空") - @DiffLogField(name = "状态", function = CrmProductStatusParseFunction.NAME) - private Integer status; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "产品分类编号不能为空") - @DiffLogField(name = "产品分类编号") - private Long categoryId; - - @Schema(description = "产品描述", example = "你说的对") - @DiffLogField(name = "产品描述") - private String description; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") - @NotNull(message = "负责人的用户编号不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java deleted file mode 100644 index 1b7dfa361..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 回款") -@RestController -@RequestMapping("/crm/receivable") -@Validated -public class CrmReceivableController { - - @Resource - private CrmReceivableService receivableService; - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建回款") - @PreAuthorize("@ss.hasPermission('crm:receivable:create')") - public CommonResult createReceivable(@Valid @RequestBody CrmReceivableSaveReqVO createReqVO) { - return success(receivableService.createReceivable(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新回款") - @PreAuthorize("@ss.hasPermission('crm:receivable:update')") - public CommonResult updateReceivable(@Valid @RequestBody CrmReceivableSaveReqVO updateReqVO) { - receivableService.updateReceivable(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除回款") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") - public CommonResult deleteReceivable(@RequestParam("id") Long id) { - receivableService.deleteReceivable(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得回款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult getReceivable(@RequestParam("id") Long id) { - CrmReceivableDO receivable = receivableService.getReceivable(id); - return success(buildReceivableDetail(receivable)); - } - - private CrmReceivableRespVO buildReceivableDetail(CrmReceivableDO receivable) { - if (receivable == null) { - return null; - } - return buildReceivableDetailList(Collections.singletonList(receivable)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得回款分页") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { - PageResult pageResult = receivableService.getReceivablePage(pageReqVO, getLoginUserId()); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得回款分页,基于指定客户") - public CommonResult> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = receivableService.getReceivablePageByCustomerId(pageReqVO); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出回款 Excel") - @PreAuthorize("@ss.hasPermission('crm:receivable:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PAGE_SIZE_NONE); - List list = receivableService.getReceivablePage(exportReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, - buildReceivableDetailList(list)); - } - - private List buildReceivableDetailList(List receivableList) { - if (CollUtil.isEmpty(receivableList)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(receivableList, CrmReceivableDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 获得合同列表 - Map contractMap = contractService.getContractMap( - convertSet(receivableList, CrmReceivableDO::getContractId)); - // 2. 拼接结果 - return BeanUtils.toBean(receivableList, CrmReceivableRespVO.class, (receivableVO) -> { - // 2.1 拼接客户名称 - findAndThen(customerMap, receivableVO.getCustomerId(), customer -> receivableVO.setCustomerName(customer.getName())); - // 2.2 拼接负责人、创建人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(receivableVO.getCreator()), - user -> receivableVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, receivableVO.getOwnerUserId(), user -> { - receivableVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> receivableVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.3 拼接合同信息 - findAndThen(contractMap, receivableVO.getContractId(), contract -> - receivableVO.setContract(BeanUtils.toBean(contract, CrmContractRespVO.class))); - }); - } - - @PutMapping("/submit") - @Operation(summary = "提交回款审批") - @PreAuthorize("@ss.hasPermission('crm:receivable:update')") - public CommonResult submitContract(@RequestParam("id") Long id) { - receivableService.submitReceivable(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/audit-count") - @Operation(summary = "获得待审核回款数量") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult getAuditReceivableCount() { - return success(receivableService.getAuditReceivableCount(getLoginUserId())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java deleted file mode 100644 index 74ba2e0e1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 回款计划") -@RestController -@RequestMapping("/crm/receivable-plan") -@Validated -public class CrmReceivablePlanController { - - @Resource - private CrmReceivablePlanService receivablePlanService; - @Resource - private CrmReceivableService receivableService; - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建回款计划") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") - public CommonResult createReceivablePlan(@Valid @RequestBody CrmReceivablePlanSaveReqVO createReqVO) { - return success(receivablePlanService.createReceivablePlan(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新回款计划") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") - public CommonResult updateReceivablePlan(@Valid @RequestBody CrmReceivablePlanSaveReqVO updateReqVO) { - receivablePlanService.updateReceivablePlan(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除回款计划") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") - public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { - receivablePlanService.deleteReceivablePlan(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得回款计划") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult getReceivablePlan(@RequestParam("id") Long id) { - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); - return success(buildReceivablePlanDetail(receivablePlan)); - } - - private CrmReceivablePlanRespVO buildReceivablePlanDetail(CrmReceivablePlanDO receivablePlan) { - if (receivablePlan == null) { - return null; - } - return buildReceivableDetailList(Collections.singletonList(receivablePlan)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得回款计划分页") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageReqVO) { - PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO, getLoginUserId()); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得回款计划分页,基于指定客户") - public CommonResult> getReceivablePlanPageByCustomer(@Valid CrmReceivablePlanPageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = receivablePlanService.getReceivablePlanPageByCustomerId(pageReqVO); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出回款计划 Excel") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PAGE_SIZE_NONE); - List list = receivablePlanService.getReceivablePlanPage(exportReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class, - buildReceivableDetailList(list)); - } - - private List buildReceivableDetailList(List receivablePlanList) { - if (CollUtil.isEmpty(receivablePlanList)) { - return Collections.emptyList(); - } - // 1.1 获取客户 Map - Map customerMap = customerService.getCustomerMap( - convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - // 1.3 获得合同 Map - Map contractMap = contractService.getContractMap( - convertSet(receivablePlanList, CrmReceivablePlanDO::getContractId)); - // 1.4 获得回款 Map - Map receivableMap = receivableService.getReceivableMap( - convertSet(receivablePlanList, CrmReceivablePlanDO::getReceivableId)); - // 2. 拼接数据 - return BeanUtils.toBean(receivablePlanList, CrmReceivablePlanRespVO.class, (receivablePlanVO) -> { - // 2.1 拼接客户信息 - findAndThen(customerMap, receivablePlanVO.getCustomerId(), customer -> receivablePlanVO.setCustomerName(customer.getName())); - // 2.2 拼接用户信息 - findAndThen(userMap, receivablePlanVO.getOwnerUserId(), user -> receivablePlanVO.setOwnerUserName(user.getNickname())); - findAndThen(userMap, Long.parseLong(receivablePlanVO.getCreator()), user -> receivablePlanVO.setCreatorName(user.getNickname())); - // 2.3 拼接合同信息 - findAndThen(contractMap, receivablePlanVO.getContractId(), contract -> receivablePlanVO.setContractNo(contract.getNo())); - // 2.4 拼接回款信息 - receivablePlanVO.setReceivable(BeanUtils.toBean(receivableMap.get(receivablePlanVO.getReceivableId()), CrmReceivableRespVO.class)); - }); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得回款计划精简列表", description = "获得回款计划精简列表,主要用于前端的下拉选项") - @Parameters({ - @Parameter(name = "customerId", description = "客户编号", required = true), - @Parameter(name = "contractId", description = "合同编号", required = true) - }) - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanSimpleList(@RequestParam("customerId") Long customerId, - @RequestParam("contractId") Long contractId) { - CrmReceivablePlanPageReqVO pageReqVO = new CrmReceivablePlanPageReqVO().setCustomerId(customerId).setContractId(contractId); - pageReqVO.setPageNo(PAGE_SIZE_NONE); - PageResult pageResult = receivablePlanService.getReceivablePlanPageByCustomerId(pageReqVO); - return success(convertList(pageResult.getList(), receivablePlan -> new CrmReceivablePlanRespVO() // 只返回 id、period 等信息 - .setId(receivablePlan.getId()).setPeriod(receivablePlan.getPeriod()).setReceivableId(receivablePlan.getReceivableId()) - .setPrice(receivablePlan.getPrice()).setReturnType(receivablePlan.getReturnType()))); - } - - @GetMapping("/remind-count") - @Operation(summary = "获得待回款提醒数量") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult getReceivablePlanRemindCount() { - return success(receivablePlanService.getReceivablePlanRemindCount(getLoginUserId())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java deleted file mode 100644 index b730128ce..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 回款计划分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePlanPageReqVO extends PageParam { - - /** - * 提醒类型 - 待回款 - */ - public final static Integer REMIND_TYPE_NEEDED = 1; - /** - * 提醒类型 - 已逾期 - */ - public final static Integer REMIND_TYPE_EXPIRED = 2; - /** - * 提醒类型 - 已回款 - */ - public final static Integer REMIND_TYPE_RECEIVED = 3; - - @Schema(description = "客户编号", example = "18026") - private Long customerId; - - @Schema(description = "合同编号", example = "H3473") - private String contractNo; - - @Schema(description = "合同编号", example = "3473") - private Long contractId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "提醒类型", example = "1") - private Integer remindType; // 提醒类型,为 null 时则表示全部 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java deleted file mode 100644 index ad1ce3a7b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款计划 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmReceivablePlanRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "期数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("期数") - private Integer period; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("客户编号") - private Long customerId; - @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") - @ExcelProperty("客户名字") - private String customerName; - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("合同编号") - private Long contractId; - @Schema(description = "合同编号", example = "Q110") - @ExcelProperty("合同编号") - private String contractNo; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("负责人编号") - private Long ownerUserId; - @Schema(description = "负责人", example = "test") - @ExcelProperty("负责人") - private String ownerUserName; - - @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @ExcelProperty("计划回款日期") - private LocalDateTime returnTime; - - @Schema(description = "计划回款方式", example = "1") - @ExcelProperty("计划回款方式") - private Integer returnType; - - @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @ExcelProperty("计划回款金额") - private BigDecimal price; - - @Schema(description = "回款编号", example = "19852") - @ExcelProperty("回款编号") - private Long receivableId; - @Schema(description = "回款信息") - @ExcelProperty("回款信息") - private CrmReceivableRespVO receivable; - - @Schema(description = "提前几天提醒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("提前几天提醒") - private Integer remindDays; - - @Schema(description = "提醒日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @ExcelProperty("提醒日期") - private LocalDateTime remindTime; - - @Schema(description = "备注", example = "备注") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanSaveReqVO.java deleted file mode 100644 index cefb02a9e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanSaveReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款计划新增/修改 Request VO") -@Data -public class CrmReceivablePlanSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "客户编号", hidden = true, example = "2") - private Long customerId; // 该字段不通过前端传递,而是 contractId 查询出来设置进去 - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "合同编号不能为空") - private Long contractId; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "负责人编号不能为空") - private Long ownerUserId; - - @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @NotNull(message = "计划回款日期不能为空") - private LocalDateTime returnTime; - - @Schema(description = "回款方式", example = "1") - private Integer returnType; - - @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @NotNull(message = "计划回款金额不能为空") - private BigDecimal price; - - @Schema(description = "提前几天提醒", example = "1") - private Integer remindDays; - - @Schema(description = "备注", example = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java deleted file mode 100644 index 415816c5d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 回款分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePageReqVO extends PageParam { - - @Schema(description = "回款编号") - private String no; - - @Schema(description = "回款计划编号", example = "31177") - private Long planId; - - @Schema(description = "客户编号", example = "4963") - private Long customerId; - - @Schema(description = "合同编号", example = "4963") - private Long contractId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "审批状态", example = "20") - @InEnum(CrmAuditStatusEnum.class) - private Integer auditStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java deleted file mode 100644 index 12dcbaa02..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmReceivableRespVO { - - @Schema(description = "编号", example = "25787") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "回款编号", example = "31177") - @ExcelProperty("回款编号") - private String no; - - @Schema(description = "回款计划编号", example = "1024") - @ExcelProperty("回款计划编号") - private Long planId; - - @Schema(description = "回款方式", example = "2") - @ExcelProperty("回款方式") - private Integer returnType; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @ExcelProperty("回款金额") - private BigDecimal price; - - @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @ExcelProperty("计划回款日期") - private LocalDateTime returnTime; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("客户编号") - private Long customerId; - @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") - @ExcelProperty("客户名字") - private String customerName; - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("合同编号") - private Long contractId; - @Schema(description = "合同信息") - @ExcelProperty("合同信息") - private CrmContractRespVO contract; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "工作流编号", example = "1043") - @ExcelProperty("工作流编号") - private String processInstanceId; - - @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @ExcelProperty("审批状态") - private Integer auditStatus; - - @Schema(description = "工作流编号", example = "备注") - @ExcelProperty("工作流编号") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "25682") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "test") - @ExcelProperty("创建人名字") - private String creatorName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableSaveReqVO.java deleted file mode 100644 index 1064fc924..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableSaveReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableReturnTypeEnum; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.*; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款新增/修改 Request VO") -@Data -public class CrmReceivableSaveReqVO { - - @Schema(description = "编号", example = "25787") - private Long id; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - @NotNull(message = "负责人编号不能为空") - private Long ownerUserId; - - @Schema(description = "客户编号", example = "2") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - private Long customerId; // 该字段不通过前端传递,而是 contractId 查询出来设置进去 - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DiffLogField(name = "合同", function = CrmContractParseFunction.NAME) - @NotNull(message = "合同编号不能为空") - private Long contractId; - - @Schema(description = "回款计划编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @DiffLogField(name = "合同", function = CrmReceivablePlanParseFunction.NAME) - private Long planId; - - @Schema(description = "回款方式", example = "2") - @DiffLogField(name = "回款方式", function = CrmReceivableReturnTypeParseFunction.NAME) - @InEnum(CrmReceivableReturnTypeEnum.class) - private Integer returnType; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @DiffLogField(name = "回款金额") - @NotNull(message = "回款金额不能为空") - private BigDecimal price; - - @Schema(description = "回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @NotNull(message = "回款日期不能为空") - @DiffLogField(name = "回款日期") - private LocalDateTime returnTime; - - @Schema(description = "备注", example = "备注") - @DiffLogField(name = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http deleted file mode 100644 index 6b960512d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http +++ /dev/null @@ -1,65 +0,0 @@ -# == 1. 客户总量分析 == -### 1.1 客户总量分析(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 1.2 客户总量统计(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 2. 客户跟进次数分析 == -### 2.1 客户跟进次数分析(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 2.2 客户总量统计(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 3. 客户跟进方式分析 == -### 3.1 客户跟进方式分析 -GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-type?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 4. 客户成交周期 == -### 4.1 合同摘要信息(客户转化率页面) -GET {{baseUrl}}/crm/statistics-customer/get-contract-summary?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 5. 客户成交周期 == -### 5.1 获取客户公海分析(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-pool-summary-by-date?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 5.2 获取客户公海分析(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-pool-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 6. 客户成交周期 == -### 6.1 客户成交周期(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 6.2 获取客户成交周期(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 6.3 获取客户成交周期(按区域) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-area?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 6.4 获取客户成交周期(按产品) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-product?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java deleted file mode 100644 index f9586e51a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsCustomerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户统计") -@RestController -@RequestMapping("/crm/statistics-customer") -@Validated -public class CrmStatisticsCustomerController { - - @Resource - private CrmStatisticsCustomerService customerService; - - @GetMapping("/get-customer-summary-by-date") - @Operation(summary = "获取客户总量分析(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerSummaryByDate(reqVO)); - } - - @GetMapping("/get-customer-summary-by-user") - @Operation(summary = "获取客户总量分析(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerSummaryByUser(reqVO)); - } - - @GetMapping("/get-follow-up-summary-by-date") - @Operation(summary = "获取客户跟进次数分析(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getFollowupSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getFollowUpSummaryByDate(reqVO)); - } - - @GetMapping("/get-follow-up-summary-by-user") - @Operation(summary = "获取客户跟进次数分析(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getFollowUpSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getFollowUpSummaryByUser(reqVO)); - } - - @GetMapping("/get-follow-up-summary-by-type") - @Operation(summary = "获取客户跟进次数分析(按类型)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getFollowUpSummaryByType(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getFollowUpSummaryByType(reqVO)); - } - - @GetMapping("/get-contract-summary") - @Operation(summary = "获取客户的首次合同、回款信息列表", description = "用于【客户转化率】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getContractSummary(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getContractSummary(reqVO)); - } - - @GetMapping("/get-pool-summary-by-date") - @Operation(summary = "获取公海客户分析(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getPoolSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getPoolSummaryByDate(reqVO)); - } - - @GetMapping("/get-pool-summary-by-user") - @Operation(summary = "获取公海客户分析(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getPoolSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getPoolSummaryByUser(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-date") - @Operation(summary = "获取客户成交周期(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByDate(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-user") - @Operation(summary = "获取客户成交周期(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByUser(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-area") - @Operation(summary = "获取客户成交周期(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByArea(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByArea(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-product") - @Operation(summary = "获取客户成交周期(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByProduct(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByProduct(reqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java deleted file mode 100644 index 17451e768..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.CrmBusinessController; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsFunnelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 销售漏斗") -@RestController -@RequestMapping("/crm/statistics-funnel") -@Validated -public class CrmStatisticsFunnelController { - - @Resource - private CrmStatisticsFunnelService funnelService; - - @GetMapping("/get-funnel-summary") - @Operation(summary = "获取销售漏斗统计数据", description = "用于【销售漏斗】页面的【销售漏斗分析】") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult getFunnelSummary(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getFunnelSummary(reqVO)); - } - - @GetMapping("/get-business-summary-by-end-status") - @Operation(summary = "获取商机结束状态统计", description = "用于【销售漏斗】页面的【销售漏斗分析】") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessSummaryByEndStatus(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessSummaryByEndStatus(reqVO)); - } - - @GetMapping("/get-business-summary-by-date") - @Operation(summary = "获取新增商机分析(按日期)", description = "用于【销售漏斗】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessSummaryByDate(reqVO)); - } - - @GetMapping("/get-business-inversion-rate-summary-by-date") - @Operation(summary = "获取商机转化率分析(按日期)", description = "用于【销售漏斗】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessInversionRateSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessInversionRateSummaryByDate(reqVO)); - } - - @GetMapping("/get-business-page-by-date") - @Operation(summary = "获得商机分页(按日期)", description = "用于【销售漏斗】页面的【新增商机分析】") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPageByDate(@Valid CrmStatisticsFunnelReqVO pageVO) { - PageResult pageResult = funnelService.getBusinessPageByDate(pageVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - private List buildBusinessDetailList(List list) { - return SpringUtil.getBean(CrmBusinessController.class).buildBusinessDetailList(list); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java deleted file mode 100644 index 6f705aa7a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsPerformanceService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - CRM 员工业绩统计") -@RestController -@RequestMapping("/crm/statistics-performance") -@Validated -public class CrmStatisticsPerformanceController { - - @Resource - private CrmStatisticsPerformanceService performanceService; - - @GetMapping("/get-contract-count-performance") - @Operation(summary = "合同数量统计", description = "用于【合同数量分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getContractCountPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) { - return success(performanceService.getContractCountPerformance(performanceReqVO)); - } - - @GetMapping("/get-contract-price-performance") - @Operation(summary = "合同金额统计") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getContractPriceStaffPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) { - return success(performanceService.getContractPricePerformance(performanceReqVO)); - } - - @GetMapping("/get-receivable-price-performance") - @Operation(summary = "回款金额统计") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getReceivablePriceStaffPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) { - return success(performanceService.getReceivablePricePerformance(performanceReqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPortraitController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPortraitController.java deleted file mode 100644 index 101b9c0c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPortraitController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsPortraitService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户画像") -@RestController -@RequestMapping("/crm/statistics-portrait") -@Validated -public class CrmStatisticsPortraitController { - - @Resource - private CrmStatisticsPortraitService statisticsPortraitService; - - @GetMapping("/get-customer-area-summary") - @Operation(summary = "获取客户地区统计数据", description = "用于【城市分布分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerAreaSummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryByArea(reqVO)); - } - - @GetMapping("/get-customer-industry-summary") - @Operation(summary = "获取客户行业统计数据", description = "用于【客户行业分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerIndustrySummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryByIndustry(reqVO)); - } - - @GetMapping("/get-customer-level-summary") - @Operation(summary = "获取客户级别统计数据", description = "用于【客户级别分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerLevelSummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryByLevel(reqVO)); - } - - @GetMapping("/get-customer-source-summary") - @Operation(summary = "获取客户来源统计数据", description = "用于【客户来源分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerSourceSummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryBySource(reqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.http deleted file mode 100644 index e878ba1a9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.http +++ /dev/null @@ -1,9 +0,0 @@ -### 合同金额排行榜 -GET {{baseUrl}}/crm/statistics-rank/get-contract-price-rank?deptId=100×[0]=2022-12-12 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 回款金额排行榜 -GET {{baseUrl}}/crm/statistics-rank/get-receivable-price-rank?deptId=100×[0]=2022-12-12 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.java deleted file mode 100644 index 627b5961d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsRankService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 排行榜统计") -@RestController -@RequestMapping("/crm/statistics-rank") -@Validated -public class CrmStatisticsRankController { - - @Resource - private CrmStatisticsRankService rankService; - - @GetMapping("/get-contract-price-rank") - @Operation(summary = "获得合同金额排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getContractPriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getContractPriceRank(rankingReqVO)); - } - - @GetMapping("/get-receivable-price-rank") - @Operation(summary = "获得回款金额排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getReceivablePriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getReceivablePriceRank(rankingReqVO)); - } - - @GetMapping("/get-contract-count-rank") - @Operation(summary = "获得签约合同数量排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getContractCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getContractCountRank(rankingReqVO)); - } - - @GetMapping("/get-product-sales-rank") - @Operation(summary = "获得产品销量排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getProductSalesRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getProductSalesRank(rankingReqVO)); - } - - @GetMapping("/get-customer-count-rank") - @Operation(summary = "获得新增客户数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getCustomerCountRank(rankingReqVO)); - } - - @GetMapping("/get-contacts-count-rank") - @Operation(summary = "获得新增联系人数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getContactsCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getContactsCountRank(rankingReqVO)); - } - - @GetMapping("/get-follow-count-rank") - @Operation(summary = "获得跟进次数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getFollowCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getFollowCountRank(rankingReqVO)); - } - - @GetMapping("/get-follow-customer-count-rank") - @Operation(summary = "获得跟进客户数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getFollowCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getFollowCustomerCountRank(rankingReqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java deleted file mode 100644 index bde0029c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 用户客户统计响应 Base Response VO - * - * 目的:可以统一拼接子 VO 的 ownerUserId、ownerUserName 属性 - */ -@Data -public class CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - - @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String ownerUserName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java deleted file mode 100644 index fa03d4609..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 客户转化率分析 VO") -@Data -public class CrmStatisticsCustomerContractSummaryRespVO { - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String customerName; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "演示合同") - private String contractName; - - @Schema(description = "合同总金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1200.00") - private BigDecimal totalPrice; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1200.00") - private BigDecimal receivablePrice; - - @Schema(description = "客户行业编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer industryId; - - @Schema(description = "客户来源编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer source; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String ownerUserName; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private String creator; - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "源码") - private String creatorUserName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-01 13:24:26") - private LocalDateTime createTime; - - @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02 00:00:00") - private LocalDateTime orderDate; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java deleted file mode 100644 index 369837827..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按区域) VO") -@Data -public class CrmStatisticsCustomerDealCycleByAreaRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @JsonIgnore - private Integer areaId; - - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByDateRespVO.java deleted file mode 100644 index 62facb053..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByDateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按日期) VO") -@Data -public class CrmStatisticsCustomerDealCycleByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java deleted file mode 100644 index 442c195aa..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按产品) VO") -@Data -public class CrmStatisticsCustomerDealCycleByProductRespVO { - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "演示产品") - private String productName; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByUserRespVO.java deleted file mode 100644 index 1c394b8b4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByUserRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 成交周期分析(按用户) VO") -@Data -public class CrmStatisticsCustomerDealCycleByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java deleted file mode 100644 index 620a00848..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 数据统计的员工客户分析 Request VO") -@Data -public class CrmStatisticsCustomerReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间间隔类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DateIntervalEnum.class, message = "时间间隔类型,必须是 {value}") - private Integer interval; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByDateRespVO.java deleted file mode 100644 index 7ffcb20ff..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户总量分析(按日期) VO") -@Data -public class CrmStatisticsCustomerSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "新建客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCreateCount; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java deleted file mode 100644 index fa8372b8b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 客户总量分析(按用户) VO") -@Data -public class CrmStatisticsCustomerSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "新建客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCreateCount; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - - @Schema(description = "合同总金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal contractPrice; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal receivablePrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByDateRespVO.java deleted file mode 100644 index 9040c1eab..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 跟进次数分析(按日期) VO") -@Data -public class CrmStatisticsFollowUpSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "跟进次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpRecordCount; - - @Schema(description = "跟进客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpCustomerCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByTypeRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByTypeRespVO.java deleted file mode 100644 index d39f1cc0d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByTypeRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 跟进次数分析(按类型) VO") -@Data -public class CrmStatisticsFollowUpSummaryByTypeRespVO { - - @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpType; - - @Schema(description = "跟进次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpRecordCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByUserRespVO.java deleted file mode 100644 index 065135626..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByUserRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 跟进次数分析(按用户) VO") -@Data -public class CrmStatisticsFollowUpSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "跟进次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpRecordCount; - - @Schema(description = "跟进客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpCustomerCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java deleted file mode 100644 index ce09a9933..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 公海客户分析(按日期) VO") -@Data -public class CrmStatisticsPoolSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerPutCount; - - @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerTakeCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java deleted file mode 100644 index fb59e8477..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 公海客户分析(按用户) VO") -@Data -public class CrmStatisticsPoolSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerPutCount; - - @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerTakeCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java deleted file mode 100644 index 38d1c118f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - CRM 销售漏斗 Response VO") -@NoArgsConstructor -@AllArgsConstructor -@Data -public class CrmStatisticFunnelSummaryRespVO { - - @Schema(description = "客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long customerCount; - - @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "赢单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessWinCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java deleted file mode 100644 index 5e2ff5b2e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 商机转化率分析(按日期) VO") -@Data -public class CrmStatisticsBusinessInversionRateSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "赢单商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessWinCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java deleted file mode 100644 index 1f8056c46..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 新增商机分析(按日期) VO") -@Data -public class CrmStatisticsBusinessSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "新增商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCreateCount; - - @Schema(description = "新增商机金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java deleted file mode 100644 index 023fdb846..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 商机结束状态统计 Response VO") -@NoArgsConstructor -@AllArgsConstructor -@Data -public class CrmStatisticsBusinessSummaryByEndStatusRespVO { - - @Schema(description = "结束状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer endStatus; - - @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "商机总金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java deleted file mode 100644 index 85ba52e17..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 销售漏斗 Request VO") -@Data -public class CrmStatisticsFunnelReqVO extends PageParam { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间间隔类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DateIntervalEnum.class, message = "时间间隔类型,必须是 {value}") - private Integer interval; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java deleted file mode 100644 index 58b539914..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 员工业绩统计 Request VO") -@Data -public class CrmStatisticsPerformanceReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - *

- * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") - private List userIds; - - // TODO @scholar:应该传递的是 int year;年份 - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间范围不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceRespVO.java deleted file mode 100644 index f2cb9be60..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - - -@Schema(description = "管理后台 - CRM 员工业绩统计 Response VO") -@Data -public class CrmStatisticsPerformanceRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "当月统计结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal currentMonthCount; - - @Schema(description = "上月统计结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private BigDecimal lastMonthCount; - - @Schema(description = "去年同期统计结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private BigDecimal lastYearCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerAreaRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerAreaRespVO.java deleted file mode 100644 index 3420e7e5b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerAreaRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户省份分析 VO") -@Data -public class CrmStatisticCustomerAreaRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer areaId; - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerIndustryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerIndustryRespVO.java deleted file mode 100644 index 84b8de70f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerIndustryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户行业分析 VO") -@Data -public class CrmStatisticCustomerIndustryRespVO { - - @Schema(description = "客户行业ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer industryId; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerLevelRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerLevelRespVO.java deleted file mode 100644 index dea4eeb0c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerLevelRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户级别分析 VO") -@Data -public class CrmStatisticCustomerLevelRespVO { - - @Schema(description = "客户级别编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer level; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerSourceRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerSourceRespVO.java deleted file mode 100644 index 61b9688ff..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerSourceRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户来源分析 VO") -@Data -public class CrmStatisticCustomerSourceRespVO { - - @Schema(description = "客户来源编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer source; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticsPortraitReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticsPortraitReqVO.java deleted file mode 100644 index eb65cb3c9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticsPortraitReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 客户画像 Request VO") -@Data -public class CrmStatisticsPortraitReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankReqVO.java deleted file mode 100644 index c4a16ef55..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 排行榜统计 Request VO") -@Data -public class CrmStatisticsRankReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - *

- * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") - private List userIds; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间范围不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java deleted file mode 100644 index feb2f3f2e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - - -@Schema(description = "管理后台 - CRM 排行榜统计 Response VO") -@Data -public class CrmStatisticsRankRespVO { - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - - @Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String nickname; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String deptName; - - /** - * 数量是个特别“抽象”的概念,在不同排行下,代表不同含义 - * - * 1. 金额:合同金额排行、回款金额排行 - * 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行 - * - * 为什么使用 BigDecimal 的原因: - */ - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal count; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java deleted file mode 100644 index 78d85635c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.controller.app; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java deleted file mode 100644 index 8354b3176..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.crm.controller; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java deleted file mode 100644 index 6fbc52508..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.crm.convert; diff --git "a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b7..000000000 --- "a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java deleted file mode 100644 index a30ece21f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * CRM 商机 DO - * - * @author ljlleo - */ -@TableName("crm_business") -@KeySequence("crm_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 商机名称 - */ - private String name; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 商机状态组编号 - * - * 关联 {@link CrmBusinessStatusTypeDO#getId()} - */ - private Long statusTypeId; - /** - * 商机状态编号 - * - * 关联 {@link CrmBusinessStatusDO#getId()} - */ - private Long statusId; - /** - * 结束状态 - * - * 枚举 {@link CrmBusinessEndStatusEnum} - */ - private Integer endStatus; - /** - * 结束时的备注 - */ - private String endRemark; - - /** - * 预计成交日期 - */ - private LocalDateTime dealTime; - /** - * 产品总金额,单位:元 - * - * productPrice = ∑({@link CrmBusinessProductDO#getTotalPrice()}) - */ - private BigDecimal totalProductPrice; - /** - * 整单折扣,百分比 - */ - private BigDecimal discountPercent; - /** - * 商机总金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java deleted file mode 100644 index 2f66fc34d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * CRM 商机产品关联表 DO - * - * CrmBusinessDO : CrmBusinessProductDO = 1 : N - * - * @author lzxhqs - */ -@TableName("crm_business_product") -@KeySequence("crm_business_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessProductDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 商机编号 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - private Long businessId; - /** - * 产品编号 - * - * 关联 {@link CrmProductDO#getId()} - */ - private Long productId; - /** - * 产品单价,单位:元 - * - * 冗余 {@link CrmProductDO#getPrice()} - */ - private BigDecimal productPrice; - /** - * 商机价格, 单位:元 - */ - private BigDecimal businessPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总计价格,单位:元 - * - * totalPrice = businessPrice * count - */ - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java deleted file mode 100644 index 4ec8bbe4a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 商机状态 DO - * - * 注意,它是个配置表 - * - * @author ljlleo - */ -@TableName("crm_business_status") -@KeySequence("crm_business_status_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessStatusDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 状态类型编号 - * - * 关联 {@link CrmBusinessStatusTypeDO#getId()} - */ - private Long typeId; - /** - * 状态名 - */ - private String name; - /** - * 赢单率,百分比 - */ - private Integer percent; - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java deleted file mode 100644 index 95b7a1f26..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * CRM 商机状态组 DO - * - * 注意,它是个配置表 - * - * @author ljlleo - */ -@TableName(value = "crm_business_status_type", autoResultMap = true) -@KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessStatusTypeDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 状态类型名 - */ - private String name; - - /** - * 使用的部门编号 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List deptIds; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java deleted file mode 100644 index 3af6feec4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.clue; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 线索 DO - * - * @author Wanwan - */ -@TableName("crm_clue") -@KeySequence("crm_clue_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmClueDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 线索名称 - */ - private String name; - - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 转化状态 - * - * true 表示已转换,会更新 {@link #customerId} 字段 - */ - private Boolean transformStatus; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - - /** - * 手机号 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - /** - * email - */ - private String email; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java deleted file mode 100644 index 929b9b6fe..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java deleted file mode 100644 index 46185a5ac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 联系人与商机的关联 DO - * - * @author 芋道源码 - */ -@TableName("crm_contact_business") -@KeySequence("crm_contact_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactBusinessDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 联系人编号 - * - * 关联 {@link CrmContactDO#getId()} 字段 - */ - private Long contactId; - /** - * 商机编号 - * - * 关联 {@link CrmBusinessDO#getId()} 字段 - */ - private Long businessId; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java deleted file mode 100644 index 5a891eb9c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 联系人 DO - * - * @author 芋道源码 - */ -@TableName("crm_contact") -@KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 联系人姓名 - */ - private String name; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 手机号 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * QQ - */ - private Long qq; - /** - * 微信 - */ - private String wechat; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 性别 - * - * 枚举 {@link cn.iocoder.yudao.module.system.enums.common.SexEnum} - */ - private Integer sex; - /** - * 是否关键决策人 - */ - private Boolean master; - /** - * 职位 - */ - private String post; - /** - * 直属上级 - * - * 关联 {@link CrmContactDO#id} - */ - private Long parentId; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java deleted file mode 100644 index dfe0898e3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 联系人 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractConfigDO.java deleted file mode 100644 index ab0c2d28e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractConfigDO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.*; -import lombok.*; - -@TableName("crm_contract_config") -@KeySequence("crm_contract_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 是否开启提前提醒 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Boolean notifyEnabled; - /** - * 提前提醒天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java deleted file mode 100644 index 89f4fd98a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * CRM 合同 DO - * - * @author dhb52 - */ -@TableName("crm_contract") -@KeySequence("crm_contract_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractDO extends BaseDO { - - /** - * 合同编号 - */ - @TableId - private Long id; - /** - * 合同名称 - */ - private String name; - /** - * 合同编号 - */ - private String no; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 商机编号,非必须 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - private Long businessId; - - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 工作流编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 审批状态 - * - * 枚举 {@link CrmAuditStatusEnum} - */ - private Integer auditStatus; - - /** - * 下单日期 - */ - private LocalDateTime orderDate; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 产品总金额,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 整单折扣 - */ - private BigDecimal discountPercent; - /** - * 合同总金额,单位:分 - */ - private BigDecimal totalPrice; - /** - * 客户签约人,非必须 - * - * 关联 {@link CrmContactDO#getId()} - */ - private Long signContactId; - /** - * 公司签约人,非必须 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long signUserId; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java deleted file mode 100644 index 6bb3e6bf0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * CRM 合同产品关联表 DO - * - * @author HUIHUI - */ -@TableName("crm_contract_product") -@KeySequence("crm_contract_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractProductDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 合同编号 - * - * 关联 {@link CrmContractDO#getId()} - */ - private Long contractId; - /** - * 产品编号 - * - * 关联 {@link CrmProductDO#getId()} - */ - private Long productId; - /** - * 产品单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 合同价格, 单位:元 - */ - private BigDecimal contractPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总计价格,单位:元 - * - * totalPrice = businessPrice * count - */ - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java deleted file mode 100644 index 76d511115..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 客户 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer") -@KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 客户名称 - */ - private String name; - - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - /** - * 成为负责人的时间 - */ - private LocalDateTime ownerTime; - - /** - * 锁定状态 - */ - private Boolean lockStatus; - /** - * 成交状态 - */ - private Boolean dealStatus; - - /** - * 手机 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - /** - * email - */ - private String email; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java deleted file mode 100644 index df3d3be6f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 客户限制配置 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer_limit_config", autoResultMap = true) -@KeySequence("crm_customer_limit_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerLimitConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 规则类型 - *

- * 枚举 {@link CrmCustomerLimitConfigTypeEnum} - */ - private Integer type; - /** - * 规则适用人群 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List userIds; - /** - * 规则适用部门 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List deptIds; - /** - * 数量上限 - */ - private Integer maxCount; - /** - * 成交客户是否占有拥有客户数 - * - * 当且仅当 {@link #type} 为 1 时,进行使用 - */ - private Boolean dealCountEnabled; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java deleted file mode 100644 index 76f20dc3b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.*; -import lombok.*; - -/** - * 客户公海配置 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer_pool_config") -@KeySequence("crm_customer_pool_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerPoolConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 是否启用客户公海 - */ - private Boolean enabled; - /** - * 未跟进放入公海天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer contactExpireDays; - /** - * 未成交放入公海天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer dealExpireDays; - /** - * 是否开启提前提醒 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Boolean notifyEnabled; - /** - * 提前提醒天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java deleted file mode 100644 index a01d47af9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.followup; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 跟进记录 DO - * - * 用于记录客户、联系人的每一次跟进 - * - * @author 芋道源码 - */ -@TableName(value = "crm_follow_up_record", autoResultMap = true) -@KeySequence("crm_follow_up_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmFollowUpRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - private Long bizId; - - /** - * 跟进类型 - * - * 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典 - */ - private Integer type; - /** - * 跟进内容 - */ - private String content; - /** - * 下次联系时间 - */ - private LocalDateTime nextTime; - - /** - * 图片 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List picUrls; - /** - * 附件 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List fileUrls; - - /** - * 关联的商机编号数组 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List businessIds; - /** - * 关联的联系人编号数组 - * - * 关联 {@link CrmContactDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List contactIds; - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java deleted file mode 100644 index 59e47a5a8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.permission; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 数据权限 DO - * - * @author HUIHUI - */ -@TableName("crm_permission") -@KeySequence("crm_permission_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmPermissionDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - private Long bizId; - - /** - * 用户编号 - * - * 关联 AdminUser 的 id 字段 - */ - private Long userId; - - /** - * 权限级别 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java deleted file mode 100644 index e0f4d6245..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 产品分类 DO - * - * @author ZanGe丶 - */ -@TableName("crm_product_category") -@KeySequence("crm_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - /** - * 限定分类层级 - */ - public static final int CATEGORY_LEVEL = 2; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 分类名称 - */ - private String name; - /** - * 父级编号 - * - * 关联 {@link CrmProductCategoryDO#getId()} - */ - private Long parentId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java deleted file mode 100644 index caeeb53d2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * CRM 产品 DO - * - * @author ZanGe丶 - */ -@TableName("crm_product") -@KeySequence("crm_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmProductDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品名称 - */ - private String name; - /** - * 产品编码 - */ - private String no; - /** - * 单位 - * - * 字典 {@link DictTypeConstants#CRM_PRODUCT_UNIT} - */ - private Integer unit; - /** - * 价格,单位:元 - */ - private BigDecimal price; - /** - * 状态 - * - * 关联 {@link CrmProductStatusEnum} - */ - private Integer status; - /** - * 产品分类 ID - * - * 关联 {@link CrmProductCategoryDO#getId()} 字段 - */ - private Long categoryId; - /** - * 产品描述 - */ - private String description; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java deleted file mode 100644 index 4c7282d73..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 产品表 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java deleted file mode 100644 index 269cac6cc..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableReturnTypeEnum; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * 回款 DO - * - * @author 赤焰 - */ -@TableName("crm_receivable") -@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmReceivableDO extends BaseDO { - - /** - * ID - */ - @TableId - private Long id; - /** - * 回款编号 - */ - private String no; - /** - * 回款计划编号 - * - * 关联 {@link CrmReceivablePlanDO#getId()},非必须 - */ - private Long planId; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 合同编号 - * - * 关联 {@link CrmContractDO#getId()} - */ - private Long contractId; - /** - * 负责人编号,关联 {@link AdminUserRespDTO#getId()} - */ - private Long ownerUserId; - - /** - * 回款日期 - */ - private LocalDateTime returnTime; - /** - * 回款方式,关联枚举{@link CrmReceivableReturnTypeEnum} - */ - private Integer returnType; - /** - * 计划回款金额,单位:元 - */ - private BigDecimal price; - /** - * 备注 - */ - private String remark; - - /** - * 工作流编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 审批状态 - * - * 枚举 {@link CrmAuditStatusEnum} - */ - private Integer auditStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java deleted file mode 100644 index 5ddefc559..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableReturnTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * CRM 回款计划 DO - * - * @author 芋道源码 - */ -@TableName("crm_receivable_plan") -@KeySequence("crm_receivable_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmReceivablePlanDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 期数 - */ - private Integer period; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 合同编号 - * - * 关联 {@link CrmContractDO#getId()} - */ - private Long contractId; - - /** - * 负责人编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 计划回款日期 - */ - private LocalDateTime returnTime; - /** - * 计划回款类型 - * - * 枚举 {@link CrmReceivableReturnTypeEnum} - */ - private Integer returnType; - /** - * 计划回款金额,单位:元 - */ - private BigDecimal price; - - /** - * 回款编号,关联 {@link CrmReceivableDO#getId()} - */ - private Long receivableId; - - /** - * 提前几天提醒 - */ - private Integer remindDays; - /** - * 提醒日期 - */ - private LocalDateTime remindTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java deleted file mode 100644 index ba347bcf6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 商机 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessMapper extends BaseMapperX { - - default int updateOwnerUserIdById(Long id, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmBusinessDO::getId, id) - .set(CrmBusinessDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 - .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) - .orderByDesc(CrmBusinessDO::getId)); - } - - default PageResult selectPageByContactId(CrmBusinessPageReqVO pageReqVO, Collection businessIds) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .in(CrmBusinessDO::getId, businessIds) // 指定商机编号 - .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) - .orderByDesc(CrmBusinessDO::getId)); - } - - default PageResult selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), - CrmBusinessDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmBusinessDO.class) - .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) - .orderByDesc(CrmBusinessDO::getId); - return selectJoinPage(pageReqVO, CrmBusinessDO.class, query); - } - - default Long selectCountByStatusTypeId(Long statusTypeId) { - return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId); - } - - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmBusinessDO::getCustomerId, customerId) - .eq(CrmBusinessDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPage(CrmStatisticsFunnelReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .in(CrmBusinessDO::getOwnerUserId, pageVO.getUserIds()) - .betweenIfPresent(CrmBusinessDO::getCreateTime, pageVO.getTimes())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java deleted file mode 100644 index a91a0fd14..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商机产品 Mapper - * - * @author lzxhqs - */ -@Mapper -public interface CrmBusinessProductMapper extends BaseMapperX { - - default List selectListByBusinessId(Long businessId) { - return selectList(CrmBusinessProductDO::getBusinessId, businessId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java deleted file mode 100644 index dfe7afcc3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商机状态 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusMapper extends BaseMapperX { - - default int deleteByTypeId(Long typeId) { - return delete(CrmBusinessStatusDO::getTypeId, typeId); - } - - default List selectListByTypeId(Long typeId) { - return selectList(CrmBusinessStatusDO::getTypeId, typeId); - } - - default CrmBusinessStatusDO selectByTypeIdAndId(Long statusTypeId, Long statusId) { - return selectOne(CrmBusinessStatusDO::getTypeId, statusTypeId, - CrmBusinessStatusDO::getId, statusId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java deleted file mode 100644 index 3444e58a7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 商机状态组 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusTypeMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(CrmBusinessStatusTypeDO::getId)); - } - - default CrmBusinessStatusTypeDO selectByName(String name) { - return selectOne(CrmBusinessStatusTypeDO::getName, name); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java deleted file mode 100644 index d0665c604..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.clue; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 线索 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmClueMapper extends BaseMapperX { - - default PageResult selectPage(CrmCluePageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), - CrmClueDO::getId, userId, pageReqVO.getSceneType(), pageReqVO.getPool()); - // 拼接自身的查询条件 - query.selectAll(CrmClueDO.class) - .likeIfPresent(CrmClueDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmClueDO::getTransformStatus, pageReqVO.getTransformStatus()) - .likeIfPresent(CrmClueDO::getTelephone, pageReqVO.getTelephone()) - .likeIfPresent(CrmClueDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmClueDO::getIndustryId, pageReqVO.getIndustryId()) - .eqIfPresent(CrmClueDO::getLevel, pageReqVO.getLevel()) - .eqIfPresent(CrmClueDO::getSource, pageReqVO.getSource()) - .eqIfPresent(CrmClueDO::getFollowUpStatus, pageReqVO.getFollowUpStatus()) - .orderByDesc(CrmClueDO::getId); - return selectJoinPage(pageReqVO, CrmClueDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), ids, userId); - query.selectAll(CrmClueDO.class).in(CrmClueDO::getId, ids).orderByDesc(CrmClueDO::getId); - // 拼接自身的查询条件 - return selectJoinList(CrmClueDO.class, query); - } - - default Long selectCountByFollow(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), - CrmClueDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未跟进 + 未转化 - query.eq(CrmClueDO::getFollowUpStatus, false) - .eq(CrmClueDO::getTransformStatus, false); - return selectCount(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java deleted file mode 100644 index f9978e868..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java deleted file mode 100644 index 7bff0c204..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contact; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * CRM 联系人商机关联 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmContactBusinessMapper extends BaseMapperX { - - default CrmContactBusinessDO selectByContactIdAndBusinessId(Long contactId, Long businessId) { - return selectOne(CrmContactBusinessDO::getContactId, contactId, - CrmContactBusinessDO::getBusinessId, businessId); - } - - default void deleteByContactIdAndBusinessId(Long contactId, Collection businessIds) { - delete(new LambdaQueryWrapper() - .eq(CrmContactBusinessDO::getContactId, contactId) - .in(CrmContactBusinessDO::getBusinessId, businessIds)); - } - - default void deleteByBusinessIdAndContactId(Long businessId, List contactIds) { - delete(new LambdaQueryWrapper() - .eq(CrmContactBusinessDO::getBusinessId, businessId) - .in(CrmContactBusinessDO::getContactId, contactIds)); - } - - default List selectListByContactId(Long contactId) { - return selectList(CrmContactBusinessDO::getContactId, contactId); - } - - default List selectListByBusinessId(Long businessId) { - return selectList(CrmContactBusinessDO::getBusinessId, businessId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java deleted file mode 100644 index 75f2a750e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * CRM 联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmContactMapper extends BaseMapperX { - - default int updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmContactDO::getCustomerId, customerId) - .set(CrmContactDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPageByCustomerId(CrmContactPageReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 指定客户编号 - .likeIfPresent(CrmContactDO::getName, pageVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) - .orderByDesc(CrmContactDO::getId)); - } - - default PageResult selectPageByBusinessId(CrmContactPageReqVO pageVO, Collection ids) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .in(CrmContactDO::getId, ids) // 指定联系人编号 - .likeIfPresent(CrmContactDO::getName, pageVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) - .orderByDesc(CrmContactDO::getId)); - } - - default PageResult selectPage(CrmContactPageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), - CrmContactDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmContactDO.class) - .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageReqVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageReqVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageReqVO.getWechat()) - .orderByDesc(CrmContactDO::getId); - return selectJoinPage(pageReqVO, CrmContactDO.class, query); - } - - default List selectListByCustomerId(Long customerId) { - return selectList(CrmContactDO::getCustomerId, customerId); - } - - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return selectList(CrmContactDO::getCustomerId, customerId, - CrmContactDO::getOwnerUserId, ownerUserId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractConfigMapper.java deleted file mode 100644 index 64e6f918b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractConfigMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 合同配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmContractConfigMapper extends BaseMapperX { - - default CrmContractConfigDO selectOne() { - return selectOne(new QueryWrapperX().limitN(1)); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java deleted file mode 100644 index 14d743291..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * CRM 合同 Mapper - * - * @author dhb52 - */ -@Mapper -public interface CrmContractMapper extends BaseMapperX { - - default CrmContractDO selectByNo(String no) { - return selectOne(CrmContractDO::getNo, no); - } - - default PageResult selectPageByCustomerId(CrmContractPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .orderByDesc(CrmContractDO::getId)); - } - - default PageResult selectPageByBusinessId(CrmContractPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .orderByDesc(CrmContractDO::getId)); - } - - default PageResult selectPage(CrmContractPageReqVO pageReqVO, Long userId, CrmContractConfigDO config) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), - CrmContractDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmContractDO.class) - .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .eqIfPresent(CrmContractDO::getAuditStatus, pageReqVO.getAuditStatus()) - .orderByDesc(CrmContractDO::getId); - - // Backlog: 即将到期的合同 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - if (CrmContractPageReqVO.EXPIRY_TYPE_ABOUT_TO_EXPIRE.equals(pageReqVO.getExpiryType())) { // 即将到期 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.APPROVE.getStatus()) - .between(CrmContractDO::getEndTime, beginOfToday, endOfToday.plusDays(config.getNotifyDays())); - } else if (CrmContractPageReqVO.EXPIRY_TYPE_EXPIRED.equals(pageReqVO.getExpiryType())) { // 已到期 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.APPROVE.getStatus()) - .lt(CrmContractDO::getEndTime, endOfToday); - } - return selectJoinPage(pageReqVO, CrmContractDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 构建数据权限连表条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), ids, userId); - // 拼接自身的查询条件 - query.selectAll(CrmContractDO.class).in(CrmContractDO::getId, ids).orderByDesc(CrmContractDO::getId); - return selectJoinList(CrmContractDO.class, query); - } - - default Long selectCountByContactId(Long contactId) { - return selectCount(CrmContractDO::getSignContactId, contactId); - } - - default Long selectCountByBusinessId(Long businessId) { - return selectCount(CrmContractDO::getBusinessId, businessId); - } - - default Long selectCountByAudit(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), - CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未审核 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.PROCESS.getStatus()); - return selectCount(query); - } - - default Long selectCountByRemind(Long userId, CrmContractConfigDO config) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), - CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 即将到期 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.APPROVE.getStatus()) // 必须审批通过! - .between(CrmContractDO::getEndTime, beginOfToday, endOfToday.plusDays(config.getNotifyDays())); - return selectCount(query); - } - - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmContractDO::getCustomerId, customerId) - .eq(CrmContractDO::getOwnerUserId, ownerUserId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java deleted file mode 100644 index feafbc444..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 合同产品 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmContractProductMapper extends BaseMapperX { - - default List selectListByContractId(Long contractId) { - return selectList(new LambdaQueryWrapperX().eq(CrmContractProductDO::getContractId, contractId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java deleted file mode 100644 index 08beaf808..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 客户限制配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerLimitConfigMapper extends BaseMapperX { - - default PageResult selectPage(CrmCustomerLimitConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmCustomerLimitConfigDO::getType, reqVO.getType()) - .orderByDesc(CrmCustomerLimitConfigDO::getId)); - } - - default List selectListByTypeAndUserIdAndDeptId( - Integer type, Long userId, Long deptId) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - .eq(CrmCustomerLimitConfigDO::getType, type); - query.apply("FIND_IN_SET({0}, user_ids) > 0", userId); - if (deptId != null) { - query.apply("FIND_IN_SET({0}, dept_ids) > 0", deptId); - } - return selectList(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java deleted file mode 100644 index 503445388..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ /dev/null @@ -1,189 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 客户 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerMapper extends BaseMapperX { - - default Long selectCountByLockStatusAndOwnerUserId(Boolean lockStatus, Long ownerUserId) { - return selectCount(new LambdaUpdateWrapper() - .eq(CrmCustomerDO::getLockStatus, lockStatus) - .eq(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - default Long selectCountByDealStatusAndOwnerUserId(@Nullable Boolean dealStatus, Long ownerUserId) { - return selectCount(new LambdaQueryWrapperX() - .eqIfPresent(CrmCustomerDO::getDealStatus, dealStatus) - .eq(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - default int updateOwnerUserIdById(Long id, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmCustomerDO::getId, id) - .set(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPage(CrmCustomerPageReqVO pageReqVO, Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), pageReqVO.getPool()); - // 拼接自身的查询条件 - query.selectAll(CrmCustomerDO.class) - .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) - .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) - .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()) - .eqIfPresent(CrmCustomerDO::getFollowUpStatus, pageReqVO.getFollowUpStatus()); - - // backlog 查询 - if (ObjUtil.isNotNull(pageReqVO.getContactStatus())) { - Assert.isNull(pageReqVO.getPool(), "pool 必须是 null"); - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系 - query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); - } else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期 - query.lt(CrmCustomerDO::getContactNextTime, beginOfToday); - } else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系 - query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday); - } else { - throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus()); - } - } - return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); - } - - default List selectBatchIds(Collection ids, Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, ownerUserId); - // 拼接自身的查询条件 - query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId); - return selectJoinList(CrmCustomerDO.class, query); - } - - default CrmCustomerDO selectByCustomerName(String name) { - return selectOne(CrmCustomerDO::getName, name); - } - - default PageResult selectPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageReqVO, - CrmCustomerPoolConfigDO poolConfig, - Long ownerUserId) { - final MPJLambdaWrapperX query = buildPutPoolRemindCustomerQuery(pageReqVO, poolConfig, ownerUserId); - return selectJoinPage(pageReqVO, CrmCustomerDO.class, query.selectAll(CrmCustomerDO.class)); - } - - default Long selectPutPoolRemindCustomerCount(CrmCustomerPageReqVO pageReqVO, - CrmCustomerPoolConfigDO poolConfigDO, - Long userId) { - final MPJLambdaWrapperX query = buildPutPoolRemindCustomerQuery(pageReqVO, poolConfigDO, userId); - return selectCount(query); - } - - static MPJLambdaWrapperX buildPutPoolRemindCustomerQuery(CrmCustomerPageReqVO pageReqVO, - CrmCustomerPoolConfigDO poolConfig, - Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), null); - - // 未锁定 + 未成交 - query.eq(CrmCustomerDO::getLockStatus, false).eq(CrmCustomerDO::getDealStatus, false); - - // 情况一:未成交提醒日期区间 - Integer dealExpireDays = poolConfig.getDealExpireDays(); - LocalDateTime startDealRemindTime = LocalDateTime.now().minusDays(dealExpireDays); - LocalDateTime endDealRemindTime = LocalDateTime.now() - .minusDays(Math.max(dealExpireDays - poolConfig.getNotifyDays(), 0)); - // 情况二:未跟进提醒日期区间 - Integer contactExpireDays = poolConfig.getContactExpireDays(); - LocalDateTime startContactRemindTime = LocalDateTime.now().minusDays(contactExpireDays); - LocalDateTime endContactRemindTime = LocalDateTime.now() - .minusDays(Math.max(contactExpireDays - poolConfig.getNotifyDays(), 0)); - query.and(q -> { - // 情况一:成交超时提醒 - q.between(CrmCustomerDO::getOwnerTime, startDealRemindTime, endDealRemindTime) - // 情况二:跟进超时提醒 - .or(w -> w.between(CrmCustomerDO::getOwnerTime, startContactRemindTime, endContactRemindTime) - .and(p -> p.between(CrmCustomerDO::getContactLastTime, startContactRemindTime, endContactRemindTime) - .or().isNull(CrmCustomerDO::getContactLastTime))); - }); - return query; - } - - /** - * 获得需要过期到公海的客户列表 - * - * @return 客户列表 - */ - default List selectListByAutoPool(CrmCustomerPoolConfigDO poolConfig) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.gt(CrmCustomerDO::getOwnerUserId, 0); - // 未锁定 + 未成交 - query.eq(CrmCustomerDO::getLockStatus, false).eq(CrmCustomerDO::getDealStatus, false); - // 已经超时 - LocalDateTime dealExpireTime = LocalDateTime.now().minusDays(poolConfig.getDealExpireDays()); - LocalDateTime contactExpireTime = LocalDateTime.now().minusDays(poolConfig.getContactExpireDays()); - query.and(q -> { - // 情况一:成交超时 - q.lt(CrmCustomerDO::getOwnerTime, dealExpireTime) - // 情况二:跟进超时 - .or(w -> w.lt(CrmCustomerDO::getOwnerTime, contactExpireTime) - .and(p -> p.lt(CrmCustomerDO::getContactLastTime, contactExpireTime) - .or().isNull(CrmCustomerDO::getContactLastTime))); - }); - return selectList(query); - } - - default Long selectCountByTodayContact(Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 今天需联系 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); - return selectCount(query); - } - - default Long selectCountByFollow(Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未跟进 - query.eq(CrmClueDO::getFollowUpStatus, false); - return selectCount(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java deleted file mode 100644 index 06cf44e4f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 客户公海配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerPoolConfigMapper extends BaseMapperX { - - default CrmCustomerPoolConfigDO selectOne() { - return selectOne(new LambdaQueryWrapperX().last("LIMIT 1")); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java deleted file mode 100644 index 45e2b412e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.followup; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 跟进记录 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmFollowUpRecordMapper extends BaseMapperX { - - default PageResult selectPage(CrmFollowUpRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmFollowUpRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(CrmFollowUpRecordDO::getBizId, reqVO.getBizId()) - .orderByDesc(CrmFollowUpRecordDO::getId)); - } - - default void deleteByBiz(Integer bizType, Long bizId) { - delete(new LambdaQueryWrapperX() - .eq(CrmFollowUpRecordDO::getBizType, bizType) - .eq(CrmFollowUpRecordDO::getBizId, bizId)); - } - - default List selectListByBiz(Integer bizType, Collection bizIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmFollowUpRecordDO::getBizType, bizType) - .in(CrmFollowUpRecordDO::getBizId, bizIds)); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java deleted file mode 100644 index 07b7b6b1f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.permission; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * crm 数据权限 mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmPermissionMapper extends BaseMapperX { - - default CrmPermissionDO selectByBizTypeAndBizIdByUserId(Integer bizType, Long bizId, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default List selectByBizTypeAndBizId(Integer bizType, Long bizId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId)); - } - - default List selectByBizTypeAndBizIds(Integer bizType, Collection bizIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .in(CrmPermissionDO::getBizId, bizIds)); - } - - default List selectListByBizTypeAndUserId(Integer bizType, Long userId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default List selectListByBizTypeAndBizIdAndLevel(Integer bizType, Long bizId, Integer level) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getLevel, level)); - } - - default CrmPermissionDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(CrmPermissionDO::getId, id, - CrmPermissionDO::getUserId, userId); - } - - default CrmPermissionDO selectByBizAndUserId(Integer bizType, Long bizId, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default int deletePermission(Integer bizType, Long bizId) { - return delete(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId)); - } - - default Long selectListByBiz(Collection bizTypes, Collection bizIds, Collection userIds) { - return selectCount(new LambdaQueryWrapperX() - .in(CrmPermissionDO::getBizType, bizTypes) - .in(CrmPermissionDO::getBizId, bizIds) - .in(CrmPermissionDO::getUserId, userIds)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java deleted file mode 100644 index ff0e16b90..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.permission; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java deleted file mode 100644 index 3cced7356..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 产品分类 Mapper - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductCategoryMapper extends BaseMapperX { - - default List selectList(CrmProductCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(CrmProductCategoryDO::getName, reqVO.getName()) - .eqIfPresent(CrmProductCategoryDO::getParentId, reqVO.getParentId()) - .orderByDesc(CrmProductCategoryDO::getId)); - } - - default CrmProductCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(CrmProductCategoryDO::getParentId, parentId, CrmProductCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(CrmProductCategoryDO::getParentId, parentId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java deleted file mode 100644 index 4d1d61809..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 产品 Mapper - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductMapper extends BaseMapperX { - - default PageResult selectPage(CrmProductPageReqVO reqVO) { - return selectPage(reqVO, new MPJLambdaWrapperX() - .likeIfPresent(CrmProductDO::getName, reqVO.getName()) - .eqIfPresent(CrmProductDO::getStatus, reqVO.getStatus()) - .orderByDesc(CrmProductDO::getId)); - } - - default CrmProductDO selectByNo(String no) { - return selectOne(CrmProductDO::getNo, no); - } - - default Long selectCountByCategoryId(Long categoryId) { - return selectCount(CrmProductDO::getCategoryId, categoryId); - } - - default List selectListByStatus(Integer status) { - return selectList(CrmProductDO::getStatus, status); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java deleted file mode 100644 index 0c821c8c2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 回款 Mapper - * - * @author 赤焰 - */ -@Mapper -public interface CrmReceivableMapper extends BaseMapperX { - - default CrmReceivableDO selectByNo(String no) { - return selectOne(CrmReceivableDO::getNo, no); - } - - default PageResult selectPageByCustomerId(CrmReceivablePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) - .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) - .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) - .orderByDesc(CrmReceivableDO::getId)); - } - - default PageResult selectPage(CrmReceivablePageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), - CrmReceivableDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmReceivableDO.class) - .eqIfPresent(CrmReceivableDO::getNo, pageReqVO.getNo()) - .eqIfPresent(CrmReceivableDO::getPlanId, pageReqVO.getPlanId()) - .eqIfPresent(CrmReceivableDO::getContractId, pageReqVO.getContractId()) - .eqIfPresent(CrmReceivableDO::getAuditStatus, pageReqVO.getAuditStatus()) - .orderByDesc(CrmReceivableDO::getId); - return selectJoinPage(pageReqVO, CrmReceivableDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId); - // 拼接自身的查询条件 - query.selectAll(CrmReceivableDO.class).in(CrmReceivableDO::getId, ids).orderByDesc(CrmReceivableDO::getId); - return selectJoinList(CrmReceivableDO.class, query); - } - - default Long selectCountByAudit(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), - CrmReceivableDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未审核 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.PROCESS.getStatus()); - return selectCount(query); - } - - default List selectListByContractIdAndStatus(Long contractId, Collection auditStatuses) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmReceivableDO::getContractId, contractId) - .in(CrmReceivableDO::getAuditStatus, auditStatuses)); - } - - default Map selectReceivablePriceMapByContractId(Collection contractIds) { - if (CollUtil.isEmpty(contractIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("contract_id, SUM(price) AS total_price") - .in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过 - CrmAuditStatusEnum.PROCESS, CrmAuditStatusEnum.APPROVE.getStatus()) - .groupBy("contract_id") - .in("contract_id", contractIds)); - // 获得金额 - return convertMap(result, obj -> (Long) obj.get("contract_id"), obj -> (BigDecimal) obj.get("total_price")); - } - - default Long selectCountByContractId(Long contractId) { - return selectCount(CrmReceivableDO::getContractId, contractId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java deleted file mode 100644 index 4d5389793..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -/** - * 回款计划 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmReceivablePlanMapper extends BaseMapperX { - - default CrmReceivablePlanDO selectMaxPeriodByContractId(Long contractId) { - return selectOne(new MPJLambdaWrapperX() - .eq(CrmReceivablePlanDO::getContractId, contractId) - .orderByDesc(CrmReceivablePlanDO::getPeriod) - .last("LIMIT 1")); - } - - default PageResult selectPageByCustomerId(CrmReceivablePlanPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - if (Objects.nonNull(reqVO.getContractNo())) { // 根据合同编号检索 - query.innerJoin(CrmContractDO.class, on -> on.like(CrmContractDO::getNo, reqVO.getContractNo()) - .eq(CrmContractDO::getId, CrmReceivablePlanDO::getContractId)); - } - query.eq(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) - .orderByDesc(CrmReceivablePlanDO::getPeriod); - return selectJoinPage(reqVO, CrmReceivablePlanDO.class, query); - } - - default PageResult selectPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), - CrmReceivablePlanDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmReceivablePlanDO.class) - .eqIfPresent(CrmReceivablePlanDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmReceivablePlanDO::getContractId, pageReqVO.getContractId()) - .orderByDesc(CrmReceivablePlanDO::getPeriod); - if (Objects.nonNull(pageReqVO.getContractNo())) { // 根据合同编号检索 - query.innerJoin(CrmContractDO.class, on -> on.like(CrmContractDO::getNo, pageReqVO.getContractNo()) - .eq(CrmContractDO::getId, CrmReceivablePlanDO::getContractId)); - } - - // Backlog: 回款提醒类型 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - if (CrmReceivablePlanPageReqVO.REMIND_TYPE_NEEDED.equals(pageReqVO.getRemindType())) { // 待回款 - query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 - .lt(CrmReceivablePlanDO::getReturnTime, beginOfToday) // 已逾期 - .lt(CrmReceivablePlanDO::getRemindTime, beginOfToday); // 今天开始提醒 - } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_EXPIRED.equals(pageReqVO.getRemindType())) { // 已逾期 - query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 - .ge(CrmReceivablePlanDO::getReturnTime, beginOfToday); // 已逾期 - } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_RECEIVED.equals(pageReqVO.getRemindType())) { // 已回款 - query.isNotNull(CrmReceivablePlanDO::getReceivableId); - } - return selectJoinPage(pageReqVO, CrmReceivablePlanDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), ids, userId); - // 拼接自身的查询条件 - query.selectAll(CrmReceivablePlanDO.class).in(CrmReceivablePlanDO::getId, ids).orderByDesc(CrmReceivablePlanDO::getId); - return selectJoinList(CrmReceivablePlanDO.class, query); - } - - default Long selectReceivablePlanCountByRemind(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), - CrmReceivablePlanDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未回款 + 已逾期 + 今天开始提醒 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 - .lt(CrmReceivablePlanDO::getReturnTime, beginOfToday) // 已逾期 - .lt(CrmReceivablePlanDO::getRemindTime, beginOfToday); // 今天开始提醒 - return selectCount(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java deleted file mode 100644 index ca9a08252..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java +++ /dev/null @@ -1,211 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 客户分析 Mapper - * - * @author dhb52 - */ -@Mapper -public interface CrmStatisticsCustomerMapper { - - /** - * 新建客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerCreateCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 成交客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 新建客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerCreateCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 成交客户数(按用户) - * - * @param reqVO 请求参数@param reqVO 请求参数@param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 合同总金额(按用户) - * - * @return 统计数据@return 统计数据@param reqVO 请求参数 - * @return 统计数据 - */ - List selectContractPriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 合同回款金额(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectReceivablePriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpRecordCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpCustomerCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpRecordCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpCustomerCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - - /** - * 首次合同、回款信息(用于【客户转化率】页面) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectContractSummary(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数(按类型) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpRecordCountGroupByType(CrmStatisticsCustomerReqVO reqVO); - - - /** - * 进入公海客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerPutCountByDate(CrmStatisticsCustomerReqVO reqVO) { - LocalDateTime currrentDate = LocalDateTimeUtil.beginOfDay(reqVO.getTimes()[0]); - LocalDateTime endDate = LocalDateTimeUtil.endOfDay(reqVO.getTimes()[1]); - List voList = new ArrayList<>(); - while (currrentDate.isBefore(endDate)) { - voList.add(new CrmStatisticsPoolSummaryByDateRespVO() - .setTime(LocalDateTimeUtil.format(currrentDate, "yyyy-MM-dd")) - .setCustomerPutCount(RandomUtil.randomInt(0, 10)) - .setCustomerTakeCount(RandomUtil.randomInt(0, 10))); - currrentDate = currrentDate.plusDays(1); - } - - return voList; - } - - /** - * 公海领取客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerTakeCountByDate(CrmStatisticsCustomerReqVO reqVO) { - return selectPoolCustomerPutCountByDate(reqVO); - } - - /** - * 进入公海客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerPutCountByUser(CrmStatisticsCustomerReqVO reqVO) { - return convertList(reqVO.getUserIds(), userId -> - (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() - .setCustomerPutCount(RandomUtil.randomInt(0, 10)) - .setCustomerTakeCount(RandomUtil.randomInt(0, 10)) - .setOwnerUserId(userId)); - } - - /** - * 公海领取客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerTakeCountByUser(CrmStatisticsCustomerReqVO reqVO) { - return selectPoolCustomerPutCountByUser(reqVO); - } - - /** - * 客户成交周期(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按区域) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByAreaId(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按产品) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByProductId(CrmStatisticsCustomerReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java deleted file mode 100644 index d69fa6290..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessInversionRateSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * CRM 销售漏斗 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmStatisticsFunnelMapper { - - Long selectCustomerCountByDate(CrmStatisticsFunnelReqVO reqVO); - - Long selectBusinessCountByDateAndEndStatus(@Param("reqVO") CrmStatisticsFunnelReqVO reqVO, @Param("status") Integer status); - - List selectBusinessSummaryListGroupByEndStatus(CrmStatisticsFunnelReqVO reqVO); - - List selectBusinessSummaryGroupByDate(CrmStatisticsFunnelReqVO reqVO); - - List selectBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPerformanceMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPerformanceMapper.java deleted file mode 100644 index 6467a098d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPerformanceMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 员工业绩分析 Mapper - * - * @author scholar - */ -@Mapper -public interface CrmStatisticsPerformanceMapper { - - /** - * 员工签约合同数量 - * - * @param performanceReqVO 参数 - * @return 员工签约合同数量 - */ - List selectContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工签约合同金额 - * - * @param performanceReqVO 参数 - * @return 员工签约合同金额 - */ - List selectContractPricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工回款金额 - * - * @param performanceReqVO 参数 - * @return 员工回款金额 - */ - List selectReceivablePricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPortraitMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPortraitMapper.java deleted file mode 100644 index a7c942752..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPortraitMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 数据画像 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmStatisticsPortraitMapper { - - List selectSummaryListGroupByAreaId(CrmStatisticsPortraitReqVO reqVO); - - List selectCustomerIndustryListGroupByIndustryId(CrmStatisticsPortraitReqVO reqVO); - - List selectCustomerSourceListGroupBySource(CrmStatisticsPortraitReqVO reqVO); - - List selectCustomerLevelListGroupByLevel(CrmStatisticsPortraitReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsRankMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsRankMapper.java deleted file mode 100644 index 55062f57a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsRankMapper.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 排行榜统计 Mapper - * - * @author anhaohao - */ -@Mapper -public interface CrmStatisticsRankMapper { - - /** - * 查询合同金额排行榜 - * - * @param rankReqVO 参数 - * @return 合同金额排行榜 - */ - List selectContractPriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询回款金额排行榜 - * - * @param rankReqVO 参数 - * @return 回款金额排行榜 - */ - List selectReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询签约合同数量排行榜 - * - * @param rankReqVO 参数 - * @return 签约合同数量排行榜 - */ - List selectContractCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询产品销量排行榜 - * - * @param rankReqVO 参数 - * @return 产品销量排行榜 - */ - List selectProductSalesRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询新增客户数排行榜 - * - * @param rankReqVO 参数 - * @return 新增客户数排行榜 - */ - List selectCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询联系人数量排行榜 - * - * @param rankReqVO 参数 - * @return 联系人数量排行榜 - */ - List selectContactsCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询跟进次数排行榜 - * - * @param rankReqVO 参数 - * @return 跟进次数排行榜 - */ - List selectFollowCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询跟进客户数排行榜 - * - * @param rankReqVO 参数 - * @return 跟进客户数排行榜 - */ - List selectFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/RedisKeyConstants.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/RedisKeyConstants.java deleted file mode 100644 index 2932c1db1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.redis; - -/** - * CRM Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String NO = "crm:seq_no:"; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/no/CrmNoRedisDAO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/no/CrmNoRedisDAO.java deleted file mode 100644 index 68f0835ec..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/no/CrmNoRedisDAO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.crm.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - - -/** - * Crm 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class CrmNoRedisDAO { - - /** - * 合同 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO} - */ - public static final String CONTRACT_NO_PREFIX = "HT"; - - /** - * 回款 {@link cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO} - */ - public static final String RECEIVABLE_PREFIX = "HK"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号,使用当前日期,格式为 {PREFIX} + yyyyMMdd + 6 位自增 - * 例如说:QTRK 202109 000001 (没有中间空格) - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN); - String key = RedisKeyConstants.NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofDays(1L)); - return noPrefix + String.format("%06d", no); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunction.java deleted file mode 100644 index 8f0a88905..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunction.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.excel.core; - -import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 地区下拉框数据源的 {@link ExcelColumnSelectFunction} 实现类 - * - * @author HUIHUI - */ -@Service -public class AreaExcelColumnSelectFunction implements ExcelColumnSelectFunction { - - public static final String NAME = "getCrmAreaNameList"; // 防止和别的模块重名 - - @Override - public String getName() { - return NAME; - } - - @Override - public List getOptions() { - // 获取地区下拉数据 - // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? - Area area = AreaUtils.getArea(Area.ID_CHINA); - return AreaUtils.getAreaNodePathList(area.getChildren()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java deleted file mode 100644 index c2deef8b8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm 模块的 excel 拓展封装 - */ -package cn.iocoder.yudao.module.crm.framework.excel; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmBusinessParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmBusinessParseFunction.java deleted file mode 100644 index 0c8baa334..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmBusinessParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 商机的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmBusinessParseFunction implements IParseFunction { - - public static final String NAME = "getBusinessById"; - - @Resource - private CrmBusinessService businessService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmBusinessDO businessDO = businessService.getBusiness(Long.parseLong(value.toString())); - return businessDO == null ? "" : businessDO.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContactParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContactParseFunction.java deleted file mode 100644 index 4d4705acc..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContactParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 联系人的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmContactParseFunction implements IParseFunction { - - public static final String NAME = "getContactById"; - - @Resource - private CrmContactService contactService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmContactDO contactDO = contactService.getContact(Long.parseLong(value.toString())); - return contactDO == null ? "" : contactDO.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java deleted file mode 100644 index 07e2b6ec4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 合同的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmContractParseFunction implements IParseFunction { - - public static final String NAME = "getContractById"; - - @Resource - private CrmContractService contractService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmContractDO contract = contractService.getContract(Long.parseLong(value.toString())); - return contract == null ? "" : contract.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerIndustryParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerIndustryParseFunction.java deleted file mode 100644 index dd0b1c781..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerIndustryParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; - -/** - * 行业的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerIndustryParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerIndustry"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_INDUSTRY, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerLevelParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerLevelParseFunction.java deleted file mode 100644 index eedd1d945..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerLevelParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; - -/** - * 客户等级的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerLevelParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerLevel"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_LEVEL, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerParseFunction.java deleted file mode 100644 index ba81ccc0f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 客户的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerById"; - - @Resource - private CrmCustomerService customerService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmCustomerDO crmCustomerDO = customerService.getCustomer(Long.parseLong(value.toString())); - return crmCustomerDO == null ? "" : crmCustomerDO.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerSourceParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerSourceParseFunction.java deleted file mode 100644 index d1a023331..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerSourceParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; - -/** - * CRM 客户来源的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerSourceParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerSource"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_SOURCE, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java deleted file mode 100644 index 446de1043..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 产品状态的 {@link IParseFunction} 实现类 - * - * @author anhaohao - */ -@Component -@Slf4j -public class CrmProductStatusParseFunction implements IParseFunction { - - public static final String NAME = "getProductStatusName"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_STATUS, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java deleted file mode 100644 index cec152e6d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 产品单位的 {@link IParseFunction} 实现类 - * - * @author anhaohao - */ -@Component -@Slf4j -public class CrmProductUnitParseFunction implements IParseFunction { - - public static final String NAME = "getProductUnitName"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_UNIT, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivablePlanParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivablePlanParseFunction.java deleted file mode 100644 index e9943eb67..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivablePlanParseFunction.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * CRM 回款计划的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmReceivablePlanParseFunction implements IParseFunction { - - public static final String NAME = "getReceivablePlanServiceById"; - - @Resource - private CrmReceivablePlanService receivablePlanService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(Long.parseLong(value.toString())); - return receivablePlan == null ? "" : receivablePlan.getPeriod().toString(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivableReturnTypeParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivableReturnTypeParseFunction.java deleted file mode 100644 index 3da7fe42f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivableReturnTypeParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_RETURN_TYPE; - -/** - * CRM 回款方式的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class CrmReceivableReturnTypeParseFunction implements IParseFunction { - - public static final String NAME = "getReceivableReturnType"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_RECEIVABLE_RETURN_TYPE, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java deleted file mode 100644 index ff2e77bfa..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 管理员名字的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class SysAdminUserParseFunction implements IParseFunction { - - public static final String NAME = "getAdminUserById"; - - @Resource - private AdminUserApi adminUserApi; - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - - // 获取用户信息 - AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(value.toString())).getCheckedData(); - if (user == null) { - log.warn("[apply][获取用户{{}}为空", value); - return ""; - } - // 返回格式 芋道源码(13888888888) - String nickname = user.getNickname(); - if (StrUtil.isEmpty(user.getMobile())) { - return nickname; - } - return StrUtil.format("{}({})", nickname, user.getMobile()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAreaParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAreaParseFunction.java deleted file mode 100644 index 3ccc76912..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAreaParseFunction.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 地名的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class SysAreaParseFunction implements IParseFunction { - - public static final String NAME = "getArea"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return AreaUtils.format(Integer.parseInt(value.toString())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysBooleanParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysBooleanParseFunction.java deleted file mode 100644 index 0e722a6f3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysBooleanParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 是否类型的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class SysBooleanParseFunction implements IParseFunction { - - public static final String NAME = "getBoolean"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BOOLEAN_STRING, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java deleted file mode 100644 index efd672a7d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 管理员名字的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class SysDeptParseFunction implements IParseFunction { - - public static final String NAME = "getDeptById"; - - @Resource - private DeptApi deptApi; - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - - // 获取部门信息 - DeptRespDTO dept = deptApi.getDept(Long.parseLong(value.toString())).getCheckedData(); - if (dept == null) { - log.warn("[apply][获取部门{{}}为空", value); - return ""; - } - return dept.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysSexParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysSexParseFunction.java deleted file mode 100644 index c8a9a9991..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysSexParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 行业的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class SysSexParseFunction implements IParseFunction { - - public static final String NAME = "getSex"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.USER_SEX, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/package-info.java deleted file mode 100644 index 413b652c1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm 模块的 operatelog 拓展封装 - */ -package cn.iocoder.yudao.module.crm.framework.operatelog; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java deleted file mode 100644 index 281e36c45..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 crm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.crm.framework; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/annotations/CrmPermission.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/annotations/CrmPermission.java deleted file mode 100644 index 9ef6d4d02..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/annotations/CrmPermission.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.permission.core.annotations; - -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; - -/** - * CRM 数据操作权限校验 AOP 注解 - * - * @author HUIHUI - */ -@Target({METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface CrmPermission { - - /** - * CRM 类型 - */ - CrmBizTypeEnum[] bizType() default {}; - - /** - * CRM 类型扩展,通过 Spring EL 表达式获取到 {@link #bizType()} - * - * 目的:用于 CrmPermissionController 团队权限校验 - */ - String bizTypeValue() default ""; - - /** - * 数据编号,通过 Spring EL 表达式获取 - */ - String bizId(); - - /** - * 操作所需权限级别 - */ - CrmPermissionLevelEnum level(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java deleted file mode 100644 index 35d99b414..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.permission.core.aop; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED; - -/** - * Crm 数据权限校验 AOP 切面 - * - * @author HUIHUI - */ -@Component -@Aspect -@Slf4j -public class CrmPermissionAspect { - - @Resource - private CrmPermissionService crmPermissionService; - - @Before("@annotation(crmPermission)") - public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { - // 1.1 获取相关属性值 - Map expressionValues = parseExpressions(joinPoint, crmPermission); - Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? - crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型 - // 1.2 处理兼容多个 bizId 的情况 - Object object = expressionValues.get(crmPermission.bizId()); // 模块数据编号 - Set bizIds = new HashSet<>(); - if (object instanceof Collection) { - bizIds.addAll(convertSet((Collection) object, item -> Long.parseLong(item.toString()))); - } else { - bizIds.add(Long.parseLong(object.toString())); - } - Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 - - // 2. 逐个校验权限 - List permissionList = crmPermissionService.getPermissionListByBiz(bizType, bizIds); - Map> multiMap = convertMultiMap(permissionList, CrmPermissionDO::getBizId); - bizIds.forEach(bizId -> validatePermission(bizType, multiMap.get(bizId), permissionLevel)); - } - - private void validatePermission(Integer bizType, List bizPermissions, Integer permissionLevel) { - // 1. 如果是超级管理员则直接通过 - if (CrmPermissionUtils.isCrmAdmin()) { - return; - } - // 1.1 没有数据权限的情况 - if (CollUtil.isEmpty(bizPermissions)) { - // 公海数据如果没有团队成员大家也因该有读权限才对 - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - return; - } - // 没有数据权限的情况下超出了读权限直接报错,避免后面校验空指针 - throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); - } else { // 1.2 有数据权限但是没有负责人的情况 - if (!anyMatch(bizPermissions, item -> CrmPermissionLevelEnum.isOwner(item.getLevel()))) { - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - return; - } - } - } - - // 2.1 情况一:如果自己是负责人,则默认有所有权限 - CrmPermissionDO userPermission = CollUtil.findOne(bizPermissions, permission -> ObjUtil.equal(permission.getUserId(), getUserId())); - if (userPermission != null) { - if (CrmPermissionLevelEnum.isOwner(userPermission.getLevel())) { - return; - } - // 2.2 情况二:校验自己是否有读权限 - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - if (CrmPermissionLevelEnum.isRead(userPermission.getLevel()) // 校验当前用户是否有读权限 - || CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限 - return; - } - } - // 2.3 情况三:校验自己是否有写权限 - if (CrmPermissionLevelEnum.isWrite(permissionLevel)) { - if (CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限 - return; - } - } - } - // 2.4 没有权限,抛出异常 - log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", // 打个 info 日志,方便后续排查问题、审计 - getUserId(), permissionLevel, toJsonString(userPermission)); - throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); - } - - /** - * 获得用户编号 - * - * @return 用户编号 - */ - private static Long getUserId() { - return WebFrameworkUtils.getLoginUserId(); - } - - private static Map parseExpressions(JoinPoint joinPoint, CrmPermission crmPermission) { - // 1. 需要解析的表达式 - List expressionStrings = new ArrayList<>(2); - expressionStrings.add(crmPermission.bizId()); - if (StrUtil.isNotEmpty(crmPermission.bizTypeValue())) { // 为空则表示 bizType 有值 - expressionStrings.add(crmPermission.bizTypeValue()); - } - // 2. 执行解析 - return SpringExpressionUtils.parseExpressions(joinPoint, expressionStrings); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/package-info.java deleted file mode 100644 index d895fe969..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.permission.core; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/package-info.java deleted file mode 100644 index 97f76dbe1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm 模块的 permission 拓展封装 - */ -package cn.iocoder.yudao.module.crm.framework.permission; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/config/RpcConfiguration.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index d36e50519..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.rpc.config; - -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {AdminUserApi.class, DeptApi.class, PostApi.class, - BpmProcessInstanceApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/package-info.java deleted file mode 100644 index 79ee21420..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.framework.rpc; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/config/SecurityConfiguration.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 59a32206f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.crm.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Crm 模块的 Security 配置 - */ -@Configuration("crmSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("crmAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").permitAll() - .antMatchers("/actuator/**").permitAll(); - // Druid 监控 - registry.antMatchers("/druid/**").permitAll(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/core/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/core/package-info.java deleted file mode 100644 index 1e6b880ae..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.framework.security.core; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java deleted file mode 100644 index 032d18129..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.job.customer; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import com.xxl.job.core.handler.annotation.XxlJob; -import javax.annotation.Resource; -import org.springframework.stereotype.Component; - -/** - * 客户自动掉入公海 Job - * - * @author 芋道源码 - */ -@Component -public class CrmCustomerAutoPutPoolJob { - - @Resource - private CrmCustomerService customerService; - - @XxlJob("customerAutoPutPoolJob") - @TenantJob - public String execute() { - int count = customerService.autoPutCustomerPool(); - return String.format("掉入公海客户 %s 个", count); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java deleted file mode 100644 index 144f64d02..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:临时占位,后续可删除 - */ -package cn.iocoder.yudao.module.crm.job; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java deleted file mode 100644 index 2ea5f9f41..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * crm 包下,客户关系管理(Customer Relationship Management)。 - * 例如说:客户、联系人、商机、合同、回款等等 - * - * 1. Controller URL:以 /crm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 crm_ 开头,方便在数据库中区分 - * - * 注意,由于 Crm 模块下,容易和其它模块重名,所以类名都加载 Crm 的前缀~ - */ -package cn.iocoder.yudao.module.crm; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java deleted file mode 100644 index d03da429f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateStatusReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商机 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessService { - - /** - * 创建商机 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createBusiness(@Valid CrmBusinessSaveReqVO createReqVO, Long userId); - - /** - * 更新商机 - * - * @param updateReqVO 更新信息 - */ - void updateBusiness(@Valid CrmBusinessSaveReqVO updateReqVO); - - /** - * 更新商机相关跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateBusinessFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 更新商机的下次联系时间 - * - * @param ids 编号数组 - * @param contactNextTime 下次联系时间 - */ - void updateBusinessContactNextTime(Collection ids, LocalDateTime contactNextTime); - - /** - * 更新商机的状态 - * - * @param reqVO 更新请求 - */ - void updateBusinessStatus(CrmBusinessUpdateStatusReqVO reqVO); - - /** - * 删除商机 - * - * @param id 编号 - */ - void deleteBusiness(Long id); - - /** - * 商机转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId); - - /** - * 获得商机 - * - * @param id 编号 - * @return 商机 - */ - CrmBusinessDO getBusiness(Long id); - - /** - * 校验商机是否有效 - * - * @param id 编号 - * @return 商机 - */ - CrmBusinessDO validateBusiness(Long id); - - /** - * 获得商机列表 - * - * @param ids 编号 - * @return 商机列表 - */ - List getBusinessList(Collection ids); - - /** - * 获得商机 Map - * - * @param ids 编号 - * @return 商机 Map - */ - default Map getBusinessMap(Collection ids) { - return convertMap(getBusinessList(ids), CrmBusinessDO::getId); - } - - /** - * 获得指定商机编号的产品列表 - * - * @param businessId 商机编号 - * @return 商机产品列表 - */ - List getBusinessProductListByBusinessId(Long businessId); - - /** - * 获得商机分页 - * - * 数据权限:基于 {@link CrmBusinessDO} - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 商机分页 - */ - PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId); - - /** - * 获得商机分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 商机分页 - */ - PageResult getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO); - - /** - * 获得商机分页,基于指定联系人 - * - * 数据权限:基于 {@link CrmContactDO} 读取 - * - * @param pageReqVO 分页参数 - * @return 商机分页 - */ - PageResult getBusinessPageByContact(CrmBusinessPageReqVO pageReqVO); - - /** - * 获取关联客户的商机数量 - * - * @param customerId 客户编号 - * @return 数量 - */ - Long getBusinessCountByCustomerId(Long customerId); - - /** - * 获得使用指定商机状态组的商机数量 - * - * @param statusTypeId 商机状态组编号 - * @return 数量 - */ - Long getBusinessCountByStatusTypeId(Long statusTypeId); - - /** - * 获得商机状态名称 - * - * @param endStatus 结束状态 - * @param status 商机状态 - * @return 商机状态名称 - */ - default String getBusinessStatusName(Integer endStatus, CrmBusinessStatusDO status) { - if (endStatus != null) { - return CrmBusinessEndStatusEnum.fromStatus(endStatus).getName(); - } - return status.getName(); - } - - /** - * 获得商机列表 - * - * @param customerId 客户编号 - * @param ownerUserId 负责人编号 - * @return 商机列表 - */ - List getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); - - /** - * 获得商机分页,目前用于【数据统计】 - * - * @param pageVO 请求 - * @return 商机分页 - */ - PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java deleted file mode 100644 index 3fad07b4d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ /dev/null @@ -1,384 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateStatusReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 商机 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessServiceImpl implements CrmBusinessService { - - @Resource - private CrmBusinessMapper businessMapper; - @Resource - private CrmBusinessProductMapper businessProductMapper; - - @Resource - private CrmBusinessStatusService businessStatusService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmContactService contactService; - @Resource - private CrmPermissionService permissionService; - @Resource - private CrmContactBusinessService contactBusinessService; - @Resource - private CrmProductService productService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_CREATE_SUB_TYPE, bizNo = "{{#business.id}}", - success = CRM_BUSINESS_CREATE_SUCCESS) - public Long createBusiness(CrmBusinessSaveReqVO createReqVO, Long userId) { - // 1.1 校验产品项的有效性 - List businessProducts = validateBusinessProducts(createReqVO.getProducts()); - // 1.2 校验关联字段 - validateRelationDataExists(createReqVO); - - // 2.1 插入商机 - CrmBusinessDO business = BeanUtils.toBean(createReqVO, CrmBusinessDO.class); - business.setStatusId(businessStatusService.getBusinessStatusListByTypeId(createReqVO.getStatusTypeId()).get(0).getId()); // 默认状态 - calculateTotalPrice(business, businessProducts); - businessMapper.insert(business); - // 2.2 插入商机关联商品 - if (CollUtil.isNotEmpty(businessProducts)) { - businessProducts.forEach(item -> item.setBusinessId(business.getId())); - businessProductMapper.insertBatch(businessProducts); - } - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(business.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()).setBizId(business.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 在联系人的详情页,如果直接【新建商机】,则需要关联下 - if (createReqVO.getContactId() != null) { - contactBusinessService.createContactBusinessList(new CrmContactBusinessReqVO().setContactId(createReqVO.getContactId()) - .setBusinessIds(Collections.singletonList(business.getId()))); - } - - // 5. 记录操作日志上下文 - LogRecordContext.putVariable("business", business); - return business.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_BUSINESS_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateBusiness(CrmBusinessSaveReqVO updateReqVO) { - updateReqVO.setOwnerUserId(null).setStatusTypeId(null); // 不允许更新的字段 - // 1.1 校验存在 - CrmBusinessDO oldBusiness = validateBusinessExists(updateReqVO.getId()); - // 1.2 校验产品项的有效性 - List businessProducts = validateBusinessProducts(updateReqVO.getProducts()); - // 1.3 校验关联字段 - validateRelationDataExists(updateReqVO); - - // 2.1 更新商机 - CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); - calculateTotalPrice(updateObj, businessProducts); - businessMapper.updateById(updateObj); - // 2.2 更新商机关联商品 - updateBusinessProduct(updateObj.getId(), businessProducts); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldBusiness, CrmBusinessSaveReqVO.class)); - LogRecordContext.putVariable("businessName", oldBusiness.getName()); - } - - @Override - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_BUSINESS_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateBusinessFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1. 校验存在 - CrmBusinessDO business = validateBusinessExists(id); - - // 2. 更新联系人的跟进信息 - businessMapper.updateById(new CrmBusinessDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now())); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("businessName", business.getName()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#ids", level = CrmPermissionLevelEnum.WRITE) - public void updateBusinessContactNextTime(Collection ids, LocalDateTime contactNextTime) { - businessMapper.updateBatch(convertList(ids, id -> new CrmBusinessDO().setId(id).setContactNextTime(contactNextTime))); - } - - private void updateBusinessProduct(Long id, List newList) { - List oldList = businessProductMapper.selectListByBusinessId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setBusinessId(id)); - businessProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - businessProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - businessProductMapper.deleteBatchIds(convertSet(diffList.get(2), CrmBusinessProductDO::getId)); - } - } - - private void validateRelationDataExists(CrmBusinessSaveReqVO saveReqVO) { - // 校验商机状态 - if (saveReqVO.getStatusTypeId() != null) { - businessStatusService.validateBusinessStatusType(saveReqVO.getStatusTypeId()); - } - // 校验客户 - if (saveReqVO.getCustomerId() != null) { - customerService.validateCustomer(saveReqVO.getCustomerId()); - } - // 校验联系人 - if (saveReqVO.getContactId() != null) { - contactService.validateContact(saveReqVO.getContactId()); - } - // 校验负责人 - if (saveReqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(saveReqVO.getOwnerUserId()); - } - } - - private List validateBusinessProducts(List list) { - // 1. 校验产品存在 - productService.validProductList(convertSet(list, CrmBusinessSaveReqVO.BusinessProduct::getProductId)); - // 2. 转化为 CrmBusinessProductDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, CrmBusinessProductDO.class, - item -> item.setTotalPrice(MoneyUtils.priceMultiply(item.getBusinessPrice(), item.getCount())))); - } - - private void calculateTotalPrice(CrmBusinessDO business, List businessProducts) { - business.setTotalProductPrice(getSumValue(businessProducts, CrmBusinessProductDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - BigDecimal discountPrice = MoneyUtils.priceMultiplyPercent(business.getTotalProductPrice(), business.getDiscountPercent()); - business.setTotalPrice(business.getTotalProductPrice().subtract(discountPrice)); - } - - @Override - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_BUSINESS_UPDATE_STATUS_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateBusinessStatus(CrmBusinessUpdateStatusReqVO reqVO) { - // 1.1 校验存在 - CrmBusinessDO business = validateBusinessExists(reqVO.getId()); - // 1.2 校验商机未结束 - if (business.getEndStatus() != null) { - throw exception(BUSINESS_UPDATE_STATUS_FAIL_END_STATUS); - } - // 1.3 校验商机状态 - CrmBusinessStatusDO status = null; - if (reqVO.getStatusId() != null) { - status = businessStatusService.validateBusinessStatus(business.getStatusTypeId(), reqVO.getStatusId()); - } - // 1.4 校验是不是状态没变更 - if ((reqVO.getStatusId() != null && reqVO.getStatusId().equals(business.getStatusId())) - || (reqVO.getEndStatus() != null && reqVO.getEndStatus().equals(business.getEndStatus()))) { - throw exception(BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS); - } - - // 2. 更新商机状态 - businessMapper.updateById(new CrmBusinessDO().setId(reqVO.getId()).setStatusId(reqVO.getStatusId()) - .setEndStatus(reqVO.getEndStatus())); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("businessName", business.getName()); - LogRecordContext.putVariable("oldStatusName", getBusinessStatusName(business.getEndStatus(), - businessStatusService.getBusinessStatus(business.getStatusId()))); - LogRecordContext.putVariable("newStatusName", getBusinessStatusName(reqVO.getEndStatus(), status)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_BUSINESS_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteBusiness(Long id) { - // 1.1 校验存在 - CrmBusinessDO business = validateBusinessExists(id); - // 1.2 校验是否关联合同 - validateContractExists(id); - - // 删除商机 - businessMapper.deleteById(id); - // 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_BUSINESS.getType(), id); - - // 记录操作日志上下文 - LogRecordContext.putVariable("businessName", business.getName()); - } - - /** - * 删除校验合同是关联合同 - * - * @param businessId 商机id - * @author lzxhqs - */ - private void validateContractExists(Long businessId) { - if (contractService.getContractCountByBusinessId(businessId) > 0) { - throw exception(BUSINESS_DELETE_FAIL_CONTRACT_EXISTS); - } - } - - private CrmBusinessDO validateBusinessExists(Long id) { - CrmBusinessDO crmBusiness = businessMapper.selectById(id); - if (crmBusiness == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - return crmBusiness; - } - - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_BUSINESS_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { - // 1 校验商机是否存在 - CrmBusinessDO business = validateBusinessExists(reqVO.getId()); - - // 2.1 数据权限转移 - permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_BUSINESS.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置新的负责人 - businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); - - // 记录操作日志上下文 - LogRecordContext.putVariable("business", business); - } - - //======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmBusinessDO getBusiness(Long id) { - return businessMapper.selectById(id); - } - - @Override - public CrmBusinessDO validateBusiness(Long id) { - return validateBusinessExists(id); - } - - @Override - public List getBusinessList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return businessMapper.selectBatchIds(ids); - } - - @Override - public List getBusinessProductListByBusinessId(Long businessId) { - return businessProductMapper.selectListByBusinessId(businessId); - } - - @Override - public PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { - return businessMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { - return businessMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#pageReqVO.contactId", level = CrmPermissionLevelEnum.READ) - public PageResult getBusinessPageByContact(CrmBusinessPageReqVO pageReqVO) { - // 1. 查询关联的商机编号 - List contactBusinessList = contactBusinessService.getContactBusinessListByContactId( - pageReqVO.getContactId()); - if (CollUtil.isEmpty(contactBusinessList)) { - return PageResult.empty(); - } - // 2. 查询商机分页 - return businessMapper.selectPageByContactId(pageReqVO, - convertSet(contactBusinessList, CrmContactBusinessDO::getBusinessId)); - } - - @Override - public Long getBusinessCountByCustomerId(Long customerId) { - return businessMapper.selectCount(CrmBusinessDO::getCustomerId, customerId); - } - - @Override - public Long getBusinessCountByStatusTypeId(Long statusTypeId) { - return businessMapper.selectCountByStatusTypeId(statusTypeId); - } - - @Override - public List getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return businessMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); - } - - @Override - public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { - return businessMapper.selectPage(pageVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java deleted file mode 100644 index 285e984d2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商机状态 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessStatusService { - - /** - * 创建商机状态 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBusinessStatus(@Valid CrmBusinessStatusSaveReqVO createReqVO); - - /** - * 更新商机状态 - * - * @param updateReqVO 更新信息 - */ - void updateBusinessStatus(@Valid CrmBusinessStatusSaveReqVO updateReqVO); - - /** - * 删除商机状态 - * - * @param id 编号 - */ - void deleteBusinessStatusType(Long id); - - /** - * 获得商机状态组 - * - * @param id 编号 - * @return 商机状态组 - */ - CrmBusinessStatusTypeDO getBusinessStatusType(Long id); - - /** - * 校验商机状态组 - * - * @param id 编号 - */ - void validateBusinessStatusType(Long id); - - /** - * 获得商机状态组列表 - * - * @return 商机状态组列表 - */ - List getBusinessStatusTypeList(); - - /** - * 获得商机状态组分页 - * - * @param pageReqVO 分页查询 - * @return 商机状态组分页 - */ - PageResult getBusinessStatusTypePage(PageParam pageReqVO); - - /** - * 获得商机状态组列表 - * - * @param ids 编号数组 - * @return 商机状态组列表 - */ - List getBusinessStatusTypeList(Collection ids); - - /** - * 获得商机状态组 Map - * - * @param ids 编号数组 - * @return 商机状态组 Map - */ - default Map getBusinessStatusTypeMap(Collection ids) { - return convertMap(getBusinessStatusTypeList(ids), CrmBusinessStatusTypeDO::getId); - } - - /** - * 获得指定类型的商机状态列表 - * - * @param typeId 商机状态组编号 - * @return 商机状态列表 - */ - List getBusinessStatusListByTypeId(Long typeId); - - /** - * 获得商机状态列表 - * - * @param ids 编号数组 - * @return 商机状态列表 - */ - List getBusinessStatusList(Collection ids); - - /** - * 获得商机状态 Map - * - * @param ids 编号数组 - * @return 商机状态 Map - */ - default Map getBusinessStatusMap(Collection ids) { - return convertMap(getBusinessStatusList(ids), CrmBusinessStatusDO::getId); - } - - /** - * 获得商机状态 - * - * @param id 编号 - * @return 商机状态 - */ - CrmBusinessStatusDO getBusinessStatus(Long id); - - /** - * 校验商机状态 - * - * @param statusTypeId 商机状态组编号 - * @param statusId 商机状态编号 - */ - CrmBusinessStatusDO validateBusinessStatus(Long statusTypeId, Long statusId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java deleted file mode 100644 index 3c2e0b664..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - -/** - * 商机状态 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { - - @Resource - private CrmBusinessStatusTypeMapper businessStatusTypeMapper; - @Resource - private CrmBusinessStatusMapper businessStatusMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmBusinessService businessService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) { - // 1.1 检验名称是否存在 - validateBusinessStatusTypeNameUnique(createReqVO.getName(), null); - // 1.2 设置状态的排序 - int sort = 0; - for (CrmBusinessStatusSaveReqVO.Status status : createReqVO.getStatuses()) { - status.setSort(sort++); - } - - // 2.1 插入类型 - CrmBusinessStatusTypeDO statusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.insert(statusType); - // 2.2 插入状态 - List statuses = BeanUtils.toBean(createReqVO.getStatuses(), CrmBusinessStatusDO.class, - status -> status.setTypeId(statusType.getId())); - businessStatusMapper.insertBatch(statuses); - return statusType.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) { - // 1.1 校验存在 - validateBusinessStatusTypeExists(updateReqVO.getId()); - // 1.2 校验名称是否存在 - validateBusinessStatusTypeNameUnique(updateReqVO.getName(), updateReqVO.getId()); - // 1.3 设置状态的排序 - int sort = 0; - for (CrmBusinessStatusSaveReqVO.Status status : updateReqVO.getStatuses()) { - status.setSort(sort++); - } - // 1.4 已经使用,无法更新 - if (businessService.getBusinessCountByStatusTypeId(updateReqVO.getId()) > 0) { - throw exception(BUSINESS_STATUS_UPDATE_FAIL_USED); - } - - // 2.1 更新类型 - CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.updateById(updateObj); - // 2.2 更新状态 - updateBusinessStatus(updateReqVO.getId(), BeanUtils.toBean(updateReqVO.getStatuses(), CrmBusinessStatusDO.class)); - } - - private void updateBusinessStatus(Long id, List newList) { - List oldList = businessStatusMapper.selectListByTypeId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setTypeId(id)); - businessStatusMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - businessStatusMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - businessStatusMapper.deleteBatchIds(convertSet(diffList.get(2), CrmBusinessStatusDO::getId)); - } - } - - private void validateBusinessStatusTypeExists(Long id) { - if (businessStatusTypeMapper.selectById(id) == null) { - throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS); - } - } - - private void validateBusinessStatusTypeNameUnique(String name, Long id) { - CrmBusinessStatusTypeDO statusType = businessStatusTypeMapper.selectByName(name); - if (statusType == null - || statusType.getId().equals(id)) { - return; - } - throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBusinessStatusType(Long id) { - // 1.1 校验存在 - validateBusinessStatusTypeExists(id); - // 1.2 已经使用,无法更新 - if (businessService.getBusinessCountByStatusTypeId(id) > 0) { - throw exception(BUSINESS_STATUS_DELETE_FAIL_USED); - } - - // 2.1 删除类型 - businessStatusTypeMapper.deleteById(id); - // 2.2 删除状态 - businessStatusMapper.deleteByTypeId(id); - } - - @Override - public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) { - return businessStatusTypeMapper.selectById(id); - } - - @Override - public void validateBusinessStatusType(Long id) { - validateBusinessStatusTypeExists(id); - } - - @Override - public List getBusinessStatusTypeList() { - return businessStatusTypeMapper.selectList(); - } - - @Override - public PageResult getBusinessStatusTypePage(PageParam pageReqVO) { - return businessStatusTypeMapper.selectPage(pageReqVO); - } - - @Override - public List getBusinessStatusTypeList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return businessStatusTypeMapper.selectBatchIds(ids); - } - - @Override - public List getBusinessStatusListByTypeId(Long typeId) { - List list = businessStatusMapper.selectListByTypeId(typeId); - list.sort(Comparator.comparingInt(CrmBusinessStatusDO::getSort)); - return list; - } - - @Override - public List getBusinessStatusList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return businessStatusMapper.selectBatchIds(ids); - } - - @Override - public CrmBusinessStatusDO getBusinessStatus(Long id) { - return businessStatusMapper.selectById(id); - } - - @Override - public CrmBusinessStatusDO validateBusinessStatus(Long statusTypeId, Long statusId) { - CrmBusinessStatusDO status = businessStatusMapper.selectByTypeIdAndId(statusTypeId, statusId); - if (status == null) { - throw exception(BUSINESS_STATUS_NOT_EXISTS); - } - return status; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java deleted file mode 100644 index b325bfd25..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 线索 Service 接口 - * - * @author Wanwan - */ -public interface CrmClueService { - - /** - * 创建线索 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createClue(@Valid CrmClueSaveReqVO createReqVO); - - /** - * 更新线索 - * - * @param updateReqVO 更新信息 - */ - void updateClue(@Valid CrmClueSaveReqVO updateReqVO); - - /** - * 更新线索相关的跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateClueFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 删除线索 - * - * @param id 编号 - */ - void deleteClue(Long id); - - /** - * 获得线索 - * - * @param id 编号 - * @return 线索 - */ - CrmClueDO getClue(Long id); - - /** - * 获得线索列表 - * - * @param ids 编号 - * @return 线索列表 - */ - List getClueList(Collection ids, Long userId); - - /** - * 获得线索分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 线索分页 - */ - PageResult getCluePage(CrmCluePageReqVO pageReqVO, Long userId); - - /** - * 线索转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferClue(CrmClueTransferReqVO reqVO, Long userId); - - /** - * 线索转化为客户 - * - * @param id 线索编号 - * @param userId 用户编号 - */ - void transformClue(Long id, Long userId); - - /** - * 获得分配给我的、待跟进的线索数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getFollowClueCount(Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java deleted file mode 100644 index 52c15547f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ /dev/null @@ -1,241 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.CrmCustomerSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerCreateReqBO; -import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService; -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.singleton; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_TRANSFORM_FAIL_ALREADY; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; - -/** - * 线索 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmClueServiceImpl implements CrmClueService { - - @Resource - private CrmClueMapper clueMapper; - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmPermissionService crmPermissionService; - @Resource - private CrmFollowUpRecordService followUpRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}", - success = CRM_CLUE_CREATE_SUCCESS) - public Long createClue(CrmClueSaveReqVO createReqVO) { - // 1.1 校验关联数据 - validateRelationDataExists(createReqVO); - // 1.2 校验负责人是否存在 - adminUserApi.validateUser(createReqVO.getOwnerUserId()); - - // 2. 插入线索 - CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class); - clueMapper.insert(clue); - - // 3. 创建数据权限 - CrmPermissionCreateReqBO createReqBO = new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CLUE.getType()) - .setBizId(clue.getId()).setUserId(clue.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel()); - crmPermissionService.createPermission(createReqBO); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("clue", clue); - return clue.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CLUE_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#updateReq.id", level = CrmPermissionLevelEnum.OWNER) - public void updateClue(CrmClueSaveReqVO updateReq) { - Assert.notNull(updateReq.getId(), "线索编号不能为空"); - // 1.1 校验线索是否存在 - CrmClueDO oldClue = validateClueExists(updateReq.getId()); - // 1.2 校验关联数据 - validateRelationDataExists(updateReq); - - // 2. 更新线索 - CrmClueDO updateObj = BeanUtils.toBean(updateReq, CrmClueDO.class); - clueMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class)); - LogRecordContext.putVariable("clueName", oldClue.getName()); - } - - private void validateRelationDataExists(CrmClueSaveReqVO reqVO) { - // 校验负责人 - if (Objects.nonNull(reqVO.getOwnerUserId()) && - Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()))) { - throw exception(USER_NOT_EXISTS); - } - } - - @Override - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CLUE_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateClueFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 校验线索是否存在 - CrmClueDO oldClue = validateClueExists(id); - - // 更新线索 - clueMapper.updateById(new CrmClueDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("clueName", oldClue.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CLUE_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteClue(Long id) { - // 1. 校验存在 - CrmClueDO clue = validateClueExists(id); - - // 2. 删除 - clueMapper.deleteById(id); - - // 3. 删除数据权限 - crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CLUE.getType(), id); - - // 4. 删除跟进 - followUpRecordService.deleteFollowUpRecordByBiz(CrmBizTypeEnum.CRM_CLUE.getType(), id); - - // 5. 记录操作日志上下文 - LogRecordContext.putVariable("clueName", clue.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CLUE_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferClue(CrmClueTransferReqVO reqVO, Long userId) { - // 1 校验线索是否存在 - CrmClueDO clue = validateClueExists(reqVO.getId()); - - // 2.1 数据权限转移 - crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CLUE.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置新的负责人 - clueMapper.updateById(new CrmClueDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); - - // 3. 记录转移日志 - LogRecordContext.putVariable("clue", clue); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSLATE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CLUE_TRANSLATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void transformClue(Long id, Long userId) { - // 1.1 校验线索都存在 - CrmClueDO clue = validateClueExists(id); - // 1.2 存在已经转化的 - if (clue.getTransformStatus()) { - throw exception(CLUE_TRANSFORM_FAIL_ALREADY); - } - - // 2.1 遍历线索(未转化的线索),创建对应的客户 - Long customerId = customerService.createCustomer(BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class), userId); - // 2.2 更新线索 - clueMapper.updateById(new CrmClueDO().setId(id).setTransformStatus(Boolean.TRUE).setCustomerId(customerId)); - // 2.3 复制跟进记录 - List followUpRecords = followUpRecordService.getFollowUpRecordByBiz( - CrmBizTypeEnum.CRM_CLUE.getType(), singleton(clue.getId())); - if (CollUtil.isNotEmpty(followUpRecords)) { - followUpRecordService.createFollowUpRecordBatch(convertList(followUpRecords, record -> - BeanUtils.toBean(record, CrmFollowUpCreateReqBO.class) - .setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(customerId))); - } - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("clueName", clue.getName()); - } - - private CrmClueDO validateClueExists(Long id) { - CrmClueDO crmClueDO = clueMapper.selectById(id); - if (crmClueDO == null) { - throw exception(CLUE_NOT_EXISTS); - } - return crmClueDO; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmClueDO getClue(Long id) { - return clueMapper.selectById(id); - } - - @Override - public List getClueList(Collection ids, Long userId) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return clueMapper.selectBatchIds(ids, userId); - } - - @Override - public PageResult getCluePage(CrmCluePageReqVO pageReqVO, Long userId) { - return clueMapper.selectPage(pageReqVO, userId); - } - - @Override - public Long getFollowClueCount(Long userId) { - return clueMapper.selectCountByFollow(userId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java deleted file mode 100644 index 7168fb9f5..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusiness2ReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import javax.validation.Valid; - -import java.util.List; - -/** - * CRM 联系人与商机的关联 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContactBusinessService { - - /** - * 创建联系人与商机的关联【通过联系人,关联商机】 - * - * @param createReqVO 创建信息 - */ - void createContactBusinessList(@Valid CrmContactBusinessReqVO createReqVO); - - /** - * 创建联系人与商机的关联【通过商机,关联联系人】 - * - * @param createReqVO 创建信息 - */ - void createContactBusinessList2(@Valid CrmContactBusiness2ReqVO createReqVO); - - /** - * 删除联系人与商机的关联【通过联系人,取关商机】 - * - * @param deleteReqVO 删除信息 - */ - void deleteContactBusinessList(@Valid CrmContactBusinessReqVO deleteReqVO); - - /** - * 删除联系人与商机的关联【通过商机,取关联系人】 - * - * @param deleteReqVO 删除信息 - */ - void deleteContactBusinessList2(@Valid CrmContactBusiness2ReqVO deleteReqVO); - - /** - * 删除联系人与商机的关联,基于联系人编号 - * - * @param contactId 联系人编号 - */ - void deleteContactBusinessByContactId(Long contactId); - - /** - * 获得联系人与商机的关联列表,基于联系人编号 - * - * @param contactId 联系人编号 - * @return 联系人商机关联 - */ - List getContactBusinessListByContactId(Long contactId); - - /** - * 获得联系人与商机的关联列表,基于商机编号 - * - * @param businessId 商机编号 - * @return 联系人商机关联 - */ - List getContactBusinessListByBusinessId(Long businessId); - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java deleted file mode 100644 index 99bbdd570..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusiness2ReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactBusinessMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; - -/** - * 联系人与商机的关联 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContactBusinessServiceImpl implements CrmContactBusinessService { - - @Resource - private CrmContactBusinessMapper contactBusinessMapper; - - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private CrmBusinessService businessService; - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private CrmContactService contactService; - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) - public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { - CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 遍历处理,考虑到一般数量不会太多,代码处理简单 - List saveDOList = new ArrayList<>(); - createReqVO.getBusinessIds().forEach(businessId -> { - CrmBusinessDO business = businessService.getBusiness(businessId); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 关联判重 - if (contactBusinessMapper.selectByContactIdAndBusinessId(createReqVO.getContactId(), businessId) != null) { - return; - } - saveDOList.add(new CrmContactBusinessDO(null, createReqVO.getContactId(), businessId)); - }); - // 批量插入 - if (CollUtil.isNotEmpty(saveDOList)) { - contactBusinessMapper.insertBatch(saveDOList); - } - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#createReqVO.businessId", level = CrmPermissionLevelEnum.WRITE) - public void createContactBusinessList2(CrmContactBusiness2ReqVO createReqVO) { - CrmBusinessDO business = businessService.getBusiness(createReqVO.getBusinessId()); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 遍历处理,考虑到一般数量不会太多,代码处理简单 - List saveDOList = new ArrayList<>(); - createReqVO.getContactIds().forEach(contactId -> { - CrmContactDO contact = contactService.getContact(contactId); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 关联判重 - if (contactBusinessMapper.selectByContactIdAndBusinessId(contactId, createReqVO.getBusinessId()) != null) { - return; - } - saveDOList.add(new CrmContactBusinessDO(null, contactId, createReqVO.getBusinessId())); - }); - // 批量插入 - if (CollUtil.isNotEmpty(saveDOList)) { - contactBusinessMapper.insertBatch(saveDOList); - } - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#deleteReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) - public void deleteContactBusinessList(CrmContactBusinessReqVO deleteReqVO) { - CrmContactDO contact = contactService.getContact(deleteReqVO.getContactId()); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 直接删除 - contactBusinessMapper.deleteByContactIdAndBusinessId( - deleteReqVO.getContactId(), deleteReqVO.getBusinessIds()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#deleteReqVO.businessId", level = CrmPermissionLevelEnum.WRITE) - public void deleteContactBusinessList2(CrmContactBusiness2ReqVO deleteReqVO) { - CrmBusinessDO business = businessService.getBusiness(deleteReqVO.getBusinessId()); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 直接删除 - contactBusinessMapper.deleteByBusinessIdAndContactId( - deleteReqVO.getBusinessId(), deleteReqVO.getContactIds()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.WRITE) - public void deleteContactBusinessByContactId(Long contactId) { - contactBusinessMapper.delete(CrmContactBusinessDO::getContactId, contactId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.READ) - public List getContactBusinessListByContactId(Long contactId) { - return contactBusinessMapper.selectListByContactId(contactId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#businessId", level = CrmPermissionLevelEnum.READ) - public List getContactBusinessListByBusinessId(Long businessId) { - return contactBusinessMapper.selectListByBusinessId(businessId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java deleted file mode 100644 index 24273db2f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 联系人 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContactService { - - /** - * 创建联系人 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContact(@Valid CrmContactSaveReqVO createReqVO, Long userId); - - /** - * 更新联系人 - * - * @param updateReqVO 更新信息 - */ - void updateContact(@Valid CrmContactSaveReqVO updateReqVO); - - /** - * 删除联系人 - * - * @param id 编号 - */ - void deleteContact(Long id); - - /** - * 联系人转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferContact(CrmContactTransferReqVO reqVO, Long userId); - - /** - * 更新指定客户的联系人的负责人 - * 数据权限基于 【客户】 - * - * @param customerId 客户编号 - * @param ownerUserId 用户编号 - */ - void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId); - - /** - * 更新联系人相关跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 更新联系人的下次联系时间 - * - * @param ids 编号数组 - * @param contactNextTime 下次联系时间 - */ - void updateContactContactNextTime(Collection ids, LocalDateTime contactNextTime); - - /** - * 获得联系人 - * - * @param id 编号 - * @return 联系人 - */ - CrmContactDO getContact(Long id); - - /** - * 校验联系人 - * - * @param id 编号 - */ - void validateContact(Long id); - - /** - * 获得联系人列表 - * - * @param ids 编号 - * @return 联系人列表 - */ - List getContactList(Collection ids); - - /** - * 获得联系人 Map - * - * @param ids 编号 - * @return 联系人 Map - */ - default Map getContactMap(Collection ids) { - return convertMap(getContactList(ids), CrmContactDO::getId); - } - - /** - * 获取联系人列表(校验权限) - * - * @param userId 用户编号 - * @return 联系人列表 - */ - List getContactList(Long userId); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmContactDO} - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 联系人分页 - */ - PageResult getContactPage(CrmContactPageReqVO pageReqVO, Long userId); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmCustomerDO} - * - * @param pageVO 分页查询 - * @return 联系人分页 - */ - PageResult getContactPageByCustomerId(CrmContactPageReqVO pageVO); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmBusinessDO} - * - * @param pageVO 分页查询 - * @return 联系人分页 - */ - PageResult getContactPageByBusinessId(CrmContactPageReqVO pageVO); - - /** - * 获取关联客户的联系人数量 - * - * @param customerId 客户编号 - * @return 数量 - */ - Long getContactCountByCustomerId(Long customerId); - - /** - * 获得联系人列表 - * - * @param customerId 客户编号 - * @param ownerUserId 负责人编号 - * @return 联系人列表 - */ - List getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java deleted file mode 100644 index d6eb2a83c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java +++ /dev/null @@ -1,306 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static java.util.Collections.singletonList; - -/** - * CRM 联系人 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContactServiceImpl implements CrmContactService { - - @Resource - private CrmContactMapper contactMapper; - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmPermissionService permissionService; - @Resource - @Lazy - private CrmContractService contractService; - @Resource - private CrmContactBusinessService contactBusinessService; - @Resource - private CrmBusinessService businessService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_CREATE_SUB_TYPE, bizNo = "{{#contact.id}}", - success = CRM_CONTACT_CREATE_SUCCESS) - public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) { - createReqVO.setId(null); - // 1. 校验关联数据 - validateRelationDataExists(createReqVO); - - // 2. 插入联系人 - CrmContactDO contact = BeanUtils.toBean(createReqVO, CrmContactDO.class); - contactMapper.insert(contact); - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) - .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 如果有关联商机,则需要创建关联 - if (createReqVO.getBusinessId() != null) { - contactBusinessService.createContactBusinessList(new CrmContactBusinessReqVO() - .setContactId(contact.getId()).setBusinessIds(singletonList(createReqVO.getBusinessId()))); - } - - // 5. 记录操作日志 - LogRecordContext.putVariable("contact", contact); - return contact.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CONTACT_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateContact(CrmContactSaveReqVO updateReqVO) { - // 1.1 校验存在 - CrmContactDO oldContact = validateContactExists(updateReqVO.getId()); - // 1.2 校验关联数据 - validateRelationDataExists(updateReqVO); - - // 2. 更新联系人 - CrmContactDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactDO.class); - contactMapper.updateById(updateObj); - - // 3. 记录操作日志 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldContact, CrmContactSaveReqVO.class)); - LogRecordContext.putVariable("contactName", oldContact.getName()); - } - - /** - * 校验关联的数据都存在 - * - * @param saveReqVO 新增/修改请求 VO - */ - private void validateRelationDataExists(CrmContactSaveReqVO saveReqVO) { - // 1. 校验客户 - if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) { - customerService.validateCustomer(saveReqVO.getCustomerId()); - } - // 2. 校验负责人 - if (saveReqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(saveReqVO.getOwnerUserId()); - } - // 3. 直属上级 - if (saveReqVO.getParentId() != null) { - validateContactExists(saveReqVO.getParentId()); - } - // 4. 如果有关联商机,则需要校验存在 - if (saveReqVO.getBusinessId() != null && businessService.getBusiness(saveReqVO.getBusinessId()) == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CONTACT_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteContact(Long id) { - // 1.1 校验存在 - CrmContactDO contact = validateContactExists(id); - // 1.2 校验是否关联合同 - if (contractService.getContractCountByContactId(id) > 0) { - throw exception(CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS); - } - - // 2. 删除联系人 - contactMapper.deleteById(id); - - // 4.1 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id); - // 4.2 删除商机关联 - contactBusinessService.deleteContactBusinessByContactId(id); - - // 记录操作日志上下文 - LogRecordContext.putVariable("contactName", contact.getName()); - } - - private CrmContactDO validateContactExists(Long id) { - CrmContactDO contact = contactMapper.selectById(id); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - return contact; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CONTACT_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferContact(CrmContactTransferReqVO reqVO, Long userId) { - // 1 校验联系人是否存在 - CrmContactDO contact = validateContactExists(reqVO.getId()); - - // 2.1 数据权限转移 - permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置新的负责人 - contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); - - // 3. 记录转移日志 - LogRecordContext.putVariable("contact", contact); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#customerId", level = CrmPermissionLevelEnum.OWNER) - public void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { - // 1. 校验存在 - List contacts = contactMapper.selectListByCustomerId(customerId); - if (CollUtil.isEmpty(contacts)) { - return; - } - int count = contactMapper.updateOwnerUserIdByCustomerId(customerId, ownerUserId); - if (count == 0) { - throw exception(CONTACT_UPDATE_OWNER_USER_FAIL); - } - - // 2. 记录操作日志 - for (CrmContactDO contact : contacts) { - receiveContactLog(contact, ownerUserId); - } - } - - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_UPDATE_OWNER_USER_SUB_TYPE, bizNo = "{{#contact.id}", - success = CRM_CONTACT_UPDATE_OWNER_USER_SUCCESS) - public void receiveContactLog(CrmContactDO contact, Long ownerUserId) { - // 记录操作日志上下文 - LogRecordContext.putVariable("contact", contact); - LogRecordContext.putVariable("ownerUserId", ownerUserId); - } - - @Override - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_CONTACT_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1. 校验存在 - CrmContactDO contact = validateContactExists(id); - - // 2. 更新联系人的跟进信息 - contactMapper.updateById(new CrmContactDO().setId(id).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("contactName", contact.getName()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#ids", level = CrmPermissionLevelEnum.WRITE) - public void updateContactContactNextTime(Collection ids, LocalDateTime contactNextTime) { - contactMapper.updateBatch(convertList(ids, id -> new CrmContactDO().setId(id).setContactNextTime(contactNextTime))); - } - - //======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmContactDO getContact(Long id) { - return contactMapper.selectById(id); - } - - @Override - public void validateContact(Long id) { - validateContactExists(id); - } - - @Override - public List getContactList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return contactMapper.selectBatchIds(ids); - } - - @Override - public List getContactList(Long userId) { - CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); - reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - return contactMapper.selectPage(reqVO, userId).getList(); - } - - @Override - public PageResult getContactPage(CrmContactPageReqVO pageReqVO, Long userId) { - return contactMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContactPageByCustomerId(CrmContactPageReqVO pageVO) { - return contactMapper.selectPageByCustomerId(pageVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#pageVO.businessId", level = CrmPermissionLevelEnum.READ) - public PageResult getContactPageByBusinessId(CrmContactPageReqVO pageVO) { - List contactBusinessList = contactBusinessService.getContactBusinessListByBusinessId(pageVO.getBusinessId()); - if (CollUtil.isEmpty(contactBusinessList)) { - return PageResult.empty(); - } - return contactMapper.selectPageByBusinessId(pageVO, convertSet(contactBusinessList, CrmContactBusinessDO::getContactId)); - } - - @Override - public Long getContactCountByCustomerId(Long customerId) { - return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId); - } - - @Override - public List getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return contactMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigService.java deleted file mode 100644 index 39a06649a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; - -import javax.validation.Valid; - -/** - * 合同配置 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContractConfigService { - - /** - * 获得合同配置 - * - * @return 合同配置 - */ - CrmContractConfigDO getContractConfig(); - - /** - * 保存合同配置 - * - * @param saveReqVO 更新信息 - */ - void saveContractConfig(@Valid CrmContractConfigSaveReqVO saveReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigServiceImpl.java deleted file mode 100644 index 2580cc30c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractConfigMapper; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Objects; - -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 合同配置 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContractConfigServiceImpl implements CrmContractConfigService { - - @Resource - private CrmContractConfigMapper contractConfigMapper; - - @Override - public CrmContractConfigDO getContractConfig() { - return contractConfigMapper.selectOne(); - } - - @Override - @LogRecord(type = CRM_CONTRACT_CONFIG_TYPE, subType = CRM_CONTRACT_CONFIG_SUB_TYPE, bizNo = "{{#configId}}", - success = CRM_CONTRACT_CONFIG_SUCCESS) - public void saveContractConfig(CrmContractConfigSaveReqVO saveReqVO) { - // 1. 存在,则进行更新 - CrmContractConfigDO dbConfig = getContractConfig(); - CrmContractConfigDO config = BeanUtils.toBean(saveReqVO, CrmContractConfigDO.class); - if (Objects.nonNull(dbConfig)) { - contractConfigMapper.updateById(config.setId(dbConfig.getId())); - // 记录操作日志上下文 - LogRecordContext.putVariable("isConfigUpdate", Boolean.TRUE); - LogRecordContext.putVariable("configId", config.getId()); - return; - } - - // 2. 不存在,则进行插入 - contractConfigMapper.insert(config); - // 记录操作日志上下文 - LogRecordContext.putVariable("isConfigUpdate", Boolean.FALSE); - LogRecordContext.putVariable("configId", config.getId()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java deleted file mode 100644 index f7a686759..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java +++ /dev/null @@ -1,205 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 合同 Service 接口 - * - * @author dhb52 - */ -public interface CrmContractService { - - /** - * 创建合同 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContract(@Valid CrmContractSaveReqVO createReqVO, Long userId); - - /** - * 更新合同 - * - * @param updateReqVO 更新信息 - */ - void updateContract(@Valid CrmContractSaveReqVO updateReqVO); - - /** - * 删除合同 - * - * @param id 编号 - */ - void deleteContract(Long id); - - /** - * 合同转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferContract(CrmContractTransferReqVO reqVO, Long userId); - - /** - * 更新合同相关的更进信息 - * - * @param id 合同编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateContractFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 发起合同审批流程 - * - * @param id 合同编号 - * @param userId 用户编号 - */ - void submitContract(Long id, Long userId); - - /** - * 更新合同流程审批结果 - * - * @param id 合同编号 - * @param bpmResult BPM 审批结果 - */ - void updateContractAuditStatus(Long id, Integer bpmResult); - - /** - * 获得合同 - * - * @param id 编号 - * @return 合同 - */ - CrmContractDO getContract(Long id); - - /** - * 校验合同是否合法 - * - * @param id 编号 - * @return 合同 - */ - CrmContractDO validateContract(Long id); - - /** - * 获得合同列表 - * - * @param ids 编号 - * @return 合同列表 - */ - List getContractList(Collection ids); - - /** - * 获得合同 Map - * - * @param ids 编号 - * @return 合同 Map - */ - default Map getContractMap(Collection ids) { - return convertMap(getContractList(ids), CrmContractDO::getId); - } - - /** - * 获得合同分页 - * - * 数据权限:基于 {@link CrmContractDO} 读取 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 合同分页 - */ - PageResult getContractPage(CrmContractPageReqVO pageReqVO, Long userId); - - /** - * 获得合同分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 合同分页 - */ - PageResult getContractPageByCustomerId(CrmContractPageReqVO pageReqVO); - - /** - * 获得合同分页,基于指定商机 - * - * 数据权限:基于 {@link CrmBusinessDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 合同分页 - */ - PageResult getContractPageByBusinessId(CrmContractPageReqVO pageReqVO); - - /** - * 查询属于某个联系人的合同数量 - * - * @param contactId 联系人ID - * @return 合同 - */ - Long getContractCountByContactId(Long contactId); - - /** - * 获取关联客户的合同数量 - * - * @param customerId 客户编号 - * @return 数量 - */ - Long getContractCountByCustomerId(Long customerId); - - /** - * 根据商机编号,获取关联客户的合同数量 - * - * @param businessId 商机编号 - * @return 数量 - */ - Long getContractCountByBusinessId(Long businessId); - - /** - * 根据合同编号,获得合同的产品列表 - * - * @param contactId 合同编号 - * @return 产品列表 - */ - List getContractProductListByContractId(Long contactId); - - /** - * 获得待审核合同数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getAuditContractCount(Long userId); - - /** - * 获得即将到期(提醒)的合同数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getRemindContractCount(Long userId); - - /** - * 获得合同列表 - * - * @param customerId 客户编号 - * @param ownerUserId 负责人编号 - * @return 合同列表 - */ - List getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java deleted file mode 100644 index bcf5d9a9d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java +++ /dev/null @@ -1,415 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractProductMapper; -import cn.iocoder.yudao.module.crm.dal.redis.no.CrmNoRedisDAO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.crm.util.CrmAuditStatusUtils.convertBpmResultToAuditStatus; - -/** - * CRM 合同 Service 实现类 - * - * @author dhb52 - */ -@Service -@Validated -@Slf4j -public class CrmContractServiceImpl implements CrmContractService { - - /** - * BPM 合同审批流程标识 - */ - public static final String BPM_PROCESS_DEFINITION_KEY = "crm-contract-audit"; - - @Resource - private CrmContractMapper contractMapper; - @Resource - private CrmContractProductMapper contractProductMapper; - - @Resource - private CrmNoRedisDAO noRedisDAO; - - @Resource - private CrmPermissionService crmPermissionService; - @Resource - private CrmProductService productService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmBusinessService businessService; - @Resource - private CrmContactService contactService; - @Resource - private CrmContractConfigService contractConfigService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmReceivableService receivableService; - @Resource - private AdminUserApi adminUserApi; - @Resource - private BpmProcessInstanceApi bpmProcessInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_CREATE_SUB_TYPE, bizNo = "{{#contract.id}}", - success = CRM_CONTRACT_CREATE_SUCCESS) - public Long createContract(CrmContractSaveReqVO createReqVO, Long userId) { - // 1.1 校验产品项的有效性 - List contractProducts = validateContractProducts(createReqVO.getProducts()); - // 1.2 校验关联字段 - validateRelationDataExists(createReqVO); - // 1.3 生成序号 - String no = noRedisDAO.generate(CrmNoRedisDAO.CONTRACT_NO_PREFIX); - if (contractMapper.selectByNo(no) != null) { - throw exception(CONTRACT_NO_EXISTS); - } - - // 2.1 插入合同 - CrmContractDO contract = BeanUtils.toBean(createReqVO, CrmContractDO.class).setNo(no); - calculateTotalPrice(contract, contractProducts); - contractMapper.insert(contract); - // 2.2 插入合同关联商品 - if (CollUtil.isNotEmpty(contractProducts)) { - contractProducts.forEach(item -> item.setContractId(contract.getId())); - contractProductMapper.insertBatch(contractProducts); - } - - // 3. 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(contract.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()).setBizId(contract.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("contract", contract); - return contract.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CONTRACT_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateContract(CrmContractSaveReqVO updateReqVO) { - Assert.notNull(updateReqVO.getId(), "合同编号不能为空"); - updateReqVO.setOwnerUserId(null); // 不允许更新的字段 - // 1.1 校验存在 - CrmContractDO contract = validateContractExists(updateReqVO.getId()); - // 1.2 只有草稿、审批中,可以编辑; - if (!ObjectUtils.equalsAny(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), - CrmAuditStatusEnum.PROCESS.getStatus())) { - throw exception(CONTRACT_UPDATE_FAIL_NOT_DRAFT); - } - // 1.3 校验产品项的有效性 - List contractProducts = validateContractProducts(updateReqVO.getProducts()); - // 1.4 校验关联字段 - validateRelationDataExists(updateReqVO); - - // 2.1 更新合同 - CrmContractDO updateObj = BeanUtils.toBean(updateReqVO, CrmContractDO.class); - calculateTotalPrice(updateObj, contractProducts); - contractMapper.updateById(updateObj); - // 2.2 更新合同关联商品 - updateContractProduct(updateReqVO.getId(), contractProducts); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(contract, CrmContractSaveReqVO.class)); - LogRecordContext.putVariable("contractName", contract.getName()); - } - - private void updateContractProduct(Long id, List newList) { - List oldList = contractProductMapper.selectListByContractId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setContractId(id)); - contractProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - contractProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - contractProductMapper.deleteBatchIds(convertSet(diffList.get(2), CrmContractProductDO::getId)); - } - } - - /** - * 校验关联数据是否存在 - * - * @param reqVO 请求 - */ - private void validateRelationDataExists(CrmContractSaveReqVO reqVO) { - // 1. 校验客户 - if (reqVO.getCustomerId() != null) { - customerService.validateCustomer(reqVO.getCustomerId()); - } - // 2. 校验负责人 - if (reqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(reqVO.getOwnerUserId()); - } - // 3. 如果有关联商机,则需要校验存在 - if (reqVO.getBusinessId() != null) { - businessService.validateBusiness(reqVO.getBusinessId()); - } - // 4. 校验签约相关字段 - if (reqVO.getSignContactId() != null) { - contactService.validateContact(reqVO.getSignContactId()); - } - if (reqVO.getSignUserId() != null) { - adminUserApi.validateUser(reqVO.getSignUserId()); - } - } - - private List validateContractProducts(List list) { - // 1. 校验产品存在 - productService.validProductList(convertSet(list, CrmContractSaveReqVO.Product::getProductId)); - // 2. 转化为 CrmContractProductDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, CrmContractProductDO.class, - item -> item.setTotalPrice(MoneyUtils.priceMultiply(item.getContractPrice(), item.getCount())))); - } - - private void calculateTotalPrice(CrmContractDO contract, List contractProducts) { - contract.setTotalProductPrice(getSumValue(contractProducts, CrmContractProductDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - BigDecimal discountPrice = MoneyUtils.priceMultiplyPercent(contract.getTotalProductPrice(), contract.getDiscountPercent()); - contract.setTotalPrice(contract.getTotalProductPrice().subtract(discountPrice)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CONTRACT_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteContract(Long id) { - // 1.1 校验存在 - CrmContractDO contract = validateContractExists(id); - // 1.2 如果被 CrmReceivableDO 所使用,则不允许删除 - if (receivableService.getReceivableCountByContractId(contract.getId()) > 0) { - throw exception(CONTRACT_DELETE_FAIL); - } - - // 2.1 删除合同 - contractMapper.deleteById(id); - // 2.2 删除数据权限 - crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTRACT.getType(), id); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("contractName", contract.getName()); - } - - private CrmContractDO validateContractExists(Long id) { - CrmContractDO contract = contractMapper.selectById(id); - if (contract == null) { - throw exception(CONTRACT_NOT_EXISTS); - } - return contract; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CONTRACT_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { - // 1. 校验合同是否存在 - CrmContractDO contract = validateContractExists(reqVO.getId()); - - // 2.1 数据权限转移 - crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTRACT.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置负责人 - contractMapper.updateById(new CrmContractDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); - - // 3. 记录转移日志 - LogRecordContext.putVariable("contract", contract); - } - - @Override - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_CONTRACT_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateContractFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1. 校验存在 - CrmContractDO contract = validateContractExists(id); - - // 2. 更新联系人的跟进信息 - contractMapper.updateById(new CrmContractDO().setId(id).setContactLastTime(LocalDateTime.now())); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("contractName", contract.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_SUBMIT_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CONTRACT_SUBMIT_SUCCESS) - public void submitContract(Long id, Long userId) { - // 1. 校验合同是否在审批 - CrmContractDO contract = validateContractExists(id); - if (ObjUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus())) { - throw exception(CONTRACT_SUBMIT_FAIL_NOT_DRAFT); - } - - // 2. 创建合同审批流程实例 - String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() - .setProcessDefinitionKey(BPM_PROCESS_DEFINITION_KEY).setBusinessKey(String.valueOf(id))).getCheckedData(); - - // 3. 更新合同工作流编号 - contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId) - .setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus())); - - // 3. 记录日志 - LogRecordContext.putVariable("contractName", contract.getName()); - } - - @Override - public void updateContractAuditStatus(Long id, Integer bpmResult) { - // 1.1 校验合同是否存在 - CrmContractDO contract = validateContractExists(id); - // 1.2 只有审批中,可以更新审批结果 - if (ObjUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.PROCESS.getStatus())) { - log.error("[updateContractAuditStatus][contract({}) 不处于审批中,无法更新审批结果({})]", - contract.getId(), bpmResult); - throw exception(CONTRACT_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); - } - - // 2. 更新合同审批结果 - Integer auditStatus = convertBpmResultToAuditStatus(bpmResult); - contractMapper.updateById(new CrmContractDO().setId(id).setAuditStatus(auditStatus)); - } - - // ======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmContractDO getContract(Long id) { - return contractMapper.selectById(id); - } - - @Override - public CrmContractDO validateContract(Long id) { - return validateContractExists(id); - } - - @Override - public List getContractList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return contractMapper.selectBatchIds(ids); - } - - @Override - public PageResult getContractPage(CrmContractPageReqVO pageReqVO, Long userId) { - // 1. 即将到期,需要查询合同配置 - CrmContractConfigDO config = null; - if (CrmContractPageReqVO.EXPIRY_TYPE_ABOUT_TO_EXPIRE.equals(pageReqVO.getExpiryType())) { - config = contractConfigService.getContractConfig(); - if (config != null && Boolean.FALSE.equals(config.getNotifyEnabled())) { - config = null; - } - if (config == null) { - return PageResult.empty(); - } - } - // 2. 查询分页 - return contractMapper.selectPage(pageReqVO, userId, config); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContractPageByCustomerId(CrmContractPageReqVO pageReqVO) { - return contractMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#pageReqVO.businessId", level = CrmPermissionLevelEnum.READ) - public PageResult getContractPageByBusinessId(CrmContractPageReqVO pageReqVO) { - return contractMapper.selectPageByBusinessId(pageReqVO); - } - - @Override - public Long getContractCountByContactId(Long contactId) { - return contractMapper.selectCountByContactId(contactId); - } - - @Override - public Long getContractCountByCustomerId(Long customerId) { - return contractMapper.selectCount(CrmContractDO::getCustomerId, customerId); - } - - @Override - public Long getContractCountByBusinessId(Long businessId) { - return contractMapper.selectCountByBusinessId(businessId); - } - - @Override - public List getContractProductListByContractId(Long contactId) { - return contractProductMapper.selectListByContractId(contactId); - } - - @Override - public Long getAuditContractCount(Long userId) { - return contractMapper.selectCountByAudit(userId); - } - - @Override - public Long getRemindContractCount(Long userId) { - CrmContractConfigDO config = contractConfigService.getContractConfig(); - if (config == null || Boolean.FALSE.equals(config.getNotifyEnabled())) { - return 0L; - } - return contractMapper.selectCountByRemind(userId, config); - } - - @Override - public List getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return contractMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractStatusListener.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractStatusListener.java deleted file mode 100644 index b3c07353a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractStatusListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract.listener; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 合同审批的结果的监听器实现类 - * - * @author HUIHUI - */ -@Component -public class CrmContractStatusListener extends BpmProcessInstanceStatusEventListener { - - @Resource - private CrmContractService contractService; - - @Override - public String getProcessDefinitionKey() { - return CrmContractServiceImpl.BPM_PROCESS_DEFINITION_KEY; - } - - @Override - protected void onEvent(BpmProcessInstanceStatusEvent event) { - contractService.updateContractAuditStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java deleted file mode 100644 index 40a6f7015..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import javax.validation.Valid; - -import java.util.List; - -/** - * 客户限制配置 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerLimitConfigService { - - /** - * 创建客户限制配置 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO createReqVO); - - /** - * 更新客户限制配置 - * - * @param updateReqVO 更新信息 - */ - void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO updateReqVO); - - /** - * 删除客户限制配置 - * - * @param id 编号 - */ - void deleteCustomerLimitConfig(Long id); - - /** - * 获得客户限制配置 - * - * @param id 编号 - * @return 客户限制配置 - */ - CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id); - - /** - * 获得客户限制配置分页 - * - * @param pageReqVO 分页查询 - * @return 客户限制配置分页 - */ - PageResult getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO); - - /** - * 查询用户对应的配置列表 - * - * @param type 类型 - * @param userId 用户类型 - */ - List getCustomerLimitConfigListByUserId(Integer type, Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java deleted file mode 100644 index fa09fb5da..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 客户限制配置 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfigService { - - @Resource - private CrmCustomerLimitConfigMapper customerLimitConfigMapper; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", - success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) - public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { - validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); - // 插入 - CrmCustomerLimitConfigDO limitConfig = BeanUtils.toBean(createReqVO, CrmCustomerLimitConfigDO.class); - customerLimitConfigMapper.insert(limitConfig); - - // 记录操作日志上下文 - LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfig.getType())); - LogRecordContext.putVariable("limitId", limitConfig.getId()); - return limitConfig.getId(); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) - public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { - // 校验存在 - CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); - validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); - // 更新 - CrmCustomerLimitConfigDO updateObj = BeanUtils.toBean(updateReqVO, CrmCustomerLimitConfigDO.class); - customerLimitConfigMapper.updateById(updateObj); - - // 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldLimitConfig, CrmCustomerLimitConfigSaveReqVO.class)); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) - public void deleteCustomerLimitConfig(Long id) { - // 校验存在 - CrmCustomerLimitConfigDO limitConfig = validateCustomerLimitConfigExists(id); - // 删除 - customerLimitConfigMapper.deleteById(id); - - // 记录操作日志上下文 - LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfig.getType())); - } - - @Override - public CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id) { - return customerLimitConfigMapper.selectById(id); - } - - @Override - public PageResult getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO) { - return customerLimitConfigMapper.selectPage(pageReqVO); - } - - private CrmCustomerLimitConfigDO validateCustomerLimitConfigExists(Long id) { - CrmCustomerLimitConfigDO limitConfigDO = customerLimitConfigMapper.selectById(id); - if (limitConfigDO == null) { - throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); - } - return limitConfigDO; - } - - /** - * 校验入参的用户和部门 - * - * @param userIds 用户 ids - * @param deptIds 部门 ids - */ - private void validateUserAndDept(Collection userIds, Collection deptIds) { - deptApi.validateDeptList(deptIds); - adminUserApi.validateUserList(userIds); - } - - @Override - public List getCustomerLimitConfigListByUserId(Integer type, Long userId) { - AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); - Assert.notNull(user, "用户({})不存在", userId); - return customerLimitConfigMapper.selectListByTypeAndUserIdAndDeptId(type, userId, user.getDeptId()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java deleted file mode 100644 index 5a7c91842..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; - -import javax.validation.Valid; - -/** - * 客户公海配置 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerPoolConfigService { - - /** - * 获得客户公海配置 - * - * @return 客户公海配置 - */ - CrmCustomerPoolConfigDO getCustomerPoolConfig(); - - /** - * 保存客户公海配置 - * - * @param saveReqVO 更新信息 - */ - void saveCustomerPoolConfig(@Valid CrmCustomerPoolConfigSaveReqVO saveReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java deleted file mode 100644 index d0984efa7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Objects; - -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 客户公海配置 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { - - @Resource - private CrmCustomerPoolConfigMapper customerPoolConfigMapper; - - @Override - public CrmCustomerPoolConfigDO getCustomerPoolConfig() { - return customerPoolConfigMapper.selectOne(); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", - success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) - public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { - // 1. 存在,则进行更新 - CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); - CrmCustomerPoolConfigDO poolConfig = BeanUtils.toBean(saveReqVO, CrmCustomerPoolConfigDO.class); - if (Objects.nonNull(dbConfig)) { - customerPoolConfigMapper.updateById(poolConfig.setId(dbConfig.getId())); - // 记录操作日志上下文 - LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.TRUE); - LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); - return; - } - - // 2. 不存在,则进行插入 - customerPoolConfigMapper.insert(poolConfig); - // 记录操作日志上下文 - LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE); - LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java deleted file mode 100644 index 3a133be96..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ /dev/null @@ -1,198 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerCreateReqBO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 客户 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerService { - - /** - * 创建客户 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createCustomer(@Valid CrmCustomerSaveReqVO createReqVO, Long userId); - - /** - * 更新客户 - * - * @param updateReqVO 更新信息 - */ - void updateCustomer(@Valid CrmCustomerSaveReqVO updateReqVO); - - /** - * 更新客户的跟进状态 - * - * @param id 编号 - * @param dealStatus 跟进状态 - */ - void updateCustomerDealStatus(Long id, Boolean dealStatus); - - /** - * 更新客户相关的跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateCustomerFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 删除客户 - * - * @param id 编号 - */ - void deleteCustomer(Long id); - - /** - * 获得客户 - * - * @param id 编号 - * @return 客户 - */ - CrmCustomerDO getCustomer(Long id); - - /** - * 获得客户列表 - * - * @param ids 客户编号数组 - * @return 客户列表 - * @author ljlleo - */ - List getCustomerList(Collection ids); - - /** - * 获得客户 Map - * - * @param ids 客户编号数组 - * @return 客户 Map - */ - default Map getCustomerMap(Collection ids) { - return convertMap(getCustomerList(ids), CrmCustomerDO::getId); - } - - /** - * 获得客户分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 客户分页 - */ - PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId); - - /** - * 获得放入公海提醒的客户分页 - * - * @param pageVO 分页查询 - * @param userId 用户编号 - * @return 客户分页 - */ - PageResult getPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageVO, Long userId); - - /** - * 获得待进入公海的客户数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getPutPoolRemindCustomerCount(Long userId); - - /** - * 获得今日需联系客户数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getTodayContactCustomerCount(Long userId); - - /** - * 获得分配给我的客户数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getFollowCustomerCount(Long userId); - - /** - * 校验客户是否存在 - * - * @param id 编号 - */ - void validateCustomer(Long id); - - /** - * 客户转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId); - - /** - * 锁定/解锁客户 - * - * @param lockReqVO 更新信息 - * @param userId 用户编号 - */ - void lockCustomer(@Valid CrmCustomerLockReqVO lockReqVO, Long userId); - - /** - * 创建客户 - * - * @param customerCreateReq 请求信息 - * @param userId 用户编号 - * @return 客户列表 - */ - Long createCustomer(CrmCustomerCreateReqBO customerCreateReq, Long userId); - - /** - * 批量导入客户 - * - * @param importCustomers 导入客户列表 - * @param importReqVO 请求 - * @return 导入结果 - */ - CrmCustomerImportRespVO importCustomerList(List importCustomers, CrmCustomerImportReqVO importReqVO); - - // ==================== 公海相关操作 ==================== - - /** - * 客户放入公海 - * - * @param id 客户编号 - */ - void putCustomerPool(Long id); - - /** - * 领取公海客户 - * - * @param ids 要领取的客户编号数组 - * @param ownerUserId 负责人 - * @param isReceive 是/否领取;true - 领取;false - 分配 - */ - void receiveCustomer(List ids, Long ownerUserId, Boolean isReceive); - - /** - * 【系统】客户自动掉入公海 - * - * @return 掉入公海数量 - */ - int autoPutCustomerPool(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java deleted file mode 100644 index 2ca6c9cc2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ /dev/null @@ -1,662 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_LOCK_LIMIT; -import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_OWNER_LIMIT; -import static java.util.Collections.singletonList; - -/** - * 客户 Service 实现类 - * - * @author Wanwan - */ -@Service -@Slf4j -@Validated -public class CrmCustomerServiceImpl implements CrmCustomerService { - - @Resource - private CrmCustomerMapper customerMapper; - - @Resource - private CrmPermissionService permissionService; - @Resource - private CrmCustomerLimitConfigService customerLimitConfigService; - @Resource - @Lazy - private CrmCustomerPoolConfigService customerPoolConfigService; - @Resource - @Lazy - private CrmContactService contactService; - @Resource - @Lazy - private CrmBusinessService businessService; - @Resource - @Lazy - private CrmContractService contractService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_CREATE_SUCCESS) - public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) { - createReqVO.setId(null); - // 1. 校验拥有客户是否到达上限 - validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1); - - // 2. 插入客户 - CrmCustomerDO customer = initCustomer(createReqVO, userId); - customerMapper.insert(customer); - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("customer", customer); - return customer.getId(); - } - - /** - * 初始化客户的通用字段 - * - * @param customer 客户信息 - * @param ownerUserId 负责人编号 - * @return 客户信息 DO - */ - private static CrmCustomerDO initCustomer(Object customer, Long ownerUserId) { - return BeanUtils.toBean(customer, CrmCustomerDO.class).setOwnerUserId(ownerUserId) - .setOwnerTime(LocalDateTime.now()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CUSTOMER_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) { - Assert.notNull(updateReqVO.getId(), "客户编号不能为空"); - updateReqVO.setOwnerUserId(null); // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改 - // 1. 校验存在 - CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId()); - - // 2. 更新客户 - CrmCustomerDO updateObj = BeanUtils.toBean(updateReqVO, CrmCustomerDO.class); - customerMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerSaveReqVO.class)); - LogRecordContext.putVariable("customerName", oldCustomer.getName()); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomerDealStatus(Long id, Boolean dealStatus) { - // 1.1 校验存在 - CrmCustomerDO customer = validateCustomerExists(id); - // 1.2 校验是否重复操作 - if (Objects.equals(customer.getDealStatus(), dealStatus)) { - throw exception(CUSTOMER_UPDATE_DEAL_STATUS_FAIL); - } - - // 2. 更新客户的成交状态 - customerMapper.updateById(new CrmCustomerDO().setId(id).setDealStatus(dealStatus)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - LogRecordContext.putVariable("dealStatus", dealStatus); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_CUSTOMER_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomerFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1.1 校验存在 - CrmCustomerDO customer = validateCustomerExists(id); - - // 2. 更新客户的跟进信息 - customerMapper.updateById(new CrmCustomerDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteCustomer(Long id) { - // 1.1 校验存在 - CrmCustomerDO customer = validateCustomerExists(id); - // 1.2 检查引用 - validateCustomerReference(id); - - // 2. 删除客户 - customerMapper.deleteById(id); - // 3. 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CUSTOMER_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { - // 1.1 校验客户是否存在 - CrmCustomerDO customer = validateCustomerExists(reqVO.getId()); - // 1.2 校验拥有客户是否到达上限 - validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1); - // 2.1 数据权限转移 - permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 转移后重新设置负责人 - customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getId()) - .setOwnerUserId(reqVO.getNewOwnerUserId()).setOwnerTime(LocalDateTime.now())); - - // 2.3 同时转移 - if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) { - transfer(reqVO, userId); - } - - // 3. 记录转移日志 - LogRecordContext.putVariable("customer", customer); - } - - /** - * 转移客户时,需要额外有【联系人】【商机】【合同】 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) { - if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) { - List contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getId(), userId); - contactList.forEach(item -> { - contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), - reqVO.getOldOwnerPermissionLevel()), userId); - }); - } - if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) { - List businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getId(), userId); - businessList.forEach(item -> { - businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), - reqVO.getOldOwnerPermissionLevel()), userId); - }); - } - if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) { - List contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getId(), userId); - contractList.forEach(item -> { - contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), - reqVO.getOldOwnerPermissionLevel()), userId); - }); - } - } - - @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", - success = CRM_CUSTOMER_LOCK_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#lockReqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) { - // 1.1 校验当前客户是否存在 - CrmCustomerDO customer = validateCustomerExists(lockReqVO.getId()); - // 1.2 校验当前是否重复操作锁定/解锁状态 - if (customer.getLockStatus().equals(lockReqVO.getLockStatus())) { - throw exception(customer.getLockStatus() ? CUSTOMER_LOCK_FAIL_IS_LOCK : CUSTOMER_UNLOCK_FAIL_IS_UNLOCK); - } - // 1.3 校验锁定上限 - if (lockReqVO.getLockStatus()) { - validateCustomerExceedLockLimit(userId); - } - - // 2. 更新锁定状态 - customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class)); - - // 3. 记录操作日志上下文 - // tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定 - LogRecordContext.putVariable("customer", customer); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_CREATE_SUCCESS) - public Long createCustomer(CrmCustomerCreateReqBO createReqBO, Long userId) { - // 1. 插入客户 - CrmCustomerDO customer = initCustomer(createReqBO, userId); - customerMapper.insert(customer); - - // 2. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("customer", customer); - return customer.getId(); - } - - @Override - public CrmCustomerImportRespVO importCustomerList(List importCustomers, - CrmCustomerImportReqVO importReqVO) { - // 校验非空 - importCustomers = filterList(importCustomers, item -> Objects.nonNull(item.getName())); - if (CollUtil.isEmpty(importCustomers)) { - throw exception(CUSTOMER_IMPORT_LIST_IS_EMPTY); - } - - // 逐条处理 - CrmCustomerImportRespVO respVO = CrmCustomerImportRespVO.builder().createCustomerNames(new ArrayList<>()) - .updateCustomerNames(new ArrayList<>()).failureCustomerNames(new LinkedHashMap<>()).build(); - importCustomers.forEach(importCustomer -> { - // 校验,判断是否有不符合的原因 - try { - validateCustomerForCreate(importCustomer); - } catch (ServiceException ex) { - respVO.getFailureCustomerNames().put(importCustomer.getName(), ex.getMessage()); - return; - } - // 情况一:判断如果不存在,在进行插入 - CrmCustomerDO existCustomer = customerMapper.selectByCustomerName(importCustomer.getName()); - if (existCustomer == null) { - // 1.1 插入客户信息 - CrmCustomerDO customer = initCustomer(importCustomer, importReqVO.getOwnerUserId()); - customerMapper.insert(customer); - respVO.getCreateCustomerNames().add(importCustomer.getName()); - // 1.2 创建数据权限 - if (importReqVO.getOwnerUserId() != null) { - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } - // 1.3 记录操作日志 - getSelf().importCustomerLog(customer, false); - return; - } - - // 情况二:如果存在,判断是否允许更新 - if (!importReqVO.getUpdateSupport()) { - respVO.getFailureCustomerNames().put(importCustomer.getName(), - StrUtil.format(CUSTOMER_NAME_EXISTS.getMsg(), importCustomer.getName())); - return; - } - // 2.1 更新客户信息 - CrmCustomerDO updateCustomer = BeanUtils.toBean(importCustomer, CrmCustomerDO.class) - .setId(existCustomer.getId()); - customerMapper.updateById(updateCustomer); - respVO.getUpdateCustomerNames().add(importCustomer.getName()); - // 2.2 记录操作日志 - getSelf().importCustomerLog(updateCustomer, true); - }); - return respVO; - } - - /** - * 记录导入客户时的操作日志 - * - * @param customer 客户信息 - * @param isUpdate 是否更新;true - 更新,false - 新增 - */ - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_IMPORT_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_IMPORT_SUCCESS) - public void importCustomerLog(CrmCustomerDO customer, boolean isUpdate) { - LogRecordContext.putVariable("customer", customer); - LogRecordContext.putVariable("isUpdate", isUpdate); - } - - // ==================== 公海相关操作 ==================== - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_POOL_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void putCustomerPool(Long id) { - // 1. 校验存在 - CrmCustomerDO customer = customerMapper.selectById(id); - if (customer == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 1.2. 校验是否为公海数据 - validateCustomerOwnerExists(customer, true); - // 1.3. 校验客户是否锁定 - validateCustomerIsLocked(customer, true); - - // 2. 客户放入公海 - putCustomerPool(customer); - - // 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void receiveCustomer(List ids, Long ownerUserId, Boolean isReceive) { - // 1.1 校验存在 - List customers = customerMapper.selectBatchIds(ids); - if (customers.size() != ids.size()) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 1.2 校验负责人是否存在 - adminUserApi.validateUserList(singletonList(ownerUserId)); - // 1.3 校验状态 - customers.forEach(customer -> { - // 校验是否已有负责人 - validateCustomerOwnerExists(customer, false); - // 校验是否锁定 - validateCustomerIsLocked(customer, false); - // 校验成交状态 - validateCustomerDeal(customer); - }); - // 1.4 校验负责人是否到达上限 - validateCustomerExceedOwnerLimit(ownerUserId, customers.size()); - - // 2. 领取公海数据 - List updateCustomers = new ArrayList<>(); - List createPermissions = new ArrayList<>(); - customers.forEach(customer -> { - // 2.1. 设置负责人 - updateCustomers.add(new CrmCustomerDO().setId(customer.getId()) - .setOwnerUserId(ownerUserId).setOwnerTime(LocalDateTime.now())); - // 2.2. 创建负责人数据权限 - createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - }); - // 2.2 更新客户负责人 - customerMapper.updateBatch(updateCustomers); - // 2.3 创建负责人数据权限 - permissionService.createPermissionBatch(createPermissions); - // TODO @芋艿:要不要处理关联的联系人??? - - // 3. 记录操作日志 - AdminUserRespDTO user = null; - if (!isReceive) { - user = adminUserApi.getUser(ownerUserId).getCheckedData(); - } - for (CrmCustomerDO customer : customers) { - getSelf().receiveCustomerLog(customer, user == null ? null : user.getNickname()); - } - } - - @Override - public int autoPutCustomerPool() { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (poolConfig == null || !poolConfig.getEnabled()) { - return 0; - } - // 1. 获得需要放到的客户列表 - List customerList = customerMapper.selectListByAutoPool(poolConfig); - // 2. 逐个放入公海 - int count = 0; - for (CrmCustomerDO customer : customerList) { - try { - getSelf().putCustomerPool(customer); - count++; - } catch (Throwable e) { - log.error("[autoPutCustomerPool][客户({}) 放入公海异常]", customer.getId(), e); - } - } - return count; - } - - @Transactional(rollbackFor = Exception.class) // 需要 protected 修饰,因为需要在事务中调用 - protected void putCustomerPool(CrmCustomerDO customer) { - // 1. 设置负责人为 NULL - int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); - if (updateOwnerUserIncr == 0) { - throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); - } - - // 2. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的 - contactService.updateOwnerUserIdByCustomerId(customer.getId(), null); - - // 3. 删除负责人数据权限 - // 注意:需要放在 contactService 后面,不然【客户】数据权限已经被删除,无法操作! - permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), - CrmPermissionLevelEnum.OWNER.getLevel()); - } - - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_RECEIVE_SUCCESS) - public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { - // 记录操作日志上下文 - LogRecordContext.putVariable("customer", customer); - LogRecordContext.putVariable("ownerUserName", ownerUserName); - } - - //======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmCustomerDO getCustomer(Long id) { - return customerMapper.selectById(id); - } - - @Override - public List getCustomerList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return customerMapper.selectBatchIds(ids); - } - - @Override - public PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) { - return customerMapper.selectPage(pageReqVO, userId); - } - - @Override - public PageResult getPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageVO, Long userId) { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (ObjUtil.isNull(poolConfig) - || Boolean.FALSE.equals(poolConfig.getEnabled()) - || Boolean.FALSE.equals(poolConfig.getNotifyEnabled())) { - return PageResult.empty(); - } - return customerMapper.selectPutPoolRemindCustomerPage(pageVO, poolConfig, userId); - } - - @Override - public Long getPutPoolRemindCustomerCount(Long userId) { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (ObjUtil.isNull(poolConfig) - || Boolean.FALSE.equals(poolConfig.getEnabled()) - || Boolean.FALSE.equals(poolConfig.getNotifyEnabled())) { - return 0L; - } - CrmCustomerPageReqVO pageVO = new CrmCustomerPageReqVO() - .setPool(null) - .setContactStatus(CrmCustomerPageReqVO.CONTACT_TODAY) - .setSceneType(CrmSceneTypeEnum.OWNER.getType()); - return customerMapper.selectPutPoolRemindCustomerCount(pageVO, poolConfig, userId); - } - - @Override - public Long getTodayContactCustomerCount(Long userId) { - return customerMapper.selectCountByTodayContact(userId); - } - - @Override - public Long getFollowCustomerCount(Long userId) { - return customerMapper.selectCountByFollow(userId); - } - - // ======================= 校验相关 ======================= - - private void validateCustomerForCreate(CrmCustomerImportExcelVO importCustomer) { - // 校验客户名称不能为空 - if (StrUtil.isEmptyIfStr(importCustomer.getName())) { - throw exception(CUSTOMER_CREATE_NAME_NOT_NULL); - } - } - - /** - * 校验客户是否被引用 - * - * @param id 客户编号 - */ - private void validateCustomerReference(Long id) { - if (contactService.getContactCountByCustomerId(id) > 0) { - throw exception(CUSTOMER_DELETE_FAIL_HAVE_REFERENCE, CrmBizTypeEnum.CRM_CONTACT.getName()); - } - if (businessService.getBusinessCountByCustomerId(id) > 0) { - throw exception(CUSTOMER_DELETE_FAIL_HAVE_REFERENCE, CrmBizTypeEnum.CRM_BUSINESS.getName()); - } - if (contractService.getContractCountByCustomerId(id) > 0) { - throw exception(CUSTOMER_DELETE_FAIL_HAVE_REFERENCE, CrmBizTypeEnum.CRM_CONTRACT.getName()); - } - } - - /** - * 校验客户是否存在 - * - * @param id 客户 id - */ - @Override - public void validateCustomer(Long id) { - validateCustomerExists(id); - } - - private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) { - if (customer == null) { // 防御一下 - throw exception(CUSTOMER_NOT_EXISTS); - } - // 校验是否为公海数据 - if (pool && customer.getOwnerUserId() == null) { - throw exception(CUSTOMER_IN_POOL, customer.getName()); - } - // 负责人已存在 - if (!pool && customer.getOwnerUserId() != null) { - throw exception(CUSTOMER_OWNER_EXISTS, customer.getName()); - } - } - - private CrmCustomerDO validateCustomerExists(Long id) { - CrmCustomerDO customerDO = customerMapper.selectById(id); - if (customerDO == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - return customerDO; - } - - private void validateCustomerIsLocked(CrmCustomerDO customer, Boolean pool) { - if (customer.getLockStatus()) { - throw exception(pool ? CUSTOMER_LOCKED_PUT_POOL_FAIL : CUSTOMER_LOCKED, customer.getName()); - } - } - - private void validateCustomerDeal(CrmCustomerDO customer) { - if (customer.getDealStatus()) { - throw exception(CUSTOMER_ALREADY_DEAL); - } - } - - /** - * 校验用户拥有的客户数量,是否到达上限 - * - * @param userId 用户编号 - * @param newCount 附加数量 - */ - private void validateCustomerExceedOwnerLimit(Long userId, int newCount) { - List limitConfigs = customerLimitConfigService.getCustomerLimitConfigListByUserId( - CUSTOMER_OWNER_LIMIT.getType(), userId); - if (CollUtil.isEmpty(limitConfigs)) { - return; - } - Long ownerCount = customerMapper.selectCountByDealStatusAndOwnerUserId(null, userId); - Long dealOwnerCount = customerMapper.selectCountByDealStatusAndOwnerUserId(true, userId); - limitConfigs.forEach(limitConfig -> { - long nowCount = limitConfig.getDealCountEnabled() ? ownerCount : ownerCount - dealOwnerCount; - if (nowCount + newCount > limitConfig.getMaxCount()) { - throw exception(CUSTOMER_OWNER_EXCEED_LIMIT); - } - }); - } - - /** - * 校验用户锁定的客户数量,是否到达上限 - * - * @param userId 用户编号 - */ - private void validateCustomerExceedLockLimit(Long userId) { - List limitConfigs = customerLimitConfigService.getCustomerLimitConfigListByUserId( - CUSTOMER_LOCK_LIMIT.getType(), userId); - if (CollUtil.isEmpty(limitConfigs)) { - return; - } - Long lockCount = customerMapper.selectCountByLockStatusAndOwnerUserId(true, userId); - Integer maxCount = CollectionUtils.getMaxValue(limitConfigs, CrmCustomerLimitConfigDO::getMaxCount); - assert maxCount != null; - if (lockCount >= maxCount) { - throw exception(CUSTOMER_LOCK_EXCEED_LIMIT); - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CrmCustomerServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/bo/CrmCustomerCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/bo/CrmCustomerCreateReqBO.java deleted file mode 100644 index 87a6b3387..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/bo/CrmCustomerCreateReqBO.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer.bo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Size; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 客户创建 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmCustomerCreateReqBO { - - /** - * 客户名称 - */ - @NotEmpty(message = "客户名称不能为空") - private String name; - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 锁定状态 - */ - private Boolean lockStatus; - /** - * 成交状态 - */ - private Boolean dealStatus; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - - /** - * 手机 - */ - @Mobile - private String mobile; - /** - * 电话 - */ - @Telephone - private String telephone; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - - /** - * 邮箱 - */ - @Email(message = "邮箱格式不正确") - private String email; - - /** - * 客户描述 - */ - @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") - private String description; - /** - * 备注 - */ - private String remark; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java deleted file mode 100644 index 3c043e386..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.followup; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * 跟进记录 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmFollowUpRecordService { - - /** - * 创建跟进记录 (数据权限基于 bizType、 bizId) - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createFollowUpRecord(@Valid CrmFollowUpRecordSaveReqVO createReqVO); - - /** - * 创建更进 - * - * @param list 请求 - */ - void createFollowUpRecordBatch(List list); - - /** - * 删除跟进记录 (数据权限基于 bizType、 bizId) - * - * @param id 编号 - * @param userId 用户编号 - */ - void deleteFollowUpRecord(Long id, Long userId); - - /** - * 删除跟进 - * - * @param bizType 模块类型 - * @param bizId 模块数据编号 - */ - void deleteFollowUpRecordByBiz(Integer bizType, Long bizId); - - /** - * 获得跟进记录 - * - * @param id 编号 - * @return 跟进记录 - */ - CrmFollowUpRecordDO getFollowUpRecord(Long id); - - /** - * 获得跟进记录分页 (数据权限基于 bizType、 bizId) - * - * @param pageReqVO 分页查询 - * @return 跟进记录分页 - */ - PageResult getFollowUpRecordPage(CrmFollowUpRecordPageReqVO pageReqVO); - - /** - * 获取跟进记录 - * - * @param bizType 模块类型 - * @param bizIds 模块数据编号 - * @return 跟进列表 - */ - List getFollowUpRecordByBiz(Integer bizType, Collection bizIds); - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java deleted file mode 100644 index 0bc4480e3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.followup; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.dal.mysql.followup.CrmFollowUpRecordMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_DELETE_DENIED; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_NOT_EXISTS; - -/** - * 跟进记录 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { - - @Resource - private CrmFollowUpRecordMapper crmFollowUpRecordMapper; - - @Resource - @Lazy - private CrmPermissionService permissionService; - @Resource - @Lazy - private CrmBusinessService businessService; - @Resource - @Lazy - private CrmClueService clueService; - @Resource - @Lazy - private CrmContactService contactService; - @Resource - @Lazy - private CrmContractService contractService; - @Resource - @Lazy - private CrmCustomerService customerService; - - @Override - @CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE) - public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { - // 1. 创建更进记录 - CrmFollowUpRecordDO record = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); - crmFollowUpRecordMapper.insert(record); - - // 2. 更新 bizId 对应的记录 - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息 - customerService.updateCustomerFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_BUSINESS.getType(), record.getBizType())) { // 更新商机跟进信息 - businessService.updateBusinessFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CLUE.getType(), record.getBizType())) { // 更新线索跟进信息 - clueService.updateClueFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTACT.getType(), record.getBizType())) { // 更新联系人跟进信息 - contactService.updateContactFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTRACT.getType(), record.getBizType())) { // 更新合同跟进信息 - contractService.updateContractFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - - // 3.1 更新 contactIds 对应的记录,只更新 nextTime - if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { - contactService.updateContactContactNextTime(createReqVO.getContactIds(), createReqVO.getNextTime()); - } - // 3.2 需要更新 businessIds 对应的记录,只更新 nextTime - if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { - businessService.updateBusinessContactNextTime(createReqVO.getBusinessIds(), createReqVO.getNextTime()); - } - return record.getId(); - } - - @Override - public void createFollowUpRecordBatch(List list) { - if (CollUtil.isEmpty(list)) { - return; - } - crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(list, CrmFollowUpRecordDO.class)); - } - - @Override - public void deleteFollowUpRecord(Long id, Long userId) { - // 校验存在 - CrmFollowUpRecordDO followUpRecord = validateFollowUpRecordExists(id); - // 校验权限 - if (!permissionService.hasPermission(followUpRecord.getBizType(), followUpRecord.getBizId(), userId, CrmPermissionLevelEnum.OWNER)) { - throw exception(FOLLOW_UP_RECORD_DELETE_DENIED); - } - - // 删除 - crmFollowUpRecordMapper.deleteById(id); - } - - @Override - public void deleteFollowUpRecordByBiz(Integer bizType, Long bizId) { - crmFollowUpRecordMapper.deleteByBiz(bizType, bizId); - } - - private CrmFollowUpRecordDO validateFollowUpRecordExists(Long id) { - CrmFollowUpRecordDO followUpRecord = crmFollowUpRecordMapper.selectById(id); - if (followUpRecord == null) { - throw exception(FOLLOW_UP_RECORD_NOT_EXISTS); - } - return followUpRecord; - } - - @Override - public CrmFollowUpRecordDO getFollowUpRecord(Long id) { - return crmFollowUpRecordMapper.selectById(id); - } - - @Override - @CrmPermission(bizTypeValue = "#pageReqVO.bizType", bizId = "#pageReqVO.bizId", level = CrmPermissionLevelEnum.READ) - public PageResult getFollowUpRecordPage(CrmFollowUpRecordPageReqVO pageReqVO) { - return crmFollowUpRecordMapper.selectPage(pageReqVO); - } - - @Override - public List getFollowUpRecordByBiz(Integer bizType, Collection bizIds) { - return crmFollowUpRecordMapper.selectListByBiz(bizType, bizIds); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmFollowUpCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmFollowUpCreateReqBO.java deleted file mode 100644 index f718957c7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmFollowUpCreateReqBO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.followup.bo; - -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 跟进信息 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmFollowUpCreateReqBO { - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - @NotNull(message = "数据类型不能为空") - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - @NotNull(message = "数据编号不能为空") - private Long bizId; - - /** - * 跟进类型 - * - * 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典 - */ - @NotNull(message = "跟进类型不能为空") - private Integer type; - /** - * 跟进内容 - */ - @NotEmpty(message = "跟进内容不能为空") - private String content; - /** - * 下次联系时间 - */ - @NotNull(message = "下次联系时间不能为空") - private LocalDateTime nextTime; - - /** - * 图片 - */ - private List picUrls; - /** - * 附件 - */ - private List fileUrls; - - /** - * 关联的商机编号数组 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - private List businessIds; - - /** - * 关联的联系人编号数组 - * - * 关联 {@link CrmContactDO#getId()} - */ - private List contactIds; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java deleted file mode 100644 index c5a6b854c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission; - - -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * crm 数据权限 Service 接口 - * - * @author HUIHUI - */ -public interface CrmPermissionService { - - /** - * 创建数据权限 - * - * @param reqVO 创建信息 - * @param userId 用户编号 - */ - void createPermission(CrmPermissionSaveReqVO reqVO, Long userId); - - /** - * 创建数据权限 - * - * @param createReqBO 创建信息 - * @return 编号 - */ - Long createPermission(@Valid CrmPermissionCreateReqBO createReqBO); - - /** - * 创建数据权限 - * - * @param createReqBOs 创建信息 - */ - void createPermissionBatch(@Valid List createReqBOs); - - /** - * 更新数据权限 - * - * @param updateReqVO 更新信息 - */ - void updatePermission(CrmPermissionUpdateReqVO updateReqVO); - - /** - * 数据权限转移 - * - * @param crmPermissionTransferReqBO 数据权限转移请求 - */ - void transferPermission(@Valid CrmPermissionTransferReqBO crmPermissionTransferReqBO); - - /** - * 删除数据权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @param level 数据权限级别,关联 {@link CrmPermissionLevelEnum} - */ - void deletePermission(Integer bizType, Long bizId, Integer level); - - /** - * 删除数据权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - */ - void deletePermission(Integer bizType, Long bizId); - - /** - * 批量删除数据权限 - * - * @param ids 权限编号 - * @param userId 用户编号 - */ - void deletePermissionBatch(Collection ids, Long userId); - - /** - * 删除指定用户数据权限 - * - * @param id 权限编号 - * @param userId 用户编号 - */ - void deleteSelfPermission(Long id, Long userId); - - /** - * 获取数据权限列表,通过 数据类型 x 某个数据 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @return Crm 数据权限列表 - */ - List getPermissionListByBiz(Integer bizType, Long bizId); - - /** - * 获取数据权限列表,通过 数据类型 x 某个数据 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @return Crm 数据权限列表 - */ - List getPermissionListByBiz(Integer bizType, Collection bizIds); - - /** - * 获取用户参与的模块数据列表 - * - * @param bizType 模块类型 - * @param userId 用户编号 - * @return 模块数据列表 - */ - List getPermissionListByBizTypeAndUserId(Integer bizType, Long userId); - - /** - * 校验是否有指定数据的操作权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @param userId 用户编号 - * @param level 权限级别 - * @return 是否有权限 - */ - boolean hasPermission(Integer bizType, Long bizId, Long userId, CrmPermissionLevelEnum level); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java deleted file mode 100644 index 74f43e779..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java +++ /dev/null @@ -1,335 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum.isOwner; - -/** - * CRM 数据权限 Service 接口实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CrmPermissionServiceImpl implements CrmPermissionService { - - @Resource - private CrmPermissionMapper permissionMapper; - @Resource - @Lazy // 解决依赖循环 - private CrmContactService contactService; - @Resource - @Lazy // 解决依赖循环 - private CrmBusinessService businessService; - @Resource - @Lazy // 解决依赖循环 - private CrmContractService contractService; - @Resource - private AdminUserApi adminUserApi; - - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) - public void createPermission(CrmPermissionSaveReqVO reqVO, Long userId) { - // 1. 创建数据权限 - createPermission0(BeanUtils.toBean(reqVO, CrmPermissionCreateReqBO.class)); - - // 2. 处理【同时添加至】的权限 - if (CollUtil.isEmpty(reqVO.getToBizTypes())) { - return; - } - List createPermissions = new ArrayList<>(); - buildContactPermissions(reqVO, userId, createPermissions); - buildBusinessPermissions(reqVO, userId, createPermissions); - buildContractPermissions(reqVO, userId, createPermissions); - if (CollUtil.isEmpty(createPermissions)) { - return; - } - createPermissionBatch(createPermissions); - } - - /** - * 处理同时添加至联系人 - * - * @param reqVO 请求 - * @param userId 操作人 - * @param createPermissions 待添加权限列表 - */ - private void buildContactPermissions(CrmPermissionSaveReqVO reqVO, Long userId, List createPermissions) { - // 1. 校验是否被同时添加 - Integer type = CrmBizTypeEnum.CRM_CONTACT.getType(); - if (!reqVO.getToBizTypes().contains(type)) { - return; - } - // 2. 添加数据权限 - List contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); - contactList.forEach(item -> createBizTypePermissions(reqVO, type, item.getId(), item.getName(), createPermissions)); - } - - /** - * 处理同时添加至商机 - * - * @param reqVO 请求 - * @param userId 操作人 - * @param createPermissions 待添加权限列表 - */ - private void buildBusinessPermissions(CrmPermissionSaveReqVO reqVO, Long userId, List createPermissions) { - // 1. 校验是否被同时添加 - Integer type = CrmBizTypeEnum.CRM_BUSINESS.getType(); - if (!reqVO.getToBizTypes().contains(type)) { - return; - } - // 2. 添加数据权限 - List businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); - businessList.forEach(item -> createBizTypePermissions(reqVO, type, item.getId(), item.getName(), createPermissions)); - } - - /** - * 处理同时添加至合同 - * - * @param reqVO 请求 - * @param userId 操作人 - * @param createPermissions 待添加权限列表 - */ - private void buildContractPermissions(CrmPermissionSaveReqVO reqVO, Long userId, List createPermissions) { - // 1. 校验是否被同时添加 - Integer type = CrmBizTypeEnum.CRM_CONTRACT.getType(); - if (!reqVO.getToBizTypes().contains(type)) { - return; - } - // 2. 添加数据权限 - List contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); - contractList.forEach(item -> createBizTypePermissions(reqVO, type, item.getId(), item.getName(), createPermissions)); - } - - private void createBizTypePermissions(CrmPermissionSaveReqVO reqVO, Integer type, Long bizId, String name, - List createPermissions) { - AdminUserRespDTO user = adminUserApi.getUser(reqVO.getUserId()).getCheckedData(); - // 1. 需要考虑,被添加人,是不是应该有对应的权限了; - CrmPermissionDO permission = hasAnyPermission(type, bizId, reqVO.getUserId()); - if (ObjUtil.isNotNull(permission)) { - throw exception(CRM_PERMISSION_CREATE_FAIL_EXISTS, user.getNickname(), CrmBizTypeEnum.getNameByType(type), - name, CrmPermissionLevelEnum.getNameByLevel(permission.getLevel())); - } - // 2. 添加数据权限 - createPermissions.add(new CrmPermissionCreateReqBO().setBizType(type) - .setBizId(bizId).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPermission(CrmPermissionCreateReqBO createReqBO) { - return createPermission0(createReqBO); - } - - private Long createPermission0(CrmPermissionCreateReqBO createReqBO) { - validatePermissionNotExists(Collections.singletonList(createReqBO)); - // 1. 校验用户是否存在 - adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())); - // 2. 插入权限 - CrmPermissionDO permission = BeanUtils.toBean(createReqBO, CrmPermissionDO.class); - permissionMapper.insert(permission); - return permission.getId(); - } - - @Override - public void createPermissionBatch(List createReqBOs) { - validatePermissionNotExists(createReqBOs); - // 1. 校验用户是否存在 - adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId)); - - // 2. 创建 - List permissions = BeanUtils.toBean(createReqBOs, CrmPermissionDO.class); - permissionMapper.insertBatch(permissions); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePermission(CrmPermissionUpdateReqVO updateReqVO) { - // 1. 校验存在 - validatePermissionExists(updateReqVO.getIds()); - // 2. 更新 - List updateList = CollectionUtils.convertList(updateReqVO.getIds(), - id -> new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel())); - permissionMapper.updateBatch(updateList); - } - - private void validatePermissionExists(Collection ids) { - List permissionList = permissionMapper.selectBatchIds(ids); - if (ObjUtil.notEqual(permissionList.size(), ids.size())) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - } - - private void validatePermissionNotExists(Collection createReqBOs) { - Set bizTypes = convertSet(createReqBOs, CrmPermissionCreateReqBO::getBizType); - Set bizIds = convertSet(createReqBOs, CrmPermissionCreateReqBO::getBizId); - Set userIds = convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId); - Long count = permissionMapper.selectListByBiz(bizTypes, bizIds, userIds); - if (count > 0) { - throw exception(CRM_PERMISSION_CREATE_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void transferPermission(CrmPermissionTransferReqBO transferReqBO) { - // 1. 校验数据权限:是否是负责人,只有负责人才可以转移 - CrmPermissionDO oldPermission = permissionMapper.selectByBizTypeAndBizIdByUserId( - transferReqBO.getBizType(), transferReqBO.getBizId(), transferReqBO.getUserId()); - String bizTypeName = CrmBizTypeEnum.getNameByType(transferReqBO.getBizType()); - if (oldPermission == null // 不是拥有者,并且不是超管 - || (!isOwner(oldPermission.getLevel()) && !CrmPermissionUtils.isCrmAdmin())) { - throw exception(CRM_PERMISSION_DENIED, bizTypeName); - } - // 1.1 校验转移对象是否已经是该负责人 - if (ObjUtil.equal(transferReqBO.getNewOwnerUserId(), oldPermission.getUserId())) { - throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName); - } - // 1.2 校验新负责人是否存在 - adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())); - - // 2. 修改新负责人的权限 - List permissions = permissionMapper.selectByBizTypeAndBizId( - transferReqBO.getBizType(), transferReqBO.getBizId()); // 获得所有数据权限 - CrmPermissionDO permission = CollUtil.findOne(permissions, - item -> ObjUtil.equal(item.getUserId(), transferReqBO.getNewOwnerUserId())); - if (permission == null) { - permissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType()) - .setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } else { - permissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } - - // 3. 修改老负责人的权限 - if (transferReqBO.getOldOwnerPermissionLevel() != null) { - permissionMapper.updateById(new CrmPermissionDO().setId(oldPermission.getId()) - .setLevel(transferReqBO.getOldOwnerPermissionLevel())); - } else { - permissionMapper.deleteById(oldPermission.getId()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePermission(Integer bizType, Long bizId, Integer level) { - // 校验存在 - List permissions = permissionMapper.selectListByBizTypeAndBizIdAndLevel( - bizType, bizId, level); - if (CollUtil.isEmpty(permissions)) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - - // 删除数据权限 - permissionMapper.deleteBatchIds(convertSet(permissions, CrmPermissionDO::getId)); - } - - @Override - public void deletePermission(Integer bizType, Long bizId) { - int deletedCount = permissionMapper.deletePermission(bizType, bizId); - if (deletedCount == 0) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - } - - @Override - public void deletePermissionBatch(Collection ids, Long userId) { - List permissions = permissionMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(permissions)) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - // 校验:数据权限的模块数据编号是一致的不可能存在两个 - if (convertSet(permissions, CrmPermissionDO::getBizId).size() > 1) { - throw exception(CRM_PERMISSION_DELETE_FAIL); - } - // 校验操作人是否为负责人 - CrmPermissionDO permission = permissionMapper.selectByBizAndUserId(permissions.get(0).getBizType(), permissions.get(0).getBizId(), userId); - if (permission == null) { - throw exception(CRM_PERMISSION_DELETE_DENIED); - } - if (!CrmPermissionLevelEnum.isOwner(permission.getLevel())) { - throw exception(CRM_PERMISSION_DELETE_DENIED); - } - - // 删除数据权限 - permissionMapper.deleteBatchIds(ids); - } - - @Override - public void deleteSelfPermission(Long id, Long userId) { - // 校验数据存在且是自己 - CrmPermissionDO permission = permissionMapper.selectByIdAndUserId(id, userId); - if (permission == null) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - // 校验是否是负责人 - if (CrmPermissionLevelEnum.isOwner(permission.getLevel())) { - throw exception(CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER); - } - - // 删除 - permissionMapper.deleteById(id); - } - - @Override - public List getPermissionListByBiz(Integer bizType, Long bizId) { - return permissionMapper.selectByBizTypeAndBizId(bizType, bizId); - } - - @Override - public List getPermissionListByBiz(Integer bizType, Collection bizIds) { - return permissionMapper.selectByBizTypeAndBizIds(bizType, bizIds); - } - - @Override - public List getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) { - return permissionMapper.selectListByBizTypeAndUserId(bizType, userId); - } - - @Override - public boolean hasPermission(Integer bizType, Long bizId, Long userId, CrmPermissionLevelEnum level) { - List permissionList = permissionMapper.selectByBizTypeAndBizId(bizType, bizId); - return anyMatch(permissionList, permission -> - ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), level.getLevel())); - } - - public CrmPermissionDO hasAnyPermission(Integer bizType, Long bizId, Long userId) { - List permissionList = permissionMapper.selectByBizTypeAndBizId(bizType, bizId); - return findFirst(permissionList, permission -> ObjUtil.equal(permission.getUserId(), userId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java deleted file mode 100644 index ce13a2d17..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * crm 数据权限 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmPermissionCreateReqBO { - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * Crm 类型 - */ - @NotNull(message = "Crm 类型不能为空") - @InEnum(CrmBizTypeEnum.class) - private Integer bizType; - /** - * 数据编号 - */ - @NotNull(message = "Crm 数据编号不能为空") - private Long bizId; - - /** - * 权限级别 - */ - @NotNull(message = "权限级别不能为空") - @InEnum(CrmPermissionLevelEnum.class) - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java deleted file mode 100644 index fb7813a0f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -/** - * 数据权限转移 Request BO - * - * @author HUIHUI - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmPermissionTransferReqBO { - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * CRM 类型 - */ - @NotNull(message = "Crm 类型不能为空") - @InEnum(CrmBizTypeEnum.class) - private Integer bizType; - /** - * 数据编号 - */ - @NotNull(message = "CRM 数据编号不能为空") - private Long bizId; - - /** - * 新负责人的用户编号 - */ - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java deleted file mode 100644 index c82f97c4a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 产品分类 Service 接口 - * - * @author ZanGe丶 - */ -public interface CrmProductCategoryService { - - /** - * 创建产品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductCategory(@Valid CrmProductCategoryCreateReqVO createReqVO); - - /** - * 更新产品分类 - * - * @param updateReqVO 更新信息 - */ - void updateProductCategory(@Valid CrmProductCategoryCreateReqVO updateReqVO); - - /** - * 删除产品分类 - * - * @param id 编号 - */ - void deleteProductCategory(Long id); - - /** - * 获得产品分类 - * - * @param id 编号 - * @return 产品分类 - */ - CrmProductCategoryDO getProductCategory(Long id); - - /** - * 获得产品分类列表 - * - * @param listReqVO 列表请求 - * @return 产品分类列表 - */ - List getProductCategoryList(CrmProductCategoryListReqVO listReqVO); - - /** - * 获得产品分类列表 - * - * @param ids 编号数组 - * @return 产品分类列表 - */ - List getProductCategoryList(Collection ids); - - /** - * 获得产品分类 Map - * - * @param ids 编号数组 - * @return 产品分类 Map - */ - default Map getProductCategoryMap(Collection ids) { - return convertMap(getProductCategoryList(ids), CrmProductCategoryDO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java deleted file mode 100644 index 873d99622..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * CRM 产品分类 Service 实现类 - * - * @author ZanGe丶 - */ -@Service -@Validated -public class CrmProductCategoryServiceImpl implements CrmProductCategoryService { - - @Resource(name = "crmProductCategoryMapper") - private CrmProductCategoryMapper productCategoryMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private CrmProductService crmProductService; - - @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#productCategoryId}}", - success = CRM_PRODUCT_CATEGORY_CREATE_SUCCESS) - public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) { - // 1.1 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - // 1.2 分类名称是否存在 - validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName()); - - // 2. 插入分类 - CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); - productCategoryMapper.insert(category); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("productCategoryId", category.getId()); - return category.getId(); - } - - @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS) - public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) { - // 1.1 校验存在 - validateProductCategoryExists(updateReqVO.getId()); - // 1.2 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - // 1.3 分类名称是否存在 - validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 2. 更新分类 - CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class); - productCategoryMapper.updateById(updateObj); - } - - private void validateProductCategoryExists(Long id) { - if (productCategoryMapper.selectById(id) == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - CrmProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (!Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductNameExists(Long id, Long parentId, String name) { - CrmProductCategoryDO category = productCategoryMapper.selectByParentIdAndName(parentId, name); - if (category == null - || category.getId().equals(id)) { - return; - } - throw exception(PRODUCT_CATEGORY_EXISTS); - } - - @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_PRODUCT_CATEGORY_DELETE_SUCCESS) - public void deleteProductCategory(Long id) { - // 1.1 校验存在 - validateProductCategoryExists(id); - // 1.2 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(PRODUCT_CATEGORY_EXISTS_CHILDREN); - } - // 1.3 校验是否被产品使用 - if (crmProductService.getProductByCategoryId(id) > 0) { - throw exception(PRODUCT_CATEGORY_USED); - } - // 2. 删除 - productCategoryMapper.deleteById(id); - } - - @Override - public CrmProductCategoryDO getProductCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public List getProductCategoryList(CrmProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getProductCategoryList(Collection ids) { - return productCategoryMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java deleted file mode 100644 index 943819ea0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 产品 Service 接口 - * - * @author ZanGe丶 - */ -public interface CrmProductService { - - /** - * 创建产品 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProduct(@Valid CrmProductSaveReqVO createReqVO); - - /** - * 更新产品 - * - * @param updateReqVO 更新信息 - */ - void updateProduct(@Valid CrmProductSaveReqVO updateReqVO); - - /** - * 删除产品 - * - * @param id 编号 - */ - void deleteProduct(Long id); - - /** - * 获得产品 - * - * @param id 编号 - * @return 产品 - */ - CrmProductDO getProduct(Long id); - - /** - * 获得产品列表 - * - * @param ids 编号 - * @return 产品列表 - */ - List getProductList(Collection ids); - - /** - * 获得产品 Map - * - * @param ids 编号 - * @return 产品 Map - */ - default Map getProductMap(Collection ids) { - return convertMap(getProductList(ids), CrmProductDO::getId); - } - - /** - * 获得产品分页 - * - * @param pageReqVO 分页查询 - * @return 产品分页 - */ - PageResult getProductPage(CrmProductPageReqVO pageReqVO); - - /** - * 获得产品数量 - * - * @param categoryId 分类编号 - * @return 产品 - */ - Long getProductByCategoryId(Long categoryId); - - /** - * 获得指定状态的产品列表 - * - * @param status 状态 - * @return 产品列表 - */ - List getProductListByStatus(Integer status); - - /** - * 校验产品们的有效性 - * - * @param ids 编号数组 - * @return 产品列表 - */ - List validProductList(Collection ids); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java deleted file mode 100644 index 3903b4791..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - - -/** - * CRM 产品 Service 实现类 - * - * @author ZanGe丶 - */ -@Service -@Validated -public class CrmProductServiceImpl implements CrmProductService { - - @Resource(name = "crmProductMapper") - private CrmProductMapper productMapper; - - @Resource - private CrmProductCategoryService productCategoryService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#productId}}", - success = CRM_PRODUCT_CREATE_SUCCESS) - public Long createProduct(CrmProductSaveReqVO createReqVO) { - // 1. 校验产品 - adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); - validateProductNoDuplicate(null, createReqVO.getNo()); - validateProductCategoryExists(createReqVO.getCategoryId()); - - // 2. 插入产品 - CrmProductDO product = BeanUtils.toBean(createReqVO, CrmProductDO.class); - productMapper.insert(product); - - // 3. 插入数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("productId", product.getId()); - return product.getId(); - } - - @Override - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_PRODUCT_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateProduct(CrmProductSaveReqVO updateReqVO) { - // 1. 校验产品 - updateReqVO.setOwnerUserId(null); // 不修改负责人 - CrmProductDO crmProductDO = validateProductExists(updateReqVO.getId()); - validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo()); - validateProductCategoryExists(updateReqVO.getCategoryId()); - - // 2. 更新产品 - CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class); - productMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(crmProductDO, CrmProductSaveReqVO.class)); - } - - private CrmProductDO validateProductExists(Long id) { - CrmProductDO product = productMapper.selectById(id); - if (product == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - return product; - } - - private void validateProductNoDuplicate(Long id, String no) { - CrmProductDO product = productMapper.selectByNo(no); - if (product == null - || product.getId().equals(id)) { - return; - } - throw exception(PRODUCT_NO_EXISTS); - } - - private void validateProductCategoryExists(Long categoryId) { - CrmProductCategoryDO category = productCategoryService.getProductCategory(categoryId); - if (category == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - @Override - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_PRODUCT_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteProduct(Long id) { - // 校验存在 - validateProductExists(id); - // 删除 - productMapper.deleteById(id); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmProductDO getProduct(Long id) { - return productMapper.selectById(id); - } - - @Override - public PageResult getProductPage(CrmProductPageReqVO pageReqVO) { - return productMapper.selectPage(pageReqVO); - } - - @Override - public Long getProductByCategoryId(Long categoryId) { - return productMapper.selectCountByCategoryId(categoryId); - } - - @Override - public List getProductListByStatus(Integer status) { - return productMapper.selectListByStatus(status); - } - - @Override - public List validProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = productMapper.selectBatchIds(ids); - Map productMap = convertMap(list, CrmProductDO::getId); - for (Long id : ids) { - CrmProductDO product = productMap.get(id); - if (productMap.get(id) == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - if (CrmProductStatusEnum.isDisable(product.getStatus())) { - throw exception(PRODUCT_NOT_ENABLE, product.getName()); - } - } - return list; - } - - @Override - public List getProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return productMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java deleted file mode 100644 index b5a6f3ab2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * CRM 回款计划 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmReceivablePlanService { - - /** - * 创建回款计划 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createReceivablePlan(@Valid CrmReceivablePlanSaveReqVO createReqVO); - - /** - * 更新回款计划 - * - * @param updateReqVO 更新信息 - */ - void updateReceivablePlan(@Valid CrmReceivablePlanSaveReqVO updateReqVO); - - /** - * 更新回款计划关联的回款编号 - * - * @param id 编号 - * @param receivableId 回款编号 - */ - void updateReceivablePlanReceivableId(Long id, Long receivableId); - - /** - * 删除回款计划 - * - * @param id 编号 - */ - void deleteReceivablePlan(Long id); - - /** - * 获得回款计划 - * - * @param id 编号 - * @return 回款计划 - */ - CrmReceivablePlanDO getReceivablePlan(Long id); - - /** - * 获得回款计划列表 - * - * @param ids 编号 - * @return 回款计划列表 - */ - List getReceivablePlanList(Collection ids); - - /** - * 获得回款计划分页 - * - * 数据权限:基于 {@link CrmReceivablePlanDO} 读取 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 回款计划分页 - */ - PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId); - - /** - * 获得回款计划分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款计划分页 - */ - PageResult getReceivablePlanPageByCustomerId(CrmReceivablePlanPageReqVO pageReqVO); - - /** - * 获得待回款提醒数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getReceivablePlanRemindCount(Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java deleted file mode 100644 index 127ef72c1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_UPDATE_FAIL; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 回款计划 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { - - @Resource - private CrmReceivablePlanMapper receivablePlanMapper; - - @Resource - private CrmContractService contractService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_PLAN_TYPE, subType = CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE, bizNo = "{{#receivablePlan.id}}", - success = CRM_RECEIVABLE_PLAN_CREATE_SUCCESS) - public Long createReceivablePlan(CrmReceivablePlanSaveReqVO createReqVO) { - // 1. 校验关联数据是否存在 - validateRelationDataExists(createReqVO); - - // 2. 插入回款计划 - CrmReceivablePlanDO maxPeriodReceivablePlan = receivablePlanMapper.selectMaxPeriodByContractId(createReqVO.getContractId()); - int period = maxPeriodReceivablePlan == null ? 1 : maxPeriodReceivablePlan.getPeriod() + 1; - CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setPeriod(period); - if (createReqVO.getReturnTime() != null && createReqVO.getRemindDays() != null) { - receivablePlan.setRemindTime(createReqVO.getReturnTime().minusDays(createReqVO.getRemindDays())); - } - receivablePlanMapper.insert(receivablePlan); - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(createReqVO.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType()).setBizId(receivablePlan.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("receivablePlan", receivablePlan); - return receivablePlan.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_PLAN_TYPE, subType = CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE_PLAN, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateReceivablePlan(CrmReceivablePlanSaveReqVO updateReqVO) { - updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null); // 防止修改这些字段 - // 1.1 校验存在 - validateRelationDataExists(updateReqVO); - // 1.2 校验关联数据是否存在 - CrmReceivablePlanDO oldReceivablePlan = validateReceivablePlanExists(updateReqVO.getId()); - // 1.3 如果已经有对应的回款,则不允许编辑 - if (Objects.nonNull(oldReceivablePlan.getReceivableId())) { - throw exception(RECEIVABLE_PLAN_UPDATE_FAIL); - } - - // 2. 更新回款计划 - CrmReceivablePlanDO updateObj = BeanUtils.toBean(updateReqVO, CrmReceivablePlanDO.class); - if (updateReqVO.getReturnTime() != null && updateReqVO.getRemindDays() != null) { - updateObj.setRemindTime(updateReqVO.getReturnTime().minusDays(updateReqVO.getRemindDays())); - } - receivablePlanMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldReceivablePlan, CrmReceivablePlanSaveReqVO.class)); - LogRecordContext.putVariable("receivablePlan", oldReceivablePlan); - } - - private void validateRelationDataExists(CrmReceivablePlanSaveReqVO reqVO) { - // 校验负责人存在 - if (reqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(reqVO.getOwnerUserId()); - } - // 校验合同存在 - if (reqVO.getContractId() != null) { - CrmContractDO contract = contractService.getContract(reqVO.getContractId()); - reqVO.setCustomerId(contract.getCustomerId()); - } - } - - @Override - public void updateReceivablePlanReceivableId(Long id, Long receivableId) { - // 校验存在 - validateReceivablePlanExists(id); - // 更新回款计划 - receivablePlanMapper.updateById(new CrmReceivablePlanDO().setId(id).setReceivableId(receivableId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_PLAN_TYPE, subType = CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_RECEIVABLE_PLAN_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE_PLAN, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteReceivablePlan(Long id) { - // 1. 校验存在 - CrmReceivablePlanDO receivablePlan = validateReceivablePlanExists(id); - - // 2. 删除 - receivablePlanMapper.deleteById(id); - // 3. 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), id); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("receivablePlan", receivablePlan); - } - - private CrmReceivablePlanDO validateReceivablePlanExists(Long id) { - CrmReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(id); - if (receivablePlan == null) { - throw exception(RECEIVABLE_PLAN_NOT_EXISTS); - } - return receivablePlan; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE_PLAN, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmReceivablePlanDO getReceivablePlan(Long id) { - return receivablePlanMapper.selectById(id); - } - - @Override - public List getReceivablePlanList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return receivablePlanMapper.selectBatchIds(ids); - } - - @Override - public PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId) { - return receivablePlanMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getReceivablePlanPageByCustomerId(CrmReceivablePlanPageReqVO pageReqVO) { - return receivablePlanMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - public Long getReceivablePlanRemindCount(Long userId) { - return receivablePlanMapper.selectReceivablePlanCountByRemind(userId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java deleted file mode 100644 index eec4cd550..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 回款 Service 接口 - * - * @author 赤焰 - */ -public interface CrmReceivableService { - - /** - * 创建回款 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createReceivable(@Valid CrmReceivableSaveReqVO createReqVO); - - /** - * 更新回款 - * - * @param updateReqVO 更新信息 - */ - void updateReceivable(@Valid CrmReceivableSaveReqVO updateReqVO); - - /** - * 更新回款流程审批结果 - * - * @param id 回款编号 - * @param bpmResult BPM 审批结果 - */ - void updateReceivableAuditStatus(Long id, Integer bpmResult); - - /** - * 删除回款 - * - * @param id 编号 - */ - void deleteReceivable(Long id); - - /** - * 发起回款审批流程 - * - * @param id 回款编号 - * @param userId 用户编号 - */ - void submitReceivable(Long id, Long userId); - - /** - * 获得回款 - * - * @param id 编号 - * @return 回款 - */ - CrmReceivableDO getReceivable(Long id); - - /** - * 获得回款列表 - * - * @param ids 编号 - * @return 回款列表 - */ - List getReceivableList(Collection ids); - - /** - * 获得回款 Map - * - * @param ids 编号 - * @return 回款 Map - */ - default Map getReceivableMap(Collection ids) { - return convertMap(getReceivableList(ids), CrmReceivableDO::getId); - } - - /** - * 获得回款分页 - * - * 数据权限:基于 {@link CrmReceivableDO} 读取 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 回款分页 - */ - PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO, Long userId); - - /** - * 获得回款分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款分页 - */ - PageResult getReceivablePageByCustomerId(CrmReceivablePageReqVO pageReqVO); - - /** - * 获得待审核回款数量 - * - * @param userId 用户编号 - * @return 待审批数量 - */ - Long getAuditReceivableCount(Long userId); - - /** - * 获得合同已回款金额 Map - * - * @param contractIds 合同编号 - * @return 回款金额 Map - */ - Map getReceivablePriceMapByContractId(Collection contractIds); - - /** - * 根据合同编号查询回款数量 - * - * @param contractId 合同编号 - * @return 回款数量 - */ - Long getReceivableCountByContractId(Long contractId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java deleted file mode 100644 index 83e68cce2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java +++ /dev/null @@ -1,309 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; -import cn.iocoder.yudao.module.crm.dal.redis.no.CrmNoRedisDAO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.crm.util.CrmAuditStatusUtils.convertBpmResultToAuditStatus; - -/** - * CRM 回款 Service 实现类 - * - * @author 赤焰 - */ -@Service -@Validated -@Slf4j -public class CrmReceivableServiceImpl implements CrmReceivableService { - - /** - * BPM 合同审批流程标识 - */ - public static final String BPM_PROCESS_DEFINITION_KEY = "crm-receivable-audit"; - - @Resource - private CrmReceivableMapper receivableMapper; - - @Resource - private CrmNoRedisDAO noRedisDAO; - - @Resource - private CrmContractService contractService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmReceivablePlanService receivablePlanService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private BpmProcessInstanceApi bpmProcessInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_CREATE_SUB_TYPE, bizNo = "{{#receivable.id}}", - success = CRM_RECEIVABLE_CREATE_SUCCESS) - public Long createReceivable(CrmReceivableSaveReqVO createReqVO) { - // 1.1 校验可回款金额超过上限 - validateReceivablePriceExceedsLimit(createReqVO); - // 1.2 校验关联数据存在 - validateRelationDataExists(createReqVO); - // 1.3 生成回款编号 - String no = noRedisDAO.generate(CrmNoRedisDAO.RECEIVABLE_PREFIX); - if (receivableMapper.selectByNo(no) != null) { - throw exception(RECEIVABLE_NO_EXISTS); - } - - // 2.1 插入回款 - CrmReceivableDO receivable = BeanUtils.toBean(createReqVO, CrmReceivableDO.class) - .setNo(no).setAuditStatus(CrmAuditStatusEnum.DRAFT.getStatus()); - receivableMapper.insert(receivable); - // 2.2 - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_RECEIVABLE.getType()) - .setBizId(receivable.getId()).setUserId(createReqVO.getOwnerUserId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 4. 更新关联的回款计划 - if (createReqVO.getPlanId() != null) { - receivablePlanService.updateReceivablePlanReceivableId(receivable.getPlanId(), receivable.getId()); - } - - // 5. 记录操作日志上下文 - LogRecordContext.putVariable("receivable", receivable); - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); - return receivable.getId(); - } - - private void validateReceivablePriceExceedsLimit(CrmReceivableSaveReqVO reqVO) { - // 1. 计算剩余可退款金额,不包括 reqVO 自身 - CrmContractDO contract = contractService.validateContract(reqVO.getContractId()); - List receivables = receivableMapper.selectListByContractIdAndStatus(reqVO.getContractId(), - Arrays.asList(CrmAuditStatusEnum.APPROVE.getStatus(), CrmAuditStatusEnum.PROCESS.getStatus())); - if (reqVO.getId() != null) { - receivables.removeIf(receivable -> ObjectUtil.equal(receivable.getId(), reqVO.getId())); - } - BigDecimal notReceivablePrice = contract.getTotalPrice().subtract( - CollectionUtils.getSumValue(receivables, CrmReceivableDO::getPrice, BigDecimal::add, BigDecimal.ZERO)); - // 2. 校验金额是否超过 - if (reqVO.getPrice().compareTo(notReceivablePrice) > 0) { - throw exception(RECEIVABLE_CREATE_FAIL_PRICE_EXCEEDS_LIMIT, notReceivablePrice); - } - } - - private void validateRelationDataExists(CrmReceivableSaveReqVO reqVO) { - if (reqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(reqVO.getOwnerUserId()); // 校验负责人存在 - } - if (reqVO.getContractId() != null) { - CrmContractDO contract = contractService.validateContract(reqVO.getContractId()); - if (ObjectUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) { - throw exception(RECEIVABLE_CREATE_FAIL_CONTRACT_NOT_APPROVE); - } - reqVO.setCustomerId(contract.getCustomerId()); // 设置客户编号 - } - if (reqVO.getPlanId() != null) { - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(reqVO.getPlanId()); - if (receivablePlan == null) { - throw exception(RECEIVABLE_PLAN_NOT_EXISTS); - } - if (receivablePlan.getReceivableId() != null) { - throw exception(RECEIVABLE_PLAN_EXISTS_RECEIVABLE); - } - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_RECEIVABLE_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) { - Assert.notNull(updateReqVO.getId(), "回款编号不能为空"); - updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段 - // 1.1 校验存在 - CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId()); - updateReqVO.setOwnerUserId(receivable.getOwnerUserId()).setCustomerId(receivable.getCustomerId()) - .setContractId(receivable.getContractId()).setPlanId(receivable.getPlanId()); // 设置已存在的值 - // 1.2 校验可回款金额超过上限 - validateReceivablePriceExceedsLimit(updateReqVO); - - // 1.3 只有草稿、审批中,可以编辑; - if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), - CrmAuditStatusEnum.PROCESS.getStatus())) { - throw exception(RECEIVABLE_UPDATE_FAIL_EDITING_PROHIBITED); - } - - // 2. 更新回款 - CrmReceivableDO updateObj = BeanUtils.toBean(updateReqVO, CrmReceivableDO.class); - receivableMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("receivable", receivable); - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class)); - } - - private Integer getReceivablePeriod(Long planId) { - if (Objects.isNull(planId)) { - return null; - } - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(planId); - return receivablePlan.getPeriod(); - } - - @Override - public void updateReceivableAuditStatus(Long id, Integer bpmResult) { - // 1.1 校验存在 - CrmReceivableDO receivable = validateReceivableExists(id); - // 1.2 只有审批中,可以更新审批结果 - if (ObjUtil.notEqual(receivable.getAuditStatus(), CrmAuditStatusEnum.PROCESS.getStatus())) { - log.error("[updateReceivableAuditStatus][receivable({}) 不处于审批中,无法更新审批结果({})]", - receivable.getId(), bpmResult); - throw exception(RECEIVABLE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); - } - - // 2. 更新回款审批状态 - Integer auditStatus = convertBpmResultToAuditStatus(bpmResult); - receivableMapper.updateById(new CrmReceivableDO().setId(id).setAuditStatus(auditStatus)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_RECEIVABLE_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteReceivable(Long id) { - // 1.1 校验存在 - CrmReceivableDO receivable = validateReceivableExists(id); - // 1.2 如果被 CrmReceivablePlanDO 所使用,则不允许删除 - if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { - throw exception(RECEIVABLE_DELETE_FAIL); - } - // 1.3 审批通过时,不允许删除 - if (ObjUtil.equal(receivable.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) { - throw exception(RECEIVABLE_DELETE_FAIL_IS_APPROVE); - } - - // 2.1 删除回款 - receivableMapper.deleteById(id); - // 2.2 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_RECEIVABLE.getType(), id); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("receivable", receivable); - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_SUBMIT_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_RECEIVABLE_SUBMIT_SUCCESS) - public void submitReceivable(Long id, Long userId) { - // 1. 校验回款是否在审批 - CrmReceivableDO receivable = validateReceivableExists(id); - if (ObjUtil.notEqual(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus())) { - throw exception(RECEIVABLE_SUBMIT_FAIL_NOT_DRAFT); - } - - // 2. 创建回款审批流程实例 - String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() - .setProcessDefinitionKey(BPM_PROCESS_DEFINITION_KEY).setBusinessKey(String.valueOf(id))).getCheckedData(); - - // 3. 更新回款工作流编号 - receivableMapper.updateById(new CrmReceivableDO().setId(id).setProcessInstanceId(processInstanceId) - .setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus())); - - // 4. 记录日志 - LogRecordContext.putVariable("receivableNo", receivable.getNo()); - } - - private CrmReceivableDO validateReceivableExists(Long id) { - CrmReceivableDO receivable = receivableMapper.selectById(id); - if (receivable == null) { - throw exception(RECEIVABLE_NOT_EXISTS); - } - return receivable; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmReceivableDO getReceivable(Long id) { - return receivableMapper.selectById(id); - } - - @Override - public List getReceivableList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return receivableMapper.selectBatchIds(ids); - } - - @Override - public PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO, Long userId) { - return receivableMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getReceivablePageByCustomerId(CrmReceivablePageReqVO pageReqVO) { - return receivableMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - public Long getAuditReceivableCount(Long userId) { - return receivableMapper.selectCountByAudit(userId); - } - - @Override - public Map getReceivablePriceMapByContractId(Collection contractIds) { - return receivableMapper.selectReceivablePriceMapByContractId(contractIds); - } - - @Override - public Long getReceivableCountByContractId(Long contractId) { - return receivableMapper.selectCountByContractId(contractId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java deleted file mode 100644 index bd76b0118..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable.listener; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 回款审批的结果的监听器实现类 - * - * @author HUIHUI - */ -@Component -public class CrmReceivableStatusListener extends BpmProcessInstanceStatusEventListener { - - @Resource - private CrmReceivableService receivableService; - - @Override - public String getProcessDefinitionKey() { - return CrmReceivableServiceImpl.BPM_PROCESS_DEFINITION_KEY; - } - - @Override - public void onEvent(BpmProcessInstanceStatusEvent event) { - receivableService.updateReceivableAuditStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java deleted file mode 100644 index 70c720b9e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; - -import java.util.List; - -/** - * CRM 客户分析 Service 接口 - * - * @author dhb52 - */ -public interface CrmStatisticsCustomerService { - - /** - * 总量分析(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 总量分析(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数分析(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getFollowUpSummaryByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数分析(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getFollowUpSummaryByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户跟进次数分析(按类型) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getFollowUpSummaryByType(CrmStatisticsCustomerReqVO reqVO); - - /** - * 获取客户的首次合同、回款信息列表,用于【客户转化率】页面 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getContractSummary(CrmStatisticsCustomerReqVO reqVO); - - /** - * 公海客户分析(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 公海客户分析(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按日期) - * - * 成交周期的定义:客户 customer 在创建出来,到合同 contract 第一次成交的时间差 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按区域) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByArea(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按产品) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByProduct(CrmStatisticsCustomerReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java deleted file mode 100644 index bec5735c9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * CRM 客户分析 Service 实现类 - * - * @author dhb52 - */ -@Service -@Validated -public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerService { - - @Resource - private CrmStatisticsCustomerMapper customerMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getCustomerSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List customerCreateCountList = customerMapper.selectCustomerCreateCountGroupByDate(reqVO); - List customerDealCountList = customerMapper.selectCustomerDealCountGroupByDate(reqVO); - - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Integer customerCreateCount = customerCreateCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount).sum(); - Integer customerDealCount = customerDealCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount).sum(); - return new CrmStatisticsCustomerSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setCustomerCreateCount(customerCreateCount).setCustomerDealCount(customerDealCount); - }); - } - - @Override - public List getCustomerSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List customerCreateCountList = customerMapper.selectCustomerCreateCountGroupByUser(reqVO); - List customerDealCountList = customerMapper.selectCustomerDealCountGroupByUser(reqVO); - List contractPriceList = customerMapper.selectContractPriceGroupByUser(reqVO); - List receivablePriceList = customerMapper.selectReceivablePriceGroupByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Integer customerCreateCount = customerCreateCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount).sum(); - Integer customerDealCount = customerDealCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount).sum(); - BigDecimal contractPrice = contractPriceList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .reduce(BigDecimal.ZERO, (sum, vo) -> sum.add(vo.getContractPrice()), BigDecimal::add); - BigDecimal receivablePrice = receivablePriceList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .reduce(BigDecimal.ZERO, (sum, vo) -> sum.add(vo.getReceivablePrice()), BigDecimal::add); - return (CrmStatisticsCustomerSummaryByUserRespVO) new CrmStatisticsCustomerSummaryByUserRespVO() - .setCustomerCreateCount(customerCreateCount).setCustomerDealCount(customerDealCount) - .setContractPrice(contractPrice).setReceivablePrice(receivablePrice).setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getFollowUpSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List followUpRecordCountList = customerMapper.selectFollowUpRecordCountGroupByDate(reqVO); - List followUpCustomerCountList = customerMapper.selectFollowUpCustomerCountGroupByDate(reqVO); - - // 3. 按照时间间隔,合并统计数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Integer followUpRecordCount = followUpRecordCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsFollowUpSummaryByDateRespVO::getFollowUpRecordCount).sum(); - Integer followUpCustomerCount = followUpCustomerCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsFollowUpSummaryByDateRespVO::getFollowUpCustomerCount).sum(); - return new CrmStatisticsFollowUpSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setFollowUpCustomerCount(followUpRecordCount).setFollowUpRecordCount(followUpCustomerCount); - }); - } - - @Override - public List getFollowUpSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List followUpRecordCountList = customerMapper.selectFollowUpRecordCountGroupByUser(reqVO); - List followUpCustomerCountList = customerMapper.selectFollowUpCustomerCountGroupByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Integer followUpRecordCount = followUpRecordCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsFollowUpSummaryByUserRespVO::getFollowUpRecordCount).sum(); - Integer followUpCustomerCount = followUpCustomerCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsFollowUpSummaryByUserRespVO::getFollowUpCustomerCount).sum(); - return (CrmStatisticsFollowUpSummaryByUserRespVO) new CrmStatisticsFollowUpSummaryByUserRespVO() - .setFollowUpCustomerCount(followUpRecordCount).setFollowUpRecordCount(followUpCustomerCount).setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getFollowUpSummaryByType(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 获得跟进数据 - return customerMapper.selectFollowUpRecordCountGroupByType(reqVO); - } - - @Override - public List getContractSummary(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取统计数据 - List summaryList = customerMapper.selectContractSummary(reqVO); - - // 3. 拼接信息 - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(summaryList, vo -> Stream.of(NumberUtils.parseLong(vo.getCreator()), vo.getOwnerUserId()))); - summaryList.forEach(vo -> { - findAndThen(userMap, NumberUtils.parseLong(vo.getCreator()), user -> vo.setCreatorUserName(user.getNickname())); - findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())); - }); - return summaryList; - } - - @Override - public List getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List customerPutCountList = customerMapper.selectPoolCustomerPutCountByDate(reqVO); - List customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByDate(reqVO); - - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Integer customerPutCount = customerPutCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerPutCount).sum(); - Integer customerTakeCount = customerTakeCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerTakeCount).sum(); - return new CrmStatisticsPoolSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount); - }); - } - - @Override - public List getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List customerPutCountList = customerMapper.selectPoolCustomerPutCountByUser(reqVO); - List customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Integer customerPutCount = customerPutCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerPutCount).sum(); - Integer customerTakeCount = customerTakeCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerTakeCount).sum(); - return (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() - .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount) - .setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List customerDealCycleList = customerMapper.selectCustomerDealCycleGroupByDate(reqVO); - - // 3. 按照日期间隔,合并统计数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Double customerDealCycle = customerDealCycleList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToDouble(CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle).sum(); - return new CrmStatisticsCustomerDealCycleByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setCustomerDealCycle(customerDealCycle); - }); - } - - @Override - public List getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List customerDealCycleList = customerMapper.selectCustomerDealCycleGroupByUser(reqVO); - List customerDealCountList = customerMapper.selectCustomerDealCountGroupByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Double customerDealCycle = customerDealCycleList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToDouble(CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle).sum(); - Integer customerDealCount = customerDealCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount).sum(); - return (CrmStatisticsCustomerDealCycleByUserRespVO) new CrmStatisticsCustomerDealCycleByUserRespVO() - .setCustomerDealCycle(customerDealCycle).setCustomerDealCount(customerDealCount).setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getCustomerDealCycleByArea(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户地区统计数据 - List dealCycleByAreaList = customerMapper.selectCustomerDealCycleGroupByAreaId(reqVO); - if (CollUtil.isEmpty(dealCycleByAreaList)) { - return Collections.emptyList(); - } - - // 3. 拼接数据 - Map areaMap = convertMap(AreaUtils.getByType(AreaTypeEnum.PROVINCE, Function.identity()), Area::getId); - return convertList(dealCycleByAreaList, vo -> { - if (vo.getAreaId() != null) { - Integer parentId = AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE); - findAndThen(areaMap, parentId, area -> vo.setAreaId(parentId).setAreaName(area.getName())); - } - return vo; - }); - } - - @Override - public List getCustomerDealCycleByProduct(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户产品统计数据 - // TODO @dhb52:未读取产品名 - return customerMapper.selectCustomerDealCycleGroupByProductId(reqVO); - } - - /** - * 拼接用户信息(昵称) - * - * @param voList 统计数据 - */ - private void appendUserInfo(List voList) { - Map userMap = adminUserApi.getUserMap( - convertSet(voList, CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId)); - voList.forEach(vo -> findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname()))); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsCustomerReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java deleted file mode 100644 index 10458daac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; - -import java.util.List; - -/** - * CRM 销售漏斗分析 Service - * - * @author HUIHUI - */ -public interface CrmStatisticsFunnelService { - - /** - * 获得销售漏斗数据 - * - * @param reqVO 请求 - * @return 销售漏斗数据 - */ - CrmStatisticFunnelSummaryRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机结束状态统计 - * - * @param reqVO 请求 - * @return 商机结束状态统计 - */ - List getBusinessSummaryByEndStatus(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获取新增商机分析(按日期) - * - * @param reqVO 请求 - * @return 新增商机分析 - */ - List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机转化率分析(按日期) - * - * @param reqVO 请求 - * @return 商机转化率分析 - */ - List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机分页(按日期) - * - * @param pageVO 请求 - * @return 商机分页 - */ - PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java deleted file mode 100644 index e11fa2f22..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 销售漏斗分析 Service 实现类 - * - * @author HUIHUI - */ -@Service -public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelService { - - @Resource - private CrmStatisticsFunnelMapper funnelMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private CrmBusinessService businessService; - @Resource - private DeptApi deptApi; - - @Override - public CrmStatisticFunnelSummaryRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return null; - } - reqVO.setUserIds(userIds); - - // 2. 获得漏斗数据 - Long customerCount = funnelMapper.selectCustomerCountByDate(reqVO); - Long businessCount = funnelMapper.selectBusinessCountByDateAndEndStatus(reqVO, null); - Long businessWinCount = funnelMapper.selectBusinessCountByDateAndEndStatus(reqVO, CrmBusinessEndStatusEnum.WIN.getStatus()); - return new CrmStatisticFunnelSummaryRespVO(customerCount, businessCount, businessWinCount); - } - - @Override - public List getBusinessSummaryByEndStatus(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 获得统计数据 - return funnelMapper.selectBusinessSummaryListGroupByEndStatus(reqVO); - } - - @Override - public List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List businessSummaryList = funnelMapper.selectBusinessSummaryGroupByDate(reqVO); - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Long businessCreateCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessSummaryByDateRespVO::getBusinessCreateCount).sum(); - BigDecimal businessDealCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .map(CrmStatisticsBusinessSummaryByDateRespVO::getTotalPrice) - .reduce(BigDecimal.ZERO, BigDecimal::add); - return new CrmStatisticsBusinessSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setBusinessCreateCount(businessCreateCount).setTotalPrice(businessDealCount); - }); - } - - @Override - public List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List businessSummaryList = funnelMapper.selectBusinessInversionRateSummaryByDate(reqVO); - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Long businessCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessCount).sum(); - Long businessWinCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessWinCount).sum(); - return new CrmStatisticsBusinessInversionRateSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setBusinessCount(businessCount).setBusinessWinCount(businessWinCount); - }); - } - - @Override - public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { - // 1. 获得用户编号数组 - pageVO.setUserIds(getUserIds(pageVO)); - if (CollUtil.isEmpty(pageVO.getUserIds())) { - return PageResult.empty(); - } - // 2. 执行查询 - return businessService.getBusinessPageByDate(pageVO); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsFunnelReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceService.java deleted file mode 100644 index 15423af29..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - - - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; - -import java.util.List; - -/** - * CRM 员工绩效统计 Service 接口 - * - * @author scholar - */ -public interface CrmStatisticsPerformanceService { - - /** - * 员工签约合同数量分析 - * - * @param performanceReqVO 排行参数 - * @return 员工签约合同数量排行分析 - */ - List getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工签约合同金额分析 - * - * @param performanceReqVO 排行参数 - * @return 员工签约合同金额分析 - */ - List getContractPricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工获得回款金额分析 - * - * @param performanceReqVO 排行参数 - * @return 员工获得回款金额分析 - */ - List getReceivablePricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java deleted file mode 100644 index c193d9ec9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsPerformanceMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 员工业绩分析 Service 实现类 - * - * @author scholar - */ -@Service -@Validated -public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerformanceService { - - @Resource - private CrmStatisticsPerformanceMapper performanceMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - // TODO @scholar:可以把下面这个注释,你理解后,重新整理下,写到 getPerformance 里; - // 比如说,2024 年的合同数据,是不是 2022-12 到 2024-12-31,每个月的统计呢? - // 理解之后,我们可以数据 group by 年-月,20222-12 到 2024-12-31 的,然后内存在聚合出 CrmStatisticsPerformanceRespVO 这样 - // 这样,我们就可以减少数据库的计算量,提升性能;同时 SQL 也会很简单,开发者理解起来也简单哈; - return getPerformance(performanceReqVO, performanceMapper::selectContractCountPerformance); - } - - @Override - public List getContractPricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - return getPerformance(performanceReqVO, performanceMapper::selectContractPricePerformance); - } - - @Override - public List getReceivablePricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - return getPerformance(performanceReqVO, performanceMapper::selectReceivablePricePerformance); - } - - // TODO @scholar:代码注释,应该有 3 个变量哈; - /** - * 获得员工业绩数据 - * - * @param performanceReqVO 参数 - * @param performanceFunction 员工业绩统计方法 - * @return 员工业绩数据 - */ - // TODO @scholar:下面一行的变量,超过一行了,阅读不美观;可以考虑每一行一个变量; - private List getPerformance(CrmStatisticsPerformanceReqVO performanceReqVO, Function> performanceFunction) { - - // TODO @scholar:没使用到的变量,建议删除; - List performanceRespVOList; - - // 1. 获得用户编号数组 - final List userIds = getUserIds(performanceReqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - performanceReqVO.setUserIds(userIds); - // TODO @scholar:1. 和 2. 之间,可以考虑换一行;保证每一块逻辑的间隔; - // 2. 获得业绩数据 - // TODO @scholar:复数变量,建议使用 s 或者 list 结果;这里用 performanceList 好列; - List performance = performanceFunction.apply(performanceReqVO); - - // 获取查询的年份 - // TODO @scholar:逻辑可以简化一下; - // TODO 1)把 performance 转换成 map;key 是 time,value 是 count - // TODO 2)当前年,遍历 1-12 月份,去 map 拿到 count;接着月份 -1,去 map 拿 count;再年份 -1,拿 count - String currentYear = LocalDateTimeUtil.format(performanceReqVO.getTimes()[0],"yyyy"); - - // 构造查询当年和前一年,每年12个月的年月组合 - List allMonths = new ArrayList<>(); - for (int year = Integer.parseInt(currentYear)-1; year <= Integer.parseInt(currentYear); year++) { - for (int month = 1; month <= 12; month++) { - allMonths.add(String.format("%d%02d", year, month)); - } - } - - List computedList = new ArrayList<>(); - List respVOList = new ArrayList<>(); - - // 生成computedList基础数据 - // 构造完整的2*12个月的数据,如果某月数据缺失,需要补上0,一年12个月不能有缺失 - for (String month : allMonths) { - CrmStatisticsPerformanceRespVO foundData = performance.stream() - .filter(data -> data.getTime().equals(month)) - .findFirst() - .orElse(null); - - if (foundData != null) { - computedList.add(foundData); - } else { - CrmStatisticsPerformanceRespVO missingData = new CrmStatisticsPerformanceRespVO(); - missingData.setTime(month); - missingData.setCurrentMonthCount(BigDecimal.ZERO); - missingData.setLastMonthCount(BigDecimal.ZERO); - missingData.setLastYearCount(BigDecimal.ZERO); - computedList.add(missingData); - } - } - //根据查询年份和前一年的数据,计算查询年份的同比环比数据 - for (CrmStatisticsPerformanceRespVO currentData : computedList) { - String currentMonth = currentData.getTime(); - - // 根据当年和前一年的月销售数据,计算currentYear的完整数据 - if (currentMonth.startsWith(currentYear)) { - // 计算 LastMonthCount - int currentIndex = computedList.indexOf(currentData); - if (currentIndex > 0) { - CrmStatisticsPerformanceRespVO lastMonthData = computedList.get(currentIndex - 1); - currentData.setLastMonthCount(lastMonthData.getCurrentMonthCount()); - } else { - currentData.setLastMonthCount(BigDecimal.ZERO); // 第一个月的 LastMonthCount 设为0 - } - - // 计算 LastYearCount - String lastYearMonth = String.valueOf(Integer.parseInt(currentMonth) - 100); - CrmStatisticsPerformanceRespVO lastYearData = computedList.stream() - .filter(data -> data.getTime().equals(lastYearMonth)) - .findFirst() - .orElse(null); - - if (lastYearData != null) { - currentData.setLastYearCount(lastYearData.getCurrentMonthCount()); - } else { - currentData.setLastYearCount(BigDecimal.ZERO); // 如果去年同月数据不存在,设为0 - } - respVOList.add(currentData);//给前端只需要返回查询当年的数据,不需要前一年数据 - } - } - return respVOList; - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsPerformanceReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - final Long deptId = reqVO.getDeptId(); - List deptIds = convertList(deptApi.getChildDeptList(deptId).getCheckedData(), DeptRespDTO::getId); - deptIds.add(deptId); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitService.java deleted file mode 100644 index c568d3b4e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitService.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; - -import java.util.List; - -/** - * CRM 客户画像 Service 接口 - * - * @author HUIHUI - */ -public interface CrmStatisticsPortraitService { - - /** - * 获取客户地区统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByArea(CrmStatisticsPortraitReqVO reqVO); - - /** - * 获取客户行业统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByIndustry(CrmStatisticsPortraitReqVO reqVO); - - /** - * 获取客户级别统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByLevel(CrmStatisticsPortraitReqVO reqVO); - - /** - * 获取客户来源统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryBySource(CrmStatisticsPortraitReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java deleted file mode 100644 index f9b252ca6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsPortraitMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 客户画像 Service 实现类 - * - * @author HUIHUI - */ -@Service -public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitService { - - @Resource - private CrmStatisticsPortraitMapper portraitMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getCustomerSummaryByArea(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户地区统计数据 - List list = portraitMapper.selectSummaryListGroupByAreaId(reqVO); - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - - // 3. 拼接数据 - List areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); - Map areaMap = convertMap(areaList, Area::getId); - return convertList(list, item -> { - Integer parentId = AreaUtils.getParentIdByType(item.getAreaId(), AreaTypeEnum.PROVINCE); - if (parentId != null) { - Area area = areaMap.get(parentId); - if (area != null) { - item.setAreaId(parentId).setAreaName(area.getName()); - return item; - } - } - // 找不到,归到未知 - return item.setAreaId(null).setAreaName("未知"); - }); - } - - @Override - public List getCustomerSummaryByIndustry(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户行业统计数据 - return portraitMapper.selectCustomerIndustryListGroupByIndustryId(reqVO); - } - - @Override - public List getCustomerSummaryBySource(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户行业统计数据 - return portraitMapper.selectCustomerSourceListGroupBySource(reqVO); - } - - @Override - public List getCustomerSummaryByLevel(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户级别统计数据 - return portraitMapper.selectCustomerLevelListGroupByLevel(reqVO); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsPortraitReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankService.java deleted file mode 100644 index 626e19247..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; - -import java.util.List; - -/** - * CRM 排行榜统计 Service 接口 - * - * @author anhaohao - */ -public interface CrmStatisticsRankService { - - /** - * 获得合同金额排行榜 - * - * @param rankReqVO 排行参数 - * @return 合同金额排行榜 - */ - List getContractPriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得回款金额排行榜 - * - * @param rankReqVO 排行参数 - * @return 回款金额排行榜 - */ - List getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得签约合同数量排行榜 - * - * @param rankReqVO 排行参数 - * @return 签约合同数量排行榜 - */ - List getContractCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得产品销量排行榜 - * - * @param rankReqVO 排行参数 - * @return 产品销量排行榜 - */ - List getProductSalesRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得新增客户数排行榜 - * - * @param rankReqVO 排行参数 - * @return 新增客户数排行榜 - */ - List getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得联系人数量排行榜 - * - * @param rankReqVO 排行参数 - * @return 联系人数量排行榜 - */ - List getContactsCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得跟进次数排行榜 - * - * @param rankReqVO 排行参数 - * @return 跟进次数排行榜 - */ - List getFollowCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得跟进客户数排行榜 - * - * @param rankReqVO 排行参数 - * @return 跟进客户数排行榜 - */ - List getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java deleted file mode 100644 index 7b2eb5463..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * CRM 排行榜统计 Service 实现类 - * - * @author anhaohao - */ -@Service -@Validated -public class CrmStatisticsRankServiceImpl implements CrmStatisticsRankService { - - @Resource - private CrmStatisticsRankMapper rankMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getContractPriceRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectContractPriceRank); - } - - @Override - public List getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectReceivablePriceRank); - } - - @Override - public List getContractCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectContractCountRank); - } - - @Override - public List getProductSalesRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectProductSalesRank); - } - - @Override - public List getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectCustomerCountRank); - } - - @Override - public List getContactsCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectContactsCountRank); - } - - @Override - public List getFollowCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectFollowCountRank); - } - - @Override - public List getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectFollowCustomerCountRank); - } - - /** - * 获得排行版数据 - * - * @param rankReqVO 参数 - * @param rankFunction 排行榜方法 - * @return 排行版数据 - */ - private List getRank(CrmStatisticsRankReqVO rankReqVO, Function> rankFunction) { - // 1. 获得用户编号数组 - rankReqVO.setUserIds(getUserIds(rankReqVO.getDeptId())); - if (CollUtil.isEmpty(rankReqVO.getUserIds())) { - return Collections.emptyList(); - } - // 2. 获得排行数据 - List ranks = rankFunction.apply(rankReqVO); - if (CollUtil.isEmpty(ranks)) { - return Collections.emptyList(); - } - ranks.sort(Comparator.comparing(CrmStatisticsRankRespVO::getCount).reversed()); - // 3. 拼接用户信息 - appendUserInfo(ranks); - return ranks; - } - - /** - * 拼接用户信息(昵称、部门) - * - * @param ranks 排行榜数据 - */ - private void appendUserInfo(List ranks) { - Map userMap = adminUserApi.getUserMap(convertSet(ranks, CrmStatisticsRankRespVO::getOwnerUserId)); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - ranks.forEach(rank -> MapUtils.findAndThen(userMap, rank.getOwnerUserId(), user -> { - rank.setNickname(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> rank.setDeptName(dept.getName())); - })); - } - - /** - * 获得部门下的用户编号数组,包括子部门的 - * - * @param deptId 部门编号 - * @return 用户编号数组 - */ - public List getUserIds(Long deptId) { - // 1. 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(deptId).getCheckedData(), DeptRespDTO::getId); - deptIds.add(deptId); - // 2. 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmAuditStatusUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmAuditStatusUtils.java deleted file mode 100644 index c1d4eaab7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmAuditStatusUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.util; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; - -/** - * CRM 流程工具类 - * - * @author HUIHUI - */ -public class CrmAuditStatusUtils { - - /** - * BPM 审批结果转换 - * - * @param bpmResult BPM 审批结果 - */ - public static Integer convertBpmResultToAuditStatus(Integer bpmResult) { - Integer auditStatus = BpmTaskStatusEnum.APPROVE.getStatus().equals(bpmResult) ? CrmAuditStatusEnum.APPROVE.getStatus() - : BpmTaskStatusEnum.REJECT.getStatus().equals(bpmResult) ? CrmAuditStatusEnum.REJECT.getStatus() - : BpmTaskStatusEnum.CANCEL.getStatus().equals(bpmResult) ? BpmTaskStatusEnum.CANCEL.getStatus() : null; - Assert.notNull(auditStatus, "BPM 审批结果({}) 转换失败", bpmResult); - return auditStatus; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java deleted file mode 100644 index a82be864c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.crm.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; -import com.baomidou.mybatisplus.core.toolkit.support.SFunction; -import com.github.yulichang.autoconfigure.MybatisPlusJoinProperties; -import com.github.yulichang.wrapper.MPJLambdaWrapper; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * 数据权限工具类 - * - * @author HUIHUI - */ -public class CrmPermissionUtils { - - /** - * 校验用户是否是 CRM 管理员 - * - * @return 是/否 - */ - public static boolean isCrmAdmin() { - PermissionApi permissionApi = SpringUtil.getBean(PermissionApi.class); - return permissionApi.hasAnyRoles(getLoginUserId(), RoleCodeEnum.CRM_ADMIN.getCode()).getCheckedData(); - } - - /** - * 构造 CRM 数据类型数据分页查询条件 - * - * @param query 连表查询对象 - * @param bizType 数据类型 {@link CrmBizTypeEnum} - * @param bizId 数据编号 - * @param userId 用户编号 - * @param sceneType 场景类型 - * @param pool 公海 - */ - public static , S> void appendPermissionCondition(T query, Integer bizType, SFunction bizId, - Long userId, Integer sceneType, Boolean pool) { - MybatisPlusJoinProperties mybatisPlusJoinProperties = SpringUtil.getBean(MybatisPlusJoinProperties.class); - final String ownerUserIdField = mybatisPlusJoinProperties.getTableAlias() + ".owner_user_id"; - // 1. 构建数据权限连表条件 - if (!CrmPermissionUtils.isCrmAdmin() && ObjUtil.notEqual(pool, Boolean.TRUE)) { // 管理员,公海不需要数据权限 - query.innerJoin(CrmPermissionDO.class, on -> on.eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) // 只能使用 SFunction 如果传 id 解析出来的 sql 不对 - .eq(CrmPermissionDO::getUserId, userId)); - } - // 2.1 场景一:我负责的数据 - if (CrmSceneTypeEnum.isOwner(sceneType)) { - query.eq(ownerUserIdField, userId); - } - // 2.2 场景二:我参与的数据 - if (CrmSceneTypeEnum.isInvolved(sceneType)) { - query.innerJoin(CrmPermissionDO.class, on -> on.eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .in(CrmPermissionDO::getLevel, CrmPermissionLevelEnum.READ.getLevel(), CrmPermissionLevelEnum.WRITE.getLevel())); - query.ne(ownerUserIdField, userId); - } - // 2.3 场景三:下属负责的数据 - if (CrmSceneTypeEnum.isSubordinate(sceneType)) { - AdminUserApi adminUserApi = SpringUtil.getBean(AdminUserApi.class); - List subordinateUsers = adminUserApi.getUserListBySubordinate(userId).getCheckedData(); - if (CollUtil.isEmpty(subordinateUsers)) { - query.eq(ownerUserIdField, -1); // 不返回任何结果 - } else { - query.in(ownerUserIdField, convertSet(subordinateUsers, AdminUserRespDTO::getId)); - } - } - - // 3. 拼接公海的查询条件 - if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海 - query.isNull(ownerUserIdField); - } else { // 情况二:不是公海 - query.isNotNull(ownerUserIdField); - } - } - - /** - * 构造 CRM 数据类型批量数据查询条件 - * - * @param query 连表查询对象 - * @param bizType 数据类型 {@link CrmBizTypeEnum} - * @param bizIds 数据编号 - * @param userId 用户编号 - */ - public static > void appendPermissionCondition(T query, Integer bizType, Collection bizIds, Long userId) { - if (isCrmAdmin()) {// 管理员不需要数据权限 - return; - } - query.innerJoin(CrmPermissionDO.class, on -> - on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) - .eq(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-dev.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 2f6ca7bf7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-local.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 491c50045..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,123 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:8000/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.crm.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application.yaml deleted file mode 100644 index 35175f57f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,107 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.crm - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - -debug: false diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index f87220ec2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: crm-server - - profiles: - active: local - -server: - port: 48089 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/logback-spring.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml deleted file mode 100644 index dc10f1221..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml deleted file mode 100644 index a07406259..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml deleted file mode 100644 index 79ff45471..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPortraitMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPortraitMapper.xml deleted file mode 100644 index 42056a48b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPortraitMapper.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml deleted file mode 100644 index abd63f27d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index a55b301c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,49 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml deleted file mode 100644 index 1d071e479..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-erp/pom.xml b/yudao-module-erp/pom.xml deleted file mode 100644 index bed9d7d51..000000000 --- a/yudao-module-erp/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - - yudao-module-erp-api - yudao-module-erp-biz - - 4.0.0 - yudao-module-erp - pom - - ${project.artifactId} - - erp 包下,企业资源管理(Enterprise Resource Planning)。 - 例如说:采购、销售、库存、财务、产品等等 - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-api/pom.xml b/yudao-module-erp/yudao-module-erp-api/pom.xml deleted file mode 100644 index ef5394f10..000000000 --- a/yudao-module-erp/yudao-module-erp-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-erp - ${revision} - - 4.0.0 - yudao-module-erp-api - jar - - ${project.artifactId} - - erp 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/api/package-info.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/api/package-info.java deleted file mode 100644 index 540f18f0e..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * erp API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.erp.api; diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ApiConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ApiConstants.java deleted file mode 100644 index 1241dbc91..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "erp-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/erp"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java deleted file mode 100644 index 36d4df852..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -/** - * ERP 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String AUDIT_STATUS = "erp_audit_status"; // 审核状态 - String STOCK_RECORD_BIZ_TYPE = "erp_stock_record_biz_type"; // 库存明细的业务类型 - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErpAuditStatus.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErpAuditStatus.java deleted file mode 100644 index a10147a70..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErpAuditStatus.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * ERP 审核状态枚举 - * - * TODO 芋艿:目前只有待审批、已审批两个状态,未来接入工作流后,会丰富下:待提交(草稿)=》已提交(待审核)=》审核通过、审核不通过;另外,工作流需要支持“反审核”,把工作流退回到原点; - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum ErpAuditStatus implements IntArrayValuable { - - PROCESS(10, "未审核"), // 审核中 - APPROVE(20, "已审核"); // 审核通过 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpAuditStatus::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java deleted file mode 100644 index 65f64c2f5..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,168 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * ERP 错误码枚举类 - *

- * erp 系统,使用 1-030-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== ERP 供应商(1-030-100-000) ========== - ErrorCode SUPPLIER_NOT_EXISTS = new ErrorCode(1_030_100_000, "供应商不存在"); - ErrorCode SUPPLIER_NOT_ENABLE = new ErrorCode(1_030_100_000, "供应商({})未启用"); - - // ========== ERP 采购订单(1-030-101-000) ========== - ErrorCode PURCHASE_ORDER_NOT_EXISTS = new ErrorCode(1_030_101_000, "采购订单不存在"); - ErrorCode PURCHASE_ORDER_DELETE_FAIL_APPROVE = new ErrorCode(1_030_101_001, "采购订单({})已审核,无法删除"); - ErrorCode PURCHASE_ORDER_PROCESS_FAIL = new ErrorCode(1_030_101_002, "反审核失败,只有已审核的采购订单才能反审核"); - ErrorCode PURCHASE_ORDER_APPROVE_FAIL = new ErrorCode(1_030_101_003, "审核失败,只有未审核的采购订单才能审核"); - ErrorCode PURCHASE_ORDER_NO_EXISTS = new ErrorCode(1_030_101_004, "生成采购单号失败,请重新提交"); - ErrorCode PURCHASE_ORDER_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_101_005, "采购订单({})已审核,无法修改"); - ErrorCode PURCHASE_ORDER_NOT_APPROVE = new ErrorCode(1_030_101_006, "采购订单未审核,无法操作"); - ErrorCode PURCHASE_ORDER_ITEM_IN_FAIL_PRODUCT_EXCEED = new ErrorCode(1_030_101_007, "采购订单项({})超过最大允许入库数量({})"); - ErrorCode PURCHASE_ORDER_PROCESS_FAIL_EXISTS_IN = new ErrorCode(1_030_101_008, "反审核失败,已存在对应的采购入库单"); -ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_009, "采购订单项({})超过最大允许退货数量({})"); - ErrorCode PURCHASE_ORDER_PROCESS_FAIL_EXISTS_RETURN = new ErrorCode(1_030_101_010, "反审核失败,已存在对应的采购退货单"); - - // ========== ERP 采购入库(1-030-102-000) ========== - ErrorCode PURCHASE_IN_NOT_EXISTS = new ErrorCode(1_030_102_000, "采购入库单不存在"); - ErrorCode PURCHASE_IN_DELETE_FAIL_APPROVE = new ErrorCode(1_030_102_001, "采购入库单({})已审核,无法删除"); - ErrorCode PURCHASE_IN_PROCESS_FAIL = new ErrorCode(1_030_102_002, "反审核失败,只有已审核的入库单才能反审核"); - ErrorCode PURCHASE_IN_APPROVE_FAIL = new ErrorCode(1_030_102_003, "审核失败,只有未审核的入库单才能审核"); - ErrorCode PURCHASE_IN_NO_EXISTS = new ErrorCode(1_030_102_004, "生成入库单失败,请重新提交"); - ErrorCode PURCHASE_IN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_102_005, "采购入库单({})已审核,无法修改"); - ErrorCode PURCHASE_IN_NOT_APPROVE = new ErrorCode(1_030_102_006, "采购入库单未审核,无法操作"); - ErrorCode PURCHASE_IN_FAIL_PAYMENT_PRICE_EXCEED = new ErrorCode(1_030_102_007, "付款金额({})超过采购入库单总金额({})"); - ErrorCode PURCHASE_IN_PROCESS_FAIL_EXISTS_PAYMENT = new ErrorCode(1_030_102_008, "反审核失败,已存在对应的付款单"); - - // ========== ERP 采购退货(1-030-103-000) ========== - ErrorCode PURCHASE_RETURN_NOT_EXISTS = new ErrorCode(1_030_103_000, "采购退货单不存在"); - ErrorCode PURCHASE_RETURN_DELETE_FAIL_APPROVE = new ErrorCode(1_030_103_001, "采购退货单({})已审核,无法删除"); - ErrorCode PURCHASE_RETURN_PROCESS_FAIL = new ErrorCode(1_030_103_002, "反审核失败,只有已审核的退货单才能反审核"); - ErrorCode PURCHASE_RETURN_APPROVE_FAIL = new ErrorCode(1_030_103_003, "审核失败,只有未审核的退货单才能审核"); - ErrorCode PURCHASE_RETURN_NO_EXISTS = new ErrorCode(1_030_103_004, "生成退货单失败,请重新提交"); - ErrorCode PURCHASE_RETURN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_103_005, "采购退货单({})已审核,无法修改"); - ErrorCode PURCHASE_RETURN_NOT_APPROVE = new ErrorCode(1_030_103_006, "采购退货单未审核,无法操作"); - ErrorCode PURCHASE_RETURN_FAIL_REFUND_PRICE_EXCEED = new ErrorCode(1_030_103_007, "退款金额({})超过采购退货单总金额({})"); - ErrorCode PURCHASE_RETURN_PROCESS_FAIL_EXISTS_REFUND = new ErrorCode(1_030_103_008, "反审核失败,已存在对应的退款单"); - - // ========== ERP 客户(1-030-200-000)========== - ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_200_000, "客户不存在"); - ErrorCode CUSTOMER_NOT_ENABLE = new ErrorCode(1_020_200_001, "客户({})未启用"); - - // ========== ERP 销售订单(1-030-201-000) ========== - ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_201_000, "销售订单不存在"); - ErrorCode SALE_ORDER_DELETE_FAIL_APPROVE = new ErrorCode(1_020_201_001, "销售订单({})已审核,无法删除"); - ErrorCode SALE_ORDER_PROCESS_FAIL = new ErrorCode(1_020_201_002, "反审核失败,只有已审核的销售订单才能反审核"); - ErrorCode SALE_ORDER_APPROVE_FAIL = new ErrorCode(1_020_201_003, "审核失败,只有未审核的销售订单才能审核"); - ErrorCode SALE_ORDER_NO_EXISTS = new ErrorCode(1_020_201_004, "生成销售单号失败,请重新提交"); - ErrorCode SALE_ORDER_UPDATE_FAIL_APPROVE = new ErrorCode(1_020_201_005, "销售订单({})已审核,无法修改"); - ErrorCode SALE_ORDER_NOT_APPROVE = new ErrorCode(1_020_201_006, "销售订单未审核,无法操作"); - ErrorCode SALE_ORDER_ITEM_OUT_FAIL_PRODUCT_EXCEED = new ErrorCode(1_020_201_007, "销售订单项({})超过最大允许出库数量({})"); - ErrorCode SALE_ORDER_PROCESS_FAIL_EXISTS_OUT = new ErrorCode(1_020_201_008, "反审核失败,已存在对应的销售出库单"); - ErrorCode SALE_ORDER_ITEM_RETURN_FAIL_OUT_EXCEED = new ErrorCode(1_020_201_009, "销售订单项({})超过最大允许退货数量({})"); - ErrorCode SALE_ORDER_PROCESS_FAIL_EXISTS_RETURN = new ErrorCode(1_020_201_010, "反审核失败,已存在对应的销售退货单"); - - // ========== ERP 销售出库(1-030-202-000) ========== - ErrorCode SALE_OUT_NOT_EXISTS = new ErrorCode(1_020_202_000, "销售出库单不存在"); - ErrorCode SALE_OUT_DELETE_FAIL_APPROVE = new ErrorCode(1_020_202_001, "销售出库单({})已审核,无法删除"); - ErrorCode SALE_OUT_PROCESS_FAIL = new ErrorCode(1_020_202_002, "反审核失败,只有已审核的出库单才能反审核"); - ErrorCode SALE_OUT_APPROVE_FAIL = new ErrorCode(1_020_202_003, "审核失败,只有未审核的出库单才能审核"); - ErrorCode SALE_OUT_NO_EXISTS = new ErrorCode(1_020_202_004, "生成出库单失败,请重新提交"); - ErrorCode SALE_OUT_UPDATE_FAIL_APPROVE = new ErrorCode(1_020_202_005, "销售出库单({})已审核,无法修改"); - ErrorCode SALE_OUT_NOT_APPROVE = new ErrorCode(1_020_202_006, "销售出库单未审核,无法操作"); - ErrorCode SALE_OUT_FAIL_RECEIPT_PRICE_EXCEED = new ErrorCode(1_020_202_007, "收款金额({})超过销售出库单总金额({})"); - ErrorCode SALE_OUT_PROCESS_FAIL_EXISTS_RECEIPT = new ErrorCode(1_020_202_008, "反审核失败,已存在对应的收款单"); - - // ========== ERP 销售退货(1-030-203-000) ========== - ErrorCode SALE_RETURN_NOT_EXISTS = new ErrorCode(1_020_203_000, "销售退货单不存在"); - ErrorCode SALE_RETURN_DELETE_FAIL_APPROVE = new ErrorCode(1_020_203_001, "销售退货单({})已审核,无法删除"); - ErrorCode SALE_RETURN_PROCESS_FAIL = new ErrorCode(1_020_203_002, "反审核失败,只有已审核的退货单才能反审核"); - ErrorCode SALE_RETURN_APPROVE_FAIL = new ErrorCode(1_020_203_003, "审核失败,只有未审核的退货单才能审核"); - ErrorCode SALE_RETURN_NO_EXISTS = new ErrorCode(1_020_203_004, "生成退货单失败,请重新提交"); - ErrorCode SALE_RETURN_UPDATE_FAIL_APPROVE = new ErrorCode(1_020_203_005, "销售退货单({})已审核,无法修改"); - ErrorCode SALE_RETURN_NOT_APPROVE = new ErrorCode(1_020_203_006, "销售退货单未审核,无法操作"); - ErrorCode SALE_RETURN_FAIL_REFUND_PRICE_EXCEED = new ErrorCode(1_020_203_007, "退款金额({})超过销售退货单总金额({})"); - ErrorCode SALE_RETURN_PROCESS_FAIL_EXISTS_REFUND = new ErrorCode(1_020_203_008, "反审核失败,已存在对应的退款单"); - - // ========== ERP 仓库 1-030-400-000 ========== - ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); - ErrorCode WAREHOUSE_NOT_ENABLE = new ErrorCode(1_030_400_001, "仓库({})未启用"); - - // ========== ERP 其它入库单 1-030-401-000 ========== - ErrorCode STOCK_IN_NOT_EXISTS = new ErrorCode(1_030_401_000, "其它入库单不存在"); - ErrorCode STOCK_IN_DELETE_FAIL_APPROVE = new ErrorCode(1_030_401_001, "其它入库单({})已审核,无法删除"); - ErrorCode STOCK_IN_PROCESS_FAIL = new ErrorCode(1_030_401_002, "反审核失败,只有已审核的入库单才能反审核"); - ErrorCode STOCK_IN_APPROVE_FAIL = new ErrorCode(1_030_401_003, "审核失败,只有未审核的入库单才能审核"); - ErrorCode STOCK_IN_NO_EXISTS = new ErrorCode(1_030_401_004, "生成入库单失败,请重新提交"); - ErrorCode STOCK_IN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_401_005, "其它入库单({})已审核,无法修改"); - - // ========== ERP 其它出库单 1-030-402-000 ========== - ErrorCode STOCK_OUT_NOT_EXISTS = new ErrorCode(1_030_402_000, "其它出库单不存在"); - ErrorCode STOCK_OUT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_402_001, "其它出库单({})已审核,无法删除"); - ErrorCode STOCK_OUT_PROCESS_FAIL = new ErrorCode(1_030_402_002, "反审核失败,只有已审核的出库单才能反审核"); - ErrorCode STOCK_OUT_APPROVE_FAIL = new ErrorCode(1_030_402_003, "审核失败,只有未审核的出库单才能审核"); - ErrorCode STOCK_OUT_NO_EXISTS = new ErrorCode(1_030_402_004, "生成出库单失败,请重新提交"); - ErrorCode STOCK_OUT_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_402_005, "其它出库单({})已审核,无法修改"); - - // ========== ERP 库存调拨单 1-030-403-000 ========== - ErrorCode STOCK_MOVE_NOT_EXISTS = new ErrorCode(1_030_402_000, "库存调拨单不存在"); - ErrorCode STOCK_MOVE_DELETE_FAIL_APPROVE = new ErrorCode(1_030_402_001, "库存调拨单({})已审核,无法删除"); - ErrorCode STOCK_MOVE_PROCESS_FAIL = new ErrorCode(1_030_402_002, "反审核失败,只有已审核的调拨单才能反审核"); - ErrorCode STOCK_MOVE_APPROVE_FAIL = new ErrorCode(1_030_402_003, "审核失败,只有未审核的调拨单才能审核"); - ErrorCode STOCK_MOVE_NO_EXISTS = new ErrorCode(1_030_402_004, "生成调拨号失败,请重新提交"); - ErrorCode STOCK_MOVE_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_402_005, "库存调拨单({})已审核,无法修改"); - - // ========== ERP 库存盘点单 1-030-403-000 ========== - ErrorCode STOCK_CHECK_NOT_EXISTS = new ErrorCode(1_030_403_000, "库存盘点单不存在"); - ErrorCode STOCK_CHECK_DELETE_FAIL_APPROVE = new ErrorCode(1_030_403_001, "库存盘点单({})已审核,无法删除"); - ErrorCode STOCK_CHECK_PROCESS_FAIL = new ErrorCode(1_030_403_002, "反审核失败,只有已审核的盘点单才能反审核"); - ErrorCode STOCK_CHECK_APPROVE_FAIL = new ErrorCode(1_030_403_003, "审核失败,只有未审核的盘点单才能审核"); - ErrorCode STOCK_CHECK_NO_EXISTS = new ErrorCode(1_030_403_004, "生成盘点号失败,请重新提交"); - ErrorCode STOCK_CHECK_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_403_005, "库存盘点单({})已审核,无法修改"); - - // ========== ERP 产品库存 1-030-404-000 ========== - ErrorCode STOCK_COUNT_NEGATIVE = new ErrorCode(1_030_404_000, "操作失败,产品({})所在仓库({})的库存:{},小于变更数量:{}"); - ErrorCode STOCK_COUNT_NEGATIVE2 = new ErrorCode(1_030_404_001, "操作失败,产品({})所在仓库({})的库存不足"); - - // ========== ERP 产品 1-030-500-000 ========== - ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_030_500_000, "产品不存在"); - ErrorCode PRODUCT_NOT_ENABLE = new ErrorCode(1_030_500_001, "产品({})未启用"); - - // ========== ERP 产品分类 1-030-501-000 ========== - ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_030_501_001, "存在存在子产品分类,无法删除"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_030_501_002,"父级产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_PARENT_ERROR = new ErrorCode(1_030_501_003, "不能设置自己为父产品分类"); - ErrorCode PRODUCT_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_030_501_004, "已经存在该分类名称的产品分类"); - ErrorCode PRODUCT_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_030_501_005, "不能设置自己的子分类为父分类"); - ErrorCode PRODUCT_CATEGORY_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该分类,无法删除"); - - // ========== ERP 产品单位 1-030-502-000 ========== - ErrorCode PRODUCT_UNIT_NOT_EXISTS = new ErrorCode(1_030_502_000, "产品单位不存在"); - ErrorCode PRODUCT_UNIT_NAME_DUPLICATE = new ErrorCode(1_030_502_001, "已存在该名字的产品单位"); - ErrorCode PRODUCT_UNIT_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该单位,无法删除"); - - // ========== ERP 结算账户 1-030-600-000 ========== - ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_030_600_000, "结算账户不存在"); - ErrorCode ACCOUNT_NOT_ENABLE = new ErrorCode(1_030_600_001, "结算账户({})未启用"); - - // ========== ERP 付款单 1-030-601-000 ========== - ErrorCode FINANCE_PAYMENT_NOT_EXISTS = new ErrorCode(1_030_601_000, "付款单不存在"); - ErrorCode FINANCE_PAYMENT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_601_001, "付款单({})已审核,无法删除"); - ErrorCode FINANCE_PAYMENT_PROCESS_FAIL = new ErrorCode(1_030_601_002, "反审核失败,只有已审核的付款单才能反审核"); - ErrorCode FINANCE_PAYMENT_APPROVE_FAIL = new ErrorCode(1_030_601_003, "审核失败,只有未审核的付款单才能审核"); - ErrorCode FINANCE_PAYMENT_NO_EXISTS = new ErrorCode(1_030_601_004, "生成付款单号失败,请重新提交"); - ErrorCode FINANCE_PAYMENT_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_601_005, "付款单({})已审核,无法修改"); - - // ========== ERP 收款单 1-030-602-000 ========== - ErrorCode FINANCE_RECEIPT_NOT_EXISTS = new ErrorCode(1_030_602_000, "收款单不存在"); - ErrorCode FINANCE_RECEIPT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_602_001, "收款单({})已审核,无法删除"); - ErrorCode FINANCE_RECEIPT_PROCESS_FAIL = new ErrorCode(1_030_602_002, "反审核失败,只有已审核的收款单才能反审核"); - ErrorCode FINANCE_RECEIPT_APPROVE_FAIL = new ErrorCode(1_030_602_003, "审核失败,只有未审核的收款单才能审核"); - ErrorCode FINANCE_RECEIPT_NO_EXISTS = new ErrorCode(1_030_602_004, "生成收款单号失败,请重新提交"); - ErrorCode FINANCE_RECEIPT_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_602_005, "收款单({})已审核,无法修改"); - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/LogRecordConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/LogRecordConstants.java deleted file mode 100644 index 73b72c0a9..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/LogRecordConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -/** - * ERP 操作日志枚举 - * 目的:统一管理,也减少 Service 里各种“复杂”字符串 - * - * @author 芋道源码 - */ -public interface LogRecordConstants { - - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java deleted file mode 100644 index bba2b309b..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * ERP 业务类型枚举 - * - * @author HUIHUI - */ -@RequiredArgsConstructor -@Getter -public enum ErpBizTypeEnum implements IntArrayValuable { - - PURCHASE_ORDER(10, "采购订单"), - PURCHASE_IN(11, "采购入库"), - PURCHASE_RETURN(12, "采购退货"), - - SALE_ORDER(20, "销售订单"), - SALE_OUT(21, "销售订单"), - SALE_RETURN(22, "销售退货"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java deleted file mode 100644 index 559bf4ccf..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums.stock; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * ERP 库存明细 - 业务类型枚举 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum ErpStockRecordBizTypeEnum implements IntArrayValuable { - - OTHER_IN(10, "其它入库"), - OTHER_IN_CANCEL(11, "其它入库(作废)"), - - OTHER_OUT(20, "其它出库"), - OTHER_OUT_CANCEL(21, "其它出库(作废)"), - - MOVE_IN(30, "调拨入库"), - MOVE_IN_CANCEL(31, "调拨入库(作废)"), - MOVE_OUT(32, "调拨出库"), - MOVE_OUT_CANCEL(33, "调拨出库(作废)"), - - CHECK_MORE_IN(40, "盘盈入库"), - CHECK_MORE_IN_CANCEL(41, "盘盈入库(作废)"), - CHECK_LESS_OUT(42, "盘亏出库"), - CHECK_LESS_OUT_CANCEL(43, "盘亏出库(作废)"), - - SALE_OUT(50, "销售出库"), - SALE_OUT_CANCEL(51, "销售出库(作废)"), - - SALE_RETURN(60, "销售退货入库"), - SALE_RETURN_CANCEL(61, "销售退货入库(作废)"), - - PURCHASE_IN(70, "采购入库"), - PURCHASE_IN_CANCEL(71, "采购入库(作废)"), - - PURCHASE_RETURN(80, "采购退货出库"), - PURCHASE_RETURN_CANCEL(81, "采购退货出库(作废)"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpStockRecordBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/Dockerfile b/yudao-module-erp/yudao-module-erp-biz/Dockerfile deleted file mode 100644 index f46f7c83f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-erp-biz -WORKDIR /yudao-module-erp-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-erp-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48088 端口 -EXPOSE 48088 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-erp/yudao-module-erp-biz/pom.xml b/yudao-module-erp/yudao-module-erp-biz/pom.xml deleted file mode 100644 index f4ce49135..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-erp - ${revision} - - 4.0.0 - yudao-module-erp-biz - - ${project.artifactId} - - erp 包下,企业资源管理(Enterprise Resource Planning)。 - 例如说:采购、销售、库存、财务、产品等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-erp-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/ErpServerApplication.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/ErpServerApplication.java deleted file mode 100644 index 07a3cd6e1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/ErpServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - *

- * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class ErpServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(ErpServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java deleted file mode 100644 index 6bc2f6b2b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 结算账户") -@RestController -@RequestMapping("/erp/account") -@Validated -public class ErpAccountController { - - @Resource - private ErpAccountService accountService; - - @PostMapping("/create") - @Operation(summary = "创建结算账户") - @PreAuthorize("@ss.hasPermission('erp:account:create')") - public CommonResult createAccount(@Valid @RequestBody ErpAccountSaveReqVO createReqVO) { - return success(accountService.createAccount(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新结算账户") - @PreAuthorize("@ss.hasPermission('erp:account:update')") - public CommonResult updateAccount(@Valid @RequestBody ErpAccountSaveReqVO updateReqVO) { - accountService.updateAccount(updateReqVO); - return success(true); - } - - @PutMapping("/update-default-status") - @Operation(summary = "更新结算账户默认状态") - @Parameters({ - @Parameter(name = "id", description = "编号", required = true), - @Parameter(name = "status", description = "状态", required = true) - }) - public CommonResult updateAccountDefaultStatus(@RequestParam("id") Long id, - @RequestParam("defaultStatus") Boolean defaultStatus) { - accountService.updateAccountDefaultStatus(id, defaultStatus); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除结算账户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:account:delete')") - public CommonResult deleteAccount(@RequestParam("id") Long id) { - accountService.deleteAccount(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得结算账户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:account:query')") - public CommonResult getAccount(@RequestParam("id") Long id) { - ErpAccountDO account = accountService.getAccount(id); - return success(BeanUtils.toBean(account, ErpAccountRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得结算账户精简列表", description = "只包含被开启的结算账户,主要用于前端的下拉选项") - public CommonResult> getWarehouseSimpleList() { - List list = accountService.getAccountListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, account -> new ErpAccountRespVO().setId(account.getId()) - .setName(account.getName()).setDefaultStatus(account.getDefaultStatus()))); - } - - @GetMapping("/page") - @Operation(summary = "获得结算账户分页") - @PreAuthorize("@ss.hasPermission('erp:account:query')") - public CommonResult> getAccountPage(@Valid ErpAccountPageReqVO pageReqVO) { - PageResult pageResult = accountService.getAccountPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpAccountRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出结算账户 Excel") - @PreAuthorize("@ss.hasPermission('erp:account:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportAccountExcel(@Valid ErpAccountPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = accountService.getAccountPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "结算账户.xls", "数据", ErpAccountRespVO.class, - BeanUtils.toBean(list, ErpAccountRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java deleted file mode 100644 index 22d620821..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.finance.ErpFinancePaymentService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - ERP 付款单") -@RestController -@RequestMapping("/erp/finance-payment") -@Validated -public class ErpFinancePaymentController { - - @Resource - private ErpFinancePaymentService financePaymentService; - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpAccountService accountService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建付款单") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:create')") - public CommonResult createFinancePayment(@Valid @RequestBody ErpFinancePaymentSaveReqVO createReqVO) { - return success(financePaymentService.createFinancePayment(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新付款单") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:update')") - public CommonResult updateFinancePayment(@Valid @RequestBody ErpFinancePaymentSaveReqVO updateReqVO) { - financePaymentService.updateFinancePayment(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新付款单的状态") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:update-status')") - public CommonResult updateFinancePaymentStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - financePaymentService.updateFinancePaymentStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除付款单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:finance-payment:delete')") - public CommonResult deleteFinancePayment(@RequestParam("ids") List ids) { - financePaymentService.deleteFinancePayment(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得付款单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") - public CommonResult getFinancePayment(@RequestParam("id") Long id) { - ErpFinancePaymentDO payment = financePaymentService.getFinancePayment(id); - if (payment == null) { - return success(null); - } - List paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentId(id); - return success(BeanUtils.toBean(payment, ErpFinancePaymentRespVO.class, financePaymentVO -> - financePaymentVO.setItems(BeanUtils.toBean(paymentItemList, ErpFinancePaymentRespVO.Item.class)))); - } - - @GetMapping("/page") - @Operation(summary = "获得付款单分页") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") - public CommonResult> getFinancePaymentPage(@Valid ErpFinancePaymentPageReqVO pageReqVO) { - PageResult pageResult = financePaymentService.getFinancePaymentPage(pageReqVO); - return success(buildFinancePaymentVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出付款单 Excel") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportFinancePaymentExcel(@Valid ErpFinancePaymentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildFinancePaymentVOPageResult(financePaymentService.getFinancePaymentPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "付款单.xls", "数据", ErpFinancePaymentRespVO.class, list); - } - - private PageResult buildFinancePaymentVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 付款项 - List paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentIds( - convertSet(pageResult.getList(), ErpFinancePaymentDO::getId)); - Map> financePaymentItemMap = convertMultiMap(paymentItemList, ErpFinancePaymentItemDO::getPaymentId); - // 1.2 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpFinancePaymentDO::getSupplierId)); - // 1.3 结算账户信息 - Map accountMap = accountService.getAccountMap( - convertSet(pageResult.getList(), ErpFinancePaymentDO::getAccountId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getFinanceUserId()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpFinancePaymentRespVO.class, payment -> { - payment.setItems(BeanUtils.toBean(financePaymentItemMap.get(payment.getId()), ErpFinancePaymentRespVO.Item.class)); - MapUtils.findAndThen(supplierMap, payment.getSupplierId(), supplier -> payment.setSupplierName(supplier.getName())); - MapUtils.findAndThen(accountMap, payment.getAccountId(), account -> payment.setAccountName(account.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(payment.getCreator()), user -> payment.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, payment.getFinanceUserId(), user -> payment.setFinanceUserName(user.getNickname())); - }); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinanceReceiptController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinanceReceiptController.java deleted file mode 100644 index b9cc01740..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinanceReceiptController.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.finance.ErpFinanceReceiptService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - ERP 收款单") -@RestController -@RequestMapping("/erp/finance-receipt") -@Validated -public class ErpFinanceReceiptController { - - @Resource - private ErpFinanceReceiptService financeReceiptService; - @Resource - private ErpCustomerService customerService; - @Resource - private ErpAccountService accountService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建收款单") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:create')") - public CommonResult createFinanceReceipt(@Valid @RequestBody ErpFinanceReceiptSaveReqVO createReqVO) { - return success(financeReceiptService.createFinanceReceipt(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新收款单") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:update')") - public CommonResult updateFinanceReceipt(@Valid @RequestBody ErpFinanceReceiptSaveReqVO updateReqVO) { - financeReceiptService.updateFinanceReceipt(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新收款单的状态") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:update-status')") - public CommonResult updateFinanceReceiptStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - financeReceiptService.updateFinanceReceiptStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除收款单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:delete')") - public CommonResult deleteFinanceReceipt(@RequestParam("ids") List ids) { - financeReceiptService.deleteFinanceReceipt(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得收款单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:query')") - public CommonResult getFinanceReceipt(@RequestParam("id") Long id) { - ErpFinanceReceiptDO receipt = financeReceiptService.getFinanceReceipt(id); - if (receipt == null) { - return success(null); - } - List receiptItemList = financeReceiptService.getFinanceReceiptItemListByReceiptId(id); - return success(BeanUtils.toBean(receipt, ErpFinanceReceiptRespVO.class, financeReceiptVO -> - financeReceiptVO.setItems(BeanUtils.toBean(receiptItemList, ErpFinanceReceiptRespVO.Item.class)))); - } - - @GetMapping("/page") - @Operation(summary = "获得收款单分页") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:query')") - public CommonResult> getFinanceReceiptPage(@Valid ErpFinanceReceiptPageReqVO pageReqVO) { - PageResult pageResult = financeReceiptService.getFinanceReceiptPage(pageReqVO); - return success(buildFinanceReceiptVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出收款单 Excel") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportFinanceReceiptExcel(@Valid ErpFinanceReceiptPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildFinanceReceiptVOPageResult(financeReceiptService.getFinanceReceiptPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "收款单.xls", "数据", ErpFinanceReceiptRespVO.class, list); - } - - private PageResult buildFinanceReceiptVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 收款项 - List receiptItemList = financeReceiptService.getFinanceReceiptItemListByReceiptIds( - convertSet(pageResult.getList(), ErpFinanceReceiptDO::getId)); - Map> financeReceiptItemMap = convertMultiMap(receiptItemList, ErpFinanceReceiptItemDO::getReceiptId); - // 1.2 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpFinanceReceiptDO::getCustomerId)); - // 1.3 结算账户信息 - Map accountMap = accountService.getAccountMap( - convertSet(pageResult.getList(), ErpFinanceReceiptDO::getAccountId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getFinanceUserId()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpFinanceReceiptRespVO.class, receipt -> { - receipt.setItems(BeanUtils.toBean(financeReceiptItemMap.get(receipt.getId()), ErpFinanceReceiptRespVO.Item.class)); - MapUtils.findAndThen(customerMap, receipt.getCustomerId(), customer -> receipt.setCustomerName(customer.getName())); - MapUtils.findAndThen(accountMap, receipt.getAccountId(), account -> receipt.setAccountName(account.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(receipt.getCreator()), user -> receipt.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, receipt.getFinanceUserId(), user -> receipt.setFinanceUserName(user.getNickname())); - }); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java deleted file mode 100644 index 3e1fa72f4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 结算账户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpAccountPageReqVO extends PageParam { - - @Schema(description = "账户编码", example = "A88") - private String no; - - @Schema(description = "账户名称", example = "张三") - private String name; - - @Schema(description = "备注", example = "随便") - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java deleted file mode 100644 index a1c2e954d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 结算账户 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpAccountRespVO { - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28684") - @ExcelProperty("结算账户编号") - private Long id; - - @Schema(description = "账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @ExcelProperty("账户名称") - private String name; - - @Schema(description = "账户编码", example = "A88") - @ExcelProperty("账户编码") - private String no; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("开启状态") - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "是否默认", example = "1") - @ExcelProperty("是否默认") - private Boolean defaultStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java deleted file mode 100644 index e2005b703..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 结算账户新增/修改 Request VO") -@Data -public class ErpAccountSaveReqVO { - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28684") - private Long id; - - @Schema(description = "账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotEmpty(message = "账户名称不能为空") - private String name; - - @Schema(description = "账户编码", example = "A88") - private String no; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(value = CommonStatusEnum.class) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java deleted file mode 100644 index b5618cadc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 付款单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpFinancePaymentPageReqVO extends PageParam { - - @Schema(description = "付款单编号", example = "XS001") - private String no; - - @Schema(description = "付款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] paymentTime; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "创建者", example = "666") - private String creator; - - @Schema(description = "财务人员编号", example = "888") - private String financeUserId; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "付款状态", example = "2") - private Integer status; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "业务编号", example = "123") - private String bizNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java deleted file mode 100644 index 6fbab164c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 付款单 Response VO") -@Data -public class ErpFinancePaymentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "付款单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "FKD888") - private String no; - - @Schema(description = "付款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "付款时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime paymentTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - @Schema(description = "财务人员名称", example = "张三") - private String financeUserName; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - private Long supplierId; - @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小番茄公司") - private String supplierName; - - @Schema(description = "付款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - private Long accountId; - @Schema(description = "付款账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String accountName; - - @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "13832") - private BigDecimal totalPrice; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - private BigDecimal discountPrice; - - @Schema(description = "实际价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal paymentPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "付款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Data - public static class Item { - - @Schema(description = "付款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long bizId; - - @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private String bizNo; - - @Schema(description = "应付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal totalPrice; - - @Schema(description = "已付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal paidPrice; - - @Schema(description = "本次付款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次付款不能为空") - private BigDecimal paymentPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java deleted file mode 100644 index 3842f3d2f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 付款单新增/修改 Request VO") -@Data -public class ErpFinancePaymentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "付款时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "付款时间不能为空") - private LocalDateTime paymentTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - @NotNull(message = "供应商编号不能为空") - private Long supplierId; - - @Schema(description = "付款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - @NotNull(message = "付款账户编号不能为空") - private Long accountId; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - @NotNull(message = "优惠金额不能为空") - private BigDecimal discountPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "付款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "付款项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "付款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "业务编号不能为空") - private Long bizId; - - @Schema(description = "已付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "已付金额不能为空") - private BigDecimal paidPrice; - - @Schema(description = "本次付款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次付款不能为空") - private BigDecimal paymentPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptPageReqVO.java deleted file mode 100644 index d3e938c66..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 收款单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpFinanceReceiptPageReqVO extends PageParam { - - @Schema(description = "收款单编号", example = "XS001") - private String no; - - @Schema(description = "收款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] receiptTime; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "创建者", example = "666") - private String creator; - - @Schema(description = "财务人员编号", example = "888") - private String financeUserId; - - @Schema(description = "收款账户编号", example = "31189") - private Long accountId; - - @Schema(description = "收款状态", example = "2") - private Integer status; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "业务编号", example = "123") - private String bizNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptRespVO.java deleted file mode 100644 index f29e0a740..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptRespVO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 收款单 Response VO") -@Data -public class ErpFinanceReceiptRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "收款单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "FKD888") - private String no; - - @Schema(description = "收款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "收款时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime receiptTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - @Schema(description = "财务人员名称", example = "张三") - private String financeUserName; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小番茄公司") - private String customerName; - - @Schema(description = "收款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - private Long accountId; - @Schema(description = "收款账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String accountName; - - @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "13832") - private BigDecimal totalPrice; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - private BigDecimal discountPrice; - - @Schema(description = "实际价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal receiptPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "收款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Data - public static class Item { - - @Schema(description = "收款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long bizId; - - @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private String bizNo; - - @Schema(description = "应收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal totalPrice; - - @Schema(description = "已收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal receiptedPrice; - - @Schema(description = "本次收款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次收款不能为空") - private BigDecimal receiptPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptSaveReqVO.java deleted file mode 100644 index 0cb190c0d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptSaveReqVO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 收款单新增/修改 Request VO") -@Data -public class ErpFinanceReceiptSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "收款时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收款时间不能为空") - private LocalDateTime receiptTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - @NotNull(message = "客户编号不能为空") - private Long customerId; - - @Schema(description = "收款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - @NotNull(message = "收款账户编号不能为空") - private Long accountId; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - @NotNull(message = "优惠金额不能为空") - private BigDecimal discountPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "收款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "收款项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "收款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "业务编号不能为空") - private Long bizId; - - @Schema(description = "已收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "已收金额不能为空") - private BigDecimal receiptedPrice; - - @Schema(description = "本次收款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次收款不能为空") - private BigDecimal receiptPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductCategoryController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductCategoryController.java deleted file mode 100644 index 444f0af95..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductCategoryController.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategorySaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 产品分类") -@RestController -@RequestMapping("/erp/product-category") -@Validated -public class ErpProductCategoryController { - - @Resource - private ErpProductCategoryService productCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建产品分类") - @PreAuthorize("@ss.hasPermission('erp:product-category:create')") - public CommonResult createProductCategory(@Valid @RequestBody ErpProductCategorySaveReqVO createReqVO) { - return success(productCategoryService.createProductCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品分类") - @PreAuthorize("@ss.hasPermission('erp:product-category:update')") - public CommonResult updateProductCategory(@Valid @RequestBody ErpProductCategorySaveReqVO updateReqVO) { - productCategoryService.updateProductCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:product-category:delete')") - public CommonResult deleteProductCategory(@RequestParam("id") Long id) { - productCategoryService.deleteProductCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:product-category:query')") - public CommonResult getProductCategory(@RequestParam("id") Long id) { - ErpProductCategoryDO category = productCategoryService.getProductCategory(id); - return success(BeanUtils.toBean(category, ErpProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得产品分类列表") - @PreAuthorize("@ss.hasPermission('erp:product-category:query')") - public CommonResult> getProductCategoryList(@Valid ErpProductCategoryListReqVO listReqVO) { - List list = productCategoryService.getProductCategoryList(listReqVO); - return success(BeanUtils.toBean(list, ErpProductCategoryRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品分类精简列表", description = "只包含被开启的分类,主要用于前端的下拉选项") - public CommonResult> getProductCategorySimpleList() { - List list = productCategoryService.getProductCategoryList( - new ErpProductCategoryListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus())); - return success(convertList(list, category -> new ErpProductCategoryRespVO() - .setId(category.getId()).setName(category.getName()).setParentId(category.getParentId()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品分类 Excel") - @PreAuthorize("@ss.hasPermission('erp:product-category:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductCategoryExcel(@Valid ErpProductCategoryListReqVO listReqVO, - HttpServletResponse response) throws IOException { - List list = productCategoryService.getProductCategoryList(listReqVO); - // 导出 Excel - ExcelUtils.write(response, "产品分类.xls", "数据", ErpProductCategoryRespVO.class, - BeanUtils.toBean(list, ErpProductCategoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java deleted file mode 100644 index 8242837a3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 产品") -@RestController -@RequestMapping("/erp/product") -@Validated -public class ErpProductController { - - @Resource - private ErpProductService productService; - - @PostMapping("/create") - @Operation(summary = "创建产品") - @PreAuthorize("@ss.hasPermission('erp:product:create')") - public CommonResult createProduct(@Valid @RequestBody ProductSaveReqVO createReqVO) { - return success(productService.createProduct(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品") - @PreAuthorize("@ss.hasPermission('erp:product:update')") - public CommonResult updateProduct(@Valid @RequestBody ProductSaveReqVO updateReqVO) { - productService.updateProduct(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:product:delete')") - public CommonResult deleteProduct(@RequestParam("id") Long id) { - productService.deleteProduct(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:product:query')") - public CommonResult getProduct(@RequestParam("id") Long id) { - ErpProductDO product = productService.getProduct(id); - return success(BeanUtils.toBean(product, ErpProductRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品分页") - @PreAuthorize("@ss.hasPermission('erp:product:query')") - public CommonResult> getProductPage(@Valid ErpProductPageReqVO pageReqVO) { - return success(productService.getProductVOPage(pageReqVO)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") - public CommonResult> getProductSimpleList() { - List list = productService.getProductVOListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, product -> new ErpProductRespVO().setId(product.getId()) - .setName(product.getName()).setBarCode(product.getBarCode()) - .setCategoryId(product.getCategoryId()).setCategoryName(product.getCategoryName()) - .setUnitId(product.getUnitId()).setUnitName(product.getUnitName()) - .setPurchasePrice(product.getPurchasePrice()).setSalePrice(product.getSalePrice()).setMinPrice(product.getMinPrice()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品 Excel") - @PreAuthorize("@ss.hasPermission('erp:product:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductExcel(@Valid ErpProductPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - PageResult pageResult = productService.getProductVOPage(pageReqVO); - // 导出 Excel - ExcelUtils.write(response, "产品.xls", "数据", ErpProductRespVO.class, - pageResult.getList()); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductUnitController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductUnitController.java deleted file mode 100644 index 3a567c3d7..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductUnitController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 产品单位") -@RestController -@RequestMapping("/erp/product-unit") -@Validated -public class ErpProductUnitController { - - @Resource - private ErpProductUnitService productUnitService; - - @PostMapping("/create") - @Operation(summary = "创建产品单位") - @PreAuthorize("@ss.hasPermission('erp:product-unit:create')") - public CommonResult createProductUnit(@Valid @RequestBody ErpProductUnitSaveReqVO createReqVO) { - return success(productUnitService.createProductUnit(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品单位") - @PreAuthorize("@ss.hasPermission('erp:product-unit:update')") - public CommonResult updateProductUnit(@Valid @RequestBody ErpProductUnitSaveReqVO updateReqVO) { - productUnitService.updateProductUnit(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品单位") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:product-unit:delete')") - public CommonResult deleteProductUnit(@RequestParam("id") Long id) { - productUnitService.deleteProductUnit(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品单位") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:product-unit:query')") - public CommonResult getProductUnit(@RequestParam("id") Long id) { - ErpProductUnitDO productUnit = productUnitService.getProductUnit(id); - return success(BeanUtils.toBean(productUnit, ErpProductUnitRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品单位分页") - @PreAuthorize("@ss.hasPermission('erp:product-unit:query')") - public CommonResult> getProductUnitPage(@Valid ErpProductUnitPageReqVO pageReqVO) { - PageResult pageResult = productUnitService.getProductUnitPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpProductUnitRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品单位精简列表", description = "只包含被开启的单位,主要用于前端的下拉选项") - public CommonResult> getProductUnitSimpleList() { - List list = productUnitService.getProductUnitListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, unit -> new ErpProductUnitRespVO().setId(unit.getId()).setName(unit.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品单位 Excel") - @PreAuthorize("@ss.hasPermission('erp:product-unit:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductUnitExcel(@Valid ErpProductUnitPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = productUnitService.getProductUnitPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品单位.xls", "数据", ErpProductUnitRespVO.class, - BeanUtils.toBean(list, ErpProductUnitRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryListReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryListReqVO.java deleted file mode 100644 index b9b530e7d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryListReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 产品分类列表 Request VO") -@Data -public class ErpProductCategoryListReqVO { - - @Schema(description = "分类名称", example = "芋艿") - private String name; - - @Schema(description = "开启状态", example = "1") - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryRespVO.java deleted file mode 100644 index 23d7d9e8f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.category; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品分类 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5860") - @ExcelProperty("分类编号") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21829") - @ExcelProperty("父分类编号") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @ExcelProperty("分类名称") - private String name; - - @Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "S110") - @ExcelProperty("分类编码") - private String code; - - @Schema(description = "分类排序", example = "10") - @ExcelProperty("分类排序") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategorySaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategorySaveReqVO.java deleted file mode 100644 index 6c1ddef7a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategorySaveReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 产品分类新增/修改 Request VO") -@Data -public class ErpProductCategorySaveReqVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5860") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21829") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotEmpty(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "S110") - @NotEmpty(message = "分类编码不能为空") - private String code; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "分类排序不能为空") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java deleted file mode 100644 index 12818b2a6..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 产品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpProductPageReqVO extends PageParam { - - @Schema(description = "产品名称", example = "李四") - private String name; - - @Schema(description = "产品分类编号", example = "11161") - private Long categoryId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java deleted file mode 100644 index 9be9bc255..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpProductRespVO { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672") - @ExcelProperty("产品编号") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("产品名称") - private String name; - - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110") - @ExcelProperty("产品条码") - private String barCode; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161") - private Long categoryId; - @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8869") - private Long unitId; - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - @ExcelProperty("单位") - private String unitName; - - @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("产品状态") - private Integer status; - - @Schema(description = "产品规格", example = "红色") - @ExcelProperty("产品规格") - private String standard; - - @Schema(description = "产品备注", example = "你猜") - @ExcelProperty("产品备注") - private String remark; - - @Schema(description = "保质期天数", example = "10") - @ExcelProperty("保质期天数") - private Integer expiryDay; - - @Schema(description = "基础重量(kg)", example = "1.00") - @ExcelProperty("基础重量(kg)") - private BigDecimal weight; - - @Schema(description = "采购价格,单位:元", example = "10.30") - @ExcelProperty("采购价格,单位:元") - private BigDecimal purchasePrice; - - @Schema(description = "销售价格,单位:元", example = "74.32") - @ExcelProperty("销售价格,单位:元") - private BigDecimal salePrice; - - @Schema(description = "最低价格,单位:元", example = "161.87") - @ExcelProperty("最低价格,单位:元") - private BigDecimal minPrice; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductSaveReqVO.java deleted file mode 100644 index 8841541b0..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductSaveReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 产品新增/修改 Request VO") -@Data -public class ProductSaveReqVO { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "产品名称不能为空") - private String name; - - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110") - @NotEmpty(message = "产品条码不能为空") - private String barCode; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161") - @NotNull(message = "产品分类编号不能为空") - private Long categoryId; - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8869") - @NotNull(message = "单位编号不能为空") - private Long unitId; - - @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "产品状态不能为空") - private Integer status; - - @Schema(description = "产品规格", example = "红色") - private String standard; - - @Schema(description = "产品备注", example = "你猜") - private String remark; - - @Schema(description = "保质期天数", example = "10") - private Integer expiryDay; - - @Schema(description = "基础重量(kg)", example = "1.00") - private BigDecimal weight; - - @Schema(description = "采购价格,单位:元", example = "10.30") - private BigDecimal purchasePrice; - - @Schema(description = "销售价格,单位:元", example = "74.32") - private BigDecimal salePrice; - - @Schema(description = "最低价格,单位:元", example = "161.87") - private BigDecimal minPrice; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitPageReqVO.java deleted file mode 100644 index 87119c126..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 产品单位分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpProductUnitPageReqVO extends PageParam { - - @Schema(description = "单位名字", example = "芋艿") - private String name; - - @Schema(description = "单位状态", example = "1") - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitRespVO.java deleted file mode 100644 index 06f604920..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品单位 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpProductUnitRespVO { - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31254") - @ExcelProperty("单位编号") - private Long id; - - @Schema(description = "单位名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @ExcelProperty("单位名字") - private String name; - - @Schema(description = "单位状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("单位状态") - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitSaveReqVO.java deleted file mode 100644 index 67f52337c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitSaveReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 产品单位新增/修改 Request VO") -@Data -public class ErpProductUnitSaveReqVO { - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31254") - private Long id; - - @Schema(description = "单位名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotEmpty(message = "单位名字不能为空") - private String name; - - @Schema(description = "单位状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "单位状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java deleted file mode 100644 index 36d6f48b9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseInService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 采购入库") -@RestController -@RequestMapping("/erp/purchase-in") -@Validated -public class ErpPurchaseInController { - - @Resource - private ErpPurchaseInService purchaseInService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建采购入库") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:create')") - public CommonResult createPurchaseIn(@Valid @RequestBody ErpPurchaseInSaveReqVO createReqVO) { - return success(purchaseInService.createPurchaseIn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新采购入库") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:update')") - public CommonResult updatePurchaseIn(@Valid @RequestBody ErpPurchaseInSaveReqVO updateReqVO) { - purchaseInService.updatePurchaseIn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新采购入库的状态") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:update-status')") - public CommonResult updatePurchaseInStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - purchaseInService.updatePurchaseInStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除采购入库") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:purchase-in:delete')") - public CommonResult deletePurchaseIn(@RequestParam("ids") List ids) { - purchaseInService.deletePurchaseIn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得采购入库") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:query')") - public CommonResult getPurchaseIn(@RequestParam("id") Long id) { - ErpPurchaseInDO purchaseIn = purchaseInService.getPurchaseIn(id); - if (purchaseIn == null) { - return success(null); - } - List purchaseInItemList = purchaseInService.getPurchaseInItemListByInId(id); - Map productMap = productService.getProductVOMap( - convertSet(purchaseInItemList, ErpPurchaseInItemDO::getProductId)); - return success(BeanUtils.toBean(purchaseIn, ErpPurchaseInRespVO.class, purchaseInVO -> - purchaseInVO.setItems(BeanUtils.toBean(purchaseInItemList, ErpPurchaseInRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得采购入库分页") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:query')") - public CommonResult> getPurchaseInPage(@Valid ErpPurchaseInPageReqVO pageReqVO) { - PageResult pageResult = purchaseInService.getPurchaseInPage(pageReqVO); - return success(buildPurchaseInVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出采购入库 Excel") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportPurchaseInExcel(@Valid ErpPurchaseInPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildPurchaseInVOPageResult(purchaseInService.getPurchaseInPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "采购入库.xls", "数据", ErpPurchaseInRespVO.class, list); - } - - private PageResult buildPurchaseInVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 入库项 - List purchaseInItemList = purchaseInService.getPurchaseInItemListByInIds( - convertSet(pageResult.getList(), ErpPurchaseInDO::getId)); - Map> purchaseInItemMap = convertMultiMap(purchaseInItemList, ErpPurchaseInItemDO::getInId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(purchaseInItemList, ErpPurchaseInItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpPurchaseInDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), purchaseIn -> Long.parseLong(purchaseIn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpPurchaseInRespVO.class, purchaseIn -> { - purchaseIn.setItems(BeanUtils.toBean(purchaseInItemMap.get(purchaseIn.getId()), ErpPurchaseInRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - purchaseIn.setProductNames(CollUtil.join(purchaseIn.getItems(), ",", ErpPurchaseInRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, purchaseIn.getSupplierId(), supplier -> purchaseIn.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(purchaseIn.getCreator()), user -> purchaseIn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java deleted file mode 100644 index 10cbb6226..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseOrderService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 采购订单") -@RestController -@RequestMapping("/erp/purchase-order") -@Validated -public class ErpPurchaseOrderController { - - @Resource - private ErpPurchaseOrderService purchaseOrderService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建采购订单") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:create')") - public CommonResult createPurchaseOrder(@Valid @RequestBody ErpPurchaseOrderSaveReqVO createReqVO) { - return success(purchaseOrderService.createPurchaseOrder(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新采购订单") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:update')") - public CommonResult updatePurchaseOrder(@Valid @RequestBody ErpPurchaseOrderSaveReqVO updateReqVO) { - purchaseOrderService.updatePurchaseOrder(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新采购订单的状态") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:update-status')") - public CommonResult updatePurchaseOrderStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - purchaseOrderService.updatePurchaseOrderStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除采购订单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:purchase-order:delete')") - public CommonResult deletePurchaseOrder(@RequestParam("ids") List ids) { - purchaseOrderService.deletePurchaseOrder(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得采购订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:query')") - public CommonResult getPurchaseOrder(@RequestParam("id") Long id) { - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.getPurchaseOrder(id); - if (purchaseOrder == null) { - return success(null); - } - List purchaseOrderItemList = purchaseOrderService.getPurchaseOrderItemListByOrderId(id); - Map productMap = productService.getProductVOMap( - convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId)); - return success(BeanUtils.toBean(purchaseOrder, ErpPurchaseOrderRespVO.class, purchaseOrderVO -> - purchaseOrderVO.setItems(BeanUtils.toBean(purchaseOrderItemList, ErpPurchaseOrderRespVO.Item.class, item -> { - BigDecimal purchaseCount = stockService.getStockCount(item.getProductId()); - item.setStockCount(purchaseCount != null ? purchaseCount : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得采购订单分页") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:query')") - public CommonResult> getPurchaseOrderPage(@Valid ErpPurchaseOrderPageReqVO pageReqVO) { - PageResult pageResult = purchaseOrderService.getPurchaseOrderPage(pageReqVO); - return success(buildPurchaseOrderVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出采购订单 Excel") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportPurchaseOrderExcel(@Valid ErpPurchaseOrderPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildPurchaseOrderVOPageResult(purchaseOrderService.getPurchaseOrderPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "采购订单.xls", "数据", ErpPurchaseOrderRespVO.class, list); - } - - private PageResult buildPurchaseOrderVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 订单项 - List purchaseOrderItemList = purchaseOrderService.getPurchaseOrderItemListByOrderIds( - convertSet(pageResult.getList(), ErpPurchaseOrderDO::getId)); - Map> purchaseOrderItemMap = convertMultiMap(purchaseOrderItemList, ErpPurchaseOrderItemDO::getOrderId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpPurchaseOrderDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), purchaseOrder -> Long.parseLong(purchaseOrder.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpPurchaseOrderRespVO.class, purchaseOrder -> { - purchaseOrder.setItems(BeanUtils.toBean(purchaseOrderItemMap.get(purchaseOrder.getId()), ErpPurchaseOrderRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - purchaseOrder.setProductNames(CollUtil.join(purchaseOrder.getItems(), ",", ErpPurchaseOrderRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, purchaseOrder.getSupplierId(), supplier -> purchaseOrder.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(purchaseOrder.getCreator()), user -> purchaseOrder.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java deleted file mode 100644 index 74eec7861..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseReturnService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 采购退货") -@RestController -@RequestMapping("/erp/purchase-return") -@Validated -public class ErpPurchaseReturnController { - - @Resource - private ErpPurchaseReturnService purchaseReturnService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建采购退货") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:create')") - public CommonResult createPurchaseReturn(@Valid @RequestBody ErpPurchaseReturnSaveReqVO createReqVO) { - return success(purchaseReturnService.createPurchaseReturn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新采购退货") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:update')") - public CommonResult updatePurchaseReturn(@Valid @RequestBody ErpPurchaseReturnSaveReqVO updateReqVO) { - purchaseReturnService.updatePurchaseReturn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新采购退货的状态") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:update-status')") - public CommonResult updatePurchaseReturnStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - purchaseReturnService.updatePurchaseReturnStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除采购退货") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:purchase-return:delete')") - public CommonResult deletePurchaseReturn(@RequestParam("ids") List ids) { - purchaseReturnService.deletePurchaseReturn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得采购退货") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:query')") - public CommonResult getPurchaseReturn(@RequestParam("id") Long id) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnService.getPurchaseReturn(id); - if (purchaseReturn == null) { - return success(null); - } - List purchaseReturnItemList = purchaseReturnService.getPurchaseReturnItemListByReturnId(id); - Map productMap = productService.getProductVOMap( - convertSet(purchaseReturnItemList, ErpPurchaseReturnItemDO::getProductId)); - return success(BeanUtils.toBean(purchaseReturn, ErpPurchaseReturnRespVO.class, purchaseReturnVO -> - purchaseReturnVO.setItems(BeanUtils.toBean(purchaseReturnItemList, ErpPurchaseReturnRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得采购退货分页") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:query')") - public CommonResult> getPurchaseReturnPage(@Valid ErpPurchaseReturnPageReqVO pageReqVO) { - PageResult pageResult = purchaseReturnService.getPurchaseReturnPage(pageReqVO); - return success(buildPurchaseReturnVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出采购退货 Excel") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportPurchaseReturnExcel(@Valid ErpPurchaseReturnPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildPurchaseReturnVOPageResult(purchaseReturnService.getPurchaseReturnPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "采购退货.xls", "数据", ErpPurchaseReturnRespVO.class, list); - } - - private PageResult buildPurchaseReturnVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 退货项 - List purchaseReturnItemList = purchaseReturnService.getPurchaseReturnItemListByReturnIds( - convertSet(pageResult.getList(), ErpPurchaseReturnDO::getId)); - Map> purchaseReturnItemMap = convertMultiMap(purchaseReturnItemList, ErpPurchaseReturnItemDO::getReturnId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(purchaseReturnItemList, ErpPurchaseReturnItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpPurchaseReturnDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), purchaseReturn -> Long.parseLong(purchaseReturn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpPurchaseReturnRespVO.class, purchaseReturn -> { - purchaseReturn.setItems(BeanUtils.toBean(purchaseReturnItemMap.get(purchaseReturn.getId()), ErpPurchaseReturnRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - purchaseReturn.setProductNames(CollUtil.join(purchaseReturn.getItems(), ",", ErpPurchaseReturnRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, purchaseReturn.getSupplierId(), supplier -> purchaseReturn.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(purchaseReturn.getCreator()), user -> purchaseReturn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java deleted file mode 100644 index 569de0030..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 供应商") -@RestController -@RequestMapping("/erp/supplier") -@Validated -public class ErpSupplierController { - - @Resource - private ErpSupplierService supplierService; - - @PostMapping("/create") - @Operation(summary = "创建供应商") - @PreAuthorize("@ss.hasPermission('erp:supplier:create')") - public CommonResult createSupplier(@Valid @RequestBody ErpSupplierSaveReqVO createReqVO) { - return success(supplierService.createSupplier(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新供应商") - @PreAuthorize("@ss.hasPermission('erp:supplier:update')") - public CommonResult updateSupplier(@Valid @RequestBody ErpSupplierSaveReqVO updateReqVO) { - supplierService.updateSupplier(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除供应商") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:supplier:delete')") - public CommonResult deleteSupplier(@RequestParam("id") Long id) { - supplierService.deleteSupplier(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得供应商") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:supplier:query')") - public CommonResult getSupplier(@RequestParam("id") Long id) { - ErpSupplierDO supplier = supplierService.getSupplier(id); - return success(BeanUtils.toBean(supplier, ErpSupplierRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得供应商分页") - @PreAuthorize("@ss.hasPermission('erp:supplier:query')") - public CommonResult> getSupplierPage(@Valid ErpSupplierPageReqVO pageReqVO) { - PageResult pageResult = supplierService.getSupplierPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpSupplierRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得供应商精简列表", description = "只包含被开启的供应商,主要用于前端的下拉选项") - public CommonResult> getSupplierSimpleList() { - List list = supplierService.getSupplierListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, supplier -> new ErpSupplierRespVO().setId(supplier.getId()).setName(supplier.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出供应商 Excel") - @PreAuthorize("@ss.hasPermission('erp:supplier:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSupplierExcel(@Valid ErpSupplierPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = supplierService.getSupplierPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "供应商.xls", "数据", ErpSupplierRespVO.class, - BeanUtils.toBean(list, ErpSupplierRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java deleted file mode 100644 index e84607ce4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 采购入库分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpPurchaseInPageReqVO extends PageParam { - - public static final Integer PAYMENT_STATUS_NONE = 0; - public static final Integer PAYMENT_STATUS_PART = 1; - public static final Integer PAYMENT_STATUS_ALL = 2; - - @Schema(description = "采购单编号", example = "XS001") - private String no; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "入库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] inTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "入库状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "付款状态", example = "1") - private Integer paymentStatus; - - @Schema(description = "是否可付款", example = "true") - private Boolean paymentEnable; // 对应 paymentStatus = [0, 1] - - @Schema(description = "采购单号", example = "1") - private String orderNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java deleted file mode 100644 index dac354f9f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购入库 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpPurchaseInRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "入库单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("入库单编号") - private String no; - - @Schema(description = "入库状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("入库状态") - private Integer status; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("入库时间") - private LocalDateTime inTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "采购订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已付款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal paymentPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "入库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java deleted file mode 100644 index 9566de989..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购入库新增/修改 Request VO") -@Data -public class ErpPurchaseInSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "入库时间不能为空") - private LocalDateTime inTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "采购订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "入库清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "采购订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderPageReqVO.java deleted file mode 100644 index 8bf70d427..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderPageReqVO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 采购订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpPurchaseOrderPageReqVO extends PageParam { - - /** - * 入库状态 - 无 - */ - public static final Integer IN_STATUS_NONE = 0; - /** - * 入库状态 - 部分 - */ - public static final Integer IN_STATUS_PART = 1; - /** - * 入库状态 - 全部 - */ - public static final Integer IN_STATUS_ALL = 2; - - /** - * 退货状态 - 无 - */ - public static final Integer RETURN_STATUS_NONE = 0; - /** - * 退货状态 - 部分 - */ - public static final Integer RETURN_STATUS_PART = 1; - /** - * 退货状态 - 全部 - */ - public static final Integer RETURN_STATUS_ALL = 2; - - @Schema(description = "采购单编号", example = "XS001") - private String no; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "采购时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] orderTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "采购状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "入库状态", example = "2") - private Integer inStatus; - - @Schema(description = "退货状态", example = "2") - private Integer returnStatus; - - @Schema(description = "是否可入库", example = "true") - private Boolean inEnable; - - @Schema(description = "是否可退货", example = "true") - private Boolean returnEnable; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderRespVO.java deleted file mode 100644 index 5653e266d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderRespVO.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购订单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpPurchaseOrderRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "采购单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("采购单编号") - private String no; - - @Schema(description = "采购状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("采购状态") - private Integer status; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "采购时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("采购时间") - private LocalDateTime orderTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - // ========== 采购入库 ========== - - @Schema(description = "采购入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal inCount; - - // ========== 采购退货(出库)) ========== - - @Schema(description = "采购退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 采购入库 ========== - - @Schema(description = "采购入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal inCount; - - // ========== 采购退货(入库)) ========== - - @Schema(description = "采购退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderSaveReqVO.java deleted file mode 100644 index 557400c6d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderSaveReqVO.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购订单新增/修改 Request VO") -@Data -public class ErpPurchaseOrderSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - @NotNull(message = "供应商编号不能为空") - private Long supplierId; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "采购时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "采购时间不能为空") - private LocalDateTime orderTime; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "定金金额,单位:元", example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "订单清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java deleted file mode 100644 index a534d2e3e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 采购退货分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpPurchaseReturnPageReqVO extends PageParam { - - public static final Integer REFUND_STATUS_NONE = 0; - public static final Integer REFUND_STATUS_PART = 1; - public static final Integer REFUND_STATUS_ALL = 2; - - @Schema(description = "采购单编号", example = "XS001") - private String no; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] returnTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "采购单号", example = "1") - private String orderNo; - - @Schema(description = "退款状态", example = "1") - private Integer refundStatus; - - @Schema(description = "是否可退款", example = "true") - private Boolean refundEnable; // 对应 refundStatus = [0, 1] - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java deleted file mode 100644 index 69770ec3a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购退货 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpPurchaseReturnRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "退货单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("退货单编号") - private String no; - - @Schema(description = "退货状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("退货状态") - private Integer status; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("退货时间") - private LocalDateTime returnTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "采购订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal refundPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "退货项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java deleted file mode 100644 index 927e5108d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购退货新增/修改 Request VO") -@Data -public class ErpPurchaseReturnSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "退货时间不能为空") - private LocalDateTime returnTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "采购订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "采购订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java deleted file mode 100644 index 229ab63d9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 供应商分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSupplierPageReqVO extends PageParam { - - @Schema(description = "供应商名称", example = "芋道源码") - private String name; - - @Schema(description = "手机号码", example = "15601691300") - private String mobile; - - @Schema(description = "联系电话", example = "18818288888") - private String telephone; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java deleted file mode 100644 index 5ba5892c1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 供应商 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSupplierRespVO { - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791") - @ExcelProperty("供应商编号") - private Long id; - - @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("供应商名称") - private String name; - - @Schema(description = "联系人", example = "芋艿") - @ExcelProperty("联系人") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - @ExcelProperty("手机号码") - private String mobile; - - @Schema(description = "联系电话", example = "18818288888") - @ExcelProperty("联系电话") - private String telephone; - - @Schema(description = "电子邮箱", example = "76853@qq.com") - @ExcelProperty("电子邮箱") - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - @ExcelProperty("传真") - private String fax; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - @ExcelProperty("纳税人识别号") - private String taxNo; - - @Schema(description = "税率", example = "10") - @ExcelProperty("税率") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "张三") - @ExcelProperty("开户行") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - @ExcelProperty("开户账号") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - @ExcelProperty("开户地址") - private String bankAddress; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java deleted file mode 100644 index 9193455bd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 供应商新增/修改 Request VO") -@Data -public class ErpSupplierSaveReqVO { - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791") - private Long id; - - @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @NotEmpty(message = "供应商名称不能为空") - private String name; - - @Schema(description = "联系人", example = "芋艿") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - @Mobile - private String mobile; - - @Schema(description = "联系电话", example = "18818288888") - @Telephone - private String telephone; - - @Schema(description = "电子邮箱", example = "76853@qq.com") - @Email - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - private String fax; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(value = CommonStatusEnum.class) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - private String taxNo; - - @Schema(description = "税率", example = "10") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "张三") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java deleted file mode 100644 index 3354fbc81..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 客户") -@RestController -@RequestMapping("/erp/customer") -@Validated -public class ErpCustomerController { - - @Resource - private ErpCustomerService customerService; - - @PostMapping("/create") - @Operation(summary = "创建客户") - @PreAuthorize("@ss.hasPermission('erp:customer:create')") - public CommonResult createCustomer(@Valid @RequestBody ErpCustomerSaveReqVO createReqVO) { - return success(customerService.createCustomer(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新客户") - @PreAuthorize("@ss.hasPermission('erp:customer:update')") - public CommonResult updateCustomer(@Valid @RequestBody ErpCustomerSaveReqVO updateReqVO) { - customerService.updateCustomer(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:customer:delete')") - public CommonResult deleteCustomer(@RequestParam("id") Long id) { - customerService.deleteCustomer(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:customer:query')") - public CommonResult getCustomer(@RequestParam("id") Long id) { - ErpCustomerDO customer = customerService.getCustomer(id); - return success(BeanUtils.toBean(customer, ErpCustomerRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得客户分页") - @PreAuthorize("@ss.hasPermission('erp:customer:query')") - public CommonResult> getCustomerPage(@Valid ErpCustomerPageReqVO pageReqVO) { - PageResult pageResult = customerService.getCustomerPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpCustomerRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得客户精简列表", description = "只包含被开启的客户,主要用于前端的下拉选项") - public CommonResult> getCustomerSimpleList() { - List list = customerService.getCustomerListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, customer -> new ErpCustomerRespVO().setId(customer.getId()).setName(customer.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出客户 Excel") - @PreAuthorize("@ss.hasPermission('erp:customer:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportCustomerExcel(@Valid ErpCustomerPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = customerService.getCustomerPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "客户.xls", "数据", ErpCustomerRespVO.class, - BeanUtils.toBean(list, ErpCustomerRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java deleted file mode 100644 index d1011c0b9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOrderService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 销售订单") -@RestController -@RequestMapping("/erp/sale-order") -@Validated -public class ErpSaleOrderController { - - @Resource - private ErpSaleOrderService saleOrderService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建销售订单") - @PreAuthorize("@ss.hasPermission('erp:sale-out:create')") - public CommonResult createSaleOrder(@Valid @RequestBody ErpSaleOrderSaveReqVO createReqVO) { - return success(saleOrderService.createSaleOrder(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新销售订单") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update')") - public CommonResult updateSaleOrder(@Valid @RequestBody ErpSaleOrderSaveReqVO updateReqVO) { - saleOrderService.updateSaleOrder(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新销售订单的状态") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update-status')") - public CommonResult updateSaleOrderStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - saleOrderService.updateSaleOrderStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除销售订单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:sale-out:delete')") - public CommonResult deleteSaleOrder(@RequestParam("ids") List ids) { - saleOrderService.deleteSaleOrder(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得销售订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult getSaleOrder(@RequestParam("id") Long id) { - ErpSaleOrderDO saleOrder = saleOrderService.getSaleOrder(id); - if (saleOrder == null) { - return success(null); - } - List saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderId(id); - Map productMap = productService.getProductVOMap( - convertSet(saleOrderItemList, ErpSaleOrderItemDO::getProductId)); - return success(BeanUtils.toBean(saleOrder, ErpSaleOrderRespVO.class, saleOrderVO -> - saleOrderVO.setItems(BeanUtils.toBean(saleOrderItemList, ErpSaleOrderRespVO.Item.class, item -> { - BigDecimal stockCount = stockService.getStockCount(item.getProductId()); - item.setStockCount(stockCount != null ? stockCount : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得销售订单分页") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult> getSaleOrderPage(@Valid ErpSaleOrderPageReqVO pageReqVO) { - PageResult pageResult = saleOrderService.getSaleOrderPage(pageReqVO); - return success(buildSaleOrderVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出销售订单 Excel") - @PreAuthorize("@ss.hasPermission('erp:sale-out:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSaleOrderExcel(@Valid ErpSaleOrderPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildSaleOrderVOPageResult(saleOrderService.getSaleOrderPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "销售订单.xls", "数据", ErpSaleOrderRespVO.class, list); - } - - private PageResult buildSaleOrderVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 订单项 - List saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderIds( - convertSet(pageResult.getList(), ErpSaleOrderDO::getId)); - Map> saleOrderItemMap = convertMultiMap(saleOrderItemList, ErpSaleOrderItemDO::getOrderId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(saleOrderItemList, ErpSaleOrderItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpSaleOrderDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), saleOrder -> Long.parseLong(saleOrder.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpSaleOrderRespVO.class, saleOrder -> { - saleOrder.setItems(BeanUtils.toBean(saleOrderItemMap.get(saleOrder.getId()), ErpSaleOrderRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - saleOrder.setProductNames(CollUtil.join(saleOrder.getItems(), ",", ErpSaleOrderRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, saleOrder.getCustomerId(), supplier -> saleOrder.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(saleOrder.getCreator()), user -> saleOrder.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java deleted file mode 100644 index 4149dbfba..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOutService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 销售出库") -@RestController -@RequestMapping("/erp/sale-out") -@Validated -public class ErpSaleOutController { - - @Resource - private ErpSaleOutService saleOutService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建销售出库") - @PreAuthorize("@ss.hasPermission('erp:sale-out:create')") - public CommonResult createSaleOut(@Valid @RequestBody ErpSaleOutSaveReqVO createReqVO) { - return success(saleOutService.createSaleOut(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新销售出库") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update')") - public CommonResult updateSaleOut(@Valid @RequestBody ErpSaleOutSaveReqVO updateReqVO) { - saleOutService.updateSaleOut(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新销售出库的状态") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update-status')") - public CommonResult updateSaleOutStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - saleOutService.updateSaleOutStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除销售出库") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:sale-out:delete')") - public CommonResult deleteSaleOut(@RequestParam("ids") List ids) { - saleOutService.deleteSaleOut(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得销售出库") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult getSaleOut(@RequestParam("id") Long id) { - ErpSaleOutDO saleOut = saleOutService.getSaleOut(id); - if (saleOut == null) { - return success(null); - } - List saleOutItemList = saleOutService.getSaleOutItemListByOutId(id); - Map productMap = productService.getProductVOMap( - convertSet(saleOutItemList, ErpSaleOutItemDO::getProductId)); - return success(BeanUtils.toBean(saleOut, ErpSaleOutRespVO.class, saleOutVO -> - saleOutVO.setItems(BeanUtils.toBean(saleOutItemList, ErpSaleOutRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得销售出库分页") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult> getSaleOutPage(@Valid ErpSaleOutPageReqVO pageReqVO) { - PageResult pageResult = saleOutService.getSaleOutPage(pageReqVO); - return success(buildSaleOutVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出销售出库 Excel") - @PreAuthorize("@ss.hasPermission('erp:sale-out:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSaleOutExcel(@Valid ErpSaleOutPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildSaleOutVOPageResult(saleOutService.getSaleOutPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "销售出库.xls", "数据", ErpSaleOutRespVO.class, list); - } - - private PageResult buildSaleOutVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 出库项 - List saleOutItemList = saleOutService.getSaleOutItemListByOutIds( - convertSet(pageResult.getList(), ErpSaleOutDO::getId)); - Map> saleOutItemMap = convertMultiMap(saleOutItemList, ErpSaleOutItemDO::getOutId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(saleOutItemList, ErpSaleOutItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpSaleOutDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpSaleOutRespVO.class, saleOut -> { - saleOut.setItems(BeanUtils.toBean(saleOutItemMap.get(saleOut.getId()), ErpSaleOutRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - saleOut.setProductNames(CollUtil.join(saleOut.getItems(), ",", ErpSaleOutRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, saleOut.getCustomerId(), supplier -> saleOut.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(saleOut.getCreator()), user -> saleOut.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java deleted file mode 100644 index 1435a59fb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleReturnService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 销售退货") -@RestController -@RequestMapping("/erp/sale-return") -@Validated -public class ErpSaleReturnController { - - @Resource - private ErpSaleReturnService saleReturnService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建销售退货") - @PreAuthorize("@ss.hasPermission('erp:sale-return:create')") - public CommonResult createSaleReturn(@Valid @RequestBody ErpSaleReturnSaveReqVO createReqVO) { - return success(saleReturnService.createSaleReturn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新销售退货") - @PreAuthorize("@ss.hasPermission('erp:sale-return:update')") - public CommonResult updateSaleReturn(@Valid @RequestBody ErpSaleReturnSaveReqVO updateReqVO) { - saleReturnService.updateSaleReturn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新销售退货的状态") - @PreAuthorize("@ss.hasPermission('erp:sale-return:update-status')") - public CommonResult updateSaleReturnStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - saleReturnService.updateSaleReturnStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除销售退货") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:sale-return:delete')") - public CommonResult deleteSaleReturn(@RequestParam("ids") List ids) { - saleReturnService.deleteSaleReturn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得销售退货") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:sale-return:query')") - public CommonResult getSaleReturn(@RequestParam("id") Long id) { - ErpSaleReturnDO saleReturn = saleReturnService.getSaleReturn(id); - if (saleReturn == null) { - return success(null); - } - List saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnId(id); - Map productMap = productService.getProductVOMap( - convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId)); - return success(BeanUtils.toBean(saleReturn, ErpSaleReturnRespVO.class, saleReturnVO -> - saleReturnVO.setItems(BeanUtils.toBean(saleReturnItemList, ErpSaleReturnRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得销售退货分页") - @PreAuthorize("@ss.hasPermission('erp:sale-return:query')") - public CommonResult> getSaleReturnPage(@Valid ErpSaleReturnPageReqVO pageReqVO) { - PageResult pageResult = saleReturnService.getSaleReturnPage(pageReqVO); - return success(buildSaleReturnVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出销售退货 Excel") - @PreAuthorize("@ss.hasPermission('erp:sale-return:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSaleReturnExcel(@Valid ErpSaleReturnPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildSaleReturnVOPageResult(saleReturnService.getSaleReturnPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "销售退货.xls", "数据", ErpSaleReturnRespVO.class, list); - } - - private PageResult buildSaleReturnVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 退货项 - List saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnIds( - convertSet(pageResult.getList(), ErpSaleReturnDO::getId)); - Map> saleReturnItemMap = convertMultiMap(saleReturnItemList, ErpSaleReturnItemDO::getReturnId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpSaleReturnDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), saleReturn -> Long.parseLong(saleReturn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpSaleReturnRespVO.class, saleReturn -> { - saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - saleReturn.setProductNames(CollUtil.join(saleReturn.getItems(), ",", ErpSaleReturnRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, saleReturn.getCustomerId(), supplier -> saleReturn.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(saleReturn.getCreator()), user -> saleReturn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java deleted file mode 100644 index 8f32c0109..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 客户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpCustomerPageReqVO extends PageParam { - - @Schema(description = "客户名称", example = "张三") - private String name; - - @Schema(description = "手机号码", example = "15601691300") - private String mobile; - - @Schema(description = "联系电话", example = "15601691300") - private String telephone; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java deleted file mode 100644 index be1768d04..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 客户 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpCustomerRespVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520") - @ExcelProperty("客户编号") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @ExcelProperty("客户名称") - private String name; - - @Schema(description = "联系人", example = "老王") - @ExcelProperty("联系人") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - @ExcelProperty("手机号码") - private String mobile; - - @Schema(description = "联系电话", example = "15601691300") - @ExcelProperty("联系电话") - private String telephone; - - @Schema(description = "电子邮箱", example = "7685323@qq.com") - @ExcelProperty("电子邮箱") - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - @ExcelProperty("传真") - private String fax; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - @ExcelProperty("纳税人识别号") - private String taxNo; - - @Schema(description = "税率", example = "10") - @ExcelProperty("税率") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "芋艿") - @ExcelProperty("开户行") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - @ExcelProperty("开户账号") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - @ExcelProperty("开户地址") - private String bankAddress; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java deleted file mode 100644 index 23c4fb331..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 客户新增/修改 Request VO") -@Data -public class ErpCustomerSaveReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotEmpty(message = "客户名称不能为空") - private String name; - - @Schema(description = "联系人", example = "老王") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - private String mobile; - - @Schema(description = "联系电话", example = "15601691300") - private String telephone; - - @Schema(description = "电子邮箱", example = "7685323@qq.com") - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - private String fax; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - private String taxNo; - - @Schema(description = "税率", example = "10") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "芋艿") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java deleted file mode 100644 index 84d92fb67..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 销售订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSaleOrderPageReqVO extends PageParam { - - /** - * 出库状态 - 无 - */ - public static final Integer OUT_STATUS_NONE = 0; - /** - * 出库状态 - 部分 - */ - public static final Integer OUT_STATUS_PART = 1; - /** - * 出库状态 - 全部 - */ - public static final Integer OUT_STATUS_ALL = 2; - - /** - * 退货状态 - 无 - */ - public static final Integer RETURN_STATUS_NONE = 0; - /** - * 退货状态 - 部分 - */ - public static final Integer RETURN_STATUS_PART = 1; - /** - * 退货状态 - 全部 - */ - public static final Integer RETURN_STATUS_ALL = 2; - - @Schema(description = "销售单编号", example = "XS001") - private String no; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "下单时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] orderTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "销售状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "出库状态", example = "2") - private Integer outStatus; - - @Schema(description = "退货状态", example = "2") - private Integer returnStatus; - - @Schema(description = "是否可出库", example = "true") - private Boolean outEnable; - - @Schema(description = "是否可退货", example = "true") - private Boolean returnEnable; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java deleted file mode 100644 index ecf35871a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java +++ /dev/null @@ -1,155 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售订单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSaleOrderRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "销售单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("销售单编号") - private String no; - - @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("销售状态") - private Integer status; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("下单时间") - private LocalDateTime orderTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - // ========== 销售出库 ========== - - @Schema(description = "销售出库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal outCount; - - // ========== 销售退货(出库)) ========== - - @Schema(description = "销售退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 销售出库 ========== - - @Schema(description = "销售出库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal outCount; - - // ========== 销售退货(入库)) ========== - - @Schema(description = "销售退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderSaveReqVO.java deleted file mode 100644 index 46a440721..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderSaveReqVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售订单新增/修改 Request VO") -@Data -public class ErpSaleOrderSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - @NotNull(message = "客户编号不能为空") - private Long customerId; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "下单时间不能为空") - private LocalDateTime orderTime; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "定金金额,单位:元", example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "订单清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java deleted file mode 100644 index 5afeeea84..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 销售出库分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSaleOutPageReqVO extends PageParam { - - public static final Integer RECEIPT_STATUS_NONE = 0; - public static final Integer RECEIPT_STATUS_PART = 1; - public static final Integer RECEIPT_STATUS_ALL = 2; - - @Schema(description = "销售单编号", example = "XS001") - private String no; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "出库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] outTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "出库状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "收款状态", example = "1") - private Integer receiptStatus; - - @Schema(description = "是否可收款", example = "true") - private Boolean receiptEnable; // 对应 receiptStatus = [0, 1] - - @Schema(description = "销售单号", example = "1") - private String orderNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java deleted file mode 100644 index d33f47ee9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售出库 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSaleOutRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "出库单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("出库单编号") - private String no; - - @Schema(description = "出库状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("出库状态") - private Integer status; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "出库员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出库时间") - private LocalDateTime outTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "销售订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已收款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal receiptPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java deleted file mode 100644 index f2c26aae3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售出库新增/修改 Request VO") -@Data -public class ErpSaleOutSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库时间不能为空") - private LocalDateTime outTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "销售订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "出库清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "销售订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnPageReqVO.java deleted file mode 100644 index a9be73beb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 销售退货分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSaleReturnPageReqVO extends PageParam { - - public static final Integer REFUND_STATUS_NONE = 0; - public static final Integer REFUND_STATUS_PART = 1; - public static final Integer REFUND_STATUS_ALL = 2; - - @Schema(description = "销售单编号", example = "XS001") - private String no; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] returnTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "销售单号", example = "1") - private String orderNo; - - @Schema(description = "退款状态", example = "1") - private Integer refundStatus; - - @Schema(description = "是否可退款", example = "true") - private Boolean refundEnable; // 对应 refundStatus = [0, 1] - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnRespVO.java deleted file mode 100644 index 2ca3384fa..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnRespVO.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售退货 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSaleReturnRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "退货单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("退货单编号") - private String no; - - @Schema(description = "退货状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("退货状态") - private Integer status; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "退货员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("退货时间") - private LocalDateTime returnTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "销售订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal refundPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "退货项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnSaveReqVO.java deleted file mode 100644 index 867bd68f2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnSaveReqVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售退货新增/修改 Request VO") -@Data -public class ErpSaleReturnSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "退货时间不能为空") - private LocalDateTime returnTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "销售订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "销售订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpPurchaseStatisticsController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpPurchaseStatisticsController.java deleted file mode 100644 index be0258dab..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpPurchaseStatisticsController.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase.ErpPurchaseSummaryRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase.ErpPurchaseTimeSummaryRespVO; -import cn.iocoder.yudao.module.erp.service.statistics.ErpPurchaseStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.hutool.core.date.DatePattern.NORM_MONTH_PATTERN; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - ERP 采购统计") -@RestController -@RequestMapping("/erp/purchase-statistics") -@Validated -public class ErpPurchaseStatisticsController { - - @Resource - private ErpPurchaseStatisticsService purchaseStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得采购统计") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult getPurchaseSummary() { - LocalDateTime today = LocalDateTimeUtils.getToday(); - LocalDateTime yesterday = LocalDateTimeUtils.getYesterday(); - LocalDateTime month = LocalDateTimeUtils.getMonth(); - LocalDateTime year = LocalDateTimeUtils.getYear(); - ErpPurchaseSummaryRespVO summary = new ErpPurchaseSummaryRespVO() - .setTodayPrice(purchaseStatisticsService.getPurchasePrice(today, null)) - .setYesterdayPrice(purchaseStatisticsService.getPurchasePrice(yesterday, today)) - .setMonthPrice(purchaseStatisticsService.getPurchasePrice(month, null)) - .setYearPrice(purchaseStatisticsService.getPurchasePrice(year, null)); - return success(summary); - } - - @GetMapping("/time-summary") - @Operation(summary = "获得采购时间段统计") - @Parameter(name = "count", description = "时间段数量", example = "6") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult> getPurchaseTimeSummary( - @RequestParam(value = "count", defaultValue = "6") Integer count) { - List summaryList = new ArrayList<>(); - for (int i = count - 1; i >= 0; i--) { - LocalDateTime startTime = LocalDateTimeUtils.beginOfMonth(LocalDateTime.now().minusMonths(i)); - LocalDateTime endTime = LocalDateTimeUtils.endOfMonth(startTime); - summaryList.add(new ErpPurchaseTimeSummaryRespVO() - .setTime(LocalDateTimeUtil.format(startTime, NORM_MONTH_PATTERN)) - .setPrice(purchaseStatisticsService.getPurchasePrice(startTime, endTime))); - } - return success(summaryList); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.http b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.http deleted file mode 100644 index 5f5cab109..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.http +++ /dev/null @@ -1,11 +0,0 @@ -### 请求 /erp/sale-statistics/summary 接口 => 成功 -GET {{baseUrl}}/erp/sale-statistics/summary -Content-Type: application/json -tenant-id: {{adminTenentId}} -Authorization: Bearer {{token}} - -### 请求 /erp/sale-statistics/time-summary 接口 => 成功 -GET {{baseUrl}}/erp/sale-statistics/time-summary -Content-Type: application/json -tenant-id: {{adminTenentId}} -Authorization: Bearer {{token}} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.java deleted file mode 100644 index c43c971fe..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale.ErpSaleSummaryRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale.ErpSaleTimeSummaryRespVO; -import cn.iocoder.yudao.module.erp.service.statistics.ErpSaleStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.hutool.core.date.DatePattern.NORM_MONTH_PATTERN; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - ERP 销售统计") -@RestController -@RequestMapping("/erp/sale-statistics") -@Validated -public class ErpSaleStatisticsController { - - @Resource - private ErpSaleStatisticsService saleStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得销售统计") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult getSaleSummary() { - LocalDateTime today = LocalDateTimeUtils.getToday(); - LocalDateTime yesterday = LocalDateTimeUtils.getYesterday(); - LocalDateTime month = LocalDateTimeUtils.getMonth(); - LocalDateTime year = LocalDateTimeUtils.getYear(); - ErpSaleSummaryRespVO summary = new ErpSaleSummaryRespVO() - .setTodayPrice(saleStatisticsService.getSalePrice(today, null)) - .setYesterdayPrice(saleStatisticsService.getSalePrice(yesterday, today)) - .setMonthPrice(saleStatisticsService.getSalePrice(month, null)) - .setYearPrice(saleStatisticsService.getSalePrice(year, null)); - return success(summary); - } - - @GetMapping("/time-summary") - @Operation(summary = "获得销售时间段统计") - @Parameter(name = "count", description = "时间段数量", example = "6") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult> getSaleTimeSummary( - @RequestParam(value = "count", defaultValue = "6") Integer count) { - List summaryList = new ArrayList<>(); - for (int i = count - 1; i >= 0; i--) { - LocalDateTime startTime = LocalDateTimeUtils.beginOfMonth(LocalDateTime.now().minusMonths(i)); - LocalDateTime endTime = LocalDateTimeUtils.endOfMonth(startTime); - summaryList.add(new ErpSaleTimeSummaryRespVO() - .setTime(LocalDateTimeUtil.format(startTime, NORM_MONTH_PATTERN)) - .setPrice(saleStatisticsService.getSalePrice(startTime, endTime))); - } - return success(summaryList); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseSummaryRespVO.java deleted file mode 100644 index 22635e745..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseSummaryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 采购全局统计 Response VO") -@Data -public class ErpPurchaseSummaryRespVO { - - @Schema(description = "今日采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal todayPrice; - - @Schema(description = "昨日采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private BigDecimal yesterdayPrice; - - @Schema(description = "本月采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal monthPrice; - - @Schema(description = "今年采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "88888") - private BigDecimal yearPrice; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseTimeSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseTimeSummaryRespVO.java deleted file mode 100644 index 15ae817de..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseTimeSummaryRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 采购某个时间段的统计 Response VO") -@Data -public class ErpPurchaseTimeSummaryRespVO { - - @Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-03") - private String time; - - @Schema(description = "采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal price; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleSummaryRespVO.java deleted file mode 100644 index 575d7da5e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleSummaryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 销售全局统计 Response VO") -@Data -public class ErpSaleSummaryRespVO { - - @Schema(description = "今日销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal todayPrice; - - @Schema(description = "昨日销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private BigDecimal yesterdayPrice; - - @Schema(description = "本月销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal monthPrice; - - @Schema(description = "今年销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "88888") - private BigDecimal yearPrice; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleTimeSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleTimeSummaryRespVO.java deleted file mode 100644 index 48b9b6e9a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleTimeSummaryRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 销售某个时间段的统计 Response VO") -@Data -public class ErpSaleTimeSummaryRespVO { - - @Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-03") - private String time; - - @Schema(description = "销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal price; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java deleted file mode 100644 index b7b3c0991..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockCheckService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 库存调拨单") -@RestController -@RequestMapping("/erp/stock-check") -@Validated -public class ErpStockCheckController { - - @Resource - private ErpStockCheckService stockCheckService; - @Resource - private ErpProductService productService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-check:create')") - public CommonResult createStockCheck(@Valid @RequestBody ErpStockCheckSaveReqVO createReqVO) { - return success(stockCheckService.createStockCheck(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-check:update')") - public CommonResult updateStockCheck(@Valid @RequestBody ErpStockCheckSaveReqVO updateReqVO) { - stockCheckService.updateStockCheck(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新库存调拨单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-check:update-status')") - public CommonResult updateStockCheckStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockCheckService.updateStockCheckStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除库存调拨单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-check:delete')") - public CommonResult deleteStockCheck(@RequestParam("ids") List ids) { - stockCheckService.deleteStockCheck(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得库存调拨单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-check:query')") - public CommonResult getStockCheck(@RequestParam("id") Long id) { - ErpStockCheckDO stockCheck = stockCheckService.getStockCheck(id); - if (stockCheck == null) { - return success(null); - } - List stockCheckItemList = stockCheckService.getStockCheckItemListByCheckId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockCheckItemList, ErpStockCheckItemDO::getProductId)); - return success(BeanUtils.toBean(stockCheck, ErpStockCheckRespVO.class, stockCheckVO -> - stockCheckVO.setItems(BeanUtils.toBean(stockCheckItemList, ErpStockCheckRespVO.Item.class, item -> - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))))); - } - - @GetMapping("/page") - @Operation(summary = "获得库存调拨单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-check:query')") - public CommonResult> getStockCheckPage(@Valid ErpStockCheckPageReqVO pageReqVO) { - PageResult pageResult = stockCheckService.getStockCheckPage(pageReqVO); - return success(buildStockCheckVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出库存调拨单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-check:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockCheckExcel(@Valid ErpStockCheckPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockCheckVOPageResult(stockCheckService.getStockCheckPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "库存调拨单.xls", "数据", ErpStockCheckRespVO.class, list); - } - - private PageResult buildStockCheckVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 盘点项 - List stockCheckItemList = stockCheckService.getStockCheckItemListByCheckIds( - convertSet(pageResult.getList(), ErpStockCheckDO::getId)); - Map> stockCheckItemMap = convertMultiMap(stockCheckItemList, ErpStockCheckItemDO::getCheckId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockCheckItemList, ErpStockCheckItemDO::getProductId)); - // 1.3 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockCheck -> Long.parseLong(stockCheck.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockCheckRespVO.class, stockCheck -> { - stockCheck.setItems(BeanUtils.toBean(stockCheckItemMap.get(stockCheck.getId()), ErpStockCheckRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockCheck.setProductNames(CollUtil.join(stockCheck.getItems(), ",", ErpStockCheckRespVO.Item::getProductName)); - MapUtils.findAndThen(userMap, Long.parseLong(stockCheck.getCreator()), user -> stockCheck.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java deleted file mode 100644 index 2d9818d36..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockRespVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 产品库存") -@RestController -@RequestMapping("/erp/stock") -@Validated -public class ErpStockController { - - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - - @GetMapping("/get") - @Operation(summary = "获得产品库存") - @Parameters({ - @Parameter(name = "id", description = "编号", example = "1"), // 方案一:传递 id - @Parameter(name = "productId", description = "产品编号", example = "10"), // 方案二:传递 productId + warehouseId - @Parameter(name = "warehouseId", description = "仓库编号", example = "2") - }) - @PreAuthorize("@ss.hasPermission('erp:stock:query')") - public CommonResult getStock(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "productId", required = false) Long productId, - @RequestParam(value = "warehouseId", required = false) Long warehouseId) { - ErpStockDO stock = id != null ? stockService.getStock(id) : stockService.getStock(productId, warehouseId); - return success(BeanUtils.toBean(stock, ErpStockRespVO.class)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得产品库存数量") - @Parameter(name = "productId", description = "产品编号", example = "10") - public CommonResult getStockCount(@RequestParam("productId") Long productId) { - return success(stockService.getStockCount(productId)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品库存分页") - @PreAuthorize("@ss.hasPermission('erp:stock:query')") - public CommonResult> getStockPage(@Valid ErpStockPageReqVO pageReqVO) { - PageResult pageResult = stockService.getStockPage(pageReqVO); - return success(buildStockVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品库存 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockExcel(@Valid ErpStockPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockVOPageResult(stockService.getStockPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品库存.xls", "数据", ErpStockRespVO.class, list); - } - - private PageResult buildStockVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - Map productMap = productService.getProductVOMap( - convertSet(pageResult.getList(), ErpStockDO::getProductId)); - Map warehouseMap = warehouseService.getWarehouseMap( - convertSet(pageResult.getList(), ErpStockDO::getWarehouseId)); - return BeanUtils.toBean(pageResult, ErpStockRespVO.class, stock -> { - MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) - .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); - MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), warehouse -> stock.setWarehouseName(warehouse.getName())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java deleted file mode 100644 index cd9fb9241..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 其它入库单") -@RestController -@RequestMapping("/erp/stock-in") -@Validated -public class ErpStockInController { - - @Resource - private ErpStockInService stockInService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建其它入库单") - @PreAuthorize("@ss.hasPermission('erp:stock-in:create')") - public CommonResult createStockIn(@Valid @RequestBody ErpStockInSaveReqVO createReqVO) { - return success(stockInService.createStockIn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新其它入库单") - @PreAuthorize("@ss.hasPermission('erp:stock-in:update')") - public CommonResult updateStockIn(@Valid @RequestBody ErpStockInSaveReqVO updateReqVO) { - stockInService.updateStockIn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新其它入库单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-in:update-status')") - public CommonResult updateStockInStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockInService.updateStockInStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除其它入库单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-in:delete')") - public CommonResult deleteStockIn(@RequestParam("ids") List ids) { - stockInService.deleteStockIn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得其它入库单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-in:query')") - public CommonResult getStockIn(@RequestParam("id") Long id) { - ErpStockInDO stockIn = stockInService.getStockIn(id); - if (stockIn == null) { - return success(null); - } - List stockInItemList = stockInService.getStockInItemListByInId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockInItemList, ErpStockInItemDO::getProductId)); - return success(BeanUtils.toBean(stockIn, ErpStockInRespVO.class, stockInVO -> - stockInVO.setItems(BeanUtils.toBean(stockInItemList, ErpStockInRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得其它入库单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-in:query')") - public CommonResult> getStockInPage(@Valid ErpStockInPageReqVO pageReqVO) { - PageResult pageResult = stockInService.getStockInPage(pageReqVO); - return success(buildStockInVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出其它入库单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-in:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockInExcel(@Valid ErpStockInPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockInVOPageResult(stockInService.getStockInPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "其它入库单.xls", "数据", ErpStockInRespVO.class, list); - } - - private PageResult buildStockInVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 入库项 - List stockInItemList = stockInService.getStockInItemListByInIds( - convertSet(pageResult.getList(), ErpStockInDO::getId)); - Map> stockInItemMap = convertMultiMap(stockInItemList, ErpStockInItemDO::getInId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockInItemList, ErpStockInItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpStockInDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockIn -> Long.parseLong(stockIn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockInRespVO.class, stockIn -> { - stockIn.setItems(BeanUtils.toBean(stockInItemMap.get(stockIn.getId()), ErpStockInRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockIn.setProductNames(CollUtil.join(stockIn.getItems(), ",", ErpStockInRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, stockIn.getSupplierId(), supplier -> stockIn.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stockIn.getCreator()), user -> stockIn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java deleted file mode 100644 index 8cb85fa3c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockMoveService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 库存调拨单") -@RestController -@RequestMapping("/erp/stock-move") -@Validated -public class ErpStockMoveController { - - @Resource - private ErpStockMoveService stockMoveService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-move:create')") - public CommonResult createStockMove(@Valid @RequestBody ErpStockMoveSaveReqVO createReqVO) { - return success(stockMoveService.createStockMove(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-move:update')") - public CommonResult updateStockMove(@Valid @RequestBody ErpStockMoveSaveReqVO updateReqVO) { - stockMoveService.updateStockMove(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新库存调拨单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-move:update-status')") - public CommonResult updateStockMoveStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockMoveService.updateStockMoveStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除库存调拨单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-move:delete')") - public CommonResult deleteStockMove(@RequestParam("ids") List ids) { - stockMoveService.deleteStockMove(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得库存调拨单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-move:query')") - public CommonResult getStockMove(@RequestParam("id") Long id) { - ErpStockMoveDO stockMove = stockMoveService.getStockMove(id); - if (stockMove == null) { - return success(null); - } - List stockMoveItemList = stockMoveService.getStockMoveItemListByMoveId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockMoveItemList, ErpStockMoveItemDO::getProductId)); - return success(BeanUtils.toBean(stockMove, ErpStockMoveRespVO.class, stockMoveVO -> - stockMoveVO.setItems(BeanUtils.toBean(stockMoveItemList, ErpStockMoveRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getFromWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得库存调拨单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-move:query')") - public CommonResult> getStockMovePage(@Valid ErpStockMovePageReqVO pageReqVO) { - PageResult pageResult = stockMoveService.getStockMovePage(pageReqVO); - return success(buildStockMoveVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出库存调拨单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-move:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockMoveExcel(@Valid ErpStockMovePageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockMoveVOPageResult(stockMoveService.getStockMovePage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "库存调拨单.xls", "数据", ErpStockMoveRespVO.class, list); - } - - private PageResult buildStockMoveVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 调拨项 - List stockMoveItemList = stockMoveService.getStockMoveItemListByMoveIds( - convertSet(pageResult.getList(), ErpStockMoveDO::getId)); - Map> stockMoveItemMap = convertMultiMap(stockMoveItemList, ErpStockMoveItemDO::getMoveId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockMoveItemList, ErpStockMoveItemDO::getProductId)); - // 1.3 TODO 芋艿:搞仓库信息 - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockMove -> Long.parseLong(stockMove.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockMoveRespVO.class, stockMove -> { - stockMove.setItems(BeanUtils.toBean(stockMoveItemMap.get(stockMove.getId()), ErpStockMoveRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockMove.setProductNames(CollUtil.join(stockMove.getItems(), ",", ErpStockMoveRespVO.Item::getProductName)); - // TODO 芋艿: -// MapUtils.findAndThen(customerMap, stockMove.getCustomerId(), supplier -> stockMove.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stockMove.getCreator()), user -> stockMove.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java deleted file mode 100644 index 82eb7043c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockOutService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 其它出库单") -@RestController -@RequestMapping("/erp/stock-out") -@Validated -public class ErpStockOutController { - - @Resource - private ErpStockOutService stockOutService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建其它出库单") - @PreAuthorize("@ss.hasPermission('erp:stock-out:create')") - public CommonResult createStockOut(@Valid @RequestBody ErpStockOutSaveReqVO createReqVO) { - return success(stockOutService.createStockOut(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新其它出库单") - @PreAuthorize("@ss.hasPermission('erp:stock-out:update')") - public CommonResult updateStockOut(@Valid @RequestBody ErpStockOutSaveReqVO updateReqVO) { - stockOutService.updateStockOut(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新其它出库单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')") - public CommonResult updateStockOutStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockOutService.updateStockOutStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除其它出库单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-out:delete')") - public CommonResult deleteStockOut(@RequestParam("ids") List ids) { - stockOutService.deleteStockOut(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得其它出库单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-out:query')") - public CommonResult getStockOut(@RequestParam("id") Long id) { - ErpStockOutDO stockOut = stockOutService.getStockOut(id); - if (stockOut == null) { - return success(null); - } - List stockOutItemList = stockOutService.getStockOutItemListByOutId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockOutItemList, ErpStockOutItemDO::getProductId)); - return success(BeanUtils.toBean(stockOut, ErpStockOutRespVO.class, stockOutVO -> - stockOutVO.setItems(BeanUtils.toBean(stockOutItemList, ErpStockOutRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得其它出库单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-out:query')") - public CommonResult> getStockOutPage(@Valid ErpStockOutPageReqVO pageReqVO) { - PageResult pageResult = stockOutService.getStockOutPage(pageReqVO); - return success(buildStockOutVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出其它出库单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-out:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockOutExcel(@Valid ErpStockOutPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockOutVOPageResult(stockOutService.getStockOutPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "其它出库单.xls", "数据", ErpStockOutRespVO.class, list); - } - - private PageResult buildStockOutVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 出库项 - List stockOutItemList = stockOutService.getStockOutItemListByOutIds( - convertSet(pageResult.getList(), ErpStockOutDO::getId)); - Map> stockOutItemMap = convertMultiMap(stockOutItemList, ErpStockOutItemDO::getOutId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockOutItemList, ErpStockOutItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockOutRespVO.class, stockOut -> { - stockOut.setItems(BeanUtils.toBean(stockOutItemMap.get(stockOut.getId()), ErpStockOutRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java deleted file mode 100644 index 61fcf236a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordRespVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 产品库存明细") -@RestController -@RequestMapping("/erp/stock-record") -@Validated -public class ErpStockRecordController { - - @Resource - private ErpStockRecordService stockRecordService; - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - - @Resource - private AdminUserApi adminUserApi; - - @GetMapping("/get") - @Operation(summary = "获得产品库存明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-record:query')") - public CommonResult getStockRecord(@RequestParam("id") Long id) { - ErpStockRecordDO stockRecord = stockRecordService.getStockRecord(id); - return success(BeanUtils.toBean(stockRecord, ErpStockRecordRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品库存明细分页") - @PreAuthorize("@ss.hasPermission('erp:stock-record:query')") - public CommonResult> getStockRecordPage(@Valid ErpStockRecordPageReqVO pageReqVO) { - PageResult pageResult = stockRecordService.getStockRecordPage(pageReqVO); - return success(buildStockRecrodVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品库存明细 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-record:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockRecordExcel(@Valid ErpStockRecordPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockRecrodVOPageResult(stockRecordService.getStockRecordPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品库存明细.xls", "数据", ErpStockRecordRespVO.class, list); - } - - private PageResult buildStockRecrodVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - Map productMap = productService.getProductVOMap( - convertSet(pageResult.getList(), ErpStockRecordDO::getProductId)); - Map warehouseMap = warehouseService.getWarehouseMap( - convertSet(pageResult.getList(), ErpStockRecordDO::getWarehouseId)); - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), record -> Long.parseLong(record.getCreator()))); - return BeanUtils.toBean(pageResult, ErpStockRecordRespVO.class, stock -> { - MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) - .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); - MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), warehouse -> stock.setWarehouseName(warehouse.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stock.getCreator()), user -> stock.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java deleted file mode 100644 index 110525568..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 仓库") -@RestController -@RequestMapping("/erp/warehouse") -@Validated -public class ErpWarehouseController { - - @Resource - private ErpWarehouseService warehouseService; - - @PostMapping("/create") - @Operation(summary = "创建仓库") - @PreAuthorize("@ss.hasPermission('erp:warehouse:create')") - public CommonResult createWarehouse(@Valid @RequestBody ErpWarehouseSaveReqVO createReqVO) { - return success(warehouseService.createWarehouse(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新仓库") - @PreAuthorize("@ss.hasPermission('erp:warehouse:update')") - public CommonResult updateWarehouse(@Valid @RequestBody ErpWarehouseSaveReqVO updateReqVO) { - warehouseService.updateWarehouse(updateReqVO); - return success(true); - } - - @PutMapping("/update-default-status") - @Operation(summary = "更新仓库默认状态") - @Parameters({ - @Parameter(name = "id", description = "编号", required = true), - @Parameter(name = "status", description = "状态", required = true) - }) - public CommonResult updateWarehouseDefaultStatus(@RequestParam("id") Long id, - @RequestParam("defaultStatus") Boolean defaultStatus) { - warehouseService.updateWarehouseDefaultStatus(id, defaultStatus); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除仓库") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:warehouse:delete')") - public CommonResult deleteWarehouse(@RequestParam("id") Long id) { - warehouseService.deleteWarehouse(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得仓库") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:warehouse:query')") - public CommonResult getWarehouse(@RequestParam("id") Long id) { - ErpWarehouseDO warehouse = warehouseService.getWarehouse(id); - return success(BeanUtils.toBean(warehouse, ErpWarehouseRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得仓库分页") - @PreAuthorize("@ss.hasPermission('erp:warehouse:query')") - public CommonResult> getWarehousePage(@Valid ErpWarehousePageReqVO pageReqVO) { - PageResult pageResult = warehouseService.getWarehousePage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpWarehouseRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得仓库精简列表", description = "只包含被开启的仓库,主要用于前端的下拉选项") - public CommonResult> getWarehouseSimpleList() { - List list = warehouseService.getWarehouseListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, warehouse -> new ErpWarehouseRespVO().setId(warehouse.getId()) - .setName(warehouse.getName()).setDefaultStatus(warehouse.getDefaultStatus()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出仓库 Excel") - @PreAuthorize("@ss.hasPermission('erp:warehouse:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportWarehouseExcel(@Valid ErpWarehousePageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = warehouseService.getWarehousePage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "仓库.xls", "数据", ErpWarehouseRespVO.class, - BeanUtils.toBean(list, ErpWarehouseRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckPageReqVO.java deleted file mode 100644 index 2bae14c1e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 库存盘点单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockCheckPageReqVO extends PageParam { - - @Schema(description = "盘点单号", example = "S123") - private String no; - - @Schema(description = "仓库编号", example = "3113") - private Long warehouseId; - - @Schema(description = "盘点时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] checkTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckRespVO.java deleted file mode 100644 index 88b75bb9c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckRespVO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 库存盘点单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockCheckRespVO { - - @Schema(description = "盘点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("盘点编号") - private Long id; - - @Schema(description = "盘点单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("盘点单号") - private String no; - - @Schema(description = "盘点时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("盘点时间") - private LocalDateTime checkTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "盘点项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "盘点项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "账面数量(当前库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "账面数量不能为空") - private BigDecimal stockCount; - - @Schema(description = "实际数量(实际库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "实际数量不能为空") - private BigDecimal actualCount; - - @Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "盈亏数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckSaveReqVO.java deleted file mode 100644 index 9197eb008..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckSaveReqVO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 其它出库单新增/修改 Request VO") -@Data -public class ErpStockCheckSaveReqVO { - - @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库时间不能为空") - private LocalDateTime checkTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "出库项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "账面数量(当前库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "账面数量不能为空") - private BigDecimal stockCount; - - @Schema(description = "实际数量(实际库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "实际数量不能为空") - private BigDecimal actualCount; - - @Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "盈亏数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java deleted file mode 100644 index 02e3db37a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 其它入库单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockInPageReqVO extends PageParam { - - @Schema(description = "入库单号", example = "S123") - private String no; - - @Schema(description = "供应商编号", example = "3113") - private Long supplierId; - - @Schema(description = "入库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] inTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInRespVO.java deleted file mode 100644 index 077b9dd1b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInRespVO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 其它入库单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockInRespVO { - - @Schema(description = "入库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("入库编号") - private Long id; - - @Schema(description = "入库单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("入库单号") - private String no; - - @Schema(description = "供应商编号", example = "3113") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("入库时间") - private LocalDateTime inTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "入库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInSaveReqVO.java deleted file mode 100644 index fc1cc7e4e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInSaveReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 其它入库单新增/修改 Request VO") -@Data -public class ErpStockInSaveReqVO { - - @Schema(description = "入库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "供应商编号", example = "3113") - private Long supplierId; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "入库时间不能为空") - private LocalDateTime inTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "入库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "入库项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMovePageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMovePageReqVO.java deleted file mode 100644 index 98a1fe95e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMovePageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 库存调拨单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockMovePageReqVO extends PageParam { - - @Schema(description = "调拨单号", example = "S123") - private String no; - - @Schema(description = "调拨时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] moveTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "调出仓库编号", example = "1") - private Long fromWarehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveRespVO.java deleted file mode 100644 index 799ddc3f1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveRespVO.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 库存调拨单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockMoveRespVO { - - @Schema(description = "调拨编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("调拨编号") - private Long id; - - @Schema(description = "调拨单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("调拨单号") - private String no; - - @Schema(description = "调拨时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("调拨时间") - private LocalDateTime moveTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "调拨项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "调拨项编号", example = "11756") - private Long id; - - @Schema(description = "调出仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long fromWarehouseId; - - @Schema(description = "调入仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long toWarehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveSaveReqVO.java deleted file mode 100644 index 1930241ff..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveSaveReqVO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move; - -import cn.hutool.core.util.ObjectUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 库存调拨单新增/修改 Request VO") -@Data -public class ErpStockMoveSaveReqVO { - - @Schema(description = "调拨编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - - @Schema(description = "调拨时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "调拨时间不能为空") - private LocalDateTime moveTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "调拨项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "调拨项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "调拨项编号", example = "11756") - private Long id; - - @Schema(description = "调出仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "调出仓库编号不能为空") - private Long fromWarehouseId; - - @Schema(description = "调入仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "调入仓库编号不能为空") - private Long toWarehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - @AssertTrue(message = "调出、调仓仓库不能相同") - @JsonIgnore - public boolean isWarehouseValid() { - return ObjectUtil.notEqual(fromWarehouseId, toWarehouseId); - } - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutPageReqVO.java deleted file mode 100644 index 5f6558b19..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 其它出库单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockOutPageReqVO extends PageParam { - - @Schema(description = "出库单号", example = "S123") - private String no; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - - @Schema(description = "出库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] outTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutRespVO.java deleted file mode 100644 index 22a88e7c9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutRespVO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 其它出库单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockOutRespVO { - - @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("出库编号") - private Long id; - - @Schema(description = "出库单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("出库单号") - private String no; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出库时间") - private LocalDateTime outTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutSaveReqVO.java deleted file mode 100644 index 26abca036..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutSaveReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 其它出库单新增/修改 Request VO") -@Data -public class ErpStockOutSaveReqVO { - - @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库时间不能为空") - private LocalDateTime outTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "出库项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordPageReqVO.java deleted file mode 100644 index c478e4fef..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 产品库存明细分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockRecordPageReqVO extends PageParam { - - @Schema(description = "产品编号", example = "10625") - private Long productId; - - @Schema(description = "仓库编号", example = "32407") - private Long warehouseId; - - @Schema(description = "业务类型", example = "10") - private Integer bizType; - - @Schema(description = "业务单号", example = "Z110") - private String bizNo; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordRespVO.java deleted file mode 100644 index ff4b3e12a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordRespVO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.erp.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品库存明细 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockRecordRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18909") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10625") - private Long productId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32407") - private Long warehouseId; - - @Schema(description = "出入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "11084") - @ExcelProperty("出入库数量") - private BigDecimal count; - - @Schema(description = "总库存量", requiredMode = Schema.RequiredMode.REQUIRED, example = "4307") - @ExcelProperty("总库存量") - private BigDecimal totalCount; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "业务类型", converter = DictConvert.class) - @DictFormat(DictTypeConstants.STOCK_RECORD_BIZ_TYPE) - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27093") - @ExcelProperty("业务编号") - private Long bizId; - - @Schema(description = "业务项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23516") - @ExcelProperty("业务项编号") - private Long bizItemId; - - @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "Z110") - @ExcelProperty("业务单号") - private String bizNo; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "25682") - private String creator; - - // ========== 产品信息 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @ExcelProperty("产品名称") - private String productName; - - @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - @ExcelProperty("单位") - private String unitName; - - // ========== 仓库信息 ========== - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("仓库名称") - private String warehouseName; - - // ========== 用户信息 ========== - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @ExcelProperty("创建人") - private String creatorName; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java deleted file mode 100644 index f7f3fa343..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 库存分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockPageReqVO extends PageParam { - - @Schema(description = "产品编号", example = "19614") - private Long productId; - - @Schema(description = "仓库编号", example = "2802") - private Long warehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java deleted file mode 100644 index 06366a0dd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 库存 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17086") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19614") - private Long productId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2802") - private Long warehouseId; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "21935") - @ExcelProperty("库存数量") - private BigDecimal count; - - // ========== 产品信息 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @ExcelProperty("产品名称") - private String productName; - - @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - @ExcelProperty("单位") - private String unitName; - - // ========== 仓库信息 ========== - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("仓库名称") - private String warehouseName; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehousePageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehousePageReqVO.java deleted file mode 100644 index 2accf9a0f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehousePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 仓库分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpWarehousePageReqVO extends PageParam { - - @Schema(description = "仓库名称", example = "李四") - private String name; - - @Schema(description = "开启状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseRespVO.java deleted file mode 100644 index 188d42699..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseRespVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 仓库 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpWarehouseRespVO { - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614") - @ExcelProperty("仓库编号") - private Long id; - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("仓库名称") - private String name; - - @Schema(description = "仓库地址", example = "上海陆家嘴") - @ExcelProperty("仓库地址") - private String address; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty("排序") - private Long sort; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "负责人", example = "芋头") - @ExcelProperty("负责人") - private String principal; - - @Schema(description = "仓储费,单位:元", example = "13973") - @ExcelProperty("仓储费,单位:元") - private BigDecimal warehousePrice; - - @Schema(description = "搬运费,单位:元", example = "9903") - @ExcelProperty("搬运费,单位:元") - private BigDecimal truckagePrice; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "是否默认", example = "1") - @ExcelProperty("是否默认") - private Boolean defaultStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseSaveReqVO.java deleted file mode 100644 index 06bf5580e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseSaveReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 仓库新增/修改 Request VO") -@Data -public class ErpWarehouseSaveReqVO { - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614") - private Long id; - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "仓库名称不能为空") - private String name; - - @Schema(description = "仓库地址", example = "上海陆家嘴") - private String address; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "排序不能为空") - private Long sort; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "负责人", example = "芋头") - private String principal; - - @Schema(description = "仓储费,单位:元", example = "13973") - private BigDecimal warehousePrice; - - @Schema(description = "搬运费,单位:元", example = "9903") - private BigDecimal truckagePrice; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/package-info.java deleted file mode 100644 index ef0e5accf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.erp.controller; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpAccountDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpAccountDO.java deleted file mode 100644 index fe01cc228..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpAccountDO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * ERP 结算账户 DO - * - * @author 芋道源码 - */ -@TableName("erp_account") -@KeySequence("erp_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpAccountDO extends BaseDO { - - /** - * 结算账户编号 - */ - @TableId - private Long id; - /** - * 账户名称 - */ - private String name; - /** - * 账户编码 - */ - private String no; - /** - * 备注 - */ - private String remark; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - /** - * 是否默认 - */ - private Boolean defaultStatus; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java deleted file mode 100644 index edb55edbf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 付款单 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_payment") -@KeySequence("erp_finance_payment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinancePaymentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 付款单号 - */ - private String no; - /** - * 付款状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 付款时间 - */ - private LocalDateTime paymentTime; - /** - * 财务人员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long financeUserId; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 付款账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - - /** - * 合计价格,单位:元 - */ - private BigDecimal totalPrice; - /** - * 优惠金额,单位:元 - */ - private BigDecimal discountPrice; - /** - * 实付金额,单位:分 - * - * paymentPrice = totalPrice - discountPrice - */ - private BigDecimal paymentPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java deleted file mode 100644 index dd5bc5f69..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 付款项 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_payment_item") -@KeySequence("erp_finance_payment_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinancePaymentItemDO extends BaseDO { - - /** - * 入库项编号 - */ - @TableId - private Long id; - /** - * 付款单编号 - * - * 关联 {@link ErpFinancePaymentDO#getId()} - */ - private Long paymentId; - - /** - * 业务类型 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum} 的采购入库、退货 - */ - private Integer bizType; - /** - * 业务编号 - * - * 例如说:{@link ErpPurchaseInDO#getId()} - */ - private Long bizId; - /** - * 业务单号 - * - * 例如说:{@link ErpPurchaseInDO#getNo()} - */ - private String bizNo; - - /** - * 应付金额,单位:分 - */ - private BigDecimal totalPrice; - /** - * 已付金额,单位:分 - */ - private BigDecimal paidPrice; - /** - * 本次付款,单位:分 - */ - private BigDecimal paymentPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptDO.java deleted file mode 100644 index 46a559505..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptDO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 收款单 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_receipt") -@KeySequence("erp_finance_receipt_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinanceReceiptDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 收款单号 - */ - private String no; - /** - * 收款状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 收款时间 - */ - private LocalDateTime receiptTime; - /** - * 财务人员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long financeUserId; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 收款账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - - /** - * 合计价格,单位:元 - */ - private BigDecimal totalPrice; - /** - * 优惠金额,单位:元 - */ - private BigDecimal discountPrice; - /** - * 实付金额,单位:分 - * - * receiptPrice = totalPrice - discountPrice - */ - private BigDecimal receiptPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java deleted file mode 100644 index 87f051d5c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 收款项 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_receipt_item") -@KeySequence("erp_finance_receipt_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinanceReceiptItemDO extends BaseDO { - - /** - * 入库项编号 - */ - @TableId - private Long id; - /** - * 收款单编号 - * - * 关联 {@link ErpFinanceReceiptDO#getId()} - */ - private Long receiptId; - - /** - * 业务类型 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum} 的销售出库、退货 - */ - private Integer bizType; - /** - * 业务编号 - * - * 例如说:{@link ErpSaleOutDO#getId()} - */ - private Long bizId; - /** - * 业务单号 - * - * 例如说:{@link ErpSaleOutDO#getNo()} - */ - private String bizNo; - - /** - * 应收金额,单位:分 - */ - private BigDecimal totalPrice; - /** - * 已收金额,单位:分 - */ - private BigDecimal receiptedPrice; - /** - * 本次收款,单位:分 - */ - private BigDecimal receiptPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductCategoryDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductCategoryDO.java deleted file mode 100644 index 4c6225158..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductCategoryDO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * ERP 产品分类 DO - * - * @author 芋道源码 - */ -@TableName("erp_product_category") -@KeySequence("erp_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpProductCategoryDO extends BaseDO { - - public static final Long PARENT_ID_ROOT = 0L; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 父分类编号 - */ - private Long parentId; - /** - * 分类名称 - */ - private String name; - /** - * 分类编码 - */ - private String code; - /** - * 分类排序 - */ - private Integer sort; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductDO.java deleted file mode 100644 index 31e4aa2d9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductDO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 产品 DO - * - * @author 芋道源码 - */ -@TableName("erp_product") -@KeySequence("erp_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpProductDO extends BaseDO { - - /** - * 产品编号 - */ - @TableId - private Long id; - /** - * 产品名称 - */ - private String name; - /** - * 产品条码 - */ - private String barCode; - /** - * 产品分类编号 - * - * 关联 {@link ErpProductCategoryDO#getId()} - */ - private Long categoryId; - /** - * 单位编号 - * - * 关联 {@link ErpProductUnitDO#getId()} - */ - private Long unitId; - /** - * 产品状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 产品规格 - */ - private String standard; - /** - * 产品备注 - */ - private String remark; - /** - * 保质期天数 - */ - private Integer expiryDay; - /** - * 基础重量(kg) - */ - private BigDecimal weight; - /** - * 采购价格,单位:元 - */ - private BigDecimal purchasePrice; - /** - * 销售价格,单位:元 - */ - private BigDecimal salePrice; - /** - * 最低价格,单位:元 - */ - private BigDecimal minPrice; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductUnitDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductUnitDO.java deleted file mode 100644 index e8ce906e0..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductUnitDO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * ERP 产品单位 DO - * - * @author 芋道源码 - */ -@TableName("erp_product_unit") -@KeySequence("erp_product_unit_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpProductUnitDO extends BaseDO { - - /** - * 单位编号 - */ - @TableId - private Long id; - /** - * 单位名字 - */ - private String name; - /** - * 单位状态 - */ - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java deleted file mode 100644 index b8186f509..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购入库 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_purchase_in") -@KeySequence("erp_purchase_in_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseInDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购入库单号 - */ - private String no; - /** - * 入库状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 入库时间 - */ - private LocalDateTime inTime; - - /** - * 采购订单编号 - * - * 关联 {@link ErpPurchaseOrderDO#getId()} - */ - private Long orderId; - /** - * 采购订单号 - * - * 冗余 {@link ErpPurchaseOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已支付金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} 结合,记录已支付金额 - */ - private BigDecimal paymentPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInItemDO.java deleted file mode 100644 index 1597bc10b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInItemDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 采购入库项 DO - * - * @author 芋道源码 - */ -@TableName("erp_purchase_in_items") -@KeySequence("erp_purchase_in_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseInItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购入库编号 - * - * 关联 {@link ErpPurchaseInDO##getId()} - */ - private Long inId; - /** - * 采购订单项编号 - * - * 关联 {@link ErpPurchaseOrderItemDO#getId()} - * 目的:方便更新关联的采购订单项的入库数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java deleted file mode 100644 index bba1542e3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购订单 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_purchase_order") -@KeySequence("erp_purchase_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseOrderDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购订单号 - */ - private String no; - /** - * 采购状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 下单时间 - */ - private LocalDateTime orderTime; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice - */ - private BigDecimal totalPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 定金金额,单位:元 - */ - private BigDecimal depositPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - - // ========== 采购入库 ========== - /** - * 采购入库数量 - */ - private BigDecimal inCount; - - // ========== 采购退货(出库)) ========== - /** - * 采购退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java deleted file mode 100644 index aa54d336b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 采购订单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_purchase_order_items") -@KeySequence("erp_purchase_order_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseOrderItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购订单编号 - * - * 关联 {@link ErpPurchaseOrderDO#getId()} - */ - private Long orderId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - - // ========== 采购入库 ========== - /** - * 采购入库数量 - */ - private BigDecimal inCount; - - // ========== 采购退货(出库)) ========== - /** - * 采购退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java deleted file mode 100644 index 4189e0adc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购退货 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_purchase_return") -@KeySequence("erp_purchase_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseReturnDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购退货单号 - */ - private String no; - /** - * 退货状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 退货时间 - */ - private LocalDateTime returnTime; - - /** - * 采购订单编号 - * - * 关联 {@link ErpPurchaseOrderDO#getId()} - */ - private Long orderId; - /** - * 采购订单号 - * - * 冗余 {@link ErpPurchaseOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已退款金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} 结合,记录已支付金额 - */ - private BigDecimal refundPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnItemDO.java deleted file mode 100644 index 1e1713277..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnItemDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 采购退货项 DO - * - * @author 芋道源码 - */ -@TableName("erp_purchase_return_items") -@KeySequence("erp_purchase_return_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseReturnItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购退货编号 - * - * 关联 {@link ErpPurchaseReturnDO##getId()} - */ - private Long returnId; - /** - * 采购订单项编号 - * - * 关联 {@link ErpPurchaseOrderItemDO#getId()} - * 目的:方便更新关联的采购订单项的退货数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java deleted file mode 100644 index 6e94c6669..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 供应商 DO - * - * @author 芋道源码 - */ -@TableName("erp_supplier") -@KeySequence("erp_supplier_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSupplierDO extends BaseDO { - - /** - * 供应商编号 - */ - @TableId - private Long id; - /** - * 供应商名称 - */ - private String name; - /** - * 联系人 - */ - private String contact; - /** - * 手机号码 - */ - private String mobile; - /** - * 联系电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * 传真 - */ - private String fax; - /** - * 备注 - */ - private String remark; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - /** - * 纳税人识别号 - */ - private String taxNo; - /** - * 税率 - */ - private BigDecimal taxPercent; - /** - * 开户行 - */ - private String bankName; - /** - * 开户账号 - */ - private String bankAccount; - /** - * 开户地址 - */ - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java deleted file mode 100644 index 7bffcc17c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 客户 DO - * - * @author 芋道源码 - */ -@TableName("erp_customer") -@KeySequence("erp_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpCustomerDO extends BaseDO { - - /** - * 客户编号 - */ - @TableId - private Long id; - /** - * 客户名称 - */ - private String name; - /** - * 联系人 - */ - private String contact; - /** - * 手机号码 - */ - private String mobile; - /** - * 联系电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * 传真 - */ - private String fax; - /** - * 备注 - */ - private String remark; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - /** - * 纳税人识别号 - */ - private String taxNo; - /** - * 税率 - */ - private BigDecimal taxPercent; - /** - * 开户行 - */ - private String bankName; - /** - * 开户账号 - */ - private String bankAccount; - /** - * 开户地址 - */ - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java deleted file mode 100644 index 5cdd4344e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售订单 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_sale_order") -@KeySequence("erp_sale_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOrderDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售订单号 - */ - private String no; - /** - * 销售状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 销售员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long saleUserId; - /** - * 下单时间 - */ - private LocalDateTime orderTime; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice - */ - private BigDecimal totalPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 定金金额,单位:元 - */ - private BigDecimal depositPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - - // ========== 销售出库 ========== - /** - * 销售出库数量 - */ - private BigDecimal outCount; - - // ========== 销售退货(入库)) ========== - /** - * 销售退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java deleted file mode 100644 index 4c829765b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 销售订单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_sale_order_items") -@KeySequence("erp_sale_order_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOrderItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售订单编号 - * - * 关联 {@link ErpSaleOrderDO#getId()} - */ - private Long orderId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - - // ========== 销售出库 ========== - /** - * 销售出库数量 - */ - private BigDecimal outCount; - - // ========== 销售退货(入库)) ========== - /** - * 销售退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java deleted file mode 100644 index 65b9d941f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售出库 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_sale_out") -@KeySequence("erp_sale_out_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOutDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售出库单号 - */ - private String no; - /** - * 出库状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 销售员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long saleUserId; - /** - * 出库时间 - */ - private LocalDateTime outTime; - - /** - * 销售订单编号 - * - * 关联 {@link ErpSaleOrderDO#getId()} - */ - private Long orderId; - /** - * 销售订单号 - * - * 冗余 {@link ErpSaleOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已收款金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 结合,记录已收款金额 - */ - private BigDecimal receiptPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java deleted file mode 100644 index b9b406413..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 销售出库项 DO - * - * @author 芋道源码 - */ -@TableName("erp_sale_out_items") -@KeySequence("erp_sale_out_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOutItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售出库编号 - * - * 关联 {@link ErpStockOutDO##getId()} - */ - private Long outId; - /** - * 销售订单项编号 - * - * 关联 {@link ErpSaleOrderItemDO#getId()} - * 目的:方便更新关联的销售订单项的出库数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnDO.java deleted file mode 100644 index ba41ac91b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnDO.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售退货 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_sale_return") -@KeySequence("erp_sale_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleReturnDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售退货单号 - */ - private String no; - /** - * 退货状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 销售员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long saleUserId; - /** - * 退货时间 - */ - private LocalDateTime returnTime; - - /** - * 销售订单编号 - * - * 关联 {@link ErpSaleOrderDO#getId()} - */ - private Long orderId; - /** - * 销售订单号 - * - * 冗余 {@link ErpSaleOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已退款金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 结合,记录已退款金额 - */ - private BigDecimal refundPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnItemDO.java deleted file mode 100644 index 8851d157c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnItemDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 销售退货项 DO - * - * @author 芋道源码 - */ -@TableName("erp_sale_return_items") -@KeySequence("erp_sale_return_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleReturnItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售退货编号 - * - * 关联 {@link ErpSaleReturnDO##getId()} - */ - private Long returnId; - /** - * 销售订单项编号 - * - * 关联 {@link ErpSaleOrderItemDO#getId()} - * 目的:方便更新关联的销售订单项的退货数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckDO.java deleted file mode 100644 index e9168275f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 库存盘点单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_check") -@KeySequence("erp_stock_check_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockCheckDO extends BaseDO { - - /** - * 盘点编号 - */ - @TableId - private Long id; - /** - * 盘点单号 - */ - private String no; - /** - * 盘点时间 - */ - private LocalDateTime checkTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckItemDO.java deleted file mode 100644 index c3c4dbf99..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckItemDO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 库存盘点单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_check_item") -@KeySequence("erp_stock_check_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockCheckItemDO extends BaseDO { - - /** - * 盘点项编号 - */ - @TableId - private Long id; - /** - * 盘点编号 - * - * 关联 {@link ErpStockCheckDO#getId()} - */ - private Long checkId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 账面数量(当前库存) - */ - private BigDecimal stockCount; - /** - * 实际数量(实际库存) - */ - private BigDecimal actualCount; - /** - * 盈亏数量 - * - * count = stockCount - actualCount - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java deleted file mode 100644 index 558c6c6e5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 产品库存 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock") -@KeySequence("erp_stock_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 库存数量 - */ - private BigDecimal count; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java deleted file mode 100644 index ee2512ab6..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 其它入库单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_in") -@KeySequence("erp_stock_in_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockInDO extends BaseDO { - - /** - * 入库编号 - */ - @TableId - private Long id; - /** - * 入库单号 - */ - private String no; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 入库时间 - */ - private LocalDateTime inTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInItemDO.java deleted file mode 100644 index 3e3ca9c5c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInItemDO.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 其它入库单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_in_item") -@KeySequence("erp_stock_in_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockInItemDO extends BaseDO { - - /** - * 入库项编号 - */ - @TableId - private Long id; - /** - * 入库编号 - * - * 关联 {@link ErpStockInDO#getId()} - */ - private Long inId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 产品数量 - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveDO.java deleted file mode 100644 index 682b33104..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 库存调拨单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_move") -@KeySequence("erp_stock_move_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockMoveDO extends BaseDO { - - /** - * 调拨编号 - */ - @TableId - private Long id; - /** - * 调拨单号 - */ - private String no; - /** - * 调拨时间 - */ - private LocalDateTime moveTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveItemDO.java deleted file mode 100644 index aee203670..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveItemDO.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 库存调拨单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_move_item") -@KeySequence("erp_stock_move_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockMoveItemDO extends BaseDO { - - /** - * 调拨项编号 - */ - @TableId - private Long id; - /** - * 调拨编号 - * - * 关联 {@link ErpStockMoveDO#getId()} - */ - private Long moveId; - /** - * 调出仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long fromWarehouseId; - /** - * 调入仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long toWarehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 产品数量 - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutDO.java deleted file mode 100644 index e0b337adb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 其它出库单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_out") -@KeySequence("erp_stock_out_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockOutDO extends BaseDO { - - /** - * 出库编号 - */ - @TableId - private Long id; - /** - * 出库单号 - */ - private String no; - /** - * 客户编号 - * - * TODO 芋艿:待关联 - */ - private Long customerId; - /** - * 出库时间 - */ - private LocalDateTime outTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutItemDO.java deleted file mode 100644 index 065c5255a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutItemDO.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 其它出库单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_out_item") -@KeySequence("erp_stock_out_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockOutItemDO extends BaseDO { - - /** - * 出库项编号 - */ - @TableId - private Long id; - /** - * 出库编号 - * - * 关联 {@link ErpStockOutDO#getId()} - */ - private Long outId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 产品数量 - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java deleted file mode 100644 index 7bc5e5a01..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 产品库存明细 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_record") -@KeySequence("erp_stock_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 出入库数量 - * - * 正数,表示入库;负数,表示出库 - */ - private BigDecimal count; - /** - * 总库存量 - * - * 出入库之后,目前的库存量 - */ - private BigDecimal totalCount; - /** - * 业务类型 - * - * 枚举 {@link ErpStockRecordBizTypeEnum} - */ - private Integer bizType; - /** - * 业务编号 - * - * 例如说:{@link ErpStockInDO#getId()} - */ - private Long bizId; - /** - * 业务项编号 - * - * 例如说:{@link ErpStockInItemDO#getId()} - */ - private Long bizItemId; - /** - * 业务单号 - * - * 例如说:{@link ErpStockInDO#getNo()} - */ - private String bizNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpWarehouseDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpWarehouseDO.java deleted file mode 100644 index 4f206173f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpWarehouseDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 仓库 DO - * - * @author 芋道源码 - */ -@TableName("erp_warehouse") -@KeySequence("erp_warehouse_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpWarehouseDO extends BaseDO { - - /** - * 仓库编号 - */ - @TableId - private Long id; - /** - * 仓库名称 - */ - private String name; - /** - * 仓库地址 - */ - private String address; - /** - * 排序 - */ - private Long sort; - /** - * 备注 - */ - private String remark; - /** - * 负责人 - */ - private String principal; - /** - * 仓储费,单位:元 - */ - private BigDecimal warehousePrice; - /** - * 搬运费,单位:元 - */ - private BigDecimal truckagePrice; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 是否默认 - */ - private Boolean defaultStatus; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java deleted file mode 100644 index 2f98147e2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 结算账户 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpAccountMapper extends BaseMapperX { - - default PageResult selectPage(ErpAccountPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpAccountDO::getName, reqVO.getName()) - .likeIfPresent(ErpAccountDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpAccountDO::getRemark, reqVO.getRemark()) - .orderByDesc(ErpAccountDO::getId)); - } - - default ErpAccountDO selectByDefaultStatus() { - return selectOne(ErpAccountDO::getDefaultStatus, true); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpAccountDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java deleted file mode 100644 index 7787e8d70..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 付款单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinancePaymentItemMapper extends BaseMapperX { - - default List selectListByPaymentId(Long paymentId) { - return selectList(ErpFinancePaymentItemDO::getPaymentId, paymentId); - } - - default List selectListByPaymentIds(Collection paymentIds) { - return selectList(ErpFinancePaymentItemDO::getPaymentId, paymentIds); - } - - default BigDecimal selectPaymentPriceSumByBizIdAndBizType(Long bizId, Integer bizType) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(payment_price) AS paymentPriceSum") - .eq("biz_id", bizId) - .eq("biz_type", bizType)); - // 获得数量 - if (CollUtil.isEmpty(result)) { - return BigDecimal.ZERO; - } - return BigDecimal.valueOf(MapUtil.getDouble(result.get(0), "paymentPriceSum", 0D)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java deleted file mode 100644 index 5ad0cccfd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 付款单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinancePaymentMapper extends BaseMapperX { - - default PageResult selectPage(ErpFinancePaymentPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpFinancePaymentDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpFinancePaymentDO::getPaymentTime, reqVO.getPaymentTime()) - .eqIfPresent(ErpFinancePaymentDO::getSupplierId, reqVO.getSupplierId()) - .eqIfPresent(ErpFinancePaymentDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpFinancePaymentDO::getFinanceUserId, reqVO.getFinanceUserId()) - .eqIfPresent(ErpFinancePaymentDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(ErpFinancePaymentDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpFinancePaymentDO::getRemark, reqVO.getRemark()) - .orderByDesc(ErpFinancePaymentDO::getId); - if (reqVO.getBizNo() != null) { - query.leftJoin(ErpFinancePaymentItemDO.class, ErpFinancePaymentItemDO::getPaymentId, ErpFinancePaymentDO::getId) - .eq(reqVO.getBizNo() != null, ErpFinancePaymentItemDO::getBizNo, reqVO.getBizNo()) - .groupBy(ErpFinancePaymentDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpFinancePaymentDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpFinancePaymentDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpFinancePaymentDO::getId, id).eq(ErpFinancePaymentDO::getStatus, status)); - } - - default ErpFinancePaymentDO selectByNo(String no) { - return selectOne(ErpFinancePaymentDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptItemMapper.java deleted file mode 100644 index cb6082b0e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptItemMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 收款单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinanceReceiptItemMapper extends BaseMapperX { - - default List selectListByReceiptId(Long receiptId) { - return selectList(ErpFinanceReceiptItemDO::getReceiptId, receiptId); - } - - default List selectListByReceiptIds(Collection receiptIds) { - return selectList(ErpFinanceReceiptItemDO::getReceiptId, receiptIds); - } - - default BigDecimal selectReceiptPriceSumByBizIdAndBizType(Long bizId, Integer bizType) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(receipt_price) AS receiptPriceSum") - .eq("biz_id", bizId) - .eq("biz_type", bizType)); - // 获得数量 - if (CollUtil.isEmpty(result)) { - return BigDecimal.ZERO; - } - return BigDecimal.valueOf(MapUtil.getDouble(result.get(0), "receiptPriceSum", 0D)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptMapper.java deleted file mode 100644 index d895adea4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 收款单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinanceReceiptMapper extends BaseMapperX { - - default PageResult selectPage(ErpFinanceReceiptPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpFinanceReceiptDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpFinanceReceiptDO::getReceiptTime, reqVO.getReceiptTime()) - .eqIfPresent(ErpFinanceReceiptDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ErpFinanceReceiptDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpFinanceReceiptDO::getFinanceUserId, reqVO.getFinanceUserId()) - .eqIfPresent(ErpFinanceReceiptDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(ErpFinanceReceiptDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpFinanceReceiptDO::getRemark, reqVO.getRemark()) - .orderByDesc(ErpFinanceReceiptDO::getId); - if (reqVO.getBizNo() != null) { - query.leftJoin(ErpFinanceReceiptItemDO.class, ErpFinanceReceiptItemDO::getReceiptId, ErpFinanceReceiptDO::getId) - .eq(reqVO.getBizNo() != null, ErpFinanceReceiptItemDO::getBizNo, reqVO.getBizNo()) - .groupBy(ErpFinanceReceiptDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpFinanceReceiptDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpFinanceReceiptDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpFinanceReceiptDO::getId, id).eq(ErpFinanceReceiptDO::getStatus, status)); - } - - default ErpFinanceReceiptDO selectByNo(String no) { - return selectOne(ErpFinanceReceiptDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductCategoryMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductCategoryMapper.java deleted file mode 100644 index 70bbc6429..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductCategoryMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 产品分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpProductCategoryMapper extends BaseMapperX { - - default List selectList(ErpProductCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ErpProductCategoryDO::getName, reqVO.getName()) - .eqIfPresent(ErpProductCategoryDO::getStatus, reqVO.getStatus()) - .orderByDesc(ErpProductCategoryDO::getId)); - } - - default ErpProductCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(ErpProductCategoryDO::getParentId, parentId, ErpProductCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(ErpProductCategoryDO::getParentId, parentId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java deleted file mode 100644 index 28a0d38bb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 产品 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpProductMapper extends BaseMapperX { - - default PageResult selectPage(ErpProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpProductDO::getName, reqVO.getName()) - .eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId()) - .betweenIfPresent(ErpProductDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ErpProductDO::getId)); - } - - default Long selectCountByCategoryId(Long categoryId) { - return selectCount(ErpProductDO::getCategoryId, categoryId); - } - - default Long selectCountByUnitId(Long unitId) { - return selectCount(ErpProductDO::getUnitId, unitId); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpProductDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductUnitMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductUnitMapper.java deleted file mode 100644 index 198ea8094..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductUnitMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 产品单位 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpProductUnitMapper extends BaseMapperX { - - default PageResult selectPage(ErpProductUnitPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpProductUnitDO::getName, reqVO.getName()) - .eqIfPresent(ErpProductUnitDO::getStatus, reqVO.getStatus()) - .orderByDesc(ErpProductUnitDO::getId)); - } - - default ErpProductUnitDO selectByName(String name) { - return selectOne(ErpProductUnitDO::getName, name); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpProductUnitDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInItemMapper.java deleted file mode 100644 index 9140f9548..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 采购入库项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseInItemMapper extends BaseMapperX { - - default List selectListByInId(Long inId) { - return selectList(ErpPurchaseInItemDO::getInId, inId); - } - - default List selectListByInIds(Collection inIds) { - return selectList(ErpPurchaseInItemDO::getInId, inIds); - } - - default int deleteByInId(Long inId) { - return delete(ErpPurchaseInItemDO::getInId, inId); - } - - /** - * 基于采购订单编号,查询每个采购订单项的入库数量之和 - * - * @param inIds 入库订单项编号数组 - * @return key:采购订单项编号;value:入库数量之和 - */ - default Map selectOrderItemCountSumMapByInIds(Collection inIds) { - if (CollUtil.isEmpty(inIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("in_id", inIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java deleted file mode 100644 index c155d8cbe..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 采购入库 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseInMapper extends BaseMapperX { - - default PageResult selectPage(ErpPurchaseInPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpPurchaseInDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpPurchaseInDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpPurchaseInDO::getInTime, reqVO.getInTime()) - .eqIfPresent(ErpPurchaseInDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpPurchaseInDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpPurchaseInDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpPurchaseInDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpPurchaseInDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpPurchaseInDO::getId); - // 付款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_NONE)) { - query.eq(ErpPurchaseInDO::getPaymentPrice, 0); - } else if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_PART)) { - query.gt(ErpPurchaseInDO::getPaymentPrice, 0).apply("t.payment_price < t.total_price"); - } else if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_ALL)) { - query.apply("t.payment_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getPaymentEnable())) { - query.eq(ErpPurchaseInDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.payment_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpPurchaseInItemDO.class, ErpPurchaseInItemDO::getInId, ErpPurchaseInDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpPurchaseInItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpPurchaseInItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpPurchaseInDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpPurchaseInDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpPurchaseInDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpPurchaseInDO::getId, id).eq(ErpPurchaseInDO::getStatus, status)); - } - - default ErpPurchaseInDO selectByNo(String no) { - return selectOne(ErpPurchaseInDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpPurchaseInDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderItemMapper.java deleted file mode 100644 index 17f1fe290..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 采购订单明项目 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseOrderItemMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(ErpPurchaseOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderIds(Collection orderIds) { - return selectList(ErpPurchaseOrderItemDO::getOrderId, orderIds); - } - - default int deleteByOrderId(Long orderId) { - return delete(ErpPurchaseOrderItemDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderMapper.java deleted file mode 100644 index 01f0303f9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderMapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -/** - * ERP 采购订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseOrderMapper extends BaseMapperX { - - default PageResult selectPage(ErpPurchaseOrderPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpPurchaseOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpPurchaseOrderDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpPurchaseOrderDO::getOrderTime, reqVO.getOrderTime()) - .eqIfPresent(ErpPurchaseOrderDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpPurchaseOrderDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpPurchaseOrderDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpPurchaseOrderDO::getId); - // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 in_count 错误 - if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_NONE)) { - query.eq(ErpPurchaseOrderDO::getInCount, 0); - } else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_PART)) { - query.gt(ErpPurchaseOrderDO::getInCount, 0).apply("t.in_count < t.total_count"); - } else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_ALL)) { - query.apply("t.in_count = t.total_count"); - } - // 退货状态 - if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_NONE)) { - query.eq(ErpPurchaseOrderDO::getReturnCount, 0); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_PART)) { - query.gt(ErpPurchaseOrderDO::getReturnCount, 0).apply("t.return_count < t.total_count"); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_ALL)) { - query.apply("t.return_count = t.total_count"); - } - // 可采购入库 - if (Boolean.TRUE.equals(reqVO.getInEnable())) { - query.eq(ErpPurchaseOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.in_count < t.total_count"); - } - // 可采购退货 - if (Boolean.TRUE.equals(reqVO.getReturnEnable())) { - query.eq(ErpPurchaseOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.return_count < t.in_count"); - } - if (reqVO.getProductId() != null) { - query.leftJoin(ErpPurchaseOrderItemDO.class, ErpPurchaseOrderItemDO::getOrderId, ErpPurchaseOrderDO::getId) - .eq(reqVO.getProductId() != null, ErpPurchaseOrderItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpPurchaseOrderDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpPurchaseOrderDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpPurchaseOrderDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpPurchaseOrderDO::getId, id).eq(ErpPurchaseOrderDO::getStatus, status)); - } - - default ErpPurchaseOrderDO selectByNo(String no) { - return selectOne(ErpPurchaseOrderDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnItemMapper.java deleted file mode 100644 index 2a8011900..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 采购退货项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseReturnItemMapper extends BaseMapperX { - - default List selectListByReturnId(Long returnId) { - return selectList(ErpPurchaseReturnItemDO::getReturnId, returnId); - } - - default List selectListByReturnIds(Collection returnIds) { - return selectList(ErpPurchaseReturnItemDO::getReturnId, returnIds); - } - - default int deleteByReturnId(Long returnId) { - return delete(ErpPurchaseReturnItemDO::getReturnId, returnId); - } - - /** - * 基于采购订单编号,查询每个采购订单项的退货数量之和 - * - * @param returnIds 入库订单项编号数组 - * @return key:采购订单项编号;value:退货数量之和 - */ - default Map selectOrderItemCountSumMapByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("return_id", returnIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java deleted file mode 100644 index 689a55dfd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 采购退货 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseReturnMapper extends BaseMapperX { - - default PageResult selectPage(ErpPurchaseReturnPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpPurchaseReturnDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpPurchaseReturnDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpPurchaseReturnDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ErpPurchaseReturnDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpPurchaseReturnDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpPurchaseReturnDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpPurchaseReturnDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpPurchaseReturnDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpPurchaseReturnDO::getId); - // 退款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_NONE)) { - query.eq(ErpPurchaseReturnDO::getRefundPrice, 0); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_PART)) { - query.gt(ErpPurchaseReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price"); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_ALL)) { - query.apply("t.refund_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getRefundEnable())) { - query.eq(ErpPurchaseInDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.refund_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpPurchaseReturnItemDO.class, ErpPurchaseReturnItemDO::getReturnId, ErpPurchaseReturnDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpPurchaseReturnItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpPurchaseReturnItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpPurchaseReturnDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpPurchaseReturnDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpPurchaseReturnDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpPurchaseReturnDO::getId, id).eq(ErpPurchaseReturnDO::getStatus, status)); - } - - default ErpPurchaseReturnDO selectByNo(String no) { - return selectOne(ErpPurchaseReturnDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpPurchaseReturnDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java deleted file mode 100644 index f65ab9405..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 供应商 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSupplierMapper extends BaseMapperX { - - default PageResult selectPage(ErpSupplierPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpSupplierDO::getName, reqVO.getName()) - .likeIfPresent(ErpSupplierDO::getMobile, reqVO.getMobile()) - .likeIfPresent(ErpSupplierDO::getTelephone, reqVO.getTelephone()) - .orderByDesc(ErpSupplierDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpSupplierDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java deleted file mode 100644 index 4970f9ad5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 客户 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpCustomerMapper extends BaseMapperX { - - default PageResult selectPage(ErpCustomerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpCustomerDO::getName, reqVO.getName()) - .eqIfPresent(ErpCustomerDO::getMobile, reqVO.getMobile()) - .eqIfPresent(ErpCustomerDO::getTelephone, reqVO.getTelephone()) - .orderByDesc(ErpCustomerDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpCustomerDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java deleted file mode 100644 index d2825e563..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 销售订单明项目 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOrderItemMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(ErpSaleOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderIds(Collection orderIds) { - return selectList(ErpSaleOrderItemDO::getOrderId, orderIds); - } - - default int deleteByOrderId(Long orderId) { - return delete(ErpSaleOrderItemDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java deleted file mode 100644 index 8ed3b6fcd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -/** - * ERP 销售订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOrderMapper extends BaseMapperX { - - default PageResult selectPage(ErpSaleOrderPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpSaleOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpSaleOrderDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpSaleOrderDO::getOrderTime, reqVO.getOrderTime()) - .eqIfPresent(ErpSaleOrderDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpSaleOrderDO::getId); - // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 out_count 错误 - if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_NONE)) { - query.eq(ErpSaleOrderDO::getOutCount, 0); - } else if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_PART)) { - query.gt(ErpSaleOrderDO::getOutCount, 0).apply("t.out_count < t.total_count"); - } else if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_ALL)) { - query.apply("t.out_count = t.total_count"); - } - // 退货状态 - if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_NONE)) { - query.eq(ErpSaleOrderDO::getReturnCount, 0); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_PART)) { - query.gt(ErpSaleOrderDO::getReturnCount, 0).apply("t.return_count < t.total_count"); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_ALL)) { - query.apply("t.return_count = t.total_count"); - } - // 可销售出库 - if (Boolean.TRUE.equals(reqVO.getOutEnable())) { - query.eq(ErpSaleOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.out_count < t.total_count"); - } - // 可销售退货 - if (Boolean.TRUE.equals(reqVO.getReturnEnable())) { - query.eq(ErpSaleOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.return_count < t.out_count"); - } - if (reqVO.getProductId() != null) { - query.leftJoin(ErpSaleOrderItemDO.class, ErpSaleOrderItemDO::getOrderId, ErpSaleOrderDO::getId) - .eq(reqVO.getProductId() != null, ErpSaleOrderItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpSaleOrderDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpSaleOrderDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpSaleOrderDO::getId, id).eq(ErpSaleOrderDO::getStatus, status)); - } - - default ErpSaleOrderDO selectByNo(String no) { - return selectOne(ErpSaleOrderDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java deleted file mode 100644 index 9cd5dede0..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 销售出库项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOutItemMapper extends BaseMapperX { - - default List selectListByOutId(Long outId) { - return selectList(ErpSaleOutItemDO::getOutId, outId); - } - - default List selectListByOutIds(Collection outIds) { - return selectList(ErpSaleOutItemDO::getOutId, outIds); - } - - default int deleteByOutId(Long outId) { - return delete(ErpSaleOutItemDO::getOutId, outId); - } - - /** - * 基于销售订单编号,查询每个销售订单项的出库数量之和 - * - * @param outIds 出库订单项编号数组 - * @return key:销售订单项编号;value:出库数量之和 - */ - default Map selectOrderItemCountSumMapByOutIds(Collection outIds) { - if (CollUtil.isEmpty(outIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("out_id", outIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java deleted file mode 100644 index 128913fcd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 销售出库 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOutMapper extends BaseMapperX { - - default PageResult selectPage(ErpSaleOutPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpSaleOutDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpSaleOutDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpSaleOutDO::getOutTime, reqVO.getOutTime()) - .eqIfPresent(ErpSaleOutDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpSaleOutDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpSaleOutDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpSaleOutDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpSaleOutDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpSaleOutDO::getId); - // 收款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_NONE)) { - query.eq(ErpSaleOutDO::getReceiptPrice, 0); - } else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_PART)) { - query.gt(ErpSaleOutDO::getReceiptPrice, 0).apply("t.receipt_price < t.total_price"); - } else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_ALL)) { - query.apply("t.receipt_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) { - query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.receipt_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpSaleOutItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpSaleOutItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpSaleOutDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpSaleOutDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpSaleOutDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpSaleOutDO::getId, id).eq(ErpSaleOutDO::getStatus, status)); - } - - default ErpSaleOutDO selectByNo(String no) { - return selectOne(ErpSaleOutDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpSaleOutDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnItemMapper.java deleted file mode 100644 index fdc572964..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 销售退货项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleReturnItemMapper extends BaseMapperX { - - default List selectListByReturnId(Long returnId) { - return selectList(ErpSaleReturnItemDO::getReturnId, returnId); - } - - default List selectListByReturnIds(Collection returnIds) { - return selectList(ErpSaleReturnItemDO::getReturnId, returnIds); - } - - default int deleteByReturnId(Long returnId) { - return delete(ErpSaleReturnItemDO::getReturnId, returnId); - } - - /** - * 基于销售订单编号,查询每个销售订单项的退货数量之和 - * - * @param returnIds 出库订单项编号数组 - * @return key:销售订单项编号;value:退货数量之和 - */ - default Map selectOrderItemCountSumMapByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("return_id", returnIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java deleted file mode 100644 index 867b45499..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 销售退货 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleReturnMapper extends BaseMapperX { - - default PageResult selectPage(ErpSaleReturnPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpSaleReturnDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpSaleReturnDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpSaleReturnDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ErpSaleReturnDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpSaleReturnDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpSaleReturnDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpSaleReturnDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpSaleReturnDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpSaleReturnDO::getId); - // 退款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_NONE)) { - query.eq(ErpSaleReturnDO::getRefundPrice, 0); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_PART)) { - query.gt(ErpSaleReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price"); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_ALL)) { - query.apply("t.refund_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getRefundEnable())) { - query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.refund_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpSaleReturnItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpSaleReturnItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpSaleReturnDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpSaleReturnDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpSaleReturnDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpSaleReturnDO::getId, id).eq(ErpSaleReturnDO::getStatus, status)); - } - - default ErpSaleReturnDO selectByNo(String no) { - return selectOne(ErpSaleReturnDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpSaleReturnDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpPurchaseStatisticsMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpPurchaseStatisticsMapper.java deleted file mode 100644 index 14b4e517b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpPurchaseStatisticsMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.statistics; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购统计 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseStatisticsMapper { - - BigDecimal getPurchasePrice(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpSaleStatisticsMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpSaleStatisticsMapper.java deleted file mode 100644 index b29f1944d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpSaleStatisticsMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.statistics; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售统计 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleStatisticsMapper { - - BigDecimal getSalePrice(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckItemMapper.java deleted file mode 100644 index ae13f9f96..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存盘点单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockCheckItemMapper extends BaseMapperX { - - default List selectListByCheckId(Long checkId) { - return selectList(ErpStockCheckItemDO::getCheckId, checkId); - } - - default List selectListByCheckIds(Collection checkIds) { - return selectList(ErpStockCheckItemDO::getCheckId, checkIds); - } - - default int deleteByCheckId(Long checkId) { - return delete(ErpStockCheckItemDO::getCheckId, checkId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckMapper.java deleted file mode 100644 index dd976df3d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 库存调拨单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockCheckMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockCheckPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockCheckDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpStockCheckDO::getCheckTime, reqVO.getCheckTime()) - .eqIfPresent(ErpStockCheckDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockCheckDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockCheckDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockCheckDO::getId); - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockCheckItemDO.class, ErpStockCheckItemDO::getCheckId, ErpStockCheckDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpStockCheckItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockCheckItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockCheckDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockCheckDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockCheckDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockCheckDO::getId, id).eq(ErpStockCheckDO::getStatus, status)); - } - - default ErpStockCheckDO selectByNo(String no) { - return selectOne(ErpStockCheckDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInItemMapper.java deleted file mode 100644 index 2731aa7bb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它入库单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockInItemMapper extends BaseMapperX { - - default List selectListByInId(Long inId) { - return selectList(ErpStockInItemDO::getInId, inId); - } - - default List selectListByInIds(Collection inIds) { - return selectList(ErpStockInItemDO::getInId, inIds); - } - - default int deleteByInId(Long inId) { - return delete(ErpStockInItemDO::getInId, inId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java deleted file mode 100644 index e815583ac..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 其它入库单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockInMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockInPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockInDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpStockInDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpStockInDO::getInTime, reqVO.getInTime()) - .eqIfPresent(ErpStockInDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockInDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockInDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockInDO::getId); - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockInItemDO.class, ErpStockInItemDO::getInId, ErpStockInDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpStockInItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockInItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockInDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockInDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockInDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockInDO::getId, id).eq(ErpStockInDO::getStatus, status)); - } - - default ErpStockInDO selectByNo(String no) { - return selectOne(ErpStockInDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java deleted file mode 100644 index 0ebc98597..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -/** - * ERP 产品库存 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ErpStockDO::getProductId, reqVO.getProductId()) - .eqIfPresent(ErpStockDO::getWarehouseId, reqVO.getWarehouseId()) - .orderByDesc(ErpStockDO::getId)); - } - - default ErpStockDO selectByProductIdAndWarehouseId(Long productId, Long warehouseId) { - return selectOne(ErpStockDO::getProductId, productId, - ErpStockDO::getWarehouseId, warehouseId); - } - - default int updateCountIncrement(Long id, BigDecimal count, boolean negativeEnable) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .eq(ErpStockDO::getId, id); - if (count.compareTo(BigDecimal.ZERO) > 0) { - updateWrapper.setSql("count = count + " + count); - } else if (count.compareTo(BigDecimal.ZERO) < 0) { - if (!negativeEnable) { - updateWrapper.ge(ErpStockDO::getCount, count.abs()); - } - updateWrapper.setSql("count = count - " + count.abs()); - } - return update(null, updateWrapper); - } - - default BigDecimal selectSumByProductId(Long productId) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .eq("product_id", productId)); - // 获得数量 - if (CollUtil.isEmpty(result)) { - return BigDecimal.ZERO; - } - return BigDecimal.valueOf(MapUtil.getDouble(result.get(0), "sumCount", 0D)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveItemMapper.java deleted file mode 100644 index 21a267029..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存调拨单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockMoveItemMapper extends BaseMapperX { - - default List selectListByMoveId(Long moveId) { - return selectList(ErpStockMoveItemDO::getMoveId, moveId); - } - - default List selectListByMoveIds(Collection moveIds) { - return selectList(ErpStockMoveItemDO::getMoveId, moveIds); - } - - default int deleteByMoveId(Long moveId) { - return delete(ErpStockMoveItemDO::getMoveId, moveId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveMapper.java deleted file mode 100644 index 9a8ce0b64..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 库存调拨单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockMoveMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockMovePageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockMoveDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpStockMoveDO::getMoveTime, reqVO.getMoveTime()) - .eqIfPresent(ErpStockMoveDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockMoveDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockMoveDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockMoveDO::getId); - if (reqVO.getFromWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockMoveItemDO.class, ErpStockMoveItemDO::getMoveId, ErpStockMoveDO::getId) - .eq(reqVO.getFromWarehouseId() != null, ErpStockMoveItemDO::getFromWarehouseId, reqVO.getFromWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockMoveItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockMoveDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockMoveDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockMoveDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockMoveDO::getId, id).eq(ErpStockMoveDO::getStatus, status)); - } - - default ErpStockMoveDO selectByNo(String no) { - return selectOne(ErpStockMoveDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutItemMapper.java deleted file mode 100644 index 3b27cd3dc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它出库单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockOutItemMapper extends BaseMapperX { - - default List selectListByOutId(Long outId) { - return selectList(ErpStockOutItemDO::getOutId, outId); - } - - default List selectListByOutIds(Collection outIds) { - return selectList(ErpStockOutItemDO::getOutId, outIds); - } - - default int deleteByOutId(Long outId) { - return delete(ErpStockOutItemDO::getOutId, outId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutMapper.java deleted file mode 100644 index a73dd3ccf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 其它出库单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockOutMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockOutPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockOutDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpStockOutDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpStockOutDO::getOutTime, reqVO.getOutTime()) - .eqIfPresent(ErpStockOutDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockOutDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockOutDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockOutDO::getId); - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockOutItemDO.class, ErpStockOutItemDO::getOutId, ErpStockOutDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpStockOutItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockOutItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockOutDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockOutDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockOutDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockOutDO::getId, id).eq(ErpStockOutDO::getStatus, status)); - } - - default ErpStockOutDO selectByNo(String no) { - return selectOne(ErpStockOutDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java deleted file mode 100644 index bfd8b6751..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 产品库存明细 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockRecordMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ErpStockRecordDO::getProductId, reqVO.getProductId()) - .eqIfPresent(ErpStockRecordDO::getWarehouseId, reqVO.getWarehouseId()) - .eqIfPresent(ErpStockRecordDO::getBizType, reqVO.getBizType()) - .likeIfPresent(ErpStockRecordDO::getBizNo, reqVO.getBizNo()) - .betweenIfPresent(ErpStockRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ErpStockRecordDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java deleted file mode 100644 index b6ef0d8cf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 仓库 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpWarehouseMapper extends BaseMapperX { - - default PageResult selectPage(ErpWarehousePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpWarehouseDO::getName, reqVO.getName()) - .eqIfPresent(ErpWarehouseDO::getStatus, reqVO.getStatus()) - .orderByDesc(ErpWarehouseDO::getId)); - } - - default ErpWarehouseDO selectByDefaultStatus() { - return selectOne(ErpWarehouseDO::getDefaultStatus, true); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpWarehouseDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/RedisKeyConstants.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/RedisKeyConstants.java deleted file mode 100644 index daa5c1614..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.redis; - -/** - * ERP Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String NO = "erp:seq_no:"; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java deleted file mode 100644 index c71f3f56c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.erp.dal.redis.RedisKeyConstants; -import javax.annotation.Resource; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import java.time.Duration; -import java.time.LocalDateTime; - - -/** - * Erp 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class ErpNoRedisDAO { - - /** - * 其它入库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO} - */ - public static final String STOCK_IN_NO_PREFIX = "QTRK"; - /** - * 其它出库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO} - */ - public static final String STOCK_OUT_NO_PREFIX = "QCKD"; - - /** - * 库存调拨 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO} - */ - public static final String STOCK_MOVE_NO_PREFIX = "QCDB"; - - /** - * 库存盘点 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO} - */ - public static final String STOCK_CHECK_NO_PREFIX = "QCPD"; - - /** - * 销售订单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO} - */ - public static final String SALE_ORDER_NO_PREFIX = "XSDD"; - /** - * 销售出库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO} - */ - public static final String SALE_OUT_NO_PREFIX = "XSCK"; - /** - * 销售退货 {@link cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO} - */ - public static final String SALE_RETURN_NO_PREFIX = "XSTH"; - - /** - * 采购订单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO} - */ - public static final String PURCHASE_ORDER_NO_PREFIX = "CGDD"; - /** - * 采购入库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO} - */ - public static final String PURCHASE_IN_NO_PREFIX = "CGRK"; - /** - * 采购退货 {@link cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO} - */ - public static final String PURCHASE_RETURN_NO_PREFIX = "CGTH"; - - /** - * 付款单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} - */ - public static final String FINANCE_PAYMENT_NO_PREFIX = "FKD"; - /** - * 收款单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} - */ - public static final String FINANCE_RECEIPT_NO_PREFIX = "SKD"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号,使用当前日期,格式为 {PREFIX} + yyyyMMdd + 6 位自增 - * 例如说:QTRK 202109 000001 (没有中间空格) - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN); - String key = RedisKeyConstants.NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofDays(1L)); - return noPrefix + String.format("%06d", no); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/package-info.java deleted file mode 100644 index af7bc123c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 erp 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.erp.framework; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/config/RpcConfiguration.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index c49608e21..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.erp.framework.rpc.config; - -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = AdminUserApi.class) -public class RpcConfiguration { -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/package-info.java deleted file mode 100644 index 9f5d622be..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.erp.framework.rpc; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/config/SecurityConfiguration.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index c1825942e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.erp.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.erp.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Erp 模块的 Security 配置 - */ -@Configuration("erpSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("erpAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").permitAll() - .antMatchers("/actuator/**").permitAll(); - // Druid 监控 - registry.antMatchers("/druid/**").permitAll(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/core/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/core/package-info.java deleted file mode 100644 index f01cc8be5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.erp.framework.security.core; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/package-info.java deleted file mode 100644 index 2608a9889..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * erp 包下,企业资源管理(Enterprise Resource Planning)。 - * 例如说:采购、销售、库存、财务、产品等等 - * - * 1. Controller URL:以 /erp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 erp_ 开头,方便在数据库中区分 - * - * 注意,由于 Erp 模块下,容易和其它模块重名,所以类名都加载 Erp 的前缀~ - */ -package cn.iocoder.yudao.module.erp; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java deleted file mode 100644 index 9ac3221a9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 结算账户 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpAccountService { - - /** - * 创建结算账户 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAccount(@Valid ErpAccountSaveReqVO createReqVO); - - /** - * 更新ERP 结算账户 - * - * @param updateReqVO 更新信息 - */ - void updateAccount(@Valid ErpAccountSaveReqVO updateReqVO); - - /** - * 更新结算账户默认状态 - * - * @param id 编号 - * @param defaultStatus 默认状态 - */ - void updateAccountDefaultStatus(Long id, Boolean defaultStatus); - - /** - * 删除结算账户 - * - * @param id 编号 - */ - void deleteAccount(Long id); - - /** - * 获得结算账户 - * - * @param id 编号 - * @return 结算账户 - */ - ErpAccountDO getAccount(Long id); - - /** - * 校验结算账户 - * - * @param id 编号 - * @return 结算账户 - */ - ErpAccountDO validateAccount(Long id); - - /** - * 获得指定状态的结算账户列表 - * - * @param status 状态 - * @return 结算账户 - */ - List getAccountListByStatus(Integer status); - - /** - * 获得结算账户列表 - * - * @param ids 编号数组 - * @return 结算账户列表 - */ - List getAccountList(Collection ids); - - /** - * 获得结算账户 Map - * - * @param ids 编号数组 - * @return 结算账户 Map - */ - default Map getAccountMap(Collection ids) { - return convertMap(getAccountList(ids), ErpAccountDO::getId); - } - - /** - * 获得结算账户分页 - * - * @param pageReqVO 分页查询 - * @return 结算账户分页 - */ - PageResult getAccountPage(ErpAccountPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java deleted file mode 100644 index 578698b54..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpAccountMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.ACCOUNT_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.ACCOUNT_NOT_EXISTS; - -/** - * ERP 结算账户 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpAccountServiceImpl implements ErpAccountService { - - @Resource - private ErpAccountMapper accountMapper; - - @Override - public Long createAccount(ErpAccountSaveReqVO createReqVO) { - // 插入 - ErpAccountDO account = BeanUtils.toBean(createReqVO, ErpAccountDO.class); - accountMapper.insert(account); - // 返回 - return account.getId(); - } - - @Override - public void updateAccount(ErpAccountSaveReqVO updateReqVO) { - // 校验存在 - validateAccountExists(updateReqVO.getId()); - // 更新 - ErpAccountDO updateObj = BeanUtils.toBean(updateReqVO, ErpAccountDO.class); - accountMapper.updateById(updateObj); - } - - @Override - public void updateAccountDefaultStatus(Long id, Boolean defaultStatus) { - // 1. 校验存在 - validateAccountExists(id); - - // 2.1 如果开启,则需要关闭所有其它的默认 - if (defaultStatus) { - ErpAccountDO account = accountMapper.selectByDefaultStatus(); - if (account != null) { - accountMapper.updateById(new ErpAccountDO().setId(account.getId()).setDefaultStatus(false)); - } - } - // 2.2 更新对应的默认状态 - accountMapper.updateById(new ErpAccountDO().setId(id).setDefaultStatus(defaultStatus)); - } - - @Override - public void deleteAccount(Long id) { - // 校验存在 - validateAccountExists(id); - // 删除 - accountMapper.deleteById(id); - } - - private void validateAccountExists(Long id) { - if (accountMapper.selectById(id) == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - } - - @Override - public ErpAccountDO getAccount(Long id) { - return accountMapper.selectById(id); - } - - @Override - public ErpAccountDO validateAccount(Long id) { - ErpAccountDO account = accountMapper.selectById(id); - if (account == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(account.getStatus())) { - throw exception(ACCOUNT_NOT_ENABLE, account.getName()); - } - return account; - } - - @Override - public List getAccountListByStatus(Integer status) { - return accountMapper.selectListByStatus(status); - } - - @Override - public List getAccountList(Collection ids) { - return accountMapper.selectBatchIds(ids); - } - - @Override - public PageResult getAccountPage(ErpAccountPageReqVO pageReqVO) { - return accountMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java deleted file mode 100644 index 7cad807b2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 付款单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpFinancePaymentService { - - /** - * 创建付款单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createFinancePayment(@Valid ErpFinancePaymentSaveReqVO createReqVO); - - /** - * 更新付款单 - * - * @param updateReqVO 更新信息 - */ - void updateFinancePayment(@Valid ErpFinancePaymentSaveReqVO updateReqVO); - - /** - * 更新付款单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateFinancePaymentStatus(Long id, Integer status); - - /** - * 删除付款单 - * - * @param ids 编号数组 - */ - void deleteFinancePayment(List ids); - - /** - * 获得付款单 - * - * @param id 编号 - * @return 付款单 - */ - ErpFinancePaymentDO getFinancePayment(Long id); - - /** - * 获得付款单分页 - * - * @param pageReqVO 分页查询 - * @return 付款单分页 - */ - PageResult getFinancePaymentPage(ErpFinancePaymentPageReqVO pageReqVO); - - // ==================== 付款单项 ==================== - - /** - * 获得付款单项列表 - * - * @param paymentId 付款单编号 - * @return 付款单项列表 - */ - List getFinancePaymentItemListByPaymentId(Long paymentId); - - /** - * 获得付款单项 List - * - * @param paymentIds 付款单编号数组 - * @return 付款单项 List - */ - List getFinancePaymentItemListByPaymentIds(Collection paymentIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java deleted file mode 100644 index c7ed6b77d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinancePaymentItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinancePaymentMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseInService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseReturnService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 付款单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService { - - @Resource - private ErpFinancePaymentMapper financePaymentMapper; - @Resource - private ErpFinancePaymentItemMapper financePaymentItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpPurchaseInService purchaseInService; - @Resource - private ErpPurchaseReturnService purchaseReturnService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createFinancePayment(ErpFinancePaymentSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List paymentItems = validateFinancePaymentItems( - createReqVO.getSupplierId(), createReqVO.getItems()); - // 1.2 校验供应商 - supplierService.validateSupplier(createReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (createReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(createReqVO.getFinanceUserId()); - } - // 1.5 生成付款单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.FINANCE_PAYMENT_NO_PREFIX); - if (financePaymentMapper.selectByNo(no) != null) { - throw exception(FINANCE_PAYMENT_NO_EXISTS); - } - - // 2.1 插入付款单 - ErpFinancePaymentDO payment = BeanUtils.toBean(createReqVO, ErpFinancePaymentDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(payment, paymentItems); - financePaymentMapper.insert(payment); - // 2.2 插入付款单项 - paymentItems.forEach(o -> o.setPaymentId(payment.getId())); - financePaymentItemMapper.insertBatch(paymentItems); - - // 3. 更新采购入库、退货的付款金额情况 - updatePurchasePrice(paymentItems); - return payment.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinancePayment(ErpFinancePaymentSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpFinancePaymentDO payment = validateFinancePaymentExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(payment.getStatus())) { - throw exception(FINANCE_PAYMENT_UPDATE_FAIL_APPROVE, payment.getNo()); - } - // 1.2 校验供应商 - supplierService.validateSupplier(updateReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (updateReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(updateReqVO.getFinanceUserId()); - } - // 1.5 校验付款单项的有效性 - List paymentItems = validateFinancePaymentItems( - updateReqVO.getSupplierId(), updateReqVO.getItems()); - - // 2.1 更新付款单 - ErpFinancePaymentDO updateObj = BeanUtils.toBean(updateReqVO, ErpFinancePaymentDO.class); - calculateTotalPrice(updateObj, paymentItems); - financePaymentMapper.updateById(updateObj); - // 2.2 更新付款单项 - updateFinancePaymentItemList(updateReqVO.getId(), paymentItems); - } - - private void calculateTotalPrice(ErpFinancePaymentDO payment, List paymentItems) { - payment.setTotalPrice(getSumValue(paymentItems, ErpFinancePaymentItemDO::getPaymentPrice, BigDecimal::add, BigDecimal.ZERO)); - payment.setPaymentPrice(payment.getTotalPrice().subtract(payment.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinancePaymentStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpFinancePaymentDO payment = validateFinancePaymentExists(id); - // 1.2 校验状态 - if (payment.getStatus().equals(status)) { - throw exception(approve ? FINANCE_PAYMENT_APPROVE_FAIL : FINANCE_PAYMENT_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = financePaymentMapper.updateByIdAndStatus(id, payment.getStatus(), - new ErpFinancePaymentDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? FINANCE_PAYMENT_APPROVE_FAIL : FINANCE_PAYMENT_PROCESS_FAIL); - } - } - - private List validateFinancePaymentItems( - Long supplierId, - List list) { - return convertList(list, o -> BeanUtils.toBean(o, ErpFinancePaymentItemDO.class, item -> { - if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.PURCHASE_IN.getType())) { - ErpPurchaseInDO purchaseIn = purchaseInService.validatePurchaseIn(item.getBizId()); - Assert.equals(purchaseIn.getSupplierId(), supplierId, "供应商必须相同"); - item.setTotalPrice(purchaseIn.getTotalPrice()).setBizNo(purchaseIn.getNo()); - } else if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.PURCHASE_RETURN.getType())) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnService.validatePurchaseReturn(item.getBizId()); - Assert.equals(purchaseReturn.getSupplierId(), supplierId, "供应商必须相同"); - item.setTotalPrice(purchaseReturn.getTotalPrice().negate()).setBizNo(purchaseReturn.getNo()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + item.getBizType()); - } - })); - } - - private void updateFinancePaymentItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = financePaymentItemMapper.selectListByPaymentId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setPaymentId(id)); - financePaymentItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - financePaymentItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - financePaymentItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpFinancePaymentItemDO::getId)); - } - - // 第三步,更新采购入库、退货的付款金额情况 - updatePurchasePrice(CollectionUtils.newArrayList(diffList)); - } - - private void updatePurchasePrice(List paymentItems) { - paymentItems.forEach(paymentItem -> { - BigDecimal totalPaymentPrice = financePaymentItemMapper.selectPaymentPriceSumByBizIdAndBizType( - paymentItem.getBizId(), paymentItem.getBizType()); - if (ErpBizTypeEnum.PURCHASE_IN.getType().equals(paymentItem.getBizType())) { - purchaseInService.updatePurchaseInPaymentPrice(paymentItem.getBizId(), totalPaymentPrice); - } else if (ErpBizTypeEnum.PURCHASE_RETURN.getType().equals(paymentItem.getBizType())) { - purchaseReturnService.updatePurchaseReturnRefundPrice(paymentItem.getBizId(), totalPaymentPrice.negate()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + paymentItem.getBizType()); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteFinancePayment(List ids) { - // 1. 校验不处于已审批 - List payments = financePaymentMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(payments)) { - return; - } - payments.forEach(payment -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(payment.getStatus())) { - throw exception(FINANCE_PAYMENT_DELETE_FAIL_APPROVE, payment.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - payments.forEach(payment -> { - // 2.1 删除付款单 - financePaymentMapper.deleteById(payment.getId()); - // 2.2 删除付款单项 - List paymentItems = financePaymentItemMapper.selectListByPaymentId(payment.getId()); - financePaymentItemMapper.deleteBatchIds(convertSet(paymentItems, ErpFinancePaymentItemDO::getId)); - - // 2.3 更新采购入库、退货的付款金额情况 - updatePurchasePrice(paymentItems); - }); - } - - private ErpFinancePaymentDO validateFinancePaymentExists(Long id) { - ErpFinancePaymentDO payment = financePaymentMapper.selectById(id); - if (payment == null) { - throw exception(FINANCE_PAYMENT_NOT_EXISTS); - } - return payment; - } - - @Override - public ErpFinancePaymentDO getFinancePayment(Long id) { - return financePaymentMapper.selectById(id); - } - - @Override - public PageResult getFinancePaymentPage(ErpFinancePaymentPageReqVO pageReqVO) { - return financePaymentMapper.selectPage(pageReqVO); - } - - // ==================== 付款单项 ==================== - - @Override - public List getFinancePaymentItemListByPaymentId(Long paymentId) { - return financePaymentItemMapper.selectListByPaymentId(paymentId); - } - - @Override - public List getFinancePaymentItemListByPaymentIds(Collection paymentIds) { - if (CollUtil.isEmpty(paymentIds)) { - return Collections.emptyList(); - } - return financePaymentItemMapper.selectListByPaymentIds(paymentIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptService.java deleted file mode 100644 index e7bd335c5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 收款单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpFinanceReceiptService { - - /** - * 创建收款单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createFinanceReceipt(@Valid ErpFinanceReceiptSaveReqVO createReqVO); - - /** - * 更新收款单 - * - * @param updateReqVO 更新信息 - */ - void updateFinanceReceipt(@Valid ErpFinanceReceiptSaveReqVO updateReqVO); - - /** - * 更新收款单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateFinanceReceiptStatus(Long id, Integer status); - - /** - * 删除收款单 - * - * @param ids 编号数组 - */ - void deleteFinanceReceipt(List ids); - - /** - * 获得收款单 - * - * @param id 编号 - * @return 收款单 - */ - ErpFinanceReceiptDO getFinanceReceipt(Long id); - - /** - * 获得收款单分页 - * - * @param pageReqVO 分页查询 - * @return 收款单分页 - */ - PageResult getFinanceReceiptPage(ErpFinanceReceiptPageReqVO pageReqVO); - - // ==================== 收款单项 ==================== - - /** - * 获得收款单项列表 - * - * @param receiptId 收款单编号 - * @return 收款单项列表 - */ - List getFinanceReceiptItemListByReceiptId(Long receiptId); - - /** - * 获得收款单项 List - * - * @param receiptIds 收款单编号数组 - * @return 收款单项 List - */ - List getFinanceReceiptItemListByReceiptIds(Collection receiptIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java deleted file mode 100644 index 031043a43..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinanceReceiptItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinanceReceiptMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOutService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleReturnService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 收款单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpFinanceReceiptServiceImpl implements ErpFinanceReceiptService { - - @Resource - private ErpFinanceReceiptMapper financeReceiptMapper; - @Resource - private ErpFinanceReceiptItemMapper financeReceiptItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpCustomerService customerService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpSaleOutService saleOutService; - @Resource - private ErpSaleReturnService saleReturnService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createFinanceReceipt(ErpFinanceReceiptSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List receiptItems = validateFinanceReceiptItems( - createReqVO.getCustomerId(), createReqVO.getItems()); - // 1.2 校验客户 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (createReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(createReqVO.getFinanceUserId()); - } - // 1.5 生成收款单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.FINANCE_RECEIPT_NO_PREFIX); - if (financeReceiptMapper.selectByNo(no) != null) { - throw exception(FINANCE_RECEIPT_NO_EXISTS); - } - - // 2.1 插入收款单 - ErpFinanceReceiptDO receipt = BeanUtils.toBean(createReqVO, ErpFinanceReceiptDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(receipt, receiptItems); - financeReceiptMapper.insert(receipt); - // 2.2 插入收款单项 - receiptItems.forEach(o -> o.setReceiptId(receipt.getId())); - financeReceiptItemMapper.insertBatch(receiptItems); - - // 3. 更新销售出库、退货的收款金额情况 - updateSalePrice(receiptItems); - return receipt.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinanceReceipt(ErpFinanceReceiptSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpFinanceReceiptDO receipt = validateFinanceReceiptExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(receipt.getStatus())) { - throw exception(FINANCE_RECEIPT_UPDATE_FAIL_APPROVE, receipt.getNo()); - } - // 1.2 校验客户 - customerService.validateCustomer(updateReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (updateReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(updateReqVO.getFinanceUserId()); - } - // 1.5 校验收款单项的有效性 - List receiptItems = validateFinanceReceiptItems( - updateReqVO.getCustomerId(), updateReqVO.getItems()); - - // 2.1 更新收款单 - ErpFinanceReceiptDO updateObj = BeanUtils.toBean(updateReqVO, ErpFinanceReceiptDO.class); - calculateTotalPrice(updateObj, receiptItems); - financeReceiptMapper.updateById(updateObj); - // 2.2 更新收款单项 - updateFinanceReceiptItemList(updateReqVO.getId(), receiptItems); - } - - private void calculateTotalPrice(ErpFinanceReceiptDO receipt, List receiptItems) { - receipt.setTotalPrice(getSumValue(receiptItems, ErpFinanceReceiptItemDO::getReceiptPrice, BigDecimal::add, BigDecimal.ZERO)); - receipt.setReceiptPrice(receipt.getTotalPrice().subtract(receipt.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinanceReceiptStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpFinanceReceiptDO receipt = validateFinanceReceiptExists(id); - // 1.2 校验状态 - if (receipt.getStatus().equals(status)) { - throw exception(approve ? FINANCE_RECEIPT_APPROVE_FAIL : FINANCE_RECEIPT_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = financeReceiptMapper.updateByIdAndStatus(id, receipt.getStatus(), - new ErpFinanceReceiptDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? FINANCE_RECEIPT_APPROVE_FAIL : FINANCE_RECEIPT_PROCESS_FAIL); - } - } - - private List validateFinanceReceiptItems( - Long customerId, - List list) { - return convertList(list, o -> BeanUtils.toBean(o, ErpFinanceReceiptItemDO.class, item -> { - if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.SALE_OUT.getType())) { - ErpSaleOutDO saleOut = saleOutService.validateSaleOut(item.getBizId()); - Assert.equals(saleOut.getCustomerId(), customerId, "客户必须相同"); - item.setTotalPrice(saleOut.getTotalPrice()).setBizNo(saleOut.getNo()); - } else if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.SALE_RETURN.getType())) { - ErpSaleReturnDO saleReturn = saleReturnService.validateSaleReturn(item.getBizId()); - Assert.equals(saleReturn.getCustomerId(), customerId, "客户必须相同"); - item.setTotalPrice(saleReturn.getTotalPrice().negate()).setBizNo(saleReturn.getNo()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + item.getBizType()); - } - })); - } - - private void updateFinanceReceiptItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = financeReceiptItemMapper.selectListByReceiptId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setReceiptId(id)); - financeReceiptItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - financeReceiptItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - financeReceiptItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpFinanceReceiptItemDO::getId)); - } - - // 第三步,更新销售出库、退货的收款金额情况 - updateSalePrice(CollectionUtils.newArrayList(diffList)); - } - - private void updateSalePrice(List receiptItems) { - receiptItems.forEach(receiptItem -> { - BigDecimal totalReceiptPrice = financeReceiptItemMapper.selectReceiptPriceSumByBizIdAndBizType( - receiptItem.getBizId(), receiptItem.getBizType()); - if (ErpBizTypeEnum.SALE_OUT.getType().equals(receiptItem.getBizType())) { - saleOutService.updateSaleInReceiptPrice(receiptItem.getBizId(), totalReceiptPrice); - } else if (ErpBizTypeEnum.SALE_RETURN.getType().equals(receiptItem.getBizType())) { - saleReturnService.updateSaleReturnRefundPrice(receiptItem.getBizId(), totalReceiptPrice.negate()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + receiptItem.getBizType()); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteFinanceReceipt(List ids) { - // 1. 校验不处于已审批 - List receipts = financeReceiptMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(receipts)) { - return; - } - receipts.forEach(receipt -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(receipt.getStatus())) { - throw exception(FINANCE_RECEIPT_DELETE_FAIL_APPROVE, receipt.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - receipts.forEach(receipt -> { - // 2.1 删除收款单 - financeReceiptMapper.deleteById(receipt.getId()); - // 2.2 删除收款单项 - List receiptItems = financeReceiptItemMapper.selectListByReceiptId(receipt.getId()); - financeReceiptItemMapper.deleteBatchIds(convertSet(receiptItems, ErpFinanceReceiptItemDO::getId)); - - // 2.3 更新销售出库、退货的收款金额情况 - updateSalePrice(receiptItems); - }); - } - - private ErpFinanceReceiptDO validateFinanceReceiptExists(Long id) { - ErpFinanceReceiptDO receipt = financeReceiptMapper.selectById(id); - if (receipt == null) { - throw exception(FINANCE_RECEIPT_NOT_EXISTS); - } - return receipt; - } - - @Override - public ErpFinanceReceiptDO getFinanceReceipt(Long id) { - return financeReceiptMapper.selectById(id); - } - - @Override - public PageResult getFinanceReceiptPage(ErpFinanceReceiptPageReqVO pageReqVO) { - return financeReceiptMapper.selectPage(pageReqVO); - } - - // ==================== 收款单项 ==================== - - @Override - public List getFinanceReceiptItemListByReceiptId(Long receiptId) { - return financeReceiptItemMapper.selectListByReceiptId(receiptId); - } - - @Override - public List getFinanceReceiptItemListByReceiptIds(Collection receiptIds) { - if (CollUtil.isEmpty(receiptIds)) { - return Collections.emptyList(); - } - return financeReceiptItemMapper.selectListByReceiptIds(receiptIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryService.java deleted file mode 100644 index 2123dc79f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryService.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategorySaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 产品分类 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpProductCategoryService { - - /** - * 创建产品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductCategory(@Valid ErpProductCategorySaveReqVO createReqVO); - - /** - * 更新产品分类 - * - * @param updateReqVO 更新信息 - */ - void updateProductCategory(@Valid ErpProductCategorySaveReqVO updateReqVO); - - /** - * 删除产品分类 - * - * @param id 编号 - */ - void deleteProductCategory(Long id); - - /** - * 获得产品分类 - * - * @param id 编号 - * @return 产品分类 - */ - ErpProductCategoryDO getProductCategory(Long id); - - /** - * 获得产品分类列表 - * - * @param listReqVO 查询条件 - * @return 产品分类列表 - */ - List getProductCategoryList(ErpProductCategoryListReqVO listReqVO); - - /** - * 获得产品分类列表 - * - * @param ids 编号数组 - * @return 产品分类列表 - */ - List getProductCategoryList(Collection ids); - - /** - * 获得产品分类 Map - * - * @param ids 编号数组 - * @return 产品分类 Map - */ - default Map getProductCategoryMap(Collection ids) { - return convertMap(getProductCategoryList(ids), ErpProductCategoryDO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java deleted file mode 100644 index 4b552ac00..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategorySaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductCategoryMapper; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -/** - * ERP 产品分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpProductCategoryServiceImpl implements ErpProductCategoryService { - - @Resource - private ErpProductCategoryMapper erpProductCategoryMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpProductService productService; - - @Override - public Long createProductCategory(ErpProductCategorySaveReqVO createReqVO) { - // 校验父分类编号的有效性 - validateParentProductCategory(null, createReqVO.getParentId()); - // 校验分类名称的唯一性 - validateProductCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); - - // 插入 - ErpProductCategoryDO category = BeanUtils.toBean(createReqVO, ErpProductCategoryDO.class); - erpProductCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateProductCategory(ErpProductCategorySaveReqVO updateReqVO) { - // 校验存在 - validateProductCategoryExists(updateReqVO.getId()); - // 校验父分类编号的有效性 - validateParentProductCategory(updateReqVO.getId(), updateReqVO.getParentId()); - // 校验分类名称的唯一性 - validateProductCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 更新 - ErpProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductCategoryDO.class); - erpProductCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteProductCategory(Long id) { - // 1.1 校验存在 - validateProductCategoryExists(id); - // 1.2 校验是否有子产品分类 - if (erpProductCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(PRODUCT_CATEGORY_EXITS_CHILDREN); - } - // 1.3 校验是否有产品 - if (productService.getProductCountByCategoryId(id) > 0) { - throw exception(PRODUCT_CATEGORY_EXITS_PRODUCT); - } - // 2. 删除 - erpProductCategoryMapper.deleteById(id); - } - - private void validateProductCategoryExists(Long id) { - if (erpProductCategoryMapper.selectById(id) == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - private void validateParentProductCategory(Long id, Long parentId) { - if (parentId == null || ErpProductCategoryDO.PARENT_ID_ROOT.equals(parentId)) { - return; - } - // 1. 不能设置自己为父产品分类 - if (Objects.equals(id, parentId)) { - throw exception(PRODUCT_CATEGORY_PARENT_ERROR); - } - // 2. 父产品分类不存在 - ErpProductCategoryDO parentCategory = erpProductCategoryMapper.selectById(parentId); - if (parentCategory == null) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_EXITS); - } - // 3. 递归校验父产品分类,如果父产品分类是自己的子产品分类,则报错,避免形成环路 - if (id == null) { // id 为空,说明新增,不需要考虑环路 - return; - } - for (int i = 0; i < Short.MAX_VALUE; i++) { - // 3.1 校验环路 - parentId = parentCategory.getParentId(); - if (Objects.equals(id, parentId)) { - throw exception(PRODUCT_CATEGORY_PARENT_IS_CHILD); - } - // 3.2 继续递归下一级父产品分类 - if (parentId == null || ErpProductCategoryDO.PARENT_ID_ROOT.equals(parentId)) { - break; - } - parentCategory = erpProductCategoryMapper.selectById(parentId); - if (parentCategory == null) { - break; - } - } - } - - private void validateProductCategoryNameUnique(Long id, Long parentId, String name) { - ErpProductCategoryDO productCategory = erpProductCategoryMapper.selectByParentIdAndName(parentId, name); - if (productCategory == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的产品分类 - if (id == null) { - throw exception(PRODUCT_CATEGORY_NAME_DUPLICATE); - } - if (!Objects.equals(productCategory.getId(), id)) { - throw exception(PRODUCT_CATEGORY_NAME_DUPLICATE); - } - } - - @Override - public ErpProductCategoryDO getProductCategory(Long id) { - return erpProductCategoryMapper.selectById(id); - } - - @Override - public List getProductCategoryList(ErpProductCategoryListReqVO listReqVO) { - return erpProductCategoryMapper.selectList(listReqVO); - } - - @Override - public List getProductCategoryList(Collection ids) { - return erpProductCategoryMapper.selectBatchIds(ids); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java deleted file mode 100644 index 03b3de9f1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 产品 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpProductService { - - /** - * 创建产品 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProduct(@Valid ProductSaveReqVO createReqVO); - - /** - * 更新产品 - * - * @param updateReqVO 更新信息 - */ - void updateProduct(@Valid ProductSaveReqVO updateReqVO); - - /** - * 删除产品 - * - * @param id 编号 - */ - void deleteProduct(Long id); - - /** - * 校验产品们的有效性 - * - * @param ids 编号数组 - * @return 产品列表 - */ - List validProductList(Collection ids); - - /** - * 获得产品 - * - * @param id 编号 - * @return 产品 - */ - ErpProductDO getProduct(Long id); - - /** - * 获得指定状态的产品 VO 列表 - * - * @param status 状态 - * @return 产品 VO 列表 - */ - List getProductVOListByStatus(Integer status); - - /** - * 获得产品 VO 列表 - * - * @param ids 编号数组 - * @return 产品 VO 列表 - */ - List getProductVOList(Collection ids); - - /** - * 获得产品 VO Map - * - * @param ids 编号数组 - * @return 产品 VO Map - */ - default Map getProductVOMap(Collection ids) { - return convertMap(getProductVOList(ids), ErpProductRespVO::getId); - } - - /** - * 获得产品 VO 分页 - * - * @param pageReqVO 分页查询 - * @return 产品分页 - */ - PageResult getProductVOPage(ErpProductPageReqVO pageReqVO); - - /** - * 基于产品分类编号,获得产品数量 - * - * @param categoryId 产品分类编号 - * @return 产品数量 - */ - Long getProductCountByCategoryId(Long categoryId); - - /** - * 基于产品单位编号,获得产品数量 - * - * @param unitId 产品单位编号 - * @return 产品数量 - */ - Long getProductCountByUnitId(Long unitId); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java deleted file mode 100644 index c264b8e74..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PRODUCT_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS; - -/** - * ERP 产品 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpProductServiceImpl implements ErpProductService { - - @Resource - private ErpProductMapper productMapper; - - @Resource - private ErpProductCategoryService productCategoryService; - @Resource - private ErpProductUnitService productUnitService; - - @Override - public Long createProduct(ProductSaveReqVO createReqVO) { - // TODO 芋艿:校验分类 - // 插入 - ErpProductDO product = BeanUtils.toBean(createReqVO, ErpProductDO.class); - productMapper.insert(product); - // 返回 - return product.getId(); - } - - @Override - public void updateProduct(ProductSaveReqVO updateReqVO) { - // TODO 芋艿:校验分类 - // 校验存在 - validateProductExists(updateReqVO.getId()); - // 更新 - ErpProductDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductDO.class); - productMapper.updateById(updateObj); - } - - @Override - public void deleteProduct(Long id) { - // 校验存在 - validateProductExists(id); - // 删除 - productMapper.deleteById(id); - } - - @Override - public List validProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = productMapper.selectBatchIds(ids); - Map productMap = convertMap(list, ErpProductDO::getId); - for (Long id : ids) { - ErpProductDO product = productMap.get(id); - if (productMap.get(id) == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(product.getStatus())) { - throw exception(PRODUCT_NOT_ENABLE, product.getName()); - } - } - return list; - } - - private void validateProductExists(Long id) { - if (productMapper.selectById(id) == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - } - - @Override - public ErpProductDO getProduct(Long id) { - return productMapper.selectById(id); - } - - @Override - public List getProductVOListByStatus(Integer status) { - List list = productMapper.selectListByStatus(status); - return buildProductVOList(list); - } - - @Override - public List getProductVOList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = productMapper.selectBatchIds(ids); - return buildProductVOList(list); - } - - @Override - public PageResult getProductVOPage(ErpProductPageReqVO pageReqVO) { - PageResult pageResult = productMapper.selectPage(pageReqVO); - return new PageResult<>(buildProductVOList(pageResult.getList()), pageResult.getTotal()); - } - - private List buildProductVOList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - Map categoryMap = productCategoryService.getProductCategoryMap( - convertSet(list, ErpProductDO::getCategoryId)); - Map unitMap = productUnitService.getProductUnitMap( - convertSet(list, ErpProductDO::getUnitId)); - return BeanUtils.toBean(list, ErpProductRespVO.class, product -> { - MapUtils.findAndThen(categoryMap, product.getCategoryId(), - category -> product.setCategoryName(category.getName())); - MapUtils.findAndThen(unitMap, product.getUnitId(), - unit -> product.setUnitName(unit.getName())); - }); - } - - @Override - public Long getProductCountByCategoryId(Long categoryId) { - return productMapper.selectCountByCategoryId(categoryId); - } - - @Override - public Long getProductCountByUnitId(Long unitId) { - return productMapper.selectCountByUnitId(unitId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitService.java deleted file mode 100644 index b425af87b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 产品单位 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpProductUnitService { - - /** - * 创建产品单位 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductUnit(@Valid ErpProductUnitSaveReqVO createReqVO); - - /** - * 更新产品单位 - * - * @param updateReqVO 更新信息 - */ - void updateProductUnit(@Valid ErpProductUnitSaveReqVO updateReqVO); - - /** - * 删除产品单位 - * - * @param id 编号 - */ - void deleteProductUnit(Long id); - - /** - * 获得产品单位 - * - * @param id 编号 - * @return 产品单位 - */ - ErpProductUnitDO getProductUnit(Long id); - - /** - * 获得产品单位分页 - * - * @param pageReqVO 分页查询 - * @return 产品单位分页 - */ - PageResult getProductUnitPage(ErpProductUnitPageReqVO pageReqVO); - - /** - * 获得指定状态的产品单位列表 - * - * @param status 状态 - * @return 产品单位列表 - */ - List getProductUnitListByStatus(Integer status); - - /** - * 获得产品单位列表 - * - * @param ids 编号数组 - * @return 产品单位列表 - */ - List getProductUnitList(Collection ids); - - /** - * 获得产品单位 Map - * - * @param ids 编号数组 - * @return 产品单位 Map - */ - default Map getProductUnitMap(Collection ids) { - return convertMap(getProductUnitList(ids), ErpProductUnitDO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java deleted file mode 100644 index 95497a88b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper; -import com.google.common.annotations.VisibleForTesting; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -/** - * ERP 产品单位 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpProductUnitServiceImpl implements ErpProductUnitService { - - @Resource - private ErpProductUnitMapper productUnitMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpProductService productService; - - @Override - public Long createProductUnit(ErpProductUnitSaveReqVO createReqVO) { - // 1. 校验名字唯一 - validateProductUnitNameUnique(null, createReqVO.getName()); - // 2. 插入 - ErpProductUnitDO unit = BeanUtils.toBean(createReqVO, ErpProductUnitDO.class); - productUnitMapper.insert(unit); - return unit.getId(); - } - - @Override - public void updateProductUnit(ErpProductUnitSaveReqVO updateReqVO) { - // 1.1 校验存在 - validateProductUnitExists(updateReqVO.getId()); - // 1.2 校验名字唯一 - validateProductUnitNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 2. 更新 - ErpProductUnitDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductUnitDO.class); - productUnitMapper.updateById(updateObj); - } - - @VisibleForTesting - void validateProductUnitNameUnique(Long id, String name) { - ErpProductUnitDO unit = productUnitMapper.selectByName(name); - if (unit == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 - if (id == null) { - throw exception(PRODUCT_UNIT_NAME_DUPLICATE); - } - if (!unit.getId().equals(id)) { - throw exception(PRODUCT_UNIT_NAME_DUPLICATE); - } - } - - @Override - public void deleteProductUnit(Long id) { - // 1.1 校验存在 - validateProductUnitExists(id); - // 1.2 校验产品是否使用 - if (productService.getProductCountByUnitId(id) > 0) { - throw exception(PRODUCT_UNIT_EXITS_PRODUCT); - } - // 2. 删除 - productUnitMapper.deleteById(id); - } - - private void validateProductUnitExists(Long id) { - if (productUnitMapper.selectById(id) == null) { - throw exception(PRODUCT_UNIT_NOT_EXISTS); - } - } - - @Override - public ErpProductUnitDO getProductUnit(Long id) { - return productUnitMapper.selectById(id); - } - - @Override - public PageResult getProductUnitPage(ErpProductUnitPageReqVO pageReqVO) { - return productUnitMapper.selectPage(pageReqVO); - } - - @Override - public List getProductUnitListByStatus(Integer status) { - return productUnitMapper.selectListByStatus(status); - } - - @Override - public List getProductUnitList(Collection ids) { - return productUnitMapper.selectBatchIds(ids); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java deleted file mode 100644 index 6256c3425..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 采购入库 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseInService { - - /** - * 创建采购入库 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPurchaseIn(@Valid ErpPurchaseInSaveReqVO createReqVO); - - /** - * 更新采购入库 - * - * @param updateReqVO 更新信息 - */ - void updatePurchaseIn(@Valid ErpPurchaseInSaveReqVO updateReqVO); - - /** - * 更新采购入库的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updatePurchaseInStatus(Long id, Integer status); - - /** - * 更新采购入库的付款金额 - * - * @param id 编号 - * @param paymentPrice 付款金额 - */ - void updatePurchaseInPaymentPrice(Long id, BigDecimal paymentPrice); - - /** - * 删除采购入库 - * - * @param ids 编号数组 - */ - void deletePurchaseIn(List ids); - - /** - * 获得采购入库 - * - * @param id 编号 - * @return 采购入库 - */ - ErpPurchaseInDO getPurchaseIn(Long id); - - /** - * 校验采购入库,已经审核通过 - * - * @param id 编号 - * @return 采购入库 - */ - ErpPurchaseInDO validatePurchaseIn(Long id); - - /** - * 获得采购入库分页 - * - * @param pageReqVO 分页查询 - * @return 采购入库分页 - */ - PageResult getPurchaseInPage(ErpPurchaseInPageReqVO pageReqVO); - - // ==================== 采购入库项 ==================== - - /** - * 获得采购入库项列表 - * - * @param inId 采购入库编号 - * @return 采购入库项列表 - */ - List getPurchaseInItemListByInId(Long inId); - - /** - * 获得采购入库项 List - * - * @param inIds 采购入库编号数组 - * @return 采购入库项 List - */ - List getPurchaseInItemListByInIds(Collection inIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java deleted file mode 100644 index 939a787cc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java +++ /dev/null @@ -1,308 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseInItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseInMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 采购入库 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpPurchaseInServiceImpl implements ErpPurchaseInService { - - @Resource - private ErpPurchaseInMapper purchaseInMapper; - @Resource - private ErpPurchaseInItemMapper purchaseInItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpPurchaseOrderService purchaseOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPurchaseIn(ErpPurchaseInSaveReqVO createReqVO) { - // 1.1 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(createReqVO.getOrderId()); - // 1.2 校验入库项的有效性 - List purchaseInItems = validatePurchaseInItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 生成入库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_IN_NO_PREFIX); - if (purchaseInMapper.selectByNo(no) != null) { - throw exception(PURCHASE_IN_NO_EXISTS); - } - - // 2.1 插入入库 - ErpPurchaseInDO purchaseIn = BeanUtils.toBean(createReqVO, ErpPurchaseInDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(purchaseIn, purchaseInItems); - purchaseInMapper.insert(purchaseIn); - // 2.2 插入入库项 - purchaseInItems.forEach(o -> o.setInId(purchaseIn.getId())); - purchaseInItemMapper.insertBatch(purchaseInItems); - - // 3. 更新采购订单的入库数量 - updatePurchaseOrderInCount(createReqVO.getOrderId()); - return purchaseIn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseIn(ErpPurchaseInSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpPurchaseInDO purchaseIn = validatePurchaseInExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseIn.getStatus())) { - throw exception(PURCHASE_IN_UPDATE_FAIL_APPROVE, purchaseIn.getNo()); - } - // 1.2 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验订单项的有效性 - List purchaseInItems = validatePurchaseInItems(updateReqVO.getItems()); - - // 2.1 更新入库 - ErpPurchaseInDO updateObj = BeanUtils.toBean(updateReqVO, ErpPurchaseInDO.class) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(updateObj, purchaseInItems); - purchaseInMapper.updateById(updateObj); - // 2.2 更新入库项 - updatePurchaseInItemList(updateReqVO.getId(), purchaseInItems); - - // 3.1 更新采购订单的入库数量 - updatePurchaseOrderInCount(updateObj.getOrderId()); - // 3.2 注意:如果采购订单编号变更了,需要更新“老”采购订单的入库数量 - if (ObjectUtil.notEqual(purchaseIn.getOrderId(), updateObj.getOrderId())) { - updatePurchaseOrderInCount(purchaseIn.getOrderId()); - } - } - - private void calculateTotalPrice(ErpPurchaseInDO purchaseIn, List purchaseInItems) { - purchaseIn.setTotalCount(getSumValue(purchaseInItems, ErpPurchaseInItemDO::getCount, BigDecimal::add)); - purchaseIn.setTotalProductPrice(getSumValue(purchaseInItems, ErpPurchaseInItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseIn.setTotalTaxPrice(getSumValue(purchaseInItems, ErpPurchaseInItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseIn.setTotalPrice(purchaseIn.getTotalProductPrice().add(purchaseIn.getTotalTaxPrice())); - // 计算优惠价格 - if (purchaseIn.getDiscountPercent() == null) { - purchaseIn.setDiscountPercent(BigDecimal.ZERO); - } - purchaseIn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseIn.getTotalPrice(), purchaseIn.getDiscountPercent())); - purchaseIn.setTotalPrice(purchaseIn.getTotalPrice().subtract(purchaseIn.getDiscountPrice().add(purchaseIn.getOtherPrice()))); - } - - private void updatePurchaseOrderInCount(Long orderId) { - // 1.1 查询采购订单对应的采购入库单列表 - List purchaseIns = purchaseInMapper.selectListByOrderId(orderId); - // 1.2 查询对应的采购订单项的入库数量 - Map returnCountMap = purchaseInItemMapper.selectOrderItemCountSumMapByInIds( - convertList(purchaseIns, ErpPurchaseInDO::getId)); - // 2. 更新采购订单的入库数量 - purchaseOrderService.updatePurchaseOrderInCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseInStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpPurchaseInDO purchaseIn = validatePurchaseInExists(id); - // 1.2 校验状态 - if (purchaseIn.getStatus().equals(status)) { - throw exception(approve ? PURCHASE_IN_APPROVE_FAIL : PURCHASE_IN_PROCESS_FAIL); - } - // 1.3 校验已付款 - if (!approve && purchaseIn.getPaymentPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_IN_PROCESS_FAIL_EXISTS_PAYMENT); - } - - // 2. 更新状态 - int updateCount = purchaseInMapper.updateByIdAndStatus(id, purchaseIn.getStatus(), - new ErpPurchaseInDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? PURCHASE_IN_APPROVE_FAIL : PURCHASE_IN_PROCESS_FAIL); - } - - // 3. 变更库存 - List purchaseInItems = purchaseInItemMapper.selectListByInId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.PURCHASE_IN.getType() - : ErpStockRecordBizTypeEnum.PURCHASE_IN_CANCEL.getType(); - purchaseInItems.forEach(purchaseInItem -> { - BigDecimal count = approve ? purchaseInItem.getCount() : purchaseInItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - purchaseInItem.getProductId(), purchaseInItem.getWarehouseId(), count, - bizType, purchaseInItem.getInId(), purchaseInItem.getId(), purchaseIn.getNo())); - }); - } - - @Override - public void updatePurchaseInPaymentPrice(Long id, BigDecimal paymentPrice) { - ErpPurchaseInDO purchaseIn = purchaseInMapper.selectById(id); - if (purchaseIn.getPaymentPrice().equals(paymentPrice)) { - return; - } - if (paymentPrice.compareTo(purchaseIn.getTotalPrice()) > 0) { - throw exception(PURCHASE_IN_FAIL_PAYMENT_PRICE_EXCEED, paymentPrice, purchaseIn.getTotalPrice()); - } - purchaseInMapper.updateById(new ErpPurchaseInDO().setId(id).setPaymentPrice(paymentPrice)); - } - - private List validatePurchaseInItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpPurchaseInSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpPurchaseInItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseInItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updatePurchaseInItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = purchaseInItemMapper.selectListByInId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setInId(id)); - purchaseInItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - purchaseInItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - purchaseInItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpPurchaseInItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePurchaseIn(List ids) { - // 1. 校验不处于已审批 - List purchaseIns = purchaseInMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(purchaseIns)) { - return; - } - purchaseIns.forEach(purchaseIn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseIn.getStatus())) { - throw exception(PURCHASE_IN_DELETE_FAIL_APPROVE, purchaseIn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - purchaseIns.forEach(purchaseIn -> { - // 2.1 删除订单 - purchaseInMapper.deleteById(purchaseIn.getId()); - // 2.2 删除订单项 - purchaseInItemMapper.deleteByInId(purchaseIn.getId()); - - // 2.3 更新采购订单的入库数量 - updatePurchaseOrderInCount(purchaseIn.getOrderId()); - }); - - } - - private ErpPurchaseInDO validatePurchaseInExists(Long id) { - ErpPurchaseInDO purchaseIn = purchaseInMapper.selectById(id); - if (purchaseIn == null) { - throw exception(PURCHASE_IN_NOT_EXISTS); - } - return purchaseIn; - } - - @Override - public ErpPurchaseInDO getPurchaseIn(Long id) { - return purchaseInMapper.selectById(id); - } - - @Override - public ErpPurchaseInDO validatePurchaseIn(Long id) { - ErpPurchaseInDO purchaseIn = validatePurchaseInExists(id); - if (ObjectUtil.notEqual(purchaseIn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(PURCHASE_IN_NOT_APPROVE); - } - return purchaseIn; - } - - @Override - public PageResult getPurchaseInPage(ErpPurchaseInPageReqVO pageReqVO) { - return purchaseInMapper.selectPage(pageReqVO); - } - - // ==================== 采购入库项 ==================== - - @Override - public List getPurchaseInItemListByInId(Long inId) { - return purchaseInItemMapper.selectListByInId(inId); - } - - @Override - public List getPurchaseInItemListByInIds(Collection inIds) { - if (CollUtil.isEmpty(inIds)) { - return Collections.emptyList(); - } - return purchaseInItemMapper.selectListByInIds(inIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderService.java deleted file mode 100644 index 2b220e57f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 采购订单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseOrderService { - - /** - * 创建采购订单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPurchaseOrder(@Valid ErpPurchaseOrderSaveReqVO createReqVO); - - /** - * 更新采购订单 - * - * @param updateReqVO 更新信息 - */ - void updatePurchaseOrder(@Valid ErpPurchaseOrderSaveReqVO updateReqVO); - - /** - * 更新采购订单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updatePurchaseOrderStatus(Long id, Integer status); - - /** - * 更新采购订单的入库数量 - * - * @param id 编号 - * @param inCountMap 入库数量 Map:key 采购订单项编号;value 入库数量 - */ - void updatePurchaseOrderInCount(Long id, Map inCountMap); - - /** - * 更新采购订单的退货数量 - * - * @param orderId 编号 - * @param returnCountMap 退货数量 Map:key 采购订单项编号;value 退货数量 - */ - void updatePurchaseOrderReturnCount(Long orderId, Map returnCountMap); - - /** - * 删除采购订单 - * - * @param ids 编号数组 - */ - void deletePurchaseOrder(List ids); - - /** - * 获得采购订单 - * - * @param id 编号 - * @return 采购订单 - */ - ErpPurchaseOrderDO getPurchaseOrder(Long id); - - /** - * 校验采购订单,已经审核通过 - * - * @param id 编号 - * @return 采购订单 - */ - ErpPurchaseOrderDO validatePurchaseOrder(Long id); - - /** - * 获得采购订单分页 - * - * @param pageReqVO 分页查询 - * @return 采购订单分页 - */ - PageResult getPurchaseOrderPage(ErpPurchaseOrderPageReqVO pageReqVO); - - // ==================== 采购订单项 ==================== - - /** - * 获得采购订单项列表 - * - * @param orderId 采购订单编号 - * @return 采购订单项列表 - */ - List getPurchaseOrderItemListByOrderId(Long orderId); - - /** - * 获得采购订单项 List - * - * @param orderIds 采购订单编号数组 - * @return 采购订单项 List - */ - List getPurchaseOrderItemListByOrderIds(Collection orderIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java deleted file mode 100644 index c585490b9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java +++ /dev/null @@ -1,295 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseOrderItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseOrderMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 采购订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService { - - @Resource - private ErpPurchaseOrderMapper purchaseOrderMapper; - @Resource - private ErpPurchaseOrderItemMapper purchaseOrderItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpAccountService accountService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPurchaseOrder(ErpPurchaseOrderSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List purchaseOrderItems = validatePurchaseOrderItems(createReqVO.getItems()); - // 1.2 校验供应商 - supplierService.validateSupplier(createReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 生成订单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_ORDER_NO_PREFIX); - if (purchaseOrderMapper.selectByNo(no) != null) { - throw exception(PURCHASE_ORDER_NO_EXISTS); - } - - // 2.1 插入订单 - ErpPurchaseOrderDO purchaseOrder = BeanUtils.toBean(createReqVO, ErpPurchaseOrderDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(purchaseOrder, purchaseOrderItems); - purchaseOrderMapper.insert(purchaseOrder); - // 2.2 插入订单项 - purchaseOrderItems.forEach(o -> o.setOrderId(purchaseOrder.getId())); - purchaseOrderItemMapper.insertBatch(purchaseOrderItems); - return purchaseOrder.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseOrder(ErpPurchaseOrderSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseOrder.getStatus())) { - throw exception(PURCHASE_ORDER_UPDATE_FAIL_APPROVE, purchaseOrder.getNo()); - } - // 1.2 校验供应商 - supplierService.validateSupplier(updateReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验订单项的有效性 - List purchaseOrderItems = validatePurchaseOrderItems(updateReqVO.getItems()); - - // 2.1 更新订单 - ErpPurchaseOrderDO updateObj = BeanUtils.toBean(updateReqVO, ErpPurchaseOrderDO.class); - calculateTotalPrice(updateObj, purchaseOrderItems); - purchaseOrderMapper.updateById(updateObj); - // 2.2 更新订单项 - updatePurchaseOrderItemList(updateReqVO.getId(), purchaseOrderItems); - } - - private void calculateTotalPrice(ErpPurchaseOrderDO purchaseOrder, List purchaseOrderItems) { - purchaseOrder.setTotalCount(getSumValue(purchaseOrderItems, ErpPurchaseOrderItemDO::getCount, BigDecimal::add)); - purchaseOrder.setTotalProductPrice(getSumValue(purchaseOrderItems, ErpPurchaseOrderItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseOrder.setTotalTaxPrice(getSumValue(purchaseOrderItems, ErpPurchaseOrderItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseOrder.setTotalPrice(purchaseOrder.getTotalProductPrice().add(purchaseOrder.getTotalTaxPrice())); - // 计算优惠价格 - if (purchaseOrder.getDiscountPercent() == null) { - purchaseOrder.setDiscountPercent(BigDecimal.ZERO); - } - purchaseOrder.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseOrder.getTotalPrice(), purchaseOrder.getDiscountPercent())); - purchaseOrder.setTotalPrice(purchaseOrder.getTotalPrice().subtract(purchaseOrder.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseOrderStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(id); - // 1.2 校验状态 - if (purchaseOrder.getStatus().equals(status)) { - throw exception(approve ? PURCHASE_ORDER_APPROVE_FAIL : PURCHASE_ORDER_PROCESS_FAIL); - } - // 1.3 存在采购入单,无法反审核 - if (!approve && purchaseOrder.getInCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_ORDER_PROCESS_FAIL_EXISTS_IN); - } - // 1.4 存在采购退货单,无法反审核 - if (!approve && purchaseOrder.getReturnCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_ORDER_PROCESS_FAIL_EXISTS_RETURN); - } - - // 2. 更新状态 - int updateCount = purchaseOrderMapper.updateByIdAndStatus(id, purchaseOrder.getStatus(), - new ErpPurchaseOrderDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? PURCHASE_ORDER_APPROVE_FAIL : PURCHASE_ORDER_PROCESS_FAIL); - } - } - - private List validatePurchaseOrderItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpPurchaseOrderSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpPurchaseOrderItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseOrderItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updatePurchaseOrderItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = purchaseOrderItemMapper.selectListByOrderId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOrderId(id)); - purchaseOrderItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - purchaseOrderItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - purchaseOrderItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpPurchaseOrderItemDO::getId)); - } - } - - @Override - public void updatePurchaseOrderInCount(Long id, Map inCountMap) { - List orderItems = purchaseOrderItemMapper.selectListByOrderId(id); - // 1. 更新每个采购订单项 - orderItems.forEach(item -> { - BigDecimal inCount = inCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getInCount().equals(inCount)) { - return; - } - if (inCount.compareTo(item.getCount()) > 0) { - throw exception(PURCHASE_ORDER_ITEM_IN_FAIL_PRODUCT_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getCount()); - } - purchaseOrderItemMapper.updateById(new ErpPurchaseOrderItemDO().setId(item.getId()).setInCount(inCount)); - }); - // 2. 更新采购订单 - BigDecimal totalInCount = getSumValue(inCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - purchaseOrderMapper.updateById(new ErpPurchaseOrderDO().setId(id).setInCount(totalInCount)); - } - - @Override - public void updatePurchaseOrderReturnCount(Long orderId, Map returnCountMap) { - List orderItems = purchaseOrderItemMapper.selectListByOrderId(orderId); - // 1. 更新每个采购订单项 - orderItems.forEach(item -> { - BigDecimal returnCount = returnCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getReturnCount().equals(returnCount)) { - return; - } - if (returnCount.compareTo(item.getInCount()) > 0) { - throw exception(PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getInCount()); - } - purchaseOrderItemMapper.updateById(new ErpPurchaseOrderItemDO().setId(item.getId()).setReturnCount(returnCount)); - }); - // 2. 更新采购订单 - BigDecimal totalReturnCount = getSumValue(returnCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - purchaseOrderMapper.updateById(new ErpPurchaseOrderDO().setId(orderId).setReturnCount(totalReturnCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePurchaseOrder(List ids) { - // 1. 校验不处于已审批 - List purchaseOrders = purchaseOrderMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(purchaseOrders)) { - return; - } - purchaseOrders.forEach(purchaseOrder -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseOrder.getStatus())) { - throw exception(PURCHASE_ORDER_DELETE_FAIL_APPROVE, purchaseOrder.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - purchaseOrders.forEach(purchaseOrder -> { - // 2.1 删除订单 - purchaseOrderMapper.deleteById(purchaseOrder.getId()); - // 2.2 删除订单项 - purchaseOrderItemMapper.deleteByOrderId(purchaseOrder.getId()); - }); - } - - private ErpPurchaseOrderDO validatePurchaseOrderExists(Long id) { - ErpPurchaseOrderDO purchaseOrder = purchaseOrderMapper.selectById(id); - if (purchaseOrder == null) { - throw exception(PURCHASE_ORDER_NOT_EXISTS); - } - return purchaseOrder; - } - - @Override - public ErpPurchaseOrderDO getPurchaseOrder(Long id) { - return purchaseOrderMapper.selectById(id); - } - - @Override - public ErpPurchaseOrderDO validatePurchaseOrder(Long id) { - ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(id); - if (ObjectUtil.notEqual(purchaseOrder.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(PURCHASE_ORDER_NOT_APPROVE); - } - return purchaseOrder; - } - - @Override - public PageResult getPurchaseOrderPage(ErpPurchaseOrderPageReqVO pageReqVO) { - return purchaseOrderMapper.selectPage(pageReqVO); - } - - // ==================== 订单项 ==================== - - @Override - public List getPurchaseOrderItemListByOrderId(Long orderId) { - return purchaseOrderItemMapper.selectListByOrderId(orderId); - } - - @Override - public List getPurchaseOrderItemListByOrderIds(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return purchaseOrderItemMapper.selectListByOrderIds(orderIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java deleted file mode 100644 index 9e157925b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 采购退货 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseReturnService { - - /** - * 创建采购退货 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPurchaseReturn(@Valid ErpPurchaseReturnSaveReqVO createReqVO); - - /** - * 更新采购退货 - * - * @param updateReqVO 更新信息 - */ - void updatePurchaseReturn(@Valid ErpPurchaseReturnSaveReqVO updateReqVO); - - /** - * 更新采购退货的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updatePurchaseReturnStatus(Long id, Integer status); - - /** - * 更新采购退货的退款金额 - * - * @param id 编号 - * @param refundPrice 退款金额 - */ - void updatePurchaseReturnRefundPrice(Long id, BigDecimal refundPrice); - - /** - * 删除采购退货 - * - * @param ids 编号数组 - */ - void deletePurchaseReturn(List ids); - - /** - * 获得采购退货 - * - * @param id 编号 - * @return 采购退货 - */ - ErpPurchaseReturnDO getPurchaseReturn(Long id); - - /** - * 校验采购退货,已经审核通过 - * - * @param id 编号 - * @return 采购退货 - */ - ErpPurchaseReturnDO validatePurchaseReturn(Long id); - - /** - * 获得采购退货分页 - * - * @param pageReqVO 分页查询 - * @return 采购退货分页 - */ - PageResult getPurchaseReturnPage(ErpPurchaseReturnPageReqVO pageReqVO); - - // ==================== 采购退货项 ==================== - - /** - * 获得采购退货项列表 - * - * @param returnId 采购退货编号 - * @return 采购退货项列表 - */ - List getPurchaseReturnItemListByReturnId(Long returnId); - - /** - * 获得采购退货项 List - * - * @param returnIds 采购退货编号数组 - * @return 采购退货项 List - */ - List getPurchaseReturnItemListByReturnIds(Collection returnIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java deleted file mode 100644 index 94e8af802..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java +++ /dev/null @@ -1,304 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseReturnItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseReturnMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 采购退货 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { - - @Resource - private ErpPurchaseReturnMapper purchaseReturnMapper; - @Resource - private ErpPurchaseReturnItemMapper purchaseReturnItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpPurchaseOrderService purchaseOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPurchaseReturn(ErpPurchaseReturnSaveReqVO createReqVO) { - // 1.1 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(createReqVO.getOrderId()); - // 1.2 校验退货项的有效性 - List purchaseReturnItems = validatePurchaseReturnItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 生成退货单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_RETURN_NO_PREFIX); - if (purchaseReturnMapper.selectByNo(no) != null) { - throw exception(PURCHASE_RETURN_NO_EXISTS); - } - - // 2.1 插入退货 - ErpPurchaseReturnDO purchaseReturn = BeanUtils.toBean(createReqVO, ErpPurchaseReturnDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(purchaseReturn, purchaseReturnItems); - purchaseReturnMapper.insert(purchaseReturn); - // 2.2 插入退货项 - purchaseReturnItems.forEach(o -> o.setReturnId(purchaseReturn.getId())); - purchaseReturnItemMapper.insertBatch(purchaseReturnItems); - - // 3. 更新采购订单的退货数量 - updatePurchaseOrderReturnCount(createReqVO.getOrderId()); - return purchaseReturn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseReturn(ErpPurchaseReturnSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpPurchaseReturnDO purchaseReturn = validatePurchaseReturnExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseReturn.getStatus())) { - throw exception(PURCHASE_RETURN_UPDATE_FAIL_APPROVE, purchaseReturn.getNo()); - } - // 1.2 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验订单项的有效性 - List purchaseReturnItems = validatePurchaseReturnItems(updateReqVO.getItems()); - - // 2.1 更新退货 - ErpPurchaseReturnDO updateObj = BeanUtils.toBean(updateReqVO, ErpPurchaseReturnDO.class) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(updateObj, purchaseReturnItems); - purchaseReturnMapper.updateById(updateObj); - // 2.2 更新退货项 - updatePurchaseReturnItemList(updateReqVO.getId(), purchaseReturnItems); - - // 3.1 更新采购订单的出库数量 - updatePurchaseOrderReturnCount(updateObj.getOrderId()); - // 3.2 注意:如果采购订单编号变更了,需要更新“老”采购订单的出库数量 - if (ObjectUtil.notEqual(purchaseReturn.getOrderId(), updateObj.getOrderId())) { - updatePurchaseOrderReturnCount(purchaseReturn.getOrderId()); - } - } - - private void calculateTotalPrice(ErpPurchaseReturnDO purchaseReturn, List purchaseReturnItems) { - purchaseReturn.setTotalCount(getSumValue(purchaseReturnItems, ErpPurchaseReturnItemDO::getCount, BigDecimal::add)); - purchaseReturn.setTotalProductPrice(getSumValue(purchaseReturnItems, ErpPurchaseReturnItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseReturn.setTotalTaxPrice(getSumValue(purchaseReturnItems, ErpPurchaseReturnItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseReturn.setTotalPrice(purchaseReturn.getTotalProductPrice().add(purchaseReturn.getTotalTaxPrice())); - // 计算优惠价格 - if (purchaseReturn.getDiscountPercent() == null) { - purchaseReturn.setDiscountPercent(BigDecimal.ZERO); - } - purchaseReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseReturn.getTotalPrice(), purchaseReturn.getDiscountPercent())); - purchaseReturn.setTotalPrice(purchaseReturn.getTotalPrice().subtract(purchaseReturn.getDiscountPrice().add(purchaseReturn.getOtherPrice()))); - } - - private void updatePurchaseOrderReturnCount(Long orderId) { - // 1.1 查询采购订单对应的采购出库单列表 - List purchaseReturns = purchaseReturnMapper.selectListByOrderId(orderId); - // 1.2 查询对应的采购订单项的退货数量 - Map returnCountMap = purchaseReturnItemMapper.selectOrderItemCountSumMapByReturnIds( - convertList(purchaseReturns, ErpPurchaseReturnDO::getId)); - // 2. 更新采购订单的出库数量 - purchaseOrderService.updatePurchaseOrderReturnCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseReturnStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpPurchaseReturnDO purchaseReturn = validatePurchaseReturnExists(id); - // 1.2 校验状态 - if (purchaseReturn.getStatus().equals(status)) { - throw exception(approve ? PURCHASE_RETURN_APPROVE_FAIL : PURCHASE_RETURN_PROCESS_FAIL); - } - // 1.3 校验已退款 - if (!approve && purchaseReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_RETURN_PROCESS_FAIL_EXISTS_REFUND); - } - - // 2. 更新状态 - int updateCount = purchaseReturnMapper.updateByIdAndStatus(id, purchaseReturn.getStatus(), - new ErpPurchaseReturnDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? PURCHASE_RETURN_APPROVE_FAIL : PURCHASE_RETURN_PROCESS_FAIL); - } - - // 3. 变更库存 - List purchaseReturnItems = purchaseReturnItemMapper.selectListByReturnId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.PURCHASE_RETURN.getType() - : ErpStockRecordBizTypeEnum.PURCHASE_RETURN_CANCEL.getType(); - purchaseReturnItems.forEach(purchaseReturnItem -> { - BigDecimal count = approve ? purchaseReturnItem.getCount().negate() : purchaseReturnItem.getCount(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - purchaseReturnItem.getProductId(), purchaseReturnItem.getWarehouseId(), count, - bizType, purchaseReturnItem.getReturnId(), purchaseReturnItem.getId(), purchaseReturn.getNo())); - }); - } - - @Override - public void updatePurchaseReturnRefundPrice(Long id, BigDecimal refundPrice) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnMapper.selectById(id); - if (purchaseReturn.getRefundPrice().equals(refundPrice)) { - return; - } - if (refundPrice.compareTo(purchaseReturn.getTotalPrice()) > 0) { - throw exception(PURCHASE_RETURN_FAIL_REFUND_PRICE_EXCEED, refundPrice, purchaseReturn.getTotalPrice()); - } - purchaseReturnMapper.updateById(new ErpPurchaseReturnDO().setId(id).setRefundPrice(refundPrice)); - } - - private List validatePurchaseReturnItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpPurchaseReturnSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpPurchaseReturnItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseReturnItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updatePurchaseReturnItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = purchaseReturnItemMapper.selectListByReturnId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setReturnId(id)); - purchaseReturnItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - purchaseReturnItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - purchaseReturnItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpPurchaseReturnItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePurchaseReturn(List ids) { - // 1. 校验不处于已审批 - List purchaseReturns = purchaseReturnMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(purchaseReturns)) { - return; - } - purchaseReturns.forEach(purchaseReturn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseReturn.getStatus())) { - throw exception(PURCHASE_RETURN_DELETE_FAIL_APPROVE, purchaseReturn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - purchaseReturns.forEach(purchaseReturn -> { - // 2.1 删除订单 - purchaseReturnMapper.deleteById(purchaseReturn.getId()); - // 2.2 删除订单项 - purchaseReturnItemMapper.deleteByReturnId(purchaseReturn.getId()); - - // 2.3 更新采购订单的出库数量 - updatePurchaseOrderReturnCount(purchaseReturn.getOrderId()); - }); - - } - - private ErpPurchaseReturnDO validatePurchaseReturnExists(Long id) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnMapper.selectById(id); - if (purchaseReturn == null) { - throw exception(PURCHASE_RETURN_NOT_EXISTS); - } - return purchaseReturn; - } - - @Override - public ErpPurchaseReturnDO getPurchaseReturn(Long id) { - return purchaseReturnMapper.selectById(id); - } - - @Override - public ErpPurchaseReturnDO validatePurchaseReturn(Long id) { - ErpPurchaseReturnDO purchaseReturn = getPurchaseReturn(id); - if (ObjectUtil.notEqual(purchaseReturn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(PURCHASE_RETURN_NOT_APPROVE); - } - return purchaseReturn; - } - - @Override - public PageResult getPurchaseReturnPage(ErpPurchaseReturnPageReqVO pageReqVO) { - return purchaseReturnMapper.selectPage(pageReqVO); - } - - // ==================== 采购退货项 ==================== - - @Override - public List getPurchaseReturnItemListByReturnId(Long returnId) { - return purchaseReturnItemMapper.selectListByReturnId(returnId); - } - - @Override - public List getPurchaseReturnItemListByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyList(); - } - return purchaseReturnItemMapper.selectListByReturnIds(returnIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java deleted file mode 100644 index 71487e40e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 供应商 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSupplierService { - - /** - * 创建供应商 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSupplier(@Valid ErpSupplierSaveReqVO createReqVO); - - /** - * 更新供应商 - * - * @param updateReqVO 更新信息 - */ - void updateSupplier(@Valid ErpSupplierSaveReqVO updateReqVO); - - /** - * 删除供应商 - * - * @param id 编号 - */ - void deleteSupplier(Long id); - - /** - * 获得供应商 - * - * @param id 编号 - * @return 供应商 - */ - ErpSupplierDO getSupplier(Long id); - - /** - * 校验供应商 - * - * @param id 编号 - * @return 供应商 - */ - ErpSupplierDO validateSupplier(Long id); - - /** - * 获得供应商列表 - * - * @param ids 编号列表 - * @return 供应商列表 - */ - List getSupplierList(Collection ids); - - /** - * 获得供应商 Map - * - * @param ids 编号列表 - * @return 供应商 Map - */ - default Map getSupplierMap(Collection ids) { - return convertMap(getSupplierList(ids), ErpSupplierDO::getId); - } - - /** - * 获得供应商分页 - * - * @param pageReqVO 分页查询 - * @return 供应商分页 - */ - PageResult getSupplierPage(ErpSupplierPageReqVO pageReqVO); - - /** - * 获得指定状态的供应商列表 - * - * @param status 状态 - * @return 供应商列表 - */ - List getSupplierListByStatus(Integer status); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java deleted file mode 100644 index 6dfbb52d4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.SUPPLIER_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.SUPPLIER_NOT_EXISTS; - -/** - * ERP 供应商 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSupplierServiceImpl implements ErpSupplierService { - - @Resource - private ErpSupplierMapper supplierMapper; - - @Override - public Long createSupplier(ErpSupplierSaveReqVO createReqVO) { - ErpSupplierDO supplier = BeanUtils.toBean(createReqVO, ErpSupplierDO.class); - supplierMapper.insert(supplier); - return supplier.getId(); - } - - @Override - public void updateSupplier(ErpSupplierSaveReqVO updateReqVO) { - // 校验存在 - validateSupplierExists(updateReqVO.getId()); - // 更新 - ErpSupplierDO updateObj = BeanUtils.toBean(updateReqVO, ErpSupplierDO.class); - supplierMapper.updateById(updateObj); - } - - @Override - public void deleteSupplier(Long id) { - // 校验存在 - validateSupplierExists(id); - // 删除 - supplierMapper.deleteById(id); - } - - private void validateSupplierExists(Long id) { - if (supplierMapper.selectById(id) == null) { - throw exception(SUPPLIER_NOT_EXISTS); - } - } - - @Override - public ErpSupplierDO getSupplier(Long id) { - return supplierMapper.selectById(id); - } - - @Override - public ErpSupplierDO validateSupplier(Long id) { - ErpSupplierDO supplier = supplierMapper.selectById(id); - if (supplier == null) { - throw exception(SUPPLIER_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(supplier.getStatus())) { - throw exception(SUPPLIER_NOT_ENABLE, supplier.getName()); - } - return supplier; - } - - @Override - public List getSupplierList(Collection ids) { - return supplierMapper.selectBatchIds(ids); - } - - @Override - public PageResult getSupplierPage(ErpSupplierPageReqVO pageReqVO) { - return supplierMapper.selectPage(pageReqVO); - } - - @Override - public List getSupplierListByStatus(Integer status) { - return supplierMapper.selectListByStatus(status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java deleted file mode 100644 index 694634b8f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 客户 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpCustomerService { - - /** - * 创建客户 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCustomer(@Valid ErpCustomerSaveReqVO createReqVO); - - /** - * 更新客户 - * - * @param updateReqVO 更新信息 - */ - void updateCustomer(@Valid ErpCustomerSaveReqVO updateReqVO); - - /** - * 删除客户 - * - * @param id 编号 - */ - void deleteCustomer(Long id); - - /** - * 获得客户 - * - * @param id 编号 - * @return 客户 - */ - ErpCustomerDO getCustomer(Long id); - - /** - * 校验客户 - * - * @param id 编号 - * @return 客户 - */ - ErpCustomerDO validateCustomer(Long id); - - /** - * 获得客户列表 - * - * @param ids 编号列表 - * @return 客户列表 - */ - List getCustomerList(Collection ids); - - /** - * 获得客户 Map - * - * @param ids 编号列表 - * @return 客户 Map - */ - default Map getCustomerMap(Collection ids) { - return convertMap(getCustomerList(ids), ErpCustomerDO::getId); - } - - /** - * 获得客户分页 - * - * @param pageReqVO 分页查询 - * @return 客户分页 - */ - PageResult getCustomerPage(ErpCustomerPageReqVO pageReqVO); - - /** - * 获得指定状态的客户列表 - * - * @param status 状态 - * @return 客户列表 - */ - List getCustomerListByStatus(Integer status); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java deleted file mode 100644 index 7df07fb39..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpCustomerMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.CUSTOMER_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; - -/** - * ERP 客户 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpCustomerServiceImpl implements ErpCustomerService { - - @Resource - private ErpCustomerMapper customerMapper; - - @Override - public Long createCustomer(ErpCustomerSaveReqVO createReqVO) { - // 插入 - ErpCustomerDO customer = BeanUtils.toBean(createReqVO, ErpCustomerDO.class); - customerMapper.insert(customer); - // 返回 - return customer.getId(); - } - - @Override - public void updateCustomer(ErpCustomerSaveReqVO updateReqVO) { - // 校验存在 - validateCustomerExists(updateReqVO.getId()); - // 更新 - ErpCustomerDO updateObj = BeanUtils.toBean(updateReqVO, ErpCustomerDO.class); - customerMapper.updateById(updateObj); - } - - @Override - public void deleteCustomer(Long id) { - // 校验存在 - validateCustomerExists(id); - // 删除 - customerMapper.deleteById(id); - } - - private void validateCustomerExists(Long id) { - if (customerMapper.selectById(id) == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - } - - @Override - public ErpCustomerDO getCustomer(Long id) { - return customerMapper.selectById(id); - } - - @Override - public ErpCustomerDO validateCustomer(Long id) { - ErpCustomerDO customer = customerMapper.selectById(id); - if (customer == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(customer.getStatus())) { - throw exception(CUSTOMER_NOT_ENABLE, customer.getName()); - } - return customer; - } - - @Override - public List getCustomerList(Collection ids) { - return customerMapper.selectBatchIds(ids); - } - - @Override - public PageResult getCustomerPage(ErpCustomerPageReqVO pageReqVO) { - return customerMapper.selectPage(pageReqVO); - } - - @Override - public List getCustomerListByStatus(Integer status) { - return customerMapper.selectListByStatus(status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.java deleted file mode 100644 index 1a2e0546a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 销售订单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleOrderService { - - /** - * 创建销售订单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSaleOrder(@Valid ErpSaleOrderSaveReqVO createReqVO); - - /** - * 更新销售订单 - * - * @param updateReqVO 更新信息 - */ - void updateSaleOrder(@Valid ErpSaleOrderSaveReqVO updateReqVO); - - /** - * 更新销售订单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateSaleOrderStatus(Long id, Integer status); - - /** - * 更新销售订单的出库数量 - * - * @param id 编号 - * @param outCountMap 出库数量 Map:key 销售订单项编号;value 出库数量 - */ - void updateSaleOrderOutCount(Long id, Map outCountMap); - - /** - * 更新销售订单的退货数量 - * - * @param orderId 编号 - * @param returnCountMap 退货数量 Map:key 销售订单项编号;value 退货数量 - */ - void updateSaleOrderReturnCount(Long orderId, Map returnCountMap); - - /** - * 删除销售订单 - * - * @param ids 编号数组 - */ - void deleteSaleOrder(List ids); - - /** - * 获得销售订单 - * - * @param id 编号 - * @return 销售订单 - */ - ErpSaleOrderDO getSaleOrder(Long id); - - /** - * 校验销售订单,已经审核通过 - * - * @param id 编号 - * @return 销售订单 - */ - ErpSaleOrderDO validateSaleOrder(Long id); - - /** - * 获得销售订单分页 - * - * @param pageReqVO 分页查询 - * @return 销售订单分页 - */ - PageResult getSaleOrderPage(ErpSaleOrderPageReqVO pageReqVO); - - // ==================== 销售订单项 ==================== - - /** - * 获得销售订单项列表 - * - * @param orderId 销售订单编号 - * @return 销售订单项列表 - */ - List getSaleOrderItemListByOrderId(Long orderId); - - /** - * 获得销售订单项 List - * - * @param orderIds 销售订单编号数组 - * @return 销售订单项 List - */ - List getSaleOrderItemListByOrderIds(Collection orderIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java deleted file mode 100644 index 7c25d067e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java +++ /dev/null @@ -1,307 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 销售订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { - - @Resource - private ErpSaleOrderMapper saleOrderMapper; - @Resource - private ErpSaleOrderItemMapper saleOrderItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - @Resource - private ErpAccountService accountService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List saleOrderItems = validateSaleOrderItems(createReqVO.getItems()); - // 1.2 校验客户 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 校验销售人员 - if (createReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(createReqVO.getSaleUserId()); - } - // 1.5 生成订单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_ORDER_NO_PREFIX); - if (saleOrderMapper.selectByNo(no) != null) { - throw exception(SALE_ORDER_NO_EXISTS); - } - - // 2.1 插入订单 - ErpSaleOrderDO saleOrder = BeanUtils.toBean(createReqVO, ErpSaleOrderDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(saleOrder, saleOrderItems); - saleOrderMapper.insert(saleOrder); - // 2.2 插入订单项 - saleOrderItems.forEach(o -> o.setOrderId(saleOrder.getId())); - saleOrderItemMapper.insertBatch(saleOrderItems); - return saleOrder.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOrder(ErpSaleOrderSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpSaleOrderDO saleOrder = validateSaleOrderExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOrder.getStatus())) { - throw exception(SALE_ORDER_UPDATE_FAIL_APPROVE, saleOrder.getNo()); - } - // 1.2 校验客户 - customerService.validateCustomer(updateReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验销售人员 - if (updateReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(updateReqVO.getSaleUserId()); - } - // 1.5 校验订单项的有效性 - List saleOrderItems = validateSaleOrderItems(updateReqVO.getItems()); - - // 2.1 更新订单 - ErpSaleOrderDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleOrderDO.class); - calculateTotalPrice(updateObj, saleOrderItems); - saleOrderMapper.updateById(updateObj); - // 2.2 更新订单项 - updateSaleOrderItemList(updateReqVO.getId(), saleOrderItems); - } - - private void calculateTotalPrice(ErpSaleOrderDO saleOrder, List saleOrderItems) { - saleOrder.setTotalCount(getSumValue(saleOrderItems, ErpSaleOrderItemDO::getCount, BigDecimal::add)); - saleOrder.setTotalProductPrice(getSumValue(saleOrderItems, ErpSaleOrderItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOrder.setTotalTaxPrice(getSumValue(saleOrderItems, ErpSaleOrderItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOrder.setTotalPrice(saleOrder.getTotalProductPrice().add(saleOrder.getTotalTaxPrice())); - // 计算优惠价格 - if (saleOrder.getDiscountPercent() == null) { - saleOrder.setDiscountPercent(BigDecimal.ZERO); - } - saleOrder.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOrder.getTotalPrice(), saleOrder.getDiscountPercent())); - saleOrder.setTotalPrice(saleOrder.getTotalPrice().subtract(saleOrder.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOrderStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpSaleOrderDO saleOrder = validateSaleOrderExists(id); - // 1.2 校验状态 - if (saleOrder.getStatus().equals(status)) { - throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); - } - // 1.3 存在销售出库单,无法反审核 - if (!approve && saleOrder.getOutCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_ORDER_PROCESS_FAIL_EXISTS_OUT); - } - // 1.4 存在销售退货单,无法反审核 - if (!approve && saleOrder.getReturnCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_ORDER_PROCESS_FAIL_EXISTS_RETURN); - } - - // 2. 更新状态 - int updateCount = saleOrderMapper.updateByIdAndStatus(id, saleOrder.getStatus(), - new ErpSaleOrderDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); - } - } - - private List validateSaleOrderItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpSaleOrderSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpSaleOrderItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOrderItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updateSaleOrderItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = saleOrderItemMapper.selectListByOrderId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOrderId(id)); - saleOrderItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - saleOrderItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - saleOrderItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleOrderItemDO::getId)); - } - } - - @Override - public void updateSaleOrderOutCount(Long id, Map outCountMap) { - List orderItems = saleOrderItemMapper.selectListByOrderId(id); - // 1. 更新每个销售订单项 - orderItems.forEach(item -> { - BigDecimal outCount = outCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getOutCount().equals(outCount)) { - return; - } - if (outCount.compareTo(item.getCount()) > 0) { - throw exception(SALE_ORDER_ITEM_OUT_FAIL_PRODUCT_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getCount()); - } - saleOrderItemMapper.updateById(new ErpSaleOrderItemDO().setId(item.getId()).setOutCount(outCount)); - }); - // 2. 更新销售订单 - BigDecimal totalOutCount = getSumValue(outCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - saleOrderMapper.updateById(new ErpSaleOrderDO().setId(id).setOutCount(totalOutCount)); - } - - @Override - public void updateSaleOrderReturnCount(Long orderId, Map returnCountMap) { - List orderItems = saleOrderItemMapper.selectListByOrderId(orderId); - // 1. 更新每个销售订单项 - orderItems.forEach(item -> { - BigDecimal returnCount = returnCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getReturnCount().equals(returnCount)) { - return; - } - if (returnCount.compareTo(item.getOutCount()) > 0) { - throw exception(SALE_ORDER_ITEM_RETURN_FAIL_OUT_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getOutCount()); - } - saleOrderItemMapper.updateById(new ErpSaleOrderItemDO().setId(item.getId()).setReturnCount(returnCount)); - }); - // 2. 更新销售订单 - BigDecimal totalReturnCount = getSumValue(returnCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - saleOrderMapper.updateById(new ErpSaleOrderDO().setId(orderId).setReturnCount(totalReturnCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSaleOrder(List ids) { - // 1. 校验不处于已审批 - List saleOrders = saleOrderMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(saleOrders)) { - return; - } - saleOrders.forEach(saleOrder -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOrder.getStatus())) { - throw exception(SALE_ORDER_DELETE_FAIL_APPROVE, saleOrder.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - saleOrders.forEach(saleOrder -> { - // 2.1 删除订单 - saleOrderMapper.deleteById(saleOrder.getId()); - // 2.2 删除订单项 - saleOrderItemMapper.deleteByOrderId(saleOrder.getId()); - }); - } - - private ErpSaleOrderDO validateSaleOrderExists(Long id) { - ErpSaleOrderDO saleOrder = saleOrderMapper.selectById(id); - if (saleOrder == null) { - throw exception(SALE_ORDER_NOT_EXISTS); - } - return saleOrder; - } - - @Override - public ErpSaleOrderDO getSaleOrder(Long id) { - return saleOrderMapper.selectById(id); - } - - @Override - public ErpSaleOrderDO validateSaleOrder(Long id) { - ErpSaleOrderDO saleOrder = validateSaleOrderExists(id); - if (ObjectUtil.notEqual(saleOrder.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(SALE_ORDER_NOT_APPROVE); - } - return saleOrder; - } - - @Override - public PageResult getSaleOrderPage(ErpSaleOrderPageReqVO pageReqVO) { - return saleOrderMapper.selectPage(pageReqVO); - } - - // ==================== 订单项 ==================== - - @Override - public List getSaleOrderItemListByOrderId(Long orderId) { - return saleOrderItemMapper.selectListByOrderId(orderId); - } - - @Override - public List getSaleOrderItemListByOrderIds(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return saleOrderItemMapper.selectListByOrderIds(orderIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java deleted file mode 100644 index db78cb0dc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 销售出库 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleOutService { - - /** - * 创建销售出库 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSaleOut(@Valid ErpSaleOutSaveReqVO createReqVO); - - /** - * 更新销售出库 - * - * @param updateReqVO 更新信息 - */ - void updateSaleOut(@Valid ErpSaleOutSaveReqVO updateReqVO); - - /** - * 更新销售出库的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateSaleOutStatus(Long id, Integer status); - - /** - * 更新销售出库的收款金额 - * - * @param id 编号 - * @param receiptPrice 收款金额 - */ - void updateSaleInReceiptPrice(Long id, BigDecimal receiptPrice); - - /** - * 删除销售出库 - * - * @param ids 编号数组 - */ - void deleteSaleOut(List ids); - - /** - * 获得销售出库 - * - * @param id 编号 - * @return 销售出库 - */ - ErpSaleOutDO getSaleOut(Long id); - - /** - * 校验销售出库,已经审核通过 - * - * @param id 编号 - * @return 销售出库 - */ - ErpSaleOutDO validateSaleOut(Long id); - - /** - * 获得销售出库分页 - * - * @param pageReqVO 分页查询 - * @return 销售出库分页 - */ - PageResult getSaleOutPage(ErpSaleOutPageReqVO pageReqVO); - - // ==================== 销售出库项 ==================== - - /** - * 获得销售出库项列表 - * - * @param outId 销售出库编号 - * @return 销售出库项列表 - */ - List getSaleOutItemListByOutId(Long outId); - - /** - * 获得销售出库项 List - * - * @param outIds 销售出库编号数组 - * @return 销售出库项 List - */ - List getSaleOutItemListByOutIds(Collection outIds); - - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java deleted file mode 100644 index 16d20dd37..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java +++ /dev/null @@ -1,316 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOutItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOutMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 销售出库 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSaleOutServiceImpl implements ErpSaleOutService { - - @Resource - private ErpSaleOutMapper saleOutMapper; - @Resource - private ErpSaleOutItemMapper saleOutItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpSaleOrderService saleOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSaleOut(ErpSaleOutSaveReqVO createReqVO) { - // 1.1 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(createReqVO.getOrderId()); - // 1.2 校验出库项的有效性 - List saleOutItems = validateSaleOutItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 校验销售人员 - if (createReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(createReqVO.getSaleUserId()); - } - // 1.5 生成出库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_OUT_NO_PREFIX); - if (saleOutMapper.selectByNo(no) != null) { - throw exception(SALE_OUT_NO_EXISTS); - } - - // 2.1 插入出库 - ErpSaleOutDO saleOut = BeanUtils.toBean(createReqVO, ErpSaleOutDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(saleOut, saleOutItems); - saleOutMapper.insert(saleOut); - // 2.2 插入出库项 - saleOutItems.forEach(o -> o.setOutId(saleOut.getId())); - saleOutItemMapper.insertBatch(saleOutItems); - - // 3. 更新销售订单的出库数量 - updateSaleOrderOutCount(createReqVO.getOrderId()); - return saleOut.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOut(ErpSaleOutSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpSaleOutDO saleOut = validateSaleOutExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOut.getStatus())) { - throw exception(SALE_OUT_UPDATE_FAIL_APPROVE, saleOut.getNo()); - } - // 1.2 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验销售人员 - if (updateReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(updateReqVO.getSaleUserId()); - } - // 1.5 校验订单项的有效性 - List saleOutItems = validateSaleOutItems(updateReqVO.getItems()); - - // 2.1 更新出库 - ErpSaleOutDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleOutDO.class) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(updateObj, saleOutItems); - saleOutMapper.updateById(updateObj); - // 2.2 更新出库项 - updateSaleOutItemList(updateReqVO.getId(), saleOutItems); - - // 3.1 更新销售订单的出库数量 - updateSaleOrderOutCount(updateObj.getOrderId()); - // 3.2 注意:如果销售订单编号变更了,需要更新“老”销售订单的出库数量 - if (ObjectUtil.notEqual(saleOut.getOrderId(), updateObj.getOrderId())) { - updateSaleOrderOutCount(saleOut.getOrderId()); - } - } - - private void calculateTotalPrice(ErpSaleOutDO saleOut, List saleOutItems) { - saleOut.setTotalCount(getSumValue(saleOutItems, ErpSaleOutItemDO::getCount, BigDecimal::add)); - saleOut.setTotalProductPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOut.setTotalTaxPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOut.setTotalPrice(saleOut.getTotalProductPrice().add(saleOut.getTotalTaxPrice())); - // 计算优惠价格 - if (saleOut.getDiscountPercent() == null) { - saleOut.setDiscountPercent(BigDecimal.ZERO); - } - saleOut.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOut.getTotalPrice(), saleOut.getDiscountPercent())); - saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice().add(saleOut.getOtherPrice()))); - } - - private void updateSaleOrderOutCount(Long orderId) { - // 1.1 查询销售订单对应的销售出库单列表 - List saleOuts = saleOutMapper.selectListByOrderId(orderId); - // 1.2 查询对应的销售订单项的出库数量 - Map returnCountMap = saleOutItemMapper.selectOrderItemCountSumMapByOutIds( - convertList(saleOuts, ErpSaleOutDO::getId)); - // 2. 更新销售订单的出库数量 - saleOrderService.updateSaleOrderOutCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOutStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpSaleOutDO saleOut = validateSaleOutExists(id); - // 1.2 校验状态 - if (saleOut.getStatus().equals(status)) { - throw exception(approve ? SALE_OUT_APPROVE_FAIL : SALE_OUT_PROCESS_FAIL); - } - // 1.3 校验已退款 - if (!approve && saleOut.getReceiptPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_OUT_PROCESS_FAIL_EXISTS_RECEIPT); - } - - // 2. 更新状态 - int updateCount = saleOutMapper.updateByIdAndStatus(id, saleOut.getStatus(), - new ErpSaleOutDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? SALE_OUT_APPROVE_FAIL : SALE_OUT_PROCESS_FAIL); - } - - // 3. 变更库存 - List saleOutItems = saleOutItemMapper.selectListByOutId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_OUT.getType() - : ErpStockRecordBizTypeEnum.SALE_OUT_CANCEL.getType(); - saleOutItems.forEach(saleOutItem -> { - BigDecimal count = approve ? saleOutItem.getCount().negate() : saleOutItem.getCount(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - saleOutItem.getProductId(), saleOutItem.getWarehouseId(), count, - bizType, saleOutItem.getOutId(), saleOutItem.getId(), saleOut.getNo())); - }); - } - - @Override - public void updateSaleInReceiptPrice(Long id, BigDecimal receiptPrice) { - ErpSaleOutDO saleOut = saleOutMapper.selectById(id); - if (saleOut.getReceiptPrice().equals(receiptPrice)) { - return; - } - if (receiptPrice.compareTo(saleOut.getTotalPrice()) > 0) { - throw exception(SALE_OUT_FAIL_RECEIPT_PRICE_EXCEED, receiptPrice, saleOut.getTotalPrice()); - } - saleOutMapper.updateById(new ErpSaleOutDO().setId(id).setReceiptPrice(receiptPrice)); - } - - private List validateSaleOutItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpSaleOutSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpSaleOutItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOutItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updateSaleOutItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = saleOutItemMapper.selectListByOutId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOutId(id)); - saleOutItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - saleOutItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - saleOutItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleOutItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSaleOut(List ids) { - // 1. 校验不处于已审批 - List saleOuts = saleOutMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(saleOuts)) { - return; - } - saleOuts.forEach(saleOut -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOut.getStatus())) { - throw exception(SALE_OUT_DELETE_FAIL_APPROVE, saleOut.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - saleOuts.forEach(saleOut -> { - // 2.1 删除订单 - saleOutMapper.deleteById(saleOut.getId()); - // 2.2 删除订单项 - saleOutItemMapper.deleteByOutId(saleOut.getId()); - - // 2.3 更新销售订单的出库数量 - updateSaleOrderOutCount(saleOut.getOrderId()); - }); - - } - - private ErpSaleOutDO validateSaleOutExists(Long id) { - ErpSaleOutDO saleOut = saleOutMapper.selectById(id); - if (saleOut == null) { - throw exception(SALE_OUT_NOT_EXISTS); - } - return saleOut; - } - - @Override - public ErpSaleOutDO getSaleOut(Long id) { - return saleOutMapper.selectById(id); - } - - @Override - public ErpSaleOutDO validateSaleOut(Long id) { - ErpSaleOutDO saleOut = validateSaleOutExists(id); - if (ObjectUtil.notEqual(saleOut.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(SALE_OUT_NOT_APPROVE); - } - return saleOut; - } - - @Override - public PageResult getSaleOutPage(ErpSaleOutPageReqVO pageReqVO) { - return saleOutMapper.selectPage(pageReqVO); - } - - // ==================== 销售出库项 ==================== - - @Override - public List getSaleOutItemListByOutId(Long outId) { - return saleOutItemMapper.selectListByOutId(outId); - } - - @Override - public List getSaleOutItemListByOutIds(Collection outIds) { - if (CollUtil.isEmpty(outIds)) { - return Collections.emptyList(); - } - return saleOutItemMapper.selectListByOutIds(outIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnService.java deleted file mode 100644 index 026403237..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 销售退货 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleReturnService { - - /** - * 创建销售退货 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSaleReturn(@Valid ErpSaleReturnSaveReqVO createReqVO); - - /** - * 更新销售退货 - * - * @param updateReqVO 更新信息 - */ - void updateSaleReturn(@Valid ErpSaleReturnSaveReqVO updateReqVO); - - /** - * 更新销售退货的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateSaleReturnStatus(Long id, Integer status); - - /** - * 更新销售退货的退款金额 - * - * @param id 编号 - * @param refundPrice 退款金额 - */ - void updateSaleReturnRefundPrice(Long id, BigDecimal refundPrice); - - /** - * 删除销售退货 - * - * @param ids 编号数组 - */ - void deleteSaleReturn(List ids); - - /** - * 获得销售退货 - * - * @param id 编号 - * @return 销售退货 - */ - ErpSaleReturnDO getSaleReturn(Long id); - - /** - * 校验销售退货,已经审核通过 - * - * @param id 编号 - * @return 销售退货 - */ - ErpSaleReturnDO validateSaleReturn(Long id); - - /** - * 获得销售退货分页 - * - * @param pageReqVO 分页查询 - * @return 销售退货分页 - */ - PageResult getSaleReturnPage(ErpSaleReturnPageReqVO pageReqVO); - - // ==================== 销售退货项 ==================== - - /** - * 获得销售退货项列表 - * - * @param returnId 销售退货编号 - * @return 销售退货项列表 - */ - List getSaleReturnItemListByReturnId(Long returnId); - - /** - * 获得销售退货项 List - * - * @param returnIds 销售退货编号数组 - * @return 销售退货项 List - */ - List getSaleReturnItemListByReturnIds(Collection returnIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java deleted file mode 100644 index 209df114c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java +++ /dev/null @@ -1,316 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleReturnItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleReturnMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 销售退货 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { - - @Resource - private ErpSaleReturnMapper saleReturnMapper; - @Resource - private ErpSaleReturnItemMapper saleReturnItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpSaleOrderService saleOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSaleReturn(ErpSaleReturnSaveReqVO createReqVO) { - // 1.1 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(createReqVO.getOrderId()); - // 1.2 校验退货项的有效性 - List saleReturnItems = validateSaleReturnItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 校验销售人员 - if (createReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(createReqVO.getSaleUserId()); - } - // 1.5 生成退货单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_RETURN_NO_PREFIX); - if (saleReturnMapper.selectByNo(no) != null) { - throw exception(SALE_RETURN_NO_EXISTS); - } - - // 2.1 插入退货 - ErpSaleReturnDO saleReturn = BeanUtils.toBean(createReqVO, ErpSaleReturnDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(saleReturn, saleReturnItems); - saleReturnMapper.insert(saleReturn); - // 2.2 插入退货项 - saleReturnItems.forEach(o -> o.setReturnId(saleReturn.getId())); - saleReturnItemMapper.insertBatch(saleReturnItems); - - // 3. 更新销售订单的退货数量 - updateSaleOrderReturnCount(createReqVO.getOrderId()); - return saleReturn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleReturn(ErpSaleReturnSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpSaleReturnDO saleReturn = validateSaleReturnExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(saleReturn.getStatus())) { - throw exception(SALE_RETURN_UPDATE_FAIL_APPROVE, saleReturn.getNo()); - } - // 1.2 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验销售人员 - if (updateReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(updateReqVO.getSaleUserId()); - } - // 1.5 校验订单项的有效性 - List saleReturnItems = validateSaleReturnItems(updateReqVO.getItems()); - - // 2.1 更新退货 - ErpSaleReturnDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleReturnDO.class) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(updateObj, saleReturnItems); - saleReturnMapper.updateById(updateObj); - // 2.2 更新退货项 - updateSaleReturnItemList(updateReqVO.getId(), saleReturnItems); - - // 3.1 更新销售订单的出库数量 - updateSaleOrderReturnCount(updateObj.getOrderId()); - // 3.2 注意:如果销售订单编号变更了,需要更新“老”销售订单的出库数量 - if (ObjectUtil.notEqual(saleReturn.getOrderId(), updateObj.getOrderId())) { - updateSaleOrderReturnCount(saleReturn.getOrderId()); - } - } - - private void calculateTotalPrice(ErpSaleReturnDO saleReturn, List saleReturnItems) { - saleReturn.setTotalCount(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getCount, BigDecimal::add)); - saleReturn.setTotalProductPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - saleReturn.setTotalTaxPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - saleReturn.setTotalPrice(saleReturn.getTotalProductPrice().add(saleReturn.getTotalTaxPrice())); - // 计算优惠价格 - if (saleReturn.getDiscountPercent() == null) { - saleReturn.setDiscountPercent(BigDecimal.ZERO); - } - saleReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleReturn.getTotalPrice(), saleReturn.getDiscountPercent())); - saleReturn.setTotalPrice(saleReturn.getTotalPrice().subtract(saleReturn.getDiscountPrice().add(saleReturn.getOtherPrice()))); - } - - private void updateSaleOrderReturnCount(Long orderId) { - // 1.1 查询销售订单对应的销售出库单列表 - List saleReturns = saleReturnMapper.selectListByOrderId(orderId); - // 1.2 查询对应的销售订单项的退货数量 - Map returnCountMap = saleReturnItemMapper.selectOrderItemCountSumMapByReturnIds( - convertList(saleReturns, ErpSaleReturnDO::getId)); - // 2. 更新销售订单的出库数量 - saleOrderService.updateSaleOrderReturnCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleReturnStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpSaleReturnDO saleReturn = validateSaleReturnExists(id); - // 1.2 校验状态 - if (saleReturn.getStatus().equals(status)) { - throw exception(approve ? SALE_RETURN_APPROVE_FAIL : SALE_RETURN_PROCESS_FAIL); - } - // 1.3 校验已退款 - if (!approve && saleReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_RETURN_PROCESS_FAIL_EXISTS_REFUND); - } - - // 2. 更新状态 - int updateCount = saleReturnMapper.updateByIdAndStatus(id, saleReturn.getStatus(), - new ErpSaleReturnDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? SALE_RETURN_APPROVE_FAIL : SALE_RETURN_PROCESS_FAIL); - } - - // 3. 变更库存 - List saleReturnItems = saleReturnItemMapper.selectListByReturnId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_RETURN.getType() - : ErpStockRecordBizTypeEnum.SALE_RETURN_CANCEL.getType(); - saleReturnItems.forEach(saleReturnItem -> { - BigDecimal count = approve ? saleReturnItem.getCount() : saleReturnItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - saleReturnItem.getProductId(), saleReturnItem.getWarehouseId(), count, - bizType, saleReturnItem.getReturnId(), saleReturnItem.getId(), saleReturn.getNo())); - }); - } - - @Override - public void updateSaleReturnRefundPrice(Long id, BigDecimal refundPrice) { - ErpSaleReturnDO saleReturn = saleReturnMapper.selectById(id); - if (saleReturn.getRefundPrice().equals(refundPrice)) { - return; - } - if (refundPrice.compareTo(saleReturn.getTotalPrice()) > 0) { - throw exception(SALE_RETURN_FAIL_REFUND_PRICE_EXCEED, refundPrice, saleReturn.getTotalPrice()); - } - saleReturnMapper.updateById(new ErpSaleReturnDO().setId(id).setRefundPrice(refundPrice)); - } - - private List validateSaleReturnItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpSaleReturnSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpSaleReturnItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpSaleReturnItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updateSaleReturnItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = saleReturnItemMapper.selectListByReturnId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setReturnId(id)); - saleReturnItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - saleReturnItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - saleReturnItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleReturnItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSaleReturn(List ids) { - // 1. 校验不处于已审批 - List saleReturns = saleReturnMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(saleReturns)) { - return; - } - saleReturns.forEach(saleReturn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(saleReturn.getStatus())) { - throw exception(SALE_RETURN_DELETE_FAIL_APPROVE, saleReturn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - saleReturns.forEach(saleReturn -> { - // 2.1 删除订单 - saleReturnMapper.deleteById(saleReturn.getId()); - // 2.2 删除订单项 - saleReturnItemMapper.deleteByReturnId(saleReturn.getId()); - - // 2.3 更新销售订单的出库数量 - updateSaleOrderReturnCount(saleReturn.getOrderId()); - }); - - } - - private ErpSaleReturnDO validateSaleReturnExists(Long id) { - ErpSaleReturnDO saleReturn = saleReturnMapper.selectById(id); - if (saleReturn == null) { - throw exception(SALE_RETURN_NOT_EXISTS); - } - return saleReturn; - } - - @Override - public ErpSaleReturnDO getSaleReturn(Long id) { - return saleReturnMapper.selectById(id); - } - - @Override - public ErpSaleReturnDO validateSaleReturn(Long id) { - ErpSaleReturnDO saleReturn = validateSaleReturnExists(id); - if (ObjectUtil.notEqual(saleReturn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(SALE_RETURN_NOT_APPROVE); - } - return saleReturn; - } - - @Override - public PageResult getSaleReturnPage(ErpSaleReturnPageReqVO pageReqVO) { - return saleReturnMapper.selectPage(pageReqVO); - } - - // ==================== 销售退货项 ==================== - - @Override - public List getSaleReturnItemListByReturnId(Long returnId) { - return saleReturnItemMapper.selectListByReturnId(returnId); - } - - @Override - public List getSaleReturnItemListByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyList(); - } - return saleReturnItemMapper.selectListByReturnIds(returnIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsService.java deleted file mode 100644 index 913409487..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsService.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购统计 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseStatisticsService { - - /** - * 获得采购金额 - * - * 计算逻辑:采购出库的金额 - 采购退货的金额 - * - * @param beginTime >= 开始时间 - * @param endTime < 结束时间 - * @return 采购金额 - */ - BigDecimal getPurchasePrice(LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsServiceImpl.java deleted file mode 100644 index 588ff74ba..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpPurchaseStatisticsMapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class ErpPurchaseStatisticsServiceImpl implements ErpPurchaseStatisticsService { - - @Resource - private ErpPurchaseStatisticsMapper purchaseStatisticsMapper; - - @Override - public BigDecimal getPurchasePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return purchaseStatisticsMapper.getPurchasePrice(beginTime, endTime); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsService.java deleted file mode 100644 index 3c28bc327..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsService.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售统计 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleStatisticsService { - - /** - * 获得销售金额 - * - * 计算逻辑:销售出库的金额 - 销售退货的金额 - * - * @param beginTime >= 开始时间 - * @param endTime < 结束时间 - * @return 销售金额 - */ - BigDecimal getSalePrice(LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsServiceImpl.java deleted file mode 100644 index a6664332a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpSaleStatisticsMapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class ErpSaleStatisticsServiceImpl implements ErpSaleStatisticsService { - - @Resource - private ErpSaleStatisticsMapper saleStatisticsMapper; - - @Override - public BigDecimal getSalePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return saleStatisticsMapper.getSalePrice(beginTime, endTime); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckService.java deleted file mode 100644 index 139982905..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存盘点单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockCheckService { - - /** - * 创建库存盘点单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockCheck(@Valid ErpStockCheckSaveReqVO createReqVO); - - /** - * 更新库存盘点单 - * - * @param updateReqVO 更新信息 - */ - void updateStockCheck(@Valid ErpStockCheckSaveReqVO updateReqVO); - - /** - * 更新库存盘点单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockCheckStatus(Long id, Integer status); - - /** - * 删除库存盘点单 - * - * @param ids 编号数组 - */ - void deleteStockCheck(List ids); - - /** - * 获得库存盘点单 - * - * @param id 编号 - * @return 库存盘点单 - */ - ErpStockCheckDO getStockCheck(Long id); - - /** - * 获得库存盘点单分页 - * - * @param pageReqVO 分页查询 - * @return 库存盘点单分页 - */ - PageResult getStockCheckPage(ErpStockCheckPageReqVO pageReqVO); - - // ==================== 盘点项 ==================== - - /** - * 获得库存盘点单项列表 - * - * @param checkId 盘点编号 - * @return 库存盘点单项列表 - */ - List getStockCheckItemListByCheckId(Long checkId); - - /** - * 获得库存盘点单项 List - * - * @param checkIds 盘点编号数组 - * @return 库存盘点单项 List - */ - List getStockCheckItemListByCheckIds(Collection checkIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckServiceImpl.java deleted file mode 100644 index c70284aef..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckServiceImpl.java +++ /dev/null @@ -1,232 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockCheckItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockCheckMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 库存盘点单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockCheckServiceImpl implements ErpStockCheckService { - - @Resource - private ErpStockCheckMapper stockCheckMapper; - @Resource - private ErpStockCheckItemMapper stockCheckItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockCheck(ErpStockCheckSaveReqVO createReqVO) { - // 1.1 校验盘点项的有效性 - List stockCheckItems = validateStockCheckItems(createReqVO.getItems()); - // 1.2 生成盘点单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_CHECK_NO_PREFIX); - if (stockCheckMapper.selectByNo(no) != null) { - throw exception(STOCK_CHECK_NO_EXISTS); - } - - // 2.1 插入盘点单 - ErpStockCheckDO stockCheck = BeanUtils.toBean(createReqVO, ErpStockCheckDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockCheckItems, ErpStockCheckItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockCheckItems, ErpStockCheckItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockCheckMapper.insert(stockCheck); - // 2.2 插入盘点单项 - stockCheckItems.forEach(o -> o.setCheckId(stockCheck.getId())); - stockCheckItemMapper.insertBatch(stockCheckItems); - return stockCheck.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockCheck(ErpStockCheckSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockCheckDO stockCheck = validateStockCheckExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockCheck.getStatus())) { - throw exception(STOCK_CHECK_UPDATE_FAIL_APPROVE, stockCheck.getNo()); - } - // 1.2 校验盘点项的有效性 - List stockCheckItems = validateStockCheckItems(updateReqVO.getItems()); - - // 2.1 更新盘点单 - ErpStockCheckDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockCheckDO.class, in -> in - .setTotalCount(getSumValue(stockCheckItems, ErpStockCheckItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockCheckItems, ErpStockCheckItemDO::getTotalPrice, BigDecimal::add))); - stockCheckMapper.updateById(updateObj); - // 2.2 更新盘点单项 - updateStockCheckItemList(updateReqVO.getId(), stockCheckItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockCheckStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockCheckDO stockCheck = validateStockCheckExists(id); - // 1.2 校验状态 - if (stockCheck.getStatus().equals(status)) { - throw exception(approve ? STOCK_CHECK_APPROVE_FAIL : STOCK_CHECK_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockCheckMapper.updateByIdAndStatus(id, stockCheck.getStatus(), - new ErpStockCheckDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_CHECK_APPROVE_FAIL : STOCK_CHECK_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockCheckItems = stockCheckItemMapper.selectListByCheckId(id); - stockCheckItems.forEach(stockCheckItem -> { - // 没有盈亏,不用出入库 - if (stockCheckItem.getCount().compareTo(BigDecimal.ZERO) == 0) { - return; - } - // 10;12;-2() - BigDecimal count = approve ? stockCheckItem.getCount(): stockCheckItem.getCount().negate(); - Integer bizType; - if (approve) { - bizType = count.compareTo(BigDecimal.ZERO) > 0 ? ErpStockRecordBizTypeEnum.CHECK_MORE_IN.getType() - : ErpStockRecordBizTypeEnum.CHECK_LESS_OUT.getType(); - } else { - bizType = count.compareTo(BigDecimal.ZERO) > 0 ? ErpStockRecordBizTypeEnum.CHECK_MORE_IN_CANCEL.getType() - : ErpStockRecordBizTypeEnum.CHECK_LESS_OUT_CANCEL.getType(); - } - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockCheckItem.getProductId(), stockCheckItem.getWarehouseId(), count, - bizType, stockCheckItem.getCheckId(), stockCheckItem.getId(), stockCheck.getNo())); - }); - } - - private List validateStockCheckItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockCheckSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSet(list, ErpStockCheckSaveReqVO.Item::getWarehouseId)); - // 2. 转化为 ErpStockCheckItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockCheckItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockCheckItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockCheckItemMapper.selectListByCheckId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setCheckId(id)); - stockCheckItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockCheckItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockCheckItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockCheckItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockCheck(List ids) { - // 1. 校验不处于已审批 - List stockChecks = stockCheckMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockChecks)) { - return; - } - stockChecks.forEach(stockCheck -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockCheck.getStatus())) { - throw exception(STOCK_CHECK_DELETE_FAIL_APPROVE, stockCheck.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockChecks.forEach(stockCheck -> { - // 2.1 删除盘点单 - stockCheckMapper.deleteById(stockCheck.getId()); - // 2.2 删除盘点单项 - stockCheckItemMapper.deleteByCheckId(stockCheck.getId()); - }); - } - - private ErpStockCheckDO validateStockCheckExists(Long id) { - ErpStockCheckDO stockCheck = stockCheckMapper.selectById(id); - if (stockCheck == null) { - throw exception(STOCK_CHECK_NOT_EXISTS); - } - return stockCheck; - } - - @Override - public ErpStockCheckDO getStockCheck(Long id) { - return stockCheckMapper.selectById(id); - } - - @Override - public PageResult getStockCheckPage(ErpStockCheckPageReqVO pageReqVO) { - return stockCheckMapper.selectPage(pageReqVO); - } - - // ==================== 盘点项 ==================== - - @Override - public List getStockCheckItemListByCheckId(Long checkId) { - return stockCheckItemMapper.selectListByCheckId(checkId); - } - - @Override - public List getStockCheckItemListByCheckIds(Collection checkIds) { - if (CollUtil.isEmpty(checkIds)) { - return Collections.emptyList(); - } - return stockCheckItemMapper.selectListByCheckIds(checkIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInService.java deleted file mode 100644 index 006db5211..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它入库单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockInService { - - /** - * 创建其它入库单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockIn(@Valid ErpStockInSaveReqVO createReqVO); - - /** - * 更新其它入库单 - * - * @param updateReqVO 更新信息 - */ - void updateStockIn(@Valid ErpStockInSaveReqVO updateReqVO); - - /** - * 更新其它入库单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockInStatus(Long id, Integer status); - - /** - * 删除其它入库单 - * - * @param ids 编号数组 - */ - void deleteStockIn(List ids); - - /** - * 获得其它入库单 - * - * @param id 编号 - * @return 其它入库单 - */ - ErpStockInDO getStockIn(Long id); - - /** - * 获得其它入库单分页 - * - * @param pageReqVO 分页查询 - * @return 其它入库单分页 - */ - PageResult getStockInPage(ErpStockInPageReqVO pageReqVO); - - // ==================== 入库项 ==================== - - /** - * 获得其它入库单项列表 - * - * @param inId 入库编号 - * @return 其它入库单项列表 - */ - List getStockInItemListByInId(Long inId); - - /** - * 获得其它入库单项 List - * - * @param inIds 入库编号数组 - * @return 其它入库单项 List - */ - List getStockInItemListByInIds(Collection inIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java deleted file mode 100644 index 5bb3afb59..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 -/** - * ERP 其它入库单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockInServiceImpl implements ErpStockInService { - - @Resource - private ErpStockInMapper stockInMapper; - @Resource - private ErpStockInItemMapper stockInItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockIn(ErpStockInSaveReqVO createReqVO) { - // 1.1 校验入库项的有效性 - List stockInItems = validateStockInItems(createReqVO.getItems()); - // 1.2 校验供应商 - supplierService.validateSupplier(createReqVO.getSupplierId()); - // 1.3 生成入库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_IN_NO_PREFIX); - if (stockInMapper.selectByNo(no) != null) { - throw exception(STOCK_IN_NO_EXISTS); - } - - // 2.1 插入入库单 - ErpStockInDO stockIn = BeanUtils.toBean(createReqVO, ErpStockInDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockInItems, ErpStockInItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockInItems, ErpStockInItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockInMapper.insert(stockIn); - // 2.2 插入入库单项 - stockInItems.forEach(o -> o.setInId(stockIn.getId())); - stockInItemMapper.insertBatch(stockInItems); - return stockIn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockIn(ErpStockInSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockInDO stockIn = validateStockInExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockIn.getStatus())) { - throw exception(STOCK_IN_UPDATE_FAIL_APPROVE, stockIn.getNo()); - } - // 1.2 校验供应商 - supplierService.validateSupplier(updateReqVO.getSupplierId()); - // 1.3 校验入库项的有效性 - List stockInItems = validateStockInItems(updateReqVO.getItems()); - - // 2.1 更新入库单 - ErpStockInDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockInDO.class, in -> in - .setTotalCount(getSumValue(stockInItems, ErpStockInItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockInItems, ErpStockInItemDO::getTotalPrice, BigDecimal::add))); - stockInMapper.updateById(updateObj); - // 2.2 更新入库单项 - updateStockInItemList(updateReqVO.getId(), stockInItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockInStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockInDO stockIn = validateStockInExists(id); - // 1.2 校验状态 - if (stockIn.getStatus().equals(status)) { - throw exception(approve ? STOCK_IN_APPROVE_FAIL : STOCK_IN_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockInMapper.updateByIdAndStatus(id, stockIn.getStatus(), - new ErpStockInDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_IN_APPROVE_FAIL : STOCK_IN_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockInItems = stockInItemMapper.selectListByInId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.OTHER_IN.getType() - : ErpStockRecordBizTypeEnum.OTHER_IN_CANCEL.getType(); - stockInItems.forEach(stockInItem -> { - BigDecimal count = approve ? stockInItem.getCount() : stockInItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockInItem.getProductId(), stockInItem.getWarehouseId(), count, - bizType, stockInItem.getInId(), stockInItem.getId(), stockIn.getNo())); - }); - } - - private List validateStockInItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockInSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSet( - list, ErpStockInSaveReqVO.Item::getWarehouseId)); - // 2. 转化为 ErpStockInItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockInItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockInItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockInItemMapper.selectListByInId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setInId(id)); - stockInItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockInItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockInItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockInItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockIn(List ids) { - // 1. 校验不处于已审批 - List stockIns = stockInMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockIns)) { - return; - } - stockIns.forEach(stockIn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockIn.getStatus())) { - throw exception(STOCK_IN_DELETE_FAIL_APPROVE, stockIn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockIns.forEach(stockIn -> { - // 2.1 删除入库单 - stockInMapper.deleteById(stockIn.getId()); - // 2.2 删除入库单项 - stockInItemMapper.deleteByInId(stockIn.getId()); - }); - } - - private ErpStockInDO validateStockInExists(Long id) { - ErpStockInDO stockIn = stockInMapper.selectById(id); - if (stockIn == null) { - throw exception(STOCK_IN_NOT_EXISTS); - } - return stockIn; - } - - @Override - public ErpStockInDO getStockIn(Long id) { - return stockInMapper.selectById(id); - } - - @Override - public PageResult getStockInPage(ErpStockInPageReqVO pageReqVO) { - return stockInMapper.selectPage(pageReqVO); - } - - // ==================== 入库项 ==================== - - @Override - public List getStockInItemListByInId(Long inId) { - return stockInItemMapper.selectListByInId(inId); - } - - @Override - public List getStockInItemListByInIds(Collection inIds) { - if (CollUtil.isEmpty(inIds)) { - return Collections.emptyList(); - } - return stockInItemMapper.selectListByInIds(inIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveService.java deleted file mode 100644 index ddb0b85fa..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存调拨单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockMoveService { - - /** - * 创建库存调拨单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockMove(@Valid ErpStockMoveSaveReqVO createReqVO); - - /** - * 更新库存调拨单 - * - * @param updateReqVO 更新信息 - */ - void updateStockMove(@Valid ErpStockMoveSaveReqVO updateReqVO); - - /** - * 更新库存调拨单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockMoveStatus(Long id, Integer status); - - /** - * 删除库存调拨单 - * - * @param ids 编号数组 - */ - void deleteStockMove(List ids); - - /** - * 获得库存调拨单 - * - * @param id 编号 - * @return 库存调拨单 - */ - ErpStockMoveDO getStockMove(Long id); - - /** - * 获得库存调拨单分页 - * - * @param pageReqVO 分页查询 - * @return 库存调拨单分页 - */ - PageResult getStockMovePage(ErpStockMovePageReqVO pageReqVO); - - // ==================== 调拨项 ==================== - - /** - * 获得库存调拨单项列表 - * - * @param moveId 调拨编号 - * @return 库存调拨单项列表 - */ - List getStockMoveItemListByMoveId(Long moveId); - - /** - * 获得库存调拨单项 List - * - * @param moveIds 调拨编号数组 - * @return 库存调拨单项 List - */ - List getStockMoveItemListByMoveIds(Collection moveIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveServiceImpl.java deleted file mode 100644 index d99d02618..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveServiceImpl.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMoveItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMoveMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 库存调拨单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockMoveServiceImpl implements ErpStockMoveService { - - @Resource - private ErpStockMoveMapper stockMoveMapper; - @Resource - private ErpStockMoveItemMapper stockMoveItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockMove(ErpStockMoveSaveReqVO createReqVO) { - // 1.1 校验出库项的有效性 - List stockMoveItems = validateStockMoveItems(createReqVO.getItems()); - // 1.2 生成调拨单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_MOVE_NO_PREFIX); - if (stockMoveMapper.selectByNo(no) != null) { - throw exception(STOCK_MOVE_NO_EXISTS); - } - - // 2.1 插入出库单 - ErpStockMoveDO stockMove = BeanUtils.toBean(createReqVO, ErpStockMoveDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockMoveItems, ErpStockMoveItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockMoveItems, ErpStockMoveItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockMoveMapper.insert(stockMove); - // 2.2 插入出库单项 - stockMoveItems.forEach(o -> o.setMoveId(stockMove.getId())); - stockMoveItemMapper.insertBatch(stockMoveItems); - return stockMove.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockMove(ErpStockMoveSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockMoveDO stockMove = validateStockMoveExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockMove.getStatus())) { - throw exception(STOCK_MOVE_UPDATE_FAIL_APPROVE, stockMove.getNo()); - } - // 1.2 校验出库项的有效性 - List stockMoveItems = validateStockMoveItems(updateReqVO.getItems()); - - // 2.1 更新出库单 - ErpStockMoveDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockMoveDO.class, in -> in - .setTotalCount(getSumValue(stockMoveItems, ErpStockMoveItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockMoveItems, ErpStockMoveItemDO::getTotalPrice, BigDecimal::add))); - stockMoveMapper.updateById(updateObj); - // 2.2 更新出库单项 - updateStockMoveItemList(updateReqVO.getId(), stockMoveItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockMoveStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockMoveDO stockMove = validateStockMoveExists(id); - // 1.2 校验状态 - if (stockMove.getStatus().equals(status)) { - throw exception(approve ? STOCK_MOVE_APPROVE_FAIL : STOCK_MOVE_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockMoveMapper.updateByIdAndStatus(id, stockMove.getStatus(), - new ErpStockMoveDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_MOVE_APPROVE_FAIL : STOCK_MOVE_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockMoveItems = stockMoveItemMapper.selectListByMoveId(id); - Integer fromBizType = approve ? ErpStockRecordBizTypeEnum.MOVE_OUT.getType() - : ErpStockRecordBizTypeEnum.MOVE_OUT_CANCEL.getType(); - Integer toBizType = approve ? ErpStockRecordBizTypeEnum.MOVE_IN.getType() - : ErpStockRecordBizTypeEnum.MOVE_IN_CANCEL.getType(); - stockMoveItems.forEach(stockMoveItem -> { - BigDecimal fromCount = approve ? stockMoveItem.getCount().negate() : stockMoveItem.getCount(); - BigDecimal toCount = approve ? stockMoveItem.getCount() : stockMoveItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockMoveItem.getProductId(), stockMoveItem.getFromWarehouseId(), fromCount, - fromBizType, stockMoveItem.getMoveId(), stockMoveItem.getId(), stockMove.getNo())); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockMoveItem.getProductId(), stockMoveItem.getToWarehouseId(), toCount, - toBizType, stockMoveItem.getMoveId(), stockMoveItem.getId(), stockMove.getNo())); - }); - } - - private List validateStockMoveItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockMoveSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSetByFlatMap(list, - item -> Stream.of(item.getFromWarehouseId(), item.getToWarehouseId()))); - // 2. 转化为 ErpStockMoveItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockMoveItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockMoveItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockMoveItemMapper.selectListByMoveId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setMoveId(id)); - stockMoveItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockMoveItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockMoveItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockMoveItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockMove(List ids) { - // 1. 校验不处于已审批 - List stockMoves = stockMoveMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockMoves)) { - return; - } - stockMoves.forEach(stockMove -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockMove.getStatus())) { - throw exception(STOCK_MOVE_DELETE_FAIL_APPROVE, stockMove.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockMoves.forEach(stockMove -> { - // 2.1 删除出库单 - stockMoveMapper.deleteById(stockMove.getId()); - // 2.2 删除出库单项 - stockMoveItemMapper.deleteByMoveId(stockMove.getId()); - }); - } - - private ErpStockMoveDO validateStockMoveExists(Long id) { - ErpStockMoveDO stockMove = stockMoveMapper.selectById(id); - if (stockMove == null) { - throw exception(STOCK_MOVE_NOT_EXISTS); - } - return stockMove; - } - - @Override - public ErpStockMoveDO getStockMove(Long id) { - return stockMoveMapper.selectById(id); - } - - @Override - public PageResult getStockMovePage(ErpStockMovePageReqVO pageReqVO) { - return stockMoveMapper.selectPage(pageReqVO); - } - - // ==================== 出库项 ==================== - - @Override - public List getStockMoveItemListByMoveId(Long moveId) { - return stockMoveItemMapper.selectListByMoveId(moveId); - } - - @Override - public List getStockMoveItemListByMoveIds(Collection moveIds) { - if (CollUtil.isEmpty(moveIds)) { - return Collections.emptyList(); - } - return stockMoveItemMapper.selectListByMoveIds(moveIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutService.java deleted file mode 100644 index c1517ca13..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它出库单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockOutService { - - /** - * 创建其它出库单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockOut(@Valid ErpStockOutSaveReqVO createReqVO); - - /** - * 更新其它出库单 - * - * @param updateReqVO 更新信息 - */ - void updateStockOut(@Valid ErpStockOutSaveReqVO updateReqVO); - - /** - * 更新其它出库单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockOutStatus(Long id, Integer status); - - /** - * 删除其它出库单 - * - * @param ids 编号数组 - */ - void deleteStockOut(List ids); - - /** - * 获得其它出库单 - * - * @param id 编号 - * @return 其它出库单 - */ - ErpStockOutDO getStockOut(Long id); - - /** - * 获得其它出库单分页 - * - * @param pageReqVO 分页查询 - * @return 其它出库单分页 - */ - PageResult getStockOutPage(ErpStockOutPageReqVO pageReqVO); - - // ==================== 出库项 ==================== - - /** - * 获得其它出库单项列表 - * - * @param outId 出库编号 - * @return 其它出库单项列表 - */ - List getStockOutItemListByOutId(Long outId); - - /** - * 获得其它出库单项 List - * - * @param outIds 出库编号数组 - * @return 其它出库单项 List - */ - List getStockOutItemListByOutIds(Collection outIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java deleted file mode 100644 index 22d4cf4a2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockOutItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockOutMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 其它出库单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockOutServiceImpl implements ErpStockOutService { - - @Resource - private ErpStockOutMapper stockOutMapper; - @Resource - private ErpStockOutItemMapper stockOutItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpCustomerService customerService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockOut(ErpStockOutSaveReqVO createReqVO) { - // 1.1 校验出库项的有效性 - List stockOutItems = validateStockOutItems(createReqVO.getItems()); - // 1.2 校验客户 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 1.3 生成出库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_OUT_NO_PREFIX); - if (stockOutMapper.selectByNo(no) != null) { - throw exception(STOCK_OUT_NO_EXISTS); - } - - // 2.1 插入出库单 - ErpStockOutDO stockOut = BeanUtils.toBean(createReqVO, ErpStockOutDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockOutItems, ErpStockOutItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockOutItems, ErpStockOutItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockOutMapper.insert(stockOut); - // 2.2 插入出库单项 - stockOutItems.forEach(o -> o.setOutId(stockOut.getId())); - stockOutItemMapper.insertBatch(stockOutItems); - return stockOut.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockOut(ErpStockOutSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockOutDO stockOut = validateStockOutExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockOut.getStatus())) { - throw exception(STOCK_OUT_UPDATE_FAIL_APPROVE, stockOut.getNo()); - } - // 1.2 校验客户 - customerService.validateCustomer(updateReqVO.getCustomerId()); - // 1.3 校验出库项的有效性 - List stockOutItems = validateStockOutItems(updateReqVO.getItems()); - - // 2.1 更新出库单 - ErpStockOutDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockOutDO.class, in -> in - .setTotalCount(getSumValue(stockOutItems, ErpStockOutItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockOutItems, ErpStockOutItemDO::getTotalPrice, BigDecimal::add))); - stockOutMapper.updateById(updateObj); - // 2.2 更新出库单项 - updateStockOutItemList(updateReqVO.getId(), stockOutItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockOutStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockOutDO stockOut = validateStockOutExists(id); - // 1.2 校验状态 - if (stockOut.getStatus().equals(status)) { - throw exception(approve ? STOCK_OUT_APPROVE_FAIL : STOCK_OUT_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockOutMapper.updateByIdAndStatus(id, stockOut.getStatus(), - new ErpStockOutDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_OUT_APPROVE_FAIL : STOCK_OUT_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockOutItems = stockOutItemMapper.selectListByOutId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.OTHER_OUT.getType() - : ErpStockRecordBizTypeEnum.OTHER_OUT_CANCEL.getType(); - stockOutItems.forEach(stockOutItem -> { - BigDecimal count = approve ? stockOutItem.getCount().negate() : stockOutItem.getCount(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockOutItem.getProductId(), stockOutItem.getWarehouseId(), count, - bizType, stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo())); - }); - } - - private List validateStockOutItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockOutSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSet(list, ErpStockOutSaveReqVO.Item::getWarehouseId)); - // 2. 转化为 ErpStockOutItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockOutItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockOutItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockOutItemMapper.selectListByOutId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOutId(id)); - stockOutItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockOutItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockOutItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockOutItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockOut(List ids) { - // 1. 校验不处于已审批 - List stockOuts = stockOutMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockOuts)) { - return; - } - stockOuts.forEach(stockOut -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockOut.getStatus())) { - throw exception(STOCK_OUT_DELETE_FAIL_APPROVE, stockOut.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockOuts.forEach(stockOut -> { - // 2.1 删除出库单 - stockOutMapper.deleteById(stockOut.getId()); - // 2.2 删除出库单项 - stockOutItemMapper.deleteByOutId(stockOut.getId()); - }); - } - - private ErpStockOutDO validateStockOutExists(Long id) { - ErpStockOutDO stockOut = stockOutMapper.selectById(id); - if (stockOut == null) { - throw exception(STOCK_OUT_NOT_EXISTS); - } - return stockOut; - } - - @Override - public ErpStockOutDO getStockOut(Long id) { - return stockOutMapper.selectById(id); - } - - @Override - public PageResult getStockOutPage(ErpStockOutPageReqVO pageReqVO) { - return stockOutMapper.selectPage(pageReqVO); - } - - // ==================== 出库项 ==================== - - @Override - public List getStockOutItemListByOutId(Long outId) { - return stockOutItemMapper.selectListByOutId(outId); - } - - @Override - public List getStockOutItemListByOutIds(Collection outIds) { - if (CollUtil.isEmpty(outIds)) { - return Collections.emptyList(); - } - return stockOutItemMapper.selectListByOutIds(outIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java deleted file mode 100644 index 7cf8711ae..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.validation.Valid; - -/** - * ERP 产品库存明细 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockRecordService { - - /** - * 获得产品库存明细 - * - * @param id 编号 - * @return 产品库存明细 - */ - ErpStockRecordDO getStockRecord(Long id); - - /** - * 获得产品库存明细分页 - * - * @param pageReqVO 分页查询 - * @return 产品库存明细分页 - */ - PageResult getStockRecordPage(ErpStockRecordPageReqVO pageReqVO); - - /** - * 创建库存明细 - * - * @param createReqBO 创建库存明细 BO - */ - void createStockRecord(@Valid ErpStockRecordCreateReqBO createReqBO); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java deleted file mode 100644 index b4b3875da..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockRecordMapper; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; - -/** - * ERP 产品库存明细 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockRecordServiceImpl implements ErpStockRecordService { - - @Resource - private ErpStockRecordMapper stockRecordMapper; - - @Resource - private ErpStockService stockService; - - @Override - public ErpStockRecordDO getStockRecord(Long id) { - return stockRecordMapper.selectById(id); - } - - @Override - public PageResult getStockRecordPage(ErpStockRecordPageReqVO pageReqVO) { - return stockRecordMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createStockRecord(ErpStockRecordCreateReqBO createReqBO) { - // 1. 更新库存 - BigDecimal totalCount = stockService.updateStockCountIncrement( - createReqBO.getProductId(), createReqBO.getWarehouseId(), createReqBO.getCount()); - // 2. 创建库存明细 - ErpStockRecordDO stockRecord = BeanUtils.toBean(createReqBO, ErpStockRecordDO.class) - .setTotalCount(totalCount); - stockRecordMapper.insert(stockRecord); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java deleted file mode 100644 index 63ad5fefa..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; - -import java.math.BigDecimal; - -/** - * ERP 产品库存 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockService { - - /** - * 获得产品库存 - * - * @param id 编号 - * @return 库存 - */ - ErpStockDO getStock(Long id); - - /** - * 基于产品 + 仓库,获得产品库存 - * - * @param productId 产品编号 - * @param warehouseId 仓库编号 - * @return 产品库存 - */ - ErpStockDO getStock(Long productId, Long warehouseId); - - /** - * 获得产品库存数量 - * - * 如果不存在库存记录,则返回 0 - * - * @param productId 产品编号 - * @return 产品库存数量 - */ - BigDecimal getStockCount(Long productId); - - /** - * 获得产品库存分页 - * - * @param pageReqVO 分页查询 - * @return 库存分页 - */ - PageResult getStockPage(ErpStockPageReqVO pageReqVO); - - /** - * 增量更新产品库存数量 - * - * @param productId 产品编号 - * @param warehouseId 仓库编号 - * @param count 增量数量:正数,表示增加;负数,表示减少 - * @return 更新后的库存 - */ - BigDecimal updateStockCountIncrement(Long productId, Long warehouseId, BigDecimal count); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java deleted file mode 100644 index dabe36fb9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.STOCK_COUNT_NEGATIVE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.STOCK_COUNT_NEGATIVE2; - -/** - * ERP 产品库存 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockServiceImpl implements ErpStockService { - - /** - * 允许库存为负数 - * - * TODO 芋艿:后续做成 db 配置 - */ - private static final Boolean NEGATIVE_STOCK_COUNT_ENABLE = false; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - - @Resource - private ErpStockMapper stockMapper; - - @Override - public ErpStockDO getStock(Long id) { - return stockMapper.selectById(id); - } - - @Override - public ErpStockDO getStock(Long productId, Long warehouseId) { - return stockMapper.selectByProductIdAndWarehouseId(productId, warehouseId); - } - - @Override - public BigDecimal getStockCount(Long productId) { - BigDecimal count = stockMapper.selectSumByProductId(productId); - return count != null ? count : BigDecimal.ZERO; - } - - @Override - public PageResult getStockPage(ErpStockPageReqVO pageReqVO) { - return stockMapper.selectPage(pageReqVO); - } - - @Override - public BigDecimal updateStockCountIncrement(Long productId, Long warehouseId, BigDecimal count) { - // 1.1 查询当前库存 - ErpStockDO stock = stockMapper.selectByProductIdAndWarehouseId(productId, warehouseId); - if (stock == null) { - stock = new ErpStockDO().setProductId(productId).setWarehouseId(warehouseId).setCount(BigDecimal.ZERO); - stockMapper.insert(stock); - } - // 1.2 校验库存是否充足 - if (!NEGATIVE_STOCK_COUNT_ENABLE && stock.getCount().add(count).compareTo(BigDecimal.ZERO) < 0) { - throw exception(STOCK_COUNT_NEGATIVE, productService.getProduct(productId).getName(), - warehouseService.getWarehouse(warehouseId).getName(), stock.getCount(), count); - } - - // 2. 库存变更 - int updateCount = stockMapper.updateCountIncrement(stock.getId(), count, NEGATIVE_STOCK_COUNT_ENABLE); - if (updateCount == 0) { - // 此时不好去查询最新库存,所以直接抛出该提示,不提供具体库存数字 - throw exception(STOCK_COUNT_NEGATIVE2, productService.getProduct(productId).getName(), - warehouseService.getWarehouse(warehouseId).getName()); - } - - // 3. 返回最新库存 - return stock.getCount().add(count); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java deleted file mode 100644 index c9578cf18..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 仓库 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpWarehouseService { - - /** - * 创建仓库 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createWarehouse(@Valid ErpWarehouseSaveReqVO createReqVO); - - /** - * 更新ERP 仓库 - * - * @param updateReqVO 更新信息 - */ - void updateWarehouse(@Valid ErpWarehouseSaveReqVO updateReqVO); - - /** - * 更新仓库默认状态 - * - * @param id 编号 - * @param defaultStatus 默认状态 - */ - void updateWarehouseDefaultStatus(Long id, Boolean defaultStatus); - - /** - * 删除仓库 - * - * @param id 编号 - */ - void deleteWarehouse(Long id); - - /** - * 获得仓库 - * - * @param id 编号 - * @return 仓库 - */ - ErpWarehouseDO getWarehouse(Long id); - - /** - * 校验仓库列表的有效性 - * - * @param ids 编号数组 - * @return 仓库列表 - */ - List validWarehouseList(Collection ids); - - /** - * 获得指定状态的仓库列表 - * - * @param status 状态 - * @return 仓库列表 - */ - List getWarehouseListByStatus(Integer status); - - /** - * 获得仓库列表 - * - * @param ids 编号数组 - * @return 仓库列表 - */ - List getWarehouseList(Collection ids); - - /** - * 获得仓库 Map - * - * @param ids 编号数组 - * @return 仓库 Map - */ - default Map getWarehouseMap(Collection ids) { - return convertMap(getWarehouseList(ids), ErpWarehouseDO::getId); - } - - /** - * 获得仓库分页 - * - * @param pageReqVO 分页查询 - * @return 仓库分页 - */ - PageResult getWarehousePage(ErpWarehousePageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java deleted file mode 100644 index 9e80128dd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpWarehouseMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; - -/** - * ERP 仓库 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpWarehouseServiceImpl implements ErpWarehouseService { - - @Resource - private ErpWarehouseMapper warehouseMapper; - - @Override - public Long createWarehouse(ErpWarehouseSaveReqVO createReqVO) { - // 插入 - ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class); - warehouseMapper.insert(warehouse); - // 返回 - return warehouse.getId(); - } - - @Override - public void updateWarehouse(ErpWarehouseSaveReqVO updateReqVO) { - // 校验存在 - validateWarehouseExists(updateReqVO.getId()); - // 更新 - ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class); - warehouseMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWarehouseDefaultStatus(Long id, Boolean defaultStatus) { - // 1. 校验存在 - validateWarehouseExists(id); - - // 2.1 如果开启,则需要关闭所有其它的默认 - if (defaultStatus) { - ErpWarehouseDO warehouse = warehouseMapper.selectByDefaultStatus(); - if (warehouse != null) { - warehouseMapper.updateById(new ErpWarehouseDO().setId(warehouse.getId()).setDefaultStatus(false)); - } - } - // 2.2 更新对应的默认状态 - warehouseMapper.updateById(new ErpWarehouseDO().setId(id).setDefaultStatus(defaultStatus)); - } - - @Override - public void deleteWarehouse(Long id) { - // 校验存在 - validateWarehouseExists(id); - // 删除 - warehouseMapper.deleteById(id); - } - - private void validateWarehouseExists(Long id) { - if (warehouseMapper.selectById(id) == null) { - throw exception(WAREHOUSE_NOT_EXISTS); - } - } - - @Override - public ErpWarehouseDO getWarehouse(Long id) { - return warehouseMapper.selectById(id); - } - - @Override - public List validWarehouseList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = warehouseMapper.selectBatchIds(ids); - Map warehouseMap = convertMap(list, ErpWarehouseDO::getId); - for (Long id : ids) { - ErpWarehouseDO warehouse = warehouseMap.get(id); - if (warehouseMap.get(id) == null) { - throw exception(WAREHOUSE_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(warehouse.getStatus())) { - throw exception(WAREHOUSE_NOT_ENABLE, warehouse.getName()); - } - } - return list; - } - - @Override - public List getWarehouseListByStatus(Integer status) { - return warehouseMapper.selectListByStatus(status); - } - - @Override - public List getWarehouseList(Collection ids) { - return warehouseMapper.selectBatchIds(ids); - } - - @Override - public PageResult getWarehousePage(ErpWarehousePageReqVO pageReqVO) { - return warehouseMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/bo/ErpStockRecordCreateReqBO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/bo/ErpStockRecordCreateReqBO.java deleted file mode 100644 index 40c62a4ef..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/bo/ErpStockRecordCreateReqBO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock.bo; - -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; - -/** - * 库存明细的创建 Request BO - * - * @author 芋道源码 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockRecordCreateReqBO { - - /** - * 产品编号 - */ - @NotNull(message = "产品编号不能为空") - private Long productId; - /** - * 仓库编号 - */ - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - /** - * 出入库数量 - * - * 正数,表示入库;负数,表示出库 - */ - @NotNull(message = "出入库数量不能为空") - private BigDecimal count; - - /** - * 业务类型 - */ - @NotNull(message = "业务类型不能为空") - private Integer bizType; - /** - * 业务编号 - */ - @NotNull(message = "业务编号不能为空") - private Long bizId; - /** - * 业务项编号 - */ - @NotNull(message = "业务项编号不能为空") - private Long bizItemId; - /** - * 业务单号 - */ - @NotNull(message = "业务单号不能为空") - private String bizNo; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-dev.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index ea9b518b6..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-local.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-local.yaml deleted file mode 100644 index ea9ac953b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,123 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:8000/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.erp.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application.yaml deleted file mode 100644 index 59a1f84b3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,107 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.erp - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - -debug: false diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 70de21db1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: erp-server - - profiles: - active: local - -server: - port: 48088 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/logback-spring.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpPurchaseStatisticsMapper.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpPurchaseStatisticsMapper.xml deleted file mode 100644 index e2b25992a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpPurchaseStatisticsMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpSaleStatisticsMapper.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpSaleStatisticsMapper.xml deleted file mode 100644 index 8e74606c9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpSaleStatisticsMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/pom.xml b/yudao-module-infra/yudao-module-infra-biz/pom.xml index 91e1386de..4e3c9346d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/pom.xml +++ b/yudao-module-infra/yudao-module-infra-biz/pom.xml @@ -99,13 +99,6 @@ yudao-spring-boot-starter-mq - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - cn.iocoder.cloud diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/ftp/FtpFileClientTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/ftp/FtpFileClientTest.java deleted file mode 100644 index b8876f7fc..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/ftp/FtpFileClientTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.infra.framework.file.core.ftp; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.extra.ftp.FtpMode; -import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClient; -import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClientConfig; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class FtpFileClientTest { - - @Test - @Disabled - public void test() { - // 创建客户端 - FtpFileClientConfig config = new FtpFileClientConfig(); - config.setDomain("http://127.0.0.1:48080"); - config.setBasePath("/home/ftp"); - config.setHost("kanchai.club"); - config.setPort(221); - config.setUsername(""); - config.setPassword(""); - config.setMode(FtpMode.Passive.name()); - FtpFileClient client = new FtpFileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - if (false) { - byte[] bytes = client.getContent(path); - System.out.println("文件内容:" + bytes); - } - if (false) { - client.delete(path); - } - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/local/LocalFileClientTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/local/LocalFileClientTest.java deleted file mode 100644 index 7c622a530..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/local/LocalFileClientTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.infra.framework.file.core.local; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClient; -import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClientConfig; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class LocalFileClientTest { - - @Test - @Disabled - public void test() { - // 创建客户端 - LocalFileClientConfig config = new LocalFileClientConfig(); - config.setDomain("http://127.0.0.1:48080"); - config.setBasePath("/Users/yunai/file_test"); - LocalFileClient client = new LocalFileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - client.delete(path); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/s3/S3FileClientTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/s3/S3FileClientTest.java deleted file mode 100644 index 1933e9858..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/s3/S3FileClientTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.infra.framework.file.core.s3; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClient; -import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import javax.validation.Validation; - -public class S3FileClientTest { - - @Test - @Disabled // MinIO,如果要集成测试,可以注释本行 - public void testMinIO() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 - config.setAccessKey("admin"); - config.setAccessSecret("password"); - config.setBucket("yudaoyuanma"); - config.setDomain(null); - // 默认 9000 endpoint - config.setEndpoint("http://127.0.0.1:9000"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 阿里云 OSS,如果要集成测试,可以注释本行 - public void testAliyun() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 - config.setAccessKey(System.getenv("ALIYUN_ACCESS_KEY")); - config.setAccessSecret(System.getenv("ALIYUN_SECRET_KEY")); - config.setBucket("yunai-aoteman"); - config.setDomain(null); // 如果有自定义域名,则可以设置。http://ali-oss.iocoder.cn - // 默认北京的 endpoint - config.setEndpoint("oss-cn-beijing.aliyuncs.com"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 腾讯云 COS,如果要集成测试,可以注释本行 - public void testQCloud() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 - config.setAccessKey(System.getenv("QCLOUD_ACCESS_KEY")); - config.setAccessSecret(System.getenv("QCLOUD_SECRET_KEY")); - config.setBucket("aoteman-1255880240"); - config.setDomain(null); // 如果有自定义域名,则可以设置。http://tengxun-oss.iocoder.cn - // 默认上海的 endpoint - config.setEndpoint("cos.ap-shanghai.myqcloud.com"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 七牛云存储,如果要集成测试,可以注释本行 - public void testQiniu() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 -// config.setAccessKey(System.getenv("QINIU_ACCESS_KEY")); -// config.setAccessSecret(System.getenv("QINIU_SECRET_KEY")); - config.setAccessKey("b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8"); - config.setAccessSecret("kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP"); - config.setBucket("ruoyi-vue-pro"); - config.setDomain("http://test.yudao.iocoder.cn"); // 如果有自定义域名,则可以设置。http://static.yudao.iocoder.cn - // 默认上海的 endpoint - config.setEndpoint("s3-cn-south-1.qiniucs.com"); - - // 执行上传 - testExecuteUpload(config); - } - - @Test - @Disabled // 华为云存储,如果要集成测试,可以注释本行 - public void testHuaweiCloud() throws Exception { - S3FileClientConfig config = new S3FileClientConfig(); - // 配置成你自己的 -// config.setAccessKey(System.getenv("HUAWEI_CLOUD_ACCESS_KEY")); -// config.setAccessSecret(System.getenv("HUAWEI_CLOUD_SECRET_KEY")); - config.setBucket("yudao"); - config.setDomain(null); // 如果有自定义域名,则可以设置。 - // 默认上海的 endpoint - config.setEndpoint("obs.cn-east-3.myhuaweicloud.com"); - - // 执行上传 - testExecuteUpload(config); - } - - private void testExecuteUpload(S3FileClientConfig config) throws Exception { - // 校验配置 - ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config); - // 创建 Client - S3FileClient client = new S3FileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - // 读取文件 - if (true) { - byte[] bytes = client.getContent(path); - System.out.println("文件内容:" + bytes.length); - } - // 删除文件 - if (false) { - client.delete(path); - } - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/sftp/SftpFileClientTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/sftp/SftpFileClientTest.java deleted file mode 100644 index 1e00cf196..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/sftp/SftpFileClientTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.infra.framework.file.core.sftp; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.util.IdUtil; -import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClient; -import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClientConfig; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class SftpFileClientTest { - - @Test - @Disabled - public void test() { - // 创建客户端 - SftpFileClientConfig config = new SftpFileClientConfig(); - config.setDomain("http://127.0.0.1:48080"); - config.setBasePath("/home/ftp"); - config.setHost("kanchai.club"); - config.setPort(222); - config.setUsername(""); - config.setPassword(""); - SftpFileClient client = new SftpFileClient(0L, config); - client.init(); - // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".jpg"; - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - String fullPath = client.upload(content, path, "image/jpeg"); - System.out.println("访问地址:" + fullPath); - if (false) { - byte[] bytes = client.getContent(path); - System.out.println("文件内容:" + bytes); - } - if (false) { - client.delete(path); - } - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java deleted file mode 100644 index a6de8d9ee..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/DefaultDatabaseQueryTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.infra.service; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.generator.query.DefaultQuery; -import com.baomidou.mybatisplus.generator.config.DataSourceConfig; -import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; - -import java.util.List; - -public class DefaultDatabaseQueryTest { - - public static void main(String[] args) { -// DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:oracle:thin:@127.0.0.1:1521:xe", -// "root", "123456").build(); - DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro", - "root", "123456").build(); -// StrategyConfig strategyConfig = new StrategyConfig.Builder().build(); - - ConfigBuilder builder = new ConfigBuilder(null, dataSourceConfig, null, null, null, null); - - DefaultQuery query = new DefaultQuery(builder); - - long time = System.currentTimeMillis(); - List tableInfos = query.queryTables(); - for (TableInfo tableInfo : tableInfos) { - if (StrUtil.startWithAny(tableInfo.getName().toLowerCase(), "act_", "flw_", "qrtz_")) { - continue; - } - System.out.println(String.format("CREATE SEQUENCE %s_seq MINVALUE 1;", tableInfo.getName())); -// System.out.println(String.format("DELETE FROM %s WHERE deleted = '1';", tableInfo.getName())); - } - System.out.println(tableInfos.size()); - System.out.println(System.currentTimeMillis() - time); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java deleted file mode 100644 index 2cdc4cea6..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImplTest.java +++ /dev/null @@ -1,559 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen; - -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenCreateListReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenUpdateReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column.CodegenColumnSaveReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTablePageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.DatabaseTableRespVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenColumnMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; -import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; -import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder; -import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine; -import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import org.junit.jupiter.api.Disabled; -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 java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * {@link CodegenServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(CodegenServiceImpl.class) -public class CodegenServiceImplTest extends BaseDbUnitTest { - - @Resource - private CodegenServiceImpl codegenService; - - @Resource - private CodegenTableMapper codegenTableMapper; - @Resource - private CodegenColumnMapper codegenColumnMapper; - - @MockBean - private DatabaseTableService databaseTableService; - - @MockBean - private AdminUserApi userApi; - - @MockBean - private CodegenBuilder codegenBuilder; - @MockBean - private CodegenEngine codegenEngine; - - @MockBean - private CodegenProperties codegenProperties; - - @Test - public void testCreateCodegenList() { - // 准备参数 - Long userId = randomLongId(); - CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class, - o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai"))); - // mock 方法(TableInfo) - TableInfo tableInfo = mock(TableInfo.class); - when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) - .thenReturn(tableInfo); - when(tableInfo.getComment()).thenReturn("芋艿"); - // mock 方法(TableInfo fields) - TableField field01 = mock(TableField.class); - when(field01.getComment()).thenReturn("主键"); - TableField field02 = mock(TableField.class); - when(field02.getComment()).thenReturn("名字"); - List fields = Arrays.asList(field01, field02); - when(tableInfo.getFields()).thenReturn(fields); - // mock 方法(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class); - when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table); - // mock 方法(AdminUserRespDTO) - AdminUserRespDTO user = randomPojo(AdminUserRespDTO.class, o -> o.setNickname("芋头")); - when(userApi.getUser(eq(userId))).thenReturn(success(user)); - // mock 方法(CodegenColumnDO) - List columns = randomPojoList(CodegenColumnDO.class); - when(codegenBuilder.buildColumns(eq(table.getId()), same(fields))) - .thenReturn(columns); - // mock 方法(CodegenProperties) - when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3.getType()); - - // 调用 - List result = codegenService.createCodegenList(userId, reqVO); - // 断言 - assertEquals(1, result.size()); - // 断言(CodegenTableDO) - CodegenTableDO dbTable = codegenTableMapper.selectList().get(0); - assertPojoEquals(table, dbTable); - assertEquals(1L, dbTable.getDataSourceConfigId()); - assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene()); - assertEquals(CodegenFrontTypeEnum.VUE3.getType(), dbTable.getFrontType()); - assertEquals("芋头", dbTable.getAuthor()); - // 断言(CodegenColumnDO) - List dbColumns = codegenColumnMapper.selectList(); - assertEquals(columns.size(), dbColumns.size()); - assertTrue(dbColumns.get(0).getPrimaryKey()); - for (int i = 0; i < dbColumns.size(); i++) { - assertPojoEquals(columns.get(i), dbColumns.get(i)); - } - } - - @Test - public void testValidateTableInfo() { - // 情况一 - assertServiceException(() -> codegenService.validateTableInfo(null), - CODEGEN_IMPORT_TABLE_NULL); - // 情况二 - TableInfo tableInfo = mock(TableInfo.class); - assertServiceException(() -> codegenService.validateTableInfo(tableInfo), - CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL); - // 情况三 - when(tableInfo.getComment()).thenReturn("芋艿"); - assertServiceException(() -> codegenService.validateTableInfo(tableInfo), - CODEGEN_IMPORT_COLUMNS_NULL); - // 情况四 - TableField field = mock(TableField.class); - when(field.getName()).thenReturn("name"); - when(tableInfo.getFields()).thenReturn(Collections.singletonList(field)); - assertServiceException(() -> codegenService.validateTableInfo(tableInfo), - CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL, field.getName()); - } - - @Test - public void testUpdateCodegen_notExists() { - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class); - // mock 方法 - - // 调用,并断言 - assertServiceException(() -> codegenService.updateCodegen(updateReqVO), - CODEGEN_TABLE_NOT_EXISTS); - } - - @Test - public void testUpdateCodegen_sub_masterNotExists() { - // mock 数据 - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, - o -> o.getTable().setId(table.getId()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType())); - - // 调用,并断言 - assertServiceException(() -> codegenService.updateCodegen(updateReqVO), - CODEGEN_MASTER_TABLE_NOT_EXISTS, updateReqVO.getTable().getMasterTableId()); - } - - @Test - public void testUpdateCodegen_sub_columnNotExists() { - // mock 数据 - CodegenTableDO subTable = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(subTable); - // mock 数据(master) - CodegenTableDO masterTable = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.MASTER_ERP.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(masterTable); - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, - o -> o.getTable().setId(subTable.getId()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setMasterTableId(masterTable.getId())); - - // 调用,并断言 - assertServiceException(() -> codegenService.updateCodegen(updateReqVO), - CODEGEN_SUB_COLUMN_NOT_EXISTS, updateReqVO.getTable().getSubJoinColumnId()); - } - - @Test - public void testUpdateCodegen_success() { - // mock 数据 - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column02); - // 准备参数 - CodegenUpdateReqVO updateReqVO = randomPojo(CodegenUpdateReqVO.class, - o -> o.getTable().setId(table.getId()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) - .setScene(CodegenSceneEnum.ADMIN.getScene())); - CodegenColumnSaveReqVO columnVO01 = randomPojo(CodegenColumnSaveReqVO.class, - o -> o.setId(column01.getId()).setTableId(table.getId())); - CodegenColumnSaveReqVO columnVO02 = randomPojo(CodegenColumnSaveReqVO.class, - o -> o.setId(column02.getId()).setTableId(table.getId())); - updateReqVO.setColumns(Arrays.asList(columnVO01, columnVO02)); - - // 调用 - codegenService.updateCodegen(updateReqVO); - // 断言 - CodegenTableDO dbTable = codegenTableMapper.selectById(table.getId()); - assertPojoEquals(updateReqVO.getTable(), dbTable); - List dbColumns = codegenColumnMapper.selectList(); - assertEquals(2, dbColumns.size()); - assertPojoEquals(columnVO01, dbColumns.get(0)); - assertPojoEquals(columnVO02, dbColumns.get(1)); - } - - @Test - @Disabled // TODO @芋艿:这个单测会随机性失败,需要定位下; - public void testSyncCodegenFromDB() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, o -> o.setTableName("t_yunai") - .setDataSourceConfigId(1L).setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()) - .setColumnName("id")); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()) - .setColumnName("name")); - codegenColumnMapper.insert(column02); - // 准备参数 - Long tableId = table.getId(); - // mock 方法(TableInfo) - TableInfo tableInfo = mock(TableInfo.class); - when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) - .thenReturn(tableInfo); - when(tableInfo.getComment()).thenReturn("芋艿"); - // mock 方法(TableInfo fields) - TableField field01 = mock(TableField.class); - when(field01.getComment()).thenReturn("主键"); - TableField field03 = mock(TableField.class); - when(field03.getComment()).thenReturn("分类"); - List fields = Arrays.asList(field01, field03); - when(tableInfo.getFields()).thenReturn(fields); - when(databaseTableService.getTable(eq(1L), eq("t_yunai"))) - .thenReturn(tableInfo); - // mock 方法(CodegenTableDO) - List newColumns = randomPojoList(CodegenColumnDO.class); - when(codegenBuilder.buildColumns(eq(table.getId()), argThat(tableFields -> { - assertEquals(2, tableFields.size()); - assertSame(tableInfo.getFields(), tableFields); - return true; - }))).thenReturn(newColumns); - - // 调用 - codegenService.syncCodegenFromDB(tableId); - // 断言 - List dbColumns = codegenColumnMapper.selectList(); - assertEquals(newColumns.size(), dbColumns.size()); - assertPojoEquals(newColumns.get(0), dbColumns.get(0)); - assertPojoEquals(newColumns.get(1), dbColumns.get(1)); - } - - @Test - public void testDeleteCodegen_notExists() { - assertServiceException(() -> codegenService.deleteCodegen(randomLongId()), - CODEGEN_TABLE_NOT_EXISTS); - } - - @Test - public void testDeleteCodegen_success() { - // mock 数据 - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table); - CodegenColumnDO column = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column); - // 准备参数 - Long tableId = table.getId(); - - // 调用 - codegenService.deleteCodegen(tableId); - // 断言 - assertNull(codegenTableMapper.selectById(tableId)); - assertEquals(0, codegenColumnMapper.selectList().size()); - } - - @Test - public void testGetCodegenTableList() { - // mock 数据 - CodegenTableDO table01 = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table01); - CodegenTableDO table02 = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(table02); - // 准备参数 - Long dataSourceConfigId = table01.getDataSourceConfigId(); - - // 调用 - List result = codegenService.getCodegenTableList(dataSourceConfigId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(table01, result.get(0)); - } - - @Test - public void testGetCodegenTablePage() { - // mock 数据 - CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, o -> { - o.setTableName("t_yunai"); - o.setTableComment("芋艿"); - o.setClassName("SystemYunai"); - o.setCreateTime(buildTime(2021, 3, 10)); - }).setScene(CodegenSceneEnum.ADMIN.getScene()); - codegenTableMapper.insert(tableDO); - // 测试 tableName 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setTableName(randomString()))); - // 测试 tableComment 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setTableComment(randomString()))); - // 测试 className 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, o -> o.setClassName(randomString()))); - // 测试 createTime 不匹配 - codegenTableMapper.insert(cloneIgnoreId(tableDO, logDO -> logDO.setCreateTime(buildTime(2021, 4, 10)))); - // 准备参数 - CodegenTablePageReqVO reqVO = new CodegenTablePageReqVO(); - reqVO.setTableName("yunai"); - reqVO.setTableComment("芋"); - reqVO.setClassName("Yunai"); - reqVO.setCreateTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31)); - - // 调用 - PageResult pageResult = codegenService.getCodegenTablePage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(tableDO, pageResult.getList().get(0)); - } - - @Test - public void testGetCodegenTable() { - // mock 数据 - CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, o -> o.setScene(CodegenSceneEnum.ADMIN.getScene())); - codegenTableMapper.insert(tableDO); - // 准备参数 - Long id = tableDO.getId(); - - // 调用 - CodegenTableDO result = codegenService.getCodegenTable(id); - // 断言 - assertPojoEquals(tableDO, result); - } - - @Test - public void testGetCodegenColumnListByTableId() { - // mock 数据 - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class); - codegenColumnMapper.insert(column02); - // 准备参数 - Long tableId = column01.getTableId(); - - // 调用 - List result = codegenService.getCodegenColumnListByTableId(tableId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(column01, result.get(0)); - } - - @Test - public void testGenerationCodes_tableNotExists() { - assertServiceException(() -> codegenService.generationCodes(randomLongId()), - CODEGEN_TABLE_NOT_EXISTS); - } - - @Test - public void testGenerationCodes_columnNotExists() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // 准备参数 - Long tableId = table.getId(); - - // 调用,并断言 - assertServiceException(() -> codegenService.generationCodes(tableId), - CODEGEN_COLUMN_NOT_EXISTS); - } - - @Test - public void testGenerationCodes_sub_tableNotExists() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - // 准备参数 - Long tableId = table.getId(); - - // 调用,并断言 - assertServiceException(() -> codegenService.generationCodes(tableId), - CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_TABLE); - } - - @Test - public void testGenerationCodes_sub_columnNotExists() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - // mock 数据(sub CodegenTableDO) - CodegenTableDO subTable = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setMasterTableId(table.getId())); - codegenTableMapper.insert(subTable); - // 准备参数 - Long tableId = table.getId(); - - // 调用,并断言 - assertServiceException(() -> codegenService.generationCodes(tableId), - CODEGEN_SUB_COLUMN_NOT_EXISTS, subTable.getId()); - } - - @Test - public void testGenerationCodes_one_success() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column02); - // mock 执行生成 - Map codes = MapUtil.of(randomString(), randomString()); - when(codegenEngine.execute(eq(table), argThat(columns -> { - assertEquals(2, columns.size()); - assertEquals(column01, columns.get(0)); - assertEquals(column02, columns.get(1)); - return true; - }), isNull(), isNull())).thenReturn(codes); - // 准备参数 - Long tableId = table.getId(); - - // 调用 - Map result = codegenService.generationCodes(tableId); - // 断言 - assertSame(codes, result); - } - - @Test - public void testGenerationCodes_master_success() { - // mock 数据(CodegenTableDO) - CodegenTableDO table = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType())); - codegenTableMapper.insert(table); - // mock 数据(CodegenColumnDO) - CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column01); - CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())); - codegenColumnMapper.insert(column02); - // mock 数据(sub CodegenTableDO) - CodegenTableDO subTable = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setMasterTableId(table.getId()) - .setSubJoinColumnId(1024L)); - codegenTableMapper.insert(subTable); - // mock 数据(sub CodegenColumnDO) - CodegenColumnDO subColumn01 = randomPojo(CodegenColumnDO.class, o -> o.setId(1024L).setTableId(subTable.getId())); - codegenColumnMapper.insert(subColumn01); - // mock 执行生成 - Map codes = MapUtil.of(randomString(), randomString()); - when(codegenEngine.execute(eq(table), argThat(columns -> { - assertEquals(2, columns.size()); - assertEquals(column01, columns.get(0)); - assertEquals(column02, columns.get(1)); - return true; - }), argThat(tables -> { - assertEquals(1, tables.size()); - assertPojoEquals(subTable, tables.get(0)); - return true; - }), argThat(columns -> { - assertEquals(1, columns.size()); - assertPojoEquals(subColumn01, columns.size()); - return true; - }))).thenReturn(codes); - // 准备参数 - Long tableId = table.getId(); - - // 调用 - Map result = codegenService.generationCodes(tableId); - // 断言 - assertSame(codes, result); - } - - @Test - public void testGetDatabaseTableList() { - // 准备参数 - Long dataSourceConfigId = randomLongId(); - String name = randomString(); - String comment = randomString(); - // mock 方法 - TableInfo tableInfo01 = mock(TableInfo.class); - when(tableInfo01.getName()).thenReturn("t_yunai"); - when(tableInfo01.getComment()).thenReturn("芋艿"); - TableInfo tableInfo02 = mock(TableInfo.class); - when(tableInfo02.getName()).thenReturn("t_yunai_02"); - when(tableInfo02.getComment()).thenReturn("芋艿_02"); - when(databaseTableService.getTableList(eq(dataSourceConfigId), eq(name), eq(comment))) - .thenReturn(ListUtil.toList(tableInfo01, tableInfo02)); - // mock 数据 - CodegenTableDO tableDO = randomPojo(CodegenTableDO.class, - o -> o.setScene(CodegenSceneEnum.ADMIN.getScene()) - .setTableName("t_yunai_02") - .setDataSourceConfigId(dataSourceConfigId)); - codegenTableMapper.insert(tableDO); - - // 调用 - List result = codegenService.getDatabaseTableList(dataSourceConfigId, name, comment); - // 断言 - assertEquals(1, result.size()); - assertEquals("t_yunai", result.get(0).getName()); - assertEquals("芋艿", result.get(0).getComment()); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java deleted file mode 100644 index 7a26ea9cc..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilderTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import com.baomidou.mybatisplus.generator.config.rules.IColumnType; -import org.apache.ibatis.type.JdbcType; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; - -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CodegenBuilderTest extends BaseMockitoUnitTest { - - @InjectMocks - private CodegenBuilder codegenBuilder; - - @Test - public void testBuildTable() { - // 准备参数 - TableInfo tableInfo = mock(TableInfo.class); - // mock 方法 - when(tableInfo.getName()).thenReturn("system_user"); - when(tableInfo.getComment()).thenReturn("用户"); - - // 调用 - CodegenTableDO table = codegenBuilder.buildTable(tableInfo); - // 断言 - assertEquals("system_user", table.getTableName()); - assertEquals("用户", table.getTableComment()); - assertEquals("system", table.getModuleName()); - assertEquals("user", table.getBusinessName()); - assertEquals("User", table.getClassName()); - assertEquals("用户", table.getClassComment()); - } - - @Test - public void testBuildColumns() { - // 准备参数 - Long tableId = randomLongId(); - TableField tableField = mock(TableField.class); - List tableFields = Collections.singletonList(tableField); - // mock 方法 - TableField.MetaInfo metaInfo = mock(TableField.MetaInfo.class); - when(tableField.getMetaInfo()).thenReturn(metaInfo); - when(metaInfo.getJdbcType()).thenReturn(JdbcType.BIGINT); - when(tableField.getComment()).thenReturn("编号"); - when(tableField.isKeyFlag()).thenReturn(true); - IColumnType columnType = mock(IColumnType.class); - when(tableField.getColumnType()).thenReturn(columnType); - when(columnType.getType()).thenReturn("Long"); - when(tableField.getName()).thenReturn("id2"); - when(tableField.getPropertyName()).thenReturn("id"); - - // 调用 - List columns = codegenBuilder.buildColumns(tableId, tableFields); - // 断言 - assertEquals(1, columns.size()); - CodegenColumnDO column = columns.get(0); - assertEquals(tableId, column.getTableId()); - assertEquals("id2", column.getColumnName()); - assertEquals("BIGINT", column.getDataType()); - assertEquals("编号", column.getColumnComment()); - assertFalse(column.getNullable()); - assertTrue(column.getPrimaryKey()); - assertEquals(1, column.getOrdinalPosition()); - assertEquals("Long", column.getJavaType()); - assertEquals("id", column.getJavaField()); - assertNull(column.getDictType()); - assertNotNull(column.getExample()); - assertFalse(column.getCreateOperation()); - assertTrue(column.getUpdateOperation()); - assertFalse(column.getListOperation()); - assertEquals("=", column.getListOperationCondition()); - assertTrue(column.getListOperationResult()); - assertEquals("input", column.getHtmlType()); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java deleted file mode 100644 index 3c7390abe..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.io.resource.ResourceUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.core.util.ZipUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; -import org.junit.jupiter.api.BeforeEach; -import org.mockito.InjectMocks; -import org.mockito.Spy; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * {@link CodegenEngine} 的单元测试抽象基类 - * - * @author 芋道源码 - */ -public abstract class CodegenEngineAbstractTest extends BaseMockitoUnitTest { - - /** - * 测试文件资源目录 - */ - private String resourcesPath = ""; - - @InjectMocks - protected CodegenEngine codegenEngine; - - @Spy - protected CodegenProperties codegenProperties = new CodegenProperties() - .setBasePackage("cn.iocoder.yudao"); - - @BeforeEach - public void setUp() { - codegenEngine.setJakartaEnable(true); // 强制使用 jakarta,保证单测可以基于 jakarta 断言 - codegenEngine.initGlobalBindingMap(); - // 单测强制使用 - // 获取测试文件 resources 路径 - String absolutePath = FileUtil.getAbsolutePath("application-unit-test.yaml"); - // 系统不一样生成的文件也有差异,那就各自生成各自的 - resourcesPath = absolutePath.split("/target")[0] + "/src/test/resources/codegen/"; - } - - protected static CodegenTableDO getTable(String name) { - String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); - return JsonUtils.parseObject(content, "table", CodegenTableDO.class); - } - - protected static List getColumnList(String name) { - String content = ResourceUtil.readUtf8Str("codegen/table/" + name + ".json"); - List list = JsonUtils.parseArray(content, "columns", CodegenColumnDO.class); - list.forEach(column -> { - if (column.getNullable() == null) { - column.setNullable(false); - } - if (column.getCreateOperation() == null) { - column.setCreateOperation(false); - } - if (column.getUpdateOperation() == null) { - column.setUpdateOperation(false); - } - if (column.getListOperation() == null) { - column.setListOperation(false); - } - if (column.getListOperationResult() == null) { - column.setListOperationResult(false); - } - }); - return list; - } - - @SuppressWarnings("rawtypes") - protected static void assertResult(Map result, String path) { - String assertContent = ResourceUtil.readUtf8Str("codegen/" + path + "/assert.json"); - List asserts = JsonUtils.parseArray(assertContent, HashMap.class); - assertEquals(asserts.size(), result.size()); - // 校验每个文件 - asserts.forEach(assertMap -> { - String contentPath = (String) assertMap.get("contentPath"); - String filePath = (String) assertMap.get("filePath"); - String content = ResourceUtil.readUtf8Str("codegen/" + path + "/" + contentPath); - assertEquals(content, result.get(filePath), filePath + ":不匹配"); - }); - } - - // ==================== 调试专用 ==================== - - /** - * 【调试使用】将生成的代码,写入到文件 - * - * @param result 生成的代码 - * @param path 写入文件的路径 - */ - protected void writeFile(Map result, String path) { - // 生成压缩包 - String[] paths = result.keySet().toArray(new String[0]); - ByteArrayInputStream[] ins = result.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ZipUtil.zip(outputStream, paths, ins); - // 写入文件 - FileUtil.writeBytes(outputStream.toByteArray(), path); - } - - /** - * 【调试使用】将生成的结果,写入到文件 - * - * @param result 生成的代码 - * @param basePath 写入文件的路径(绝对路径) - */ - protected void writeResult(Map result, String basePath) { - // 写入文件内容 - List> asserts = new ArrayList<>(); - result.forEach((filePath, fileContent) -> { - String lastFilePath = StrUtil.subAfter(filePath, '/', true); - String contentPath = StrUtil.subAfter(lastFilePath, '.', true) - + '/' + StrUtil.subBefore(lastFilePath, '.', true); - asserts.add(MapUtil.builder().put("filePath", filePath) - .put("contentPath", contentPath).build()); - FileUtil.writeUtf8String(fileContent, basePath + "/" + contentPath); - }); - // 写入 assert.json 文件 - FileUtil.writeUtf8String(JsonUtils.toJsonPrettyString(asserts), basePath + "/assert.json"); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java deleted file mode 100644 index 94d24bed1..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * {@link CodegenEngine} 的 Vue2 + Element UI 单元测试 - * - * @author 芋道源码 - */ -@Disabled -public class CodegenEngineVue2Test extends CodegenEngineAbstractTest { - - @Test - public void testExecute_vue2_one() { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); - List columns = getColumnList("student"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue2_one"); - // 断言 - assertResult(result, "/vue2_one"); - } - - @Test - public void testExecute_vue2_tree() { - // 准备参数 - CodegenTableDO table = getTable("category") - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); - List columns = getColumnList("category"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue2_tree"); - // 断言 - assertResult(result, "/vue2_tree"); -// writeFile(result, "/Users/yunai/test/demo66.zip"); - } - - @Test - public void testExecute_vue2_master_normal() { - testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "/vue2_master_normal"); - } - - @Test - public void testExecute_vue2_master_erp() { - testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_ERP, "/vue2_master_erp"); - } - - @Test - public void testExecute_vue2_master_inner() { - testExecute_vue2_master(CodegenTemplateTypeEnum.MASTER_INNER, "/vue2_master_inner"); - } - - private void testExecute_vue2_master(CodegenTemplateTypeEnum templateType, - String path) { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setTemplateType(templateType.getType()); - List columns = getColumnList("student"); - // 准备参数(子表) - CodegenTableDO contactTable = getTable("contact") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setSubJoinColumnId(100L).setSubJoinMany(true); - List contactColumns = getColumnList("contact"); - // 准备参数(班主任) - CodegenTableDO teacherTable = getTable("teacher") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE2.getType()) - .setSubJoinColumnId(200L).setSubJoinMany(false); - List teacherColumns = getColumnList("teacher"); - - // 调用 - Map result = codegenEngine.execute(table, columns, - Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); - // 生成测试文件 - //writeResult(result, resourcesPath + path); - // 断言 - assertResult(result, path); -// writeFile(result, "/Users/yunai/test/demo11.zip"); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java deleted file mode 100644 index 4684db78c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue3Test.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.codegen.inner; - -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * {@link CodegenEngine} 的 Vue2 + Element Plus 单元测试 - * - * @author 芋道源码 - */ -@Disabled -public class CodegenEngineVue3Test extends CodegenEngineAbstractTest { - - @Test - public void testExecute_vue3_one() { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()); - List columns = getColumnList("student"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue3_one"); - // 断言 - assertResult(result, "/vue3_one"); - } - - @Test - public void testExecute_vue3_tree() { - // 准备参数 - CodegenTableDO table = getTable("category") - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setTemplateType(CodegenTemplateTypeEnum.TREE.getType()); - List columns = getColumnList("category"); - - // 调用 - Map result = codegenEngine.execute(table, columns, null, null); - // 生成测试文件 - //writeResult(result, resourcesPath + "/vue3_tree"); - // 断言 - assertResult(result, "/vue3_tree"); -// writeFile(result, "/Users/yunai/test/demo66.zip"); - } - - @Test - public void testExecute_vue3_master_normal() { - testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_NORMAL, "/vue3_master_normal"); - } - - @Test - public void testExecute_vue3_master_erp() { - testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_ERP, "/vue3_master_erp"); - } - - @Test - public void testExecute_vue3_master_inner() { - testExecute_vue3_master(CodegenTemplateTypeEnum.MASTER_INNER, "/vue3_master_inner"); - } - - private void testExecute_vue3_master(CodegenTemplateTypeEnum templateType, - String path) { - // 准备参数 - CodegenTableDO table = getTable("student") - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setTemplateType(templateType.getType()); - List columns = getColumnList("student"); - // 准备参数(子表) - CodegenTableDO contactTable = getTable("contact") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setSubJoinColumnId(100L).setSubJoinMany(true); - List contactColumns = getColumnList("contact"); - // 准备参数(班主任) - CodegenTableDO teacherTable = getTable("teacher") - .setTemplateType(CodegenTemplateTypeEnum.SUB.getType()) - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) - .setSubJoinColumnId(200L).setSubJoinMany(false); - List teacherColumns = getColumnList("teacher"); - - // 调用 - Map result = codegenEngine.execute(table, columns, - Arrays.asList(contactTable, teacherTable), Arrays.asList(contactColumns, teacherColumns)); - // 生成测试文件 - //writeResult(result, resourcesPath + path); - // 断言 - assertResult(result, path); - // writeFile(result, "/Users/yunai/test/demo11.zip"); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java deleted file mode 100644 index 1c1f1f3e8..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.config; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO; -import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper; -import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; - -@Import(ConfigServiceImpl.class) -public class ConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private ConfigServiceImpl configService; - - @Resource - private ConfigMapper configMapper; - - @Test - public void testCreateConfig_success() { - // 准备参数 - ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class) - .setId(null); // 防止 id 被赋值,导致唯一性校验失败 - - // 调用 - Long configId = configService.createConfig(reqVO); - // 断言 - assertNotNull(configId); - // 校验记录的属性是否正确 - ConfigDO config = configMapper.selectById(configId); - assertPojoEquals(reqVO, config, "id"); - assertEquals(ConfigTypeEnum.CUSTOM.getType(), config.getType()); - } - - @Test - public void testUpdateConfig_success() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class, o -> { - o.setId(dbConfig.getId()); // 设置更新的 ID - }); - - // 调用 - configService.updateConfig(reqVO); - // 校验是否更新正确 - ConfigDO config = configMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, config); - } - - @Test - public void testDeleteConfig_success() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(o -> { - o.setType(ConfigTypeEnum.CUSTOM.getType()); // 只能删除 CUSTOM 类型 - }); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbConfig.getId(); - - // 调用 - configService.deleteConfig(id); - // 校验数据不存在了 - assertNull(configMapper.selectById(id)); - } - - @Test - public void testDeleteConfig_canNotDeleteSystemType() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(o -> { - o.setType(ConfigTypeEnum.SYSTEM.getType()); // SYSTEM 不允许删除 - }); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbConfig.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> configService.deleteConfig(id), CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE); - } - - @Test - public void testValidateConfigExists_success() { - // mock 数据 - ConfigDO dbConfigDO = randomConfigDO(); - configMapper.insert(dbConfigDO);// @Sql: 先插入出一条存在的数据 - - // 调用成功 - configService.validateConfigExists(dbConfigDO.getId()); - } - - @Test - public void testValidateConfigExist_notExists() { - assertServiceException(() -> configService.validateConfigExists(randomLongId()), CONFIG_NOT_EXISTS); - } - - @Test - public void testValidateConfigKeyUnique_success() { - // 调用,成功 - configService.validateConfigKeyUnique(randomLongId(), randomString()); - } - - @Test - public void testValidateConfigKeyUnique_keyDuplicateForCreate() { - // 准备参数 - String key = randomString(); - // mock 数据 - configMapper.insert(randomConfigDO(o -> o.setConfigKey(key))); - - // 调用,校验异常 - assertServiceException(() -> configService.validateConfigKeyUnique(null, key), - CONFIG_KEY_DUPLICATE); - } - - @Test - public void testValidateConfigKeyUnique_keyDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String key = randomString(); - // mock 数据 - configMapper.insert(randomConfigDO(o -> o.setConfigKey(key))); - - // 调用,校验异常 - assertServiceException(() -> configService.validateConfigKeyUnique(id, key), - CONFIG_KEY_DUPLICATE); - } - - @Test - public void testGetConfigPage() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(o -> { // 等会查询到 - o.setName("芋艿"); - o.setConfigKey("yunai"); - o.setType(ConfigTypeEnum.SYSTEM.getType()); - o.setCreateTime(buildTime(2021, 2, 1)); - }); - configMapper.insert(dbConfig); - // 测试 name 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setName("土豆"))); - // 测试 key 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou"))); - // 测试 type 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType()))); - // 测试 createTime 不匹配 - configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - ConfigPageReqVO reqVO = new ConfigPageReqVO(); - reqVO.setName("艿"); - reqVO.setKey("nai"); - reqVO.setType(ConfigTypeEnum.SYSTEM.getType()); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 15, 2021, 2, 15)); - - // 调用 - PageResult pageResult = configService.getConfigPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbConfig, pageResult.getList().get(0)); - } - - @Test - public void testGetConfig() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbConfig.getId(); - - // 调用 - ConfigDO config = configService.getConfig(id); - // 断言 - assertNotNull(config); - assertPojoEquals(dbConfig, config); - } - - @Test - public void testGetConfigByKey() { - // mock 数据 - ConfigDO dbConfig = randomConfigDO(); - configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - String key = dbConfig.getConfigKey(); - - // 调用 - ConfigDO config = configService.getConfigByKey(key); - // 断言 - assertNotNull(config); - assertPojoEquals(dbConfig, config); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static ConfigDO randomConfigDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setType(randomEle(ConfigTypeEnum.values()).getType()); // 保证 key 的范围 - }; - return RandomUtils.randomPojo(ConfigDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java deleted file mode 100755 index 1c34679a3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.db; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.hutool.crypto.symmetric.AES; -import cn.iocoder.yudao.framework.mybatis.core.type.EncryptTypeHandler; -import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; -import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper; -import com.baomidou.dynamic.datasource.creator.DataSourceProperty; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.mockito.stubbing.Answer; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DATA_SOURCE_CONFIG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; - -/** - * {@link DataSourceConfigServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(DataSourceConfigServiceImpl.class) -public class DataSourceConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private DataSourceConfigServiceImpl dataSourceConfigService; - - @Resource - private DataSourceConfigMapper dataSourceConfigMapper; - - @MockBean - private AES aes; - - @MockBean - private DynamicDataSourceProperties dynamicDataSourceProperties; - - @BeforeEach - public void setUp() { - // mock 一个空实现的 StringEncryptor,避免 EncryptTypeHandler 报错 - ReflectUtil.setFieldValue(EncryptTypeHandler.class, "aes", aes); - when(aes.encryptBase64(anyString())).then((Answer) invocation -> invocation.getArgument(0)); - when(aes.decryptStr(anyString())).then((Answer) invocation -> invocation.getArgument(0)); - - // mock DynamicDataSourceProperties - when(dynamicDataSourceProperties.getPrimary()).thenReturn("primary"); - DataSourceProperty dataSourceProperty = new DataSourceProperty(); - dataSourceProperty.setUrl("http://localhost:3306"); - dataSourceProperty.setUsername("yunai"); - dataSourceProperty.setPassword("tudou"); - when(dynamicDataSourceProperties.getDatasource()).thenReturn(MapUtil.of("primary", dataSourceProperty)); - } - - @Test - public void testCreateDataSourceConfig_success() { - try (MockedStatic databaseUtilsMock = mockStatic(JdbcUtils.class)) { - // 准备参数 - DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class) - .setId(null); // 避免 id 被设置 - // mock 方法 - databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()), - eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true); - - // 调用 - Long dataSourceConfigId = dataSourceConfigService.createDataSourceConfig(reqVO); - // 断言 - assertNotNull(dataSourceConfigId); - // 校验记录的属性是否正确 - DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(dataSourceConfigId); - assertPojoEquals(reqVO, dataSourceConfig, "id"); - } - } - - @Test - public void testUpdateDataSourceConfig_success() { - try (MockedStatic databaseUtilsMock = mockStatic(JdbcUtils.class)) { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class, o -> { - o.setId(dbDataSourceConfig.getId()); // 设置更新的 ID - }); - // mock 方法 - databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()), - eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true); - - // 调用 - dataSourceConfigService.updateDataSourceConfig(reqVO); - // 校验是否更新正确 - DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, dataSourceConfig); - } - } - - @Test - public void testUpdateDataSourceConfig_notExists() { - // 准备参数 - DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> dataSourceConfigService.updateDataSourceConfig(reqVO), DATA_SOURCE_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteDataSourceConfig_success() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDataSourceConfig.getId(); - - // 调用 - dataSourceConfigService.deleteDataSourceConfig(id); - // 校验数据不存在了 - assertNull(dataSourceConfigMapper.selectById(id)); - } - - @Test - public void testDeleteDataSourceConfig_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> dataSourceConfigService.deleteDataSourceConfig(id), DATA_SOURCE_CONFIG_NOT_EXISTS); - } - - @Test // 测试使用 password 查询,可以查询到数据 - public void testSelectPassword() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - - // 调用 - DataSourceConfigDO result = dataSourceConfigMapper.selectOne(DataSourceConfigDO::getPassword, - EncryptTypeHandler.encrypt(dbDataSourceConfig.getPassword())); - assertPojoEquals(dbDataSourceConfig, result); - } - - @Test - public void testGetDataSourceConfig_master() { - // 准备参数 - Long id = 0L; - // mock 方法 - - // 调用 - DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id); - // 断言 - assertEquals(id, dataSourceConfig.getId()); - assertEquals("primary", dataSourceConfig.getName()); - assertEquals("http://localhost:3306", dataSourceConfig.getUrl()); - assertEquals("yunai", dataSourceConfig.getUsername()); - assertEquals("tudou", dataSourceConfig.getPassword()); - } - - @Test - public void testGetDataSourceConfig_normal() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDataSourceConfig.getId(); - - // 调用 - DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id); - // 断言 - assertPojoEquals(dbDataSourceConfig, dataSourceConfig); - } - - @Test - public void testGetDataSourceConfigList() { - // mock 数据 - DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class); - dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - - // 调用 - List dataSourceConfigList = dataSourceConfigService.getDataSourceConfigList(); - // 断言 - assertEquals(2, dataSourceConfigList.size()); - // master - assertEquals(0L, dataSourceConfigList.get(0).getId()); - assertEquals("primary", dataSourceConfigList.get(0).getName()); - assertEquals("http://localhost:3306", dataSourceConfigList.get(0).getUrl()); - assertEquals("yunai", dataSourceConfigList.get(0).getUsername()); - assertEquals("tudou", dataSourceConfigList.get(0).getPassword()); - // normal - assertPojoEquals(dbDataSourceConfig, dataSourceConfigList.get(1)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java deleted file mode 100644 index 6ce8c7d41..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.db; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; -import com.baomidou.mybatisplus.generator.config.po.TableField; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; -import org.apache.ibatis.type.JdbcType; -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 java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(DatabaseTableServiceImpl.class) -public class DatabaseTableServiceImplTest extends BaseDbUnitTest { - - @Resource - private DatabaseTableServiceImpl databaseTableService; - - @MockBean - private DataSourceConfigService dataSourceConfigService; - - @Test - public void testGetTableList() { - // 准备参数 - Long dataSourceConfigId = randomLongId(); - // mock 方法 - DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("") - .setUrl("jdbc:h2:mem:testdb"); - when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId))) - .thenReturn(dataSourceConfig); - - // 调用 - List tables = databaseTableService.getTableList(dataSourceConfigId, - "config", "参数"); - // 断言 - assertEquals(1, tables.size()); - assertTableInfo(tables.get(0)); - } - - @Test - public void testGetTable() { - // 准备参数 - Long dataSourceConfigId = randomLongId(); - // mock 方法 - DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("") - .setUrl("jdbc:h2:mem:testdb"); - when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId))) - .thenReturn(dataSourceConfig); - - // 调用 - TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, "infra_config"); - // 断言 - assertTableInfo(tableInfo); - } - - private void assertTableInfo(TableInfo tableInfo) { - assertEquals("infra_config", tableInfo.getName()); - assertEquals("参数配置表", tableInfo.getComment()); - assertEquals(13, tableInfo.getFields().size()); - // id 字段 - TableField idField = tableInfo.getFields().get(0); - assertEquals("id", idField.getName()); - assertEquals(JdbcType.BIGINT, idField.getMetaInfo().getJdbcType()); - assertEquals("编号", idField.getComment()); - assertFalse(idField.getMetaInfo().isNullable()); - assertTrue(idField.isKeyFlag()); - assertTrue(idField.isKeyIdentityFlag()); - assertEquals(DbColumnType.LONG, idField.getColumnType()); - assertEquals("id", idField.getPropertyName()); - // name 字段 - TableField nameField = tableInfo.getFields().get(3); - assertEquals("name", nameField.getName()); - assertEquals(JdbcType.VARCHAR, nameField.getMetaInfo().getJdbcType()); - assertEquals("名字", nameField.getComment()); - assertFalse(nameField.getMetaInfo().isNullable()); - assertFalse(nameField.isKeyFlag()); - assertFalse(nameField.isKeyIdentityFlag()); - assertEquals(DbColumnType.STRING, nameField.getColumnType()); - assertEquals("name", nameField.getPropertyName()); - } -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java deleted file mode 100755 index 275bba035..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java +++ /dev/null @@ -1,281 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.file; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; -import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO; -import cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper; -import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; -import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; -import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactory; -import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClient; -import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClientConfig; -import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum; -import lombok.Data; -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.io.Serializable; -import java.time.LocalDateTime; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_DELETE_FAIL_MASTER; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link FileConfigServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(FileConfigServiceImpl.class) -public class FileConfigServiceImplTest extends BaseDbUnitTest { - - @Resource - private FileConfigServiceImpl fileConfigService; - - @Resource - private FileConfigMapper fileConfigMapper; - - @MockBean - private Validator validator; - @MockBean - private FileClientFactory fileClientFactory; - - @Test - public void testCreateFileConfig_success() { - // 准备参数 - Map config = MapUtil.builder().put("basePath", "/yunai") - .put("domain", "https://www.iocoder.cn").build(); - FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, - o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()).setConfig(config)) - .setId(null); // 避免 id 被赋值 - - // 调用 - Long fileConfigId = fileConfigService.createFileConfig(reqVO); - // 断言 - assertNotNull(fileConfigId); - // 校验记录的属性是否正确 - FileConfigDO fileConfig = fileConfigMapper.selectById(fileConfigId); - assertPojoEquals(reqVO, fileConfig, "id", "config"); - assertFalse(fileConfig.getMaster()); - assertEquals("/yunai", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath()); - assertEquals("https://www.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain()); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(fileConfigId)); - } - - @Test - public void testUpdateFileConfig_success() { - // mock 数据 - FileConfigDO dbFileConfig = randomPojo(FileConfigDO.class, o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()) - .setConfig(new LocalFileClientConfig().setBasePath("/yunai").setDomain("https://www.iocoder.cn"))); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, o -> { - o.setId(dbFileConfig.getId()); // 设置更新的 ID - o.setStorage(FileStorageEnum.LOCAL.getStorage()); - Map config = MapUtil.builder().put("basePath", "/yunai2") - .put("domain", "https://doc.iocoder.cn").build(); - o.setConfig(config); - }); - - // 调用 - fileConfigService.updateFileConfig(reqVO); - // 校验是否更新正确 - FileConfigDO fileConfig = fileConfigMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, fileConfig, "config"); - assertEquals("/yunai2", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath()); - assertEquals("https://doc.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain()); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(fileConfig.getId())); - } - - @Test - public void testUpdateFileConfig_notExists() { - // 准备参数 - FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.updateFileConfig(reqVO), FILE_CONFIG_NOT_EXISTS); - } - - @Test - public void testUpdateFileConfigMaster_success() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - FileConfigDO masterFileConfig = randomFileConfigDO().setMaster(true); - fileConfigMapper.insert(masterFileConfig);// @Sql: 先插入出一条存在的数据 - - // 调用 - fileConfigService.updateFileConfigMaster(dbFileConfig.getId()); - // 断言数据 - assertTrue(fileConfigMapper.selectById(dbFileConfig.getId()).getMaster()); - assertFalse(fileConfigMapper.selectById(masterFileConfig.getId()).getMaster()); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(0L)); - } - - @Test - public void testUpdateFileConfigMaster_notExists() { - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.updateFileConfigMaster(randomLongId()), FILE_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteFileConfig_success() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - - // 调用 - fileConfigService.deleteFileConfig(id); - // 校验数据不存在了 - assertNull(fileConfigMapper.selectById(id)); - // 验证 cache - assertNull(fileConfigService.getClientCache().getIfPresent(id)); - } - - @Test - public void testDeleteFileConfig_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.deleteFileConfig(id), FILE_CONFIG_NOT_EXISTS); - } - - @Test - public void testDeleteFileConfig_master() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(true); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> fileConfigService.deleteFileConfig(id), FILE_CONFIG_DELETE_FAIL_MASTER); - } - - @Test - public void testGetFileConfigPage() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码") - .setStorage(FileStorageEnum.LOCAL.getStorage()); - dbFileConfig.setCreateTime(LocalDateTimeUtil.parse("2020-01-23", DatePattern.NORM_DATE_PATTERN));// 等会查询到 - fileConfigMapper.insert(dbFileConfig); - // 测试 name 不匹配 - fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码"))); - // 测试 storage 不匹配 - fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage()))); - // 测试 createTime 不匹配 - fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(LocalDateTimeUtil.parse("2020-11-23", DatePattern.NORM_DATE_PATTERN)))); - // 准备参数 - FileConfigPageReqVO reqVO = new FileConfigPageReqVO(); - reqVO.setName("芋道"); - reqVO.setStorage(FileStorageEnum.LOCAL.getStorage()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2020, 1, 1), - buildTime(2020, 1, 24)})); - - // 调用 - PageResult pageResult = fileConfigService.getFileConfigPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbFileConfig, pageResult.getList().get(0)); - } - - @Test - public void testFileConfig() throws Exception { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - // mock 获得 Client - FileClient fileClient = mock(FileClient.class); - when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); - when(fileClient.upload(any(), any(), any())).thenReturn("https://www.iocoder.cn"); - - // 调用,并断言 - assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id)); - } - - @Test - public void testGetFileConfig() { - // mock 数据 - FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbFileConfig.getId(); - - // 调用,并断言 - assertPojoEquals(dbFileConfig, fileConfigService.getFileConfig(id)); - } - - @Test - public void testGetFileClient() { - // mock 数据 - FileConfigDO fileConfig = randomFileConfigDO().setMaster(false); - fileConfigMapper.insert(fileConfig); - // 准备参数 - Long id = fileConfig.getId(); - // mock 获得 Client - FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); - when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient); - - // 调用,并断言 - assertSame(fileClient, fileConfigService.getFileClient(id)); - // 断言缓存 - verify(fileClientFactory).createOrUpdateFileClient(eq(id), eq(fileConfig.getStorage()), - eq(fileConfig.getConfig())); - } - - @Test - public void testGetMasterFileClient() { - // mock 数据 - FileConfigDO fileConfig = randomFileConfigDO().setMaster(true); - fileConfigMapper.insert(fileConfig); - // 准备参数 - Long id = fileConfig.getId(); - // mock 获得 Client - FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); - when(fileClientFactory.getFileClient(eq(fileConfig.getId()))).thenReturn(fileClient); - - // 调用,并断言 - assertSame(fileClient, fileConfigService.getMasterFileClient()); - // 断言缓存 - verify(fileClientFactory).createOrUpdateFileClient(eq(fileConfig.getId()), eq(fileConfig.getStorage()), - eq(fileConfig.getConfig())); - } - - private FileConfigDO randomFileConfigDO() { - return randomPojo(FileConfigDO.class).setStorage(randomEle(FileStorageEnum.values()).getStorage()) - .setConfig(new EmptyFileClientConfig()); - } - - @Data - public static class EmptyFileClientConfig implements FileClientConfig, Serializable { - - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java deleted file mode 100644 index aefac846c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java +++ /dev/null @@ -1,143 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.file; - -import cn.hutool.core.io.resource.ResourceUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; -import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper; -import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; -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 java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.same; -import static org.mockito.Mockito.*; - -@Import({FileServiceImpl.class}) -public class FileServiceImplTest extends BaseDbUnitTest { - - @Resource - private FileService fileService; - - @Resource - private FileMapper fileMapper; - - @MockBean - private FileConfigService fileConfigService; - - @Test - public void testGetFilePage() { - // mock 数据 - FileDO dbFile = randomPojo(FileDO.class, o -> { // 等会查询到 - o.setPath("yunai"); - o.setType("image/jpg"); - o.setCreateTime(buildTime(2021, 1, 15)); - }); - fileMapper.insert(dbFile); - // 测试 path 不匹配 - fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> o.setPath("tudou"))); - // 测试 type 不匹配 - fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> { - o.setType("image/png"); - })); - // 测试 createTime 不匹配 - fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> { - o.setCreateTime(buildTime(2020, 1, 15)); - })); - // 准备参数 - FilePageReqVO reqVO = new FilePageReqVO(); - reqVO.setPath("yunai"); - reqVO.setType("jp"); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 10), buildTime(2021, 1, 20)})); - - // 调用 - PageResult pageResult = fileService.getFilePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - AssertUtils.assertPojoEquals(dbFile, pageResult.getList().get(0)); - } - - @Test - public void testCreateFile_success() throws Exception { - // 准备参数 - String path = randomString(); - byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); - // mock Master 文件客户端 - FileClient client = mock(FileClient.class); - when(fileConfigService.getMasterFileClient()).thenReturn(client); - String url = randomString(); - when(client.upload(same(content), same(path), eq("image/jpeg"))).thenReturn(url); - when(client.getId()).thenReturn(10L); - String name = "单测文件名"; - // 调用 - String result = fileService.createFile(name, path, content); - // 断言 - assertEquals(result, url); - // 校验数据 - FileDO file = fileMapper.selectOne(FileDO::getPath, path); - assertEquals(10L, file.getConfigId()); - assertEquals(path, file.getPath()); - assertEquals(url, file.getUrl()); - assertEquals("image/jpeg", file.getType()); - assertEquals(content.length, file.getSize()); - } - - @Test - public void testDeleteFile_success() throws Exception { - // mock 数据 - FileDO dbFile = randomPojo(FileDO.class, o -> o.setConfigId(10L).setPath("tudou.jpg")); - fileMapper.insert(dbFile);// @Sql: 先插入出一条存在的数据 - // mock Master 文件客户端 - FileClient client = mock(FileClient.class); - when(fileConfigService.getFileClient(eq(10L))).thenReturn(client); - // 准备参数 - Long id = dbFile.getId(); - - // 调用 - fileService.deleteFile(id); - // 校验数据不存在了 - assertNull(fileMapper.selectById(id)); - // 校验调用 - verify(client).delete(eq("tudou.jpg")); - } - - @Test - public void testDeleteFile_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> fileService.deleteFile(id), FILE_NOT_EXISTS); - } - - @Test - public void testGetFileContent() throws Exception { - // 准备参数 - Long configId = 10L; - String path = "tudou.jpg"; - // mock 方法 - FileClient client = mock(FileClient.class); - when(fileConfigService.getFileClient(eq(10L))).thenReturn(client); - byte[] content = new byte[]{}; - when(client.getContent(eq("tudou.jpg"))).thenReturn(content); - - // 调用 - byte[] result = fileService.getFileContent(configId, path); - // 断言 - assertSame(result, content); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java deleted file mode 100644 index 02362c7a7..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.logger; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO; -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; -import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@Import(ApiAccessLogServiceImpl.class) -public class ApiAccessLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private ApiAccessLogServiceImpl apiAccessLogService; - - @Resource - private ApiAccessLogMapper apiAccessLogMapper; - - @Test - public void testGetApiAccessLogPage() { - ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> { - o.setUserId(2233L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setApplicationName("yudao-test"); - o.setRequestUrl("foo"); - o.setBeginTime(buildTime(2021, 3, 13)); - o.setDuration(1000); - o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); - }); - apiAccessLogMapper.insert(apiAccessLogDO); - // 测试 userId 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L))); - // 测试 userType 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 applicationName 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test"))); - // 测试 requestUrl 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar"))); - // 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6)))); - // 测试 duration 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100))); - // 测试 resultCode 不匹配 - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2))); - // 准备参数 - ApiAccessLogPageReqVO reqVO = new ApiAccessLogPageReqVO(); - reqVO.setUserId(2233L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setApplicationName("yudao-test"); - reqVO.setRequestUrl("foo"); - reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13)); - reqVO.setDuration(1000); - reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode()); - - // 调用 - PageResult pageResult = apiAccessLogService.getApiAccessLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(apiAccessLogDO, pageResult.getList().get(0)); - } - - @Test - public void testCleanJobLog() { - // mock 数据 - ApiAccessLogDO log01 = randomPojo(ApiAccessLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))); - apiAccessLogMapper.insert(log01); - ApiAccessLogDO log02 = randomPojo(ApiAccessLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))); - apiAccessLogMapper.insert(log02); - // 准备参数 - Integer exceedDay = 2; - Integer deleteLimit = 1; - - // 调用 - Integer count = apiAccessLogService.cleanAccessLog(exceedDay, deleteLimit); - // 断言 - assertEquals(1, count); - List logs = apiAccessLogMapper.selectList(); - assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); - } - - @Test - public void testCreateApiAccessLog() { - // 准备参数 - ApiAccessLogCreateReqDTO createDTO = randomPojo(ApiAccessLogCreateReqDTO.class); - - // 调用 - apiAccessLogService.createApiAccessLog(createDTO); - // 断言 - ApiAccessLogDO apiAccessLogDO = apiAccessLogMapper.selectOne(null); - assertPojoEquals(createDTO, apiAccessLogDO); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java deleted file mode 100644 index f6ba2687e..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.logger; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO; -import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO; -import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper; -import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Import(ApiErrorLogServiceImpl.class) -public class ApiErrorLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private ApiErrorLogServiceImpl apiErrorLogService; - - @Resource - private ApiErrorLogMapper apiErrorLogMapper; - - @Test - public void testGetApiErrorLogPage() { - // mock 数据 - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> { - o.setUserId(2233L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setApplicationName("yudao-test"); - o.setRequestUrl("foo"); - o.setExceptionTime(buildTime(2021, 3, 13)); - o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); - }); - apiErrorLogMapper.insert(apiErrorLogDO); - // 测试 userId 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L))); - // 测试 userType 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 applicationName 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setApplicationName("test"))); - // 测试 requestUrl 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setRequestUrl("bar"))); - // 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setExceptionTime(buildTime(2021, 2, 6)))); - // 测试 progressStatus 不匹配 - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus()))); - // 准备参数 - ApiErrorLogPageReqVO reqVO = new ApiErrorLogPageReqVO(); - reqVO.setUserId(2233L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setApplicationName("yudao-test"); - reqVO.setRequestUrl("foo"); - reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31)); - reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()); - - // 调用 - PageResult pageResult = apiErrorLogService.getApiErrorLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(apiErrorLogDO, pageResult.getList().get(0)); - } - - @Test - public void testCreateApiErrorLog() { - // 准备参数 - ApiErrorLogCreateReqDTO createDTO = randomPojo(ApiErrorLogCreateReqDTO.class); - - // 调用 - apiErrorLogService.createApiErrorLog(createDTO); - // 断言 - ApiErrorLogDO apiErrorLogDO = apiErrorLogMapper.selectOne(null); - assertPojoEquals(createDTO, apiErrorLogDO); - assertEquals(ApiErrorLogProcessStatusEnum.INIT.getStatus(), apiErrorLogDO.getProcessStatus()); - } - - @Test - public void testUpdateApiErrorLogProcess_success() { - // 准备参数 - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, - o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus())); - apiErrorLogMapper.insert(apiErrorLogDO); - // 准备参数 - Long id = apiErrorLogDO.getId(); - Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); - Long processUserId = randomLongId(); - - // 调用 - apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId); - // 断言 - ApiErrorLogDO dbApiErrorLogDO = apiErrorLogMapper.selectById(apiErrorLogDO.getId()); - assertEquals(processStatus, dbApiErrorLogDO.getProcessStatus()); - assertEquals(processUserId, dbApiErrorLogDO.getProcessUserId()); - assertNotNull(dbApiErrorLogDO.getProcessTime()); - } - - @Test - public void testUpdateApiErrorLogProcess_processed() { - // 准备参数 - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, - o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())); - apiErrorLogMapper.insert(apiErrorLogDO); - // 准备参数 - Long id = apiErrorLogDO.getId(); - Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); - Long processUserId = randomLongId(); - - // 调用,并断言异常 - assertServiceException(() -> - apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId), - API_ERROR_LOG_PROCESSED); - } - - @Test - public void testUpdateApiErrorLogProcess_notFound() { - // 准备参数 - Long id = randomLongId(); - Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus(); - Long processUserId = randomLongId(); - - // 调用,并断言异常 - assertServiceException(() -> - apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId), - API_ERROR_LOG_NOT_FOUND); - } - - @Test - public void testCleanJobLog() { - // mock 数据 - ApiErrorLogDO log01 = randomPojo(ApiErrorLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-3)))); - apiErrorLogMapper.insert(log01); - ApiErrorLogDO log02 = randomPojo(ApiErrorLogDO.class, o -> o.setCreateTime(addTime(Duration.ofDays(-1)))); - apiErrorLogMapper.insert(log02); - // 准备参数 - Integer exceedDay = 2; - Integer deleteLimit = 1; - - // 调用 - Integer count = apiErrorLogService.cleanErrorLog(exceedDay, deleteLimit); - // 断言 - assertEquals(1, count); - List logs = apiErrorLogMapper.selectList(); - assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); - } - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 4ad43e4b6..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,51 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.infra diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/category.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/category.json deleted file mode 100644 index 033c048a5..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/category.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "table": { - "id": 10, - "scene" : 1, - "parentMenuId" : 888, - "tableName" : "infra_category", - "tableComment" : "分类表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraCategory", - "classComment" : "分类", - "author" : "芋道源码", - "treeParentColumnId" : 22, - "treeNameColumnId" : 11 - }, - "columns": [ { - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "id" : 11, - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "id" : 22, - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "父编号", - "javaType" : "Long", - "javaField" : "parentId", - "example" : "2048", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json deleted file mode 100644 index 74f92cd1d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "table": { - "scene" : 1, - "tableName" : "infra_student_contact", - "tableComment" : "学生联系人表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraStudentContact", - "classComment" : "学生联系人", - "author" : "芋道源码" - }, - "columns": [ { - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "id" : 100, - "columnName" : "student_id", - "dataType" : "BIGINT", - "columnComment" : "学生编号", - "javaType" : "Long", - "javaField" : "studentId", - "example" : "2048", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true - }, { - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "简介", - "javaType" : "String", - "javaField" : "description", - "example" : "我是介绍", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "textarea" - }, { - "columnName" : "birthday", - "dataType" : "DATE", - "columnComment" : "出生日期", - "javaType" : "LocalDateTime", - "javaField" : "birthday", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "datetime" - }, { - "columnName" : "sex", - "dataType" : "INTEGER", - "columnComment" : "性别", - "javaType" : "Integer", - "javaField" : "sex", - "dictType" : "system_user_sex", - "example" : "1", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "select" - }, { - "columnName" : "enabled", - "dataType" : "BOOLEAN", - "columnComment" : "是否有效", - "javaType" : "Boolean", - "javaField" : "enabled", - "dictType" : "infra_boolean_string", - "example" : "true", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "radio" - }, { - "columnName" : "avatar", - "dataType" : "VARCHAR", - "columnComment" : "头像", - "javaType" : "String", - "javaField" : "avatar", - "example" : "https://www.iocoder.cn/1.png", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "imageUpload" - }, { - "columnName" : "video", - "dataType" : "VARCHAR", - "columnComment" : "附件", - "nullable" : true, - "javaType" : "String", - "javaField" : "video", - "example" : "https://www.iocoder.cn/1.mp4", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "fileUpload" - }, { - "columnName" : "memo", - "dataType" : "VARCHAR", - "columnComment" : "备注", - "javaType" : "String", - "javaField" : "memo", - "example" : "我是备注", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "editor" - }, { - "columnName" : "create_time", - "dataType" : "DATE", - "columnComment" : "创建时间", - "nullable" : true, - "javaType" : "LocalDateTime", - "javaField" : "createTime", - "listOperation" : true, - "listOperationCondition" : "BETWEEN", - "listOperationResult" : true, - "htmlType" : "datetime" - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json deleted file mode 100644 index efe8af4a2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "table": { - "id": 1, - "scene" : 1, - "parentMenuId" : 888, - "tableName" : "infra_student", - "tableComment" : "学生表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraStudent", - "classComment" : "学生", - "author" : "芋道源码" - }, - "columns": [ { - "id" : 100, - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "简介", - "javaType" : "String", - "javaField" : "description", - "example" : "我是介绍", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "textarea" - }, { - "columnName" : "birthday", - "dataType" : "DATE", - "columnComment" : "出生日期", - "javaType" : "LocalDateTime", - "javaField" : "birthday", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "datetime" - }, { - "columnName" : "sex", - "dataType" : "INTEGER", - "columnComment" : "性别", - "javaType" : "Integer", - "javaField" : "sex", - "dictType" : "system_user_sex", - "example" : "1", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "select" - }, { - "columnName" : "enabled", - "dataType" : "BOOLEAN", - "columnComment" : "是否有效", - "javaType" : "Boolean", - "javaField" : "enabled", - "dictType" : "infra_boolean_string", - "example" : "true", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "radio" - }, { - "columnName" : "avatar", - "dataType" : "VARCHAR", - "columnComment" : "头像", - "javaType" : "String", - "javaField" : "avatar", - "example" : "https://www.iocoder.cn/1.png", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "imageUpload" - }, { - "columnName" : "video", - "dataType" : "VARCHAR", - "columnComment" : "附件", - "javaType" : "String", - "javaField" : "video", - "example" : "https://www.iocoder.cn/1.mp4", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "fileUpload" - }, { - "columnName" : "memo", - "dataType" : "VARCHAR", - "columnComment" : "备注", - "javaType" : "String", - "javaField" : "memo", - "example" : "我是备注", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "editor" - }, { - "columnName" : "create_time", - "dataType" : "DATE", - "columnComment" : "创建时间", - "nullable" : true, - "javaType" : "LocalDateTime", - "javaField" : "createTime", - "listOperation" : true, - "listOperationCondition" : "BETWEEN", - "listOperationResult" : true, - "htmlType" : "datetime" - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/teacher.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/teacher.json deleted file mode 100644 index 4d93518eb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/teacher.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "table": { - "scene" : 1, - "tableName" : "infra_student_teacher", - "tableComment" : "学生班主任表", - "moduleName" : "infra", - "businessName" : "demo", - "className" : "InfraStudentTeacher", - "classComment" : "学生班主任", - "author" : "芋道源码" - }, - "columns": [ { - "columnName" : "id", - "dataType" : "BIGINT", - "columnComment" : "编号", - "primaryKey" : true, - "javaType" : "Long", - "javaField" : "id", - "example" : "1024", - "updateOperation" : true, - "listOperationResult" : true - }, { - "id" : 200, - "columnName" : "student_id", - "dataType" : "BIGINT", - "columnComment" : "学生编号", - "javaType" : "Long", - "javaField" : "studentId", - "example" : "2048", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true - }, { - "columnName" : "name", - "dataType" : "VARCHAR", - "columnComment" : "名字", - "javaType" : "String", - "javaField" : "name", - "example" : "芋头", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "LIKE", - "listOperationResult" : true, - "htmlType" : "input" - }, { - "columnName" : "description", - "dataType" : "VARCHAR", - "columnComment" : "简介", - "javaType" : "String", - "javaField" : "description", - "example" : "我是介绍", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "textarea" - }, { - "columnName" : "birthday", - "dataType" : "DATE", - "columnComment" : "出生日期", - "javaType" : "LocalDateTime", - "javaField" : "birthday", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "datetime" - }, { - "columnName" : "sex", - "dataType" : "INTEGER", - "columnComment" : "性别", - "javaType" : "Integer", - "javaField" : "sex", - "dictType" : "system_user_sex", - "example" : "1", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "select" - }, { - "columnName" : "enabled", - "dataType" : "BOOLEAN", - "columnComment" : "是否有效", - "javaType" : "Boolean", - "javaField" : "enabled", - "dictType" : "infra_boolean_string", - "example" : "true", - "createOperation" : true, - "updateOperation" : true, - "listOperation" : true, - "listOperationCondition" : "=", - "listOperationResult" : true, - "htmlType" : "radio" - }, { - "columnName" : "avatar", - "dataType" : "VARCHAR", - "columnComment" : "头像", - "javaType" : "String", - "javaField" : "avatar", - "example" : "https://www.iocoder.cn/1.png", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "imageUpload" - }, { - "columnName" : "video", - "dataType" : "VARCHAR", - "columnComment" : "附件", - "nullable" : true, - "javaType" : "String", - "javaField" : "video", - "example" : "https://www.iocoder.cn/1.mp4", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "fileUpload" - }, { - "columnName" : "memo", - "dataType" : "VARCHAR", - "columnComment" : "备注", - "javaType" : "String", - "javaField" : "memo", - "example" : "我是备注", - "createOperation" : true, - "updateOperation" : true, - "listOperationResult" : true, - "htmlType" : "editor" - }, { - "columnName" : "create_time", - "dataType" : "DATE", - "columnComment" : "创建时间", - "nullable" : true, - "javaType" : "LocalDateTime", - "javaField" : "createTime", - "listOperation" : true, - "listOperationCondition" : "BETWEEN", - "listOperationResult" : true, - "htmlType" : "datetime" - } ] -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/assert.json deleted file mode 100644 index 8edb8e612..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherList.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index d3201dec3..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,6 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); -ErrorCode STUDENT_CONTACT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生联系人不存在"); -ErrorCode STUDENT_TEACHER_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任不存在"); -ErrorCode STUDENT_TEACHER_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任已存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactMapper deleted file mode 100644 index ca662d19c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentContactMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentContactDO::getStudentId, studentId) - .orderByDesc(InfraStudentContactDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentController deleted file mode 100644 index d6f20183d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentController +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/page") - @Operation(summary = "获得学生联系人分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactPage(pageReqVO, studentId)); - } - - @PostMapping("/student-contact/create") - @Operation(summary = "创建学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - return success(studentService.createStudentContact(studentContact)); - } - - @PutMapping("/student-contact/update") - @Operation(summary = "更新学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - studentService.updateStudentContact(studentContact); - return success(true); - } - - @DeleteMapping("/student-contact/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentContact(@RequestParam("id") Long id) { - studentService.deleteStudentContact(id); - return success(true); - } - - @GetMapping("/student-contact/get") - @Operation(summary = "获得学生联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentContact(@RequestParam("id") Long id) { - return success(studentService.getStudentContact(id)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/page") - @Operation(summary = "获得学生班主任分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentTeacherPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherPage(pageReqVO, studentId)); - } - - @PostMapping("/student-teacher/create") - @Operation(summary = "创建学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - return success(studentService.createStudentTeacher(studentTeacher)); - } - - @PutMapping("/student-teacher/update") - @Operation(summary = "更新学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - studentService.updateStudentTeacher(studentTeacher); - return success(true); - } - - @DeleteMapping("/student-teacher/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentTeacher(@RequestParam("id") Long id) { - studentService.deleteStudentTeacher(id); - return success(true); - } - - @GetMapping("/student-teacher/get") - @Operation(summary = "获得学生班主任") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacher(@RequestParam("id") Long id) { - return success(studentService.getStudentTeacher(id)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentSaveReqVO deleted file mode 100644 index eaadf7432..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentService deleted file mode 100644 index 7df090d7f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentService +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生联系人分页 - */ - PageResult getStudentContactPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生联系人 - * - * @param studentContact 创建信息 - * @return 编号 - */ - Long createStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 更新学生联系人 - * - * @param studentContact 更新信息 - */ - void updateStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 删除学生联系人 - * - * @param id 编号 - */ - void deleteStudentContact(Long id); - - /** - * 获得学生联系人 - * - * @param id 编号 - * @return 学生联系人 - */ - InfraStudentContactDO getStudentContact(Long id); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生班主任分页 - */ - PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生班主任 - * - * @param studentTeacher 创建信息 - * @return 编号 - */ - Long createStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 更新学生班主任 - * - * @param studentTeacher 更新信息 - */ - void updateStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 删除学生班主任 - * - * @param id 编号 - */ - void deleteStudentTeacher(Long id); - - /** - * 获得学生班主任 - * - * @param id 编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacher(Long id); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImpl deleted file mode 100644 index 793b2dd22..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImpl +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public PageResult getStudentContactPage(PageParam pageReqVO, Long studentId) { - return studentContactMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentContact(InfraStudentContactDO studentContact) { - studentContactMapper.insert(studentContact); - return studentContact.getId(); - } - - @Override - public void updateStudentContact(InfraStudentContactDO studentContact) { - // 校验存在 - validateStudentContactExists(studentContact.getId()); - // 更新 - studentContactMapper.updateById(studentContact); - } - - @Override - public void deleteStudentContact(Long id) { - // 校验存在 - validateStudentContactExists(id); - // 删除 - studentContactMapper.deleteById(id); - } - - @Override - public InfraStudentContactDO getStudentContact(Long id) { - return studentContactMapper.selectById(id); - } - - private void validateStudentContactExists(Long id) { - if (studentContactMapper.selectById(id) == null) { - throw exception(STUDENT_CONTACT_NOT_EXISTS); - } - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId) { - return studentTeacherMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验是否已经存在 - if (studentTeacherMapper.selectByStudentId(studentTeacher.getStudentId()) != null) { - throw exception(STUDENT_TEACHER_EXISTS); - } - // 插入 - studentTeacherMapper.insert(studentTeacher); - return studentTeacher.getId(); - } - - @Override - public void updateStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验存在 - validateStudentTeacherExists(studentTeacher.getId()); - // 更新 - studentTeacherMapper.updateById(studentTeacher); - } - - @Override - public void deleteStudentTeacher(Long id) { - // 校验存在 - validateStudentTeacherExists(id); - // 删除 - studentTeacherMapper.deleteById(id); - } - - @Override - public InfraStudentTeacherDO getStudentTeacher(Long id) { - return studentTeacherMapper.selectById(id); - } - - private void validateStudentTeacherExists(Long id) { - if (studentTeacherMapper.selectById(id) == null) { - throw exception(STUDENT_TEACHER_NOT_EXISTS); - } - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherMapper deleted file mode 100644 index 994212dab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentTeacherDO::getStudentId, studentId) - .orderByDesc(InfraStudentTeacherDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/js/index deleted file mode 100644 index 211d95e42..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/js/index +++ /dev/null @@ -1,141 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} - -// ==================== 子表(学生联系人) ==================== - - // 获得学生联系人分页 - export function getStudentContactPage(params) { - return request({ - url: '/infra/student/student-contact/page', - method: 'get', - params - }) - } - // 新增学生联系人 - export function createStudentContact(data) { - return request({ - url: `/infra/student/student-contact/create`, - method: 'post', - data - }) - } - - // 修改学生联系人 - export function updateStudentContact(data) { - return request({ - url: `/infra/student/student-contact/update`, - method: 'post', - data - }) - } - - // 删除学生联系人 - export function deleteStudentContact(id) { - return request({ - url: `/infra/student/student-contact/delete?id=` + id, - method: 'delete' - }) - } - - // 获得学生联系人 - export function getStudentContact(id) { - return request({ - url: `/infra/student/student-contact/get?id=` + id, - method: 'get' - }) - } - -// ==================== 子表(学生班主任) ==================== - - // 获得学生班主任分页 - export function getStudentTeacherPage(params) { - return request({ - url: '/infra/student/student-teacher/page', - method: 'get', - params - }) - } - // 新增学生班主任 - export function createStudentTeacher(data) { - return request({ - url: `/infra/student/student-teacher/create`, - method: 'post', - data - }) - } - - // 修改学生班主任 - export function updateStudentTeacher(data) { - return request({ - url: `/infra/student/student-teacher/update`, - method: 'post', - data - }) - } - - // 删除学生班主任 - export function deleteStudentTeacher(id) { - return request({ - url: `/infra/student/student-teacher/delete?id=` + id, - method: 'delete' - }) - } - - // 获得学生班主任 - export function getStudentTeacher(id) { - return request({ - url: `/infra/student/student-teacher/get?id=` + id, - method: 'get' - }) - } \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactForm deleted file mode 100644 index de3b0a734..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactForm +++ /dev/null @@ -1,151 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactList deleted file mode 100644 index 00f1ce040..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentContactList +++ /dev/null @@ -1,129 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentForm deleted file mode 100644 index d89e5066d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentForm +++ /dev/null @@ -1,149 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherForm deleted file mode 100644 index 874a03bbc..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherForm +++ /dev/null @@ -1,151 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherList deleted file mode 100644 index 7d561a0ee..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/StudentTeacherList +++ /dev/null @@ -1,129 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/index deleted file mode 100644 index 9c7588f2a..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/vue/index +++ /dev/null @@ -1,233 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_erp/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/assert.json deleted file mode 100644 index 8edb8e612..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherList.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentController deleted file mode 100644 index b9a587b44..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentService deleted file mode 100644 index afa7d22eb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba613..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/js/index deleted file mode 100644 index b4e6ac5e4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/js/index +++ /dev/null @@ -1,74 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} - -// ==================== 子表(学生联系人) ==================== - - // 获得学生联系人列表 - export function getStudentContactListByStudentId(studentId) { - return request({ - url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - -// ==================== 子表(学生班主任) ==================== - - // 获得学生班主任 - export function getStudentTeacherByStudentId(studentId) { - return request({ - url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactForm deleted file mode 100644 index c953bfa13..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactForm +++ /dev/null @@ -1,177 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactList deleted file mode 100644 index c0a8710e9..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentContactList +++ /dev/null @@ -1,89 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentForm deleted file mode 100644 index 6d93b6122..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentForm +++ /dev/null @@ -1,180 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherForm deleted file mode 100644 index 0dac19bb3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherForm +++ /dev/null @@ -1,127 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherList deleted file mode 100644 index 9f572742d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/StudentTeacherList +++ /dev/null @@ -1,93 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/index deleted file mode 100644 index ddeafdf29..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/vue/index +++ /dev/null @@ -1,222 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_inner/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/assert.json deleted file mode 100644 index 6f94535e0..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/assert.json +++ /dev/null @@ -1,67 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/components/StudentTeacherForm.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentController deleted file mode 100644 index b9a587b44..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentService deleted file mode 100644 index afa7d22eb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba613..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/js/index deleted file mode 100644 index b4e6ac5e4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/js/index +++ /dev/null @@ -1,74 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} - -// ==================== 子表(学生联系人) ==================== - - // 获得学生联系人列表 - export function getStudentContactListByStudentId(studentId) { - return request({ - url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - -// ==================== 子表(学生班主任) ==================== - - // 获得学生班主任 - export function getStudentTeacherByStudentId(studentId) { - return request({ - url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId, - method: 'get' - }) - } - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentContactForm deleted file mode 100644 index c953bfa13..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentContactForm +++ /dev/null @@ -1,177 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentForm deleted file mode 100644 index 6d93b6122..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentForm +++ /dev/null @@ -1,180 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentTeacherForm deleted file mode 100644 index 0dac19bb3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/StudentTeacherForm +++ /dev/null @@ -1,127 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/index deleted file mode 100644 index 460758127..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/vue/index +++ /dev/null @@ -1,205 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_master_normal/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/assert.json deleted file mode 100644 index 5a37c376a..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/StudentForm.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentController deleted file mode 100644 index 3796982c4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentController +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentSaveReqVO deleted file mode 100644 index 43e7f147d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentService deleted file mode 100644 index c4a0e1792..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImpl deleted file mode 100644 index 2292a66f3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImpl +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/js/index deleted file mode 100644 index 44db46806..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/js/index +++ /dev/null @@ -1,53 +0,0 @@ -import request from '@/utils/request' - -// 创建学生 -export function createStudent(data) { - return request({ - url: '/infra/student/create', - method: 'post', - data: data - }) -} - -// 更新学生 -export function updateStudent(data) { - return request({ - url: '/infra/student/update', - method: 'put', - data: data - }) -} - -// 删除学生 -export function deleteStudent(id) { - return request({ - url: '/infra/student/delete?id=' + id, - method: 'delete' - }) -} - -// 获得学生 -export function getStudent(id) { - return request({ - url: '/infra/student/get?id=' + id, - method: 'get' - }) -} - -// 获得学生分页 -export function getStudentPage(params) { - return request({ - url: '/infra/student/page', - method: 'get', - params - }) -} -// 导出学生 Excel -export function exportStudentExcel(params) { - return request({ - url: '/infra/student/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/StudentForm deleted file mode 100644 index d89e5066d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/StudentForm +++ /dev/null @@ -1,149 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/index deleted file mode 100644 index 460758127..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/vue/index +++ /dev/null @@ -1,205 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_one/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/assert.json deleted file mode 100644 index a7d2f569c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraCategoryListReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryListReqVO.java" -}, { - "contentPath" : "java/InfraCategoryRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryRespVO.java" -}, { - "contentPath" : "java/InfraCategorySaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategorySaveReqVO.java" -}, { - "contentPath" : "java/InfraCategoryController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraCategoryController.java" -}, { - "contentPath" : "java/InfraCategoryDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraCategoryDO.java" -}, { - "contentPath" : "java/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraCategoryMapper.java" -}, { - "contentPath" : "xml/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraCategoryMapper.xml" -}, { - "contentPath" : "java/InfraCategoryServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImpl.java" -}, { - "contentPath" : "java/InfraCategoryService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryService.java" -}, { - "contentPath" : "java/InfraCategoryServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/index.vue" -}, { - "contentPath": "js/index", - "filePath": "yudao-ui-admin-vue2/src/api/infra/demo/index.js" -}, { - "contentPath" : "vue/CategoryForm", - "filePath" : "yudao-ui-admin-vue2/src/views/infra/demo/CategoryForm.vue" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index 36df6752e..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,8 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 分类 TODO 补充编号 ========== -ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(TODO 补充编号, "分类不存在"); -ErrorCode CATEGORY_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子分类,无法删除"); -ErrorCode CATEGORY_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级分类不存在"); -ErrorCode CATEGORY_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父分类"); -ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该名字的分类"); -ErrorCode CATEGORY_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子InfraCategory为父InfraCategory"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryController deleted file mode 100644 index a7b2f8163..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryController +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraCategoryService; - -@Tag(name = "管理后台 - 分类") -@RestController -@RequestMapping("/infra/category") -@Validated -public class InfraCategoryController { - - @Resource - private InfraCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建分类") - @PreAuthorize("@ss.hasPermission('infra:category:create')") - public CommonResult createCategory(@Valid @RequestBody InfraCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新分类") - @PreAuthorize("@ss.hasPermission('infra:category:update')") - public CommonResult updateCategory(@Valid @RequestBody InfraCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - InfraCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, InfraCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得分类列表") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult> getCategoryList(@Valid InfraCategoryListReqVO listReqVO) { - List list = categoryService.getCategoryList(listReqVO); - return success(BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出分类 Excel") - @PreAuthorize("@ss.hasPermission('infra:category:export')") - @OperateLog(type = EXPORT) - public void exportCategoryExcel(@Valid InfraCategoryListReqVO listReqVO, - HttpServletResponse response) throws IOException { - List list = categoryService.getCategoryList(listReqVO); - // 导出 Excel - ExcelUtils.write(response, "分类.xls", "数据", InfraCategoryRespVO.class, - BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryDO deleted file mode 100644 index 9bf21c08b..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryDO +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 分类 DO - * - * @author 芋道源码 - */ -@TableName("infra_category") -@KeySequence("infra_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraCategoryDO extends BaseDO { - - public static final Long PARENT_ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 父编号 - */ - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryListReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryListReqVO deleted file mode 100644 index e5c6f181f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryListReqVO +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -@Schema(description = "管理后台 - 分类列表 Request VO") -@Data -public class InfraCategoryListReqVO { - - @Schema(description = "名字", example = "芋头") - private String name; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryMapper deleted file mode 100644 index 9dadbf1d9..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryMapper +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraCategoryMapper extends BaseMapperX { - - default List selectList(InfraCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(InfraCategoryDO::getName, reqVO.getName()) - .orderByDesc(InfraCategoryDO::getId)); - } - - default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(InfraCategoryDO::getParentId, parentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryRespVO deleted file mode 100644 index 6325d866c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryRespVO +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import com.alibaba.excel.annotation.*; - -@Schema(description = "管理后台 - 分类 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraCategoryRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @ExcelProperty("父编号") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategorySaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategorySaveReqVO deleted file mode 100644 index 3c03b977f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategorySaveReqVO +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; - -@Schema(description = "管理后台 - 分类新增/修改 Request VO") -@Data -public class InfraCategorySaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "父编号不能为空") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryService deleted file mode 100644 index 9d0ae1afa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 分类 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraCategoryService { - - /** - * 创建分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid InfraCategorySaveReqVO createReqVO); - - /** - * 更新分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid InfraCategorySaveReqVO updateReqVO); - - /** - * 删除分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得分类 - * - * @param id 编号 - * @return 分类 - */ - InfraCategoryDO getCategory(Long id); - - /** - * 获得分类列表 - * - * @param listReqVO 查询条件 - * @return 分类列表 - */ - List getCategoryList(InfraCategoryListReqVO listReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImpl deleted file mode 100644 index 351568b18..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImpl +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraCategoryServiceImpl implements InfraCategoryService { - - @Resource - private InfraCategoryMapper categoryMapper; - - @Override - public Long createCategory(InfraCategorySaveReqVO createReqVO) { - // 校验父编号的有效性 - validateParentCategory(null, createReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); - - // 插入 - InfraCategoryDO category = BeanUtils.toBean(createReqVO, InfraCategoryDO.class); - categoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(InfraCategorySaveReqVO updateReqVO) { - // 校验存在 - validateCategoryExists(updateReqVO.getId()); - // 校验父编号的有效性 - validateParentCategory(updateReqVO.getId(), updateReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 更新 - InfraCategoryDO updateObj = BeanUtils.toBean(updateReqVO, InfraCategoryDO.class); - categoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验存在 - validateCategoryExists(id); - // 校验是否有子分类 - if (categoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXITS_CHILDREN); - } - // 删除 - categoryMapper.deleteById(id); - } - - private void validateCategoryExists(Long id) { - if (categoryMapper.selectById(id) == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - private void validateParentCategory(Long id, Long parentId) { - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - return; - } - // 1. 不能设置自己为父分类 - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_ERROR); - } - // 2. 父分类不存在 - CategoryDO parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - throw exception(CATEGORY_PARENT_NOT_EXITS); - } - // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 - if (id == null) { // id 为空,说明新增,不需要考虑环路 - return; - } - for (int i = 0; i < Short.MAX_VALUE; i++) { - // 3.1 校验环路 - parentId = parentCategory.getParentId(); - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_IS_CHILD); - } - // 3.2 继续递归下一级父分类 - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - break; - } - parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - break; - } - } - } - - private void validateCategoryNameUnique(Long id, Long parentId, String name) { - CategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); - if (category == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的分类 - if (id == null) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - if (!Objects.equals(category.getId(), id)) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - } - - @Override - public InfraCategoryDO getCategory(Long id) { - return categoryMapper.selectById(id); - } - - @Override - public List getCategoryList(InfraCategoryListReqVO listReqVO) { - return categoryMapper.selectList(listReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImplTest deleted file mode 100644 index efb70fd33..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/java/InfraCategoryServiceImplTest +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraCategoryServiceImpl.class) -public class InfraCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraCategoryServiceImpl categoryService; - - @Resource - private InfraCategoryMapper categoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - InfraCategorySaveReqVO createReqVO = randomPojo(InfraCategorySaveReqVO.class).setId(null); - - // 调用 - Long categoryId = categoryService.createCategory(createReqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - InfraCategoryDO category = categoryMapper.selectById(categoryId); - assertPojoEquals(createReqVO, category, "id"); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - }); - - // 调用 - categoryService.updateCategory(updateReqVO); - // 校验是否更新正确 - InfraCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - categoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(categoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCategoryList() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class, o -> { // 等会查询到 - o.setName(null); - }); - categoryMapper.insert(dbCategory); - // 测试 name 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); - // 准备参数 - InfraCategoryListReqVO reqVO = new InfraCategoryListReqVO(); - reqVO.setName(null); - - // 调用 - List list = categoryService.getCategoryList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbCategory, list.get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/js/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/js/index deleted file mode 100644 index 1e6ffdcea..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/js/index +++ /dev/null @@ -1,53 +0,0 @@ -import request from '@/utils/request' - -// 创建分类 -export function createCategory(data) { - return request({ - url: '/infra/category/create', - method: 'post', - data: data - }) -} - -// 更新分类 -export function updateCategory(data) { - return request({ - url: '/infra/category/update', - method: 'put', - data: data - }) -} - -// 删除分类 -export function deleteCategory(id) { - return request({ - url: '/infra/category/delete?id=' + id, - method: 'delete' - }) -} - -// 获得分类 -export function getCategory(id) { - return request({ - url: '/infra/category/get?id=' + id, - method: 'get' - }) -} - -// 获得分类列表 -export function getCategoryList(params) { - return request({ - url: '/infra/category/list', - method: 'get', - params - }) -} -// 导出分类 Excel -export function exportCategoryExcel(params) { - return request({ - url: '/infra/category/export-excel', - method: 'get', - params, - responseType: 'blob' - }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/h2 deleted file mode 100644 index 4141766cf..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/h2 +++ /dev/null @@ -1,10 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_category" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '分类表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_category"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/sql deleted file mode 100644 index 81409488a..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '分类管理', '', 2, 0, 888, - 'category', '', 'infra/demo/index', 0, 'InfraCategory' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类查询', 'infra:category:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类创建', 'infra:category:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类更新', 'infra:category:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类删除', 'infra:category:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类导出', 'infra:category:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/CategoryForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/CategoryForm deleted file mode 100644 index 7fa06e8cf..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/CategoryForm +++ /dev/null @@ -1,130 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/index deleted file mode 100644 index 88da68254..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/vue/index +++ /dev/null @@ -1,161 +0,0 @@ - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/xml/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/xml/InfraCategoryMapper deleted file mode 100644 index 025ac8507..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue2_tree/xml/InfraCategoryMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/assert.json deleted file mode 100644 index 0937ba914..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherList.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index d3201dec3..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,6 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); -ErrorCode STUDENT_CONTACT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生联系人不存在"); -ErrorCode STUDENT_TEACHER_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任不存在"); -ErrorCode STUDENT_TEACHER_EXISTS = new ErrorCode(TODO 补充编号, "学生班主任已存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactMapper deleted file mode 100644 index ca662d19c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentContactMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentContactDO::getStudentId, studentId) - .orderByDesc(InfraStudentContactDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentController deleted file mode 100644 index d6f20183d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentController +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/page") - @Operation(summary = "获得学生联系人分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactPage(pageReqVO, studentId)); - } - - @PostMapping("/student-contact/create") - @Operation(summary = "创建学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - return success(studentService.createStudentContact(studentContact)); - } - - @PutMapping("/student-contact/update") - @Operation(summary = "更新学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentContact(@Valid @RequestBody InfraStudentContactDO studentContact) { - studentService.updateStudentContact(studentContact); - return success(true); - } - - @DeleteMapping("/student-contact/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生联系人") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentContact(@RequestParam("id") Long id) { - studentService.deleteStudentContact(id); - return success(true); - } - - @GetMapping("/student-contact/get") - @Operation(summary = "获得学生联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentContact(@RequestParam("id") Long id) { - return success(studentService.getStudentContact(id)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/page") - @Operation(summary = "获得学生班主任分页") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentTeacherPage(PageParam pageReqVO, - @RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherPage(pageReqVO, studentId)); - } - - @PostMapping("/student-teacher/create") - @Operation(summary = "创建学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - return success(studentService.createStudentTeacher(studentTeacher)); - } - - @PutMapping("/student-teacher/update") - @Operation(summary = "更新学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudentTeacher(@Valid @RequestBody InfraStudentTeacherDO studentTeacher) { - studentService.updateStudentTeacher(studentTeacher); - return success(true); - } - - @DeleteMapping("/student-teacher/delete") - @Parameter(name = "id", description = "编号", required = true) - @Operation(summary = "删除学生班主任") - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudentTeacher(@RequestParam("id") Long id) { - studentService.deleteStudentTeacher(id); - return success(true); - } - - @GetMapping("/student-teacher/get") - @Operation(summary = "获得学生班主任") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacher(@RequestParam("id") Long id) { - return success(studentService.getStudentTeacher(id)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentSaveReqVO deleted file mode 100644 index eaadf7432..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentService deleted file mode 100644 index 7df090d7f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentService +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生联系人分页 - */ - PageResult getStudentContactPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生联系人 - * - * @param studentContact 创建信息 - * @return 编号 - */ - Long createStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 更新学生联系人 - * - * @param studentContact 更新信息 - */ - void updateStudentContact(@Valid InfraStudentContactDO studentContact); - - /** - * 删除学生联系人 - * - * @param id 编号 - */ - void deleteStudentContact(Long id); - - /** - * 获得学生联系人 - * - * @param id 编号 - * @return 学生联系人 - */ - InfraStudentContactDO getStudentContact(Long id); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任分页 - * - * @param pageReqVO 分页查询 - * @param studentId 学生编号 - * @return 学生班主任分页 - */ - PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId); - - /** - * 创建学生班主任 - * - * @param studentTeacher 创建信息 - * @return 编号 - */ - Long createStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 更新学生班主任 - * - * @param studentTeacher 更新信息 - */ - void updateStudentTeacher(@Valid InfraStudentTeacherDO studentTeacher); - - /** - * 删除学生班主任 - * - * @param id 编号 - */ - void deleteStudentTeacher(Long id); - - /** - * 获得学生班主任 - * - * @param id 编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacher(Long id); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImpl deleted file mode 100644 index 793b2dd22..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImpl +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public PageResult getStudentContactPage(PageParam pageReqVO, Long studentId) { - return studentContactMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentContact(InfraStudentContactDO studentContact) { - studentContactMapper.insert(studentContact); - return studentContact.getId(); - } - - @Override - public void updateStudentContact(InfraStudentContactDO studentContact) { - // 校验存在 - validateStudentContactExists(studentContact.getId()); - // 更新 - studentContactMapper.updateById(studentContact); - } - - @Override - public void deleteStudentContact(Long id) { - // 校验存在 - validateStudentContactExists(id); - // 删除 - studentContactMapper.deleteById(id); - } - - @Override - public InfraStudentContactDO getStudentContact(Long id) { - return studentContactMapper.selectById(id); - } - - private void validateStudentContactExists(Long id) { - if (studentContactMapper.selectById(id) == null) { - throw exception(STUDENT_CONTACT_NOT_EXISTS); - } - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public PageResult getStudentTeacherPage(PageParam pageReqVO, Long studentId) { - return studentTeacherMapper.selectPage(pageReqVO, studentId); - } - - @Override - public Long createStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验是否已经存在 - if (studentTeacherMapper.selectByStudentId(studentTeacher.getStudentId()) != null) { - throw exception(STUDENT_TEACHER_EXISTS); - } - // 插入 - studentTeacherMapper.insert(studentTeacher); - return studentTeacher.getId(); - } - - @Override - public void updateStudentTeacher(InfraStudentTeacherDO studentTeacher) { - // 校验存在 - validateStudentTeacherExists(studentTeacher.getId()); - // 更新 - studentTeacherMapper.updateById(studentTeacher); - } - - @Override - public void deleteStudentTeacher(Long id) { - // 校验存在 - validateStudentTeacherExists(id); - // 删除 - studentTeacherMapper.deleteById(id); - } - - @Override - public InfraStudentTeacherDO getStudentTeacher(Long id) { - return studentTeacherMapper.selectById(id); - } - - private void validateStudentTeacherExists(Long id) { - if (studentTeacherMapper.selectById(id) == null) { - throw exception(STUDENT_TEACHER_NOT_EXISTS); - } - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherMapper deleted file mode 100644 index 994212dab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long studentId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(InfraStudentTeacherDO::getStudentId, studentId) - .orderByDesc(InfraStudentTeacherDO::getId)); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/ts/index deleted file mode 100644 index 2fe87b741..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/ts/index +++ /dev/null @@ -1,95 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} - -// ==================== 子表(学生联系人) ==================== - -// 获得学生联系人分页 -export const getStudentContactPage = async (params) => { - return await request.get({ url: `/infra/student/student-contact/page`, params }) -} -// 新增学生联系人 -export const createStudentContact = async (data) => { - return await request.post({ url: `/infra/student/student-contact/create`, data }) -} - -// 修改学生联系人 -export const updateStudentContact = async (data) => { - return await request.put({ url: `/infra/student/student-contact/update`, data }) -} - -// 删除学生联系人 -export const deleteStudentContact = async (id: number) => { - return await request.delete({ url: `/infra/student/student-contact/delete?id=` + id }) -} - -// 获得学生联系人 -export const getStudentContact = async (id: number) => { - return await request.get({ url: `/infra/student/student-contact/get?id=` + id }) -} - -// ==================== 子表(学生班主任) ==================== - -// 获得学生班主任分页 -export const getStudentTeacherPage = async (params) => { - return await request.get({ url: `/infra/student/student-teacher/page`, params }) -} -// 新增学生班主任 -export const createStudentTeacher = async (data) => { - return await request.post({ url: `/infra/student/student-teacher/create`, data }) -} - -// 修改学生班主任 -export const updateStudentTeacher = async (data) => { - return await request.put({ url: `/infra/student/student-teacher/update`, data }) -} - -// 删除学生班主任 -export const deleteStudentTeacher = async (id: number) => { - return await request.delete({ url: `/infra/student/student-teacher/delete?id=` + id }) -} - -// 获得学生班主任 -export const getStudentTeacher = async (id: number) => { - return await request.get({ url: `/infra/student/student-teacher/get?id=` + id }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactForm deleted file mode 100644 index 4a139355d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactForm +++ /dev/null @@ -1,155 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactList deleted file mode 100644 index eada66a75..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentContactList +++ /dev/null @@ -1,146 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentForm deleted file mode 100644 index 0dabcb5f3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentForm +++ /dev/null @@ -1,152 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherForm deleted file mode 100644 index f93c21c41..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherForm +++ /dev/null @@ -1,155 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherList deleted file mode 100644 index 1eba0a3d0..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/StudentTeacherList +++ /dev/null @@ -1,146 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/index deleted file mode 100644 index 9d1514612..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/vue/index +++ /dev/null @@ -1,278 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_erp/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/assert.json deleted file mode 100644 index 0937ba914..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/assert.json +++ /dev/null @@ -1,73 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "vue/StudentContactList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactList.vue" -}, { - "contentPath" : "vue/StudentTeacherList", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherList.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentController deleted file mode 100644 index b9a587b44..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentService deleted file mode 100644 index afa7d22eb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba613..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/ts/index deleted file mode 100644 index 6112800a9..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/ts/index +++ /dev/null @@ -1,57 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} - -// ==================== 子表(学生联系人) ==================== - -// 获得学生联系人列表 -export const getStudentContactListByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId }) -} - -// ==================== 子表(学生班主任) ==================== - -// 获得学生班主任 -export const getStudentTeacherByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactForm deleted file mode 100644 index 55ca9945e..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactForm +++ /dev/null @@ -1,174 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactList deleted file mode 100644 index d0e89dac2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentContactList +++ /dev/null @@ -1,72 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentForm deleted file mode 100644 index d8e7bc3d0..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentForm +++ /dev/null @@ -1,184 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherForm deleted file mode 100644 index b22a4801f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherForm +++ /dev/null @@ -1,122 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherList b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherList deleted file mode 100644 index e510adcf4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/StudentTeacherList +++ /dev/null @@ -1,76 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/index deleted file mode 100644 index ee7c05f1f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/vue/index +++ /dev/null @@ -1,267 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_inner/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/assert.json deleted file mode 100644 index 60e7f4767..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/assert.json +++ /dev/null @@ -1,67 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentContactDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentContactDO.java" -}, { - "contentPath" : "java/InfraStudentTeacherDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentTeacherDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "java/InfraStudentContactMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentContactMapper.java" -}, { - "contentPath" : "java/InfraStudentTeacherMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentTeacherMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "vue/StudentContactForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentContactForm.vue" -}, { - "contentPath" : "vue/StudentTeacherForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/components/StudentTeacherForm.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactDO deleted file mode 100644 index 17c668eaa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生联系人 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_contact") -@KeySequence("infra_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentContactDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactMapper deleted file mode 100644 index 35bbd53c2..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentContactMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentContactMapper extends BaseMapperX { - - default List selectListByStudentId(Long studentId) { - return selectList(InfraStudentContactDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentContactDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentController deleted file mode 100644 index b9a587b44..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentController +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - - // ==================== 子表(学生联系人) ==================== - - @GetMapping("/student-contact/list-by-student-id") - @Operation(summary = "获得学生联系人列表") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentContactListByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentContactListByStudentId(studentId)); - } - - // ==================== 子表(学生班主任) ==================== - - @GetMapping("/student-teacher/get-by-student-id") - @Operation(summary = "获得学生班主任") - @Parameter(name = "studentId", description = "学生编号") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudentTeacherByStudentId(@RequestParam("studentId") Long studentId) { - return success(studentService.getStudentTeacherByStudentId(studentId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentSaveReqVO deleted file mode 100644 index faa491dfb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - - @Schema(description = "学生联系人列表") - private List studentContacts; - - @Schema(description = "学生班主任") - private InfraStudentTeacherDO studentTeacher; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentService deleted file mode 100644 index afa7d22eb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentService +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - - // ==================== 子表(学生联系人) ==================== - - /** - * 获得学生联系人列表 - * - * @param studentId 学生编号 - * @return 学生联系人列表 - */ - List getStudentContactListByStudentId(Long studentId); - - // ==================== 子表(学生班主任) ==================== - - /** - * 获得学生班主任 - * - * @param studentId 学生编号 - * @return 学生班主任 - */ - InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImpl deleted file mode 100644 index c57cba613..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImpl +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentContactDO; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentContactMapper; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentTeacherMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - @Resource - private InfraStudentContactMapper studentContactMapper; - @Resource - private InfraStudentTeacherMapper studentTeacherMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - - // 插入子表 - createStudentContactList(student.getId(), createReqVO.getStudentContacts()); - createStudentTeacher(student.getId(), createReqVO.getStudentTeacher()); - // 返回 - return student.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - - // 更新子表 - updateStudentContactList(updateReqVO.getId(), updateReqVO.getStudentContacts()); - updateStudentTeacher(updateReqVO.getId(), updateReqVO.getStudentTeacher()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - - // 删除子表 - deleteStudentContactByStudentId(id); - deleteStudentTeacherByStudentId(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - - // ==================== 子表(学生联系人) ==================== - - @Override - public List getStudentContactListByStudentId(Long studentId) { - return studentContactMapper.selectListByStudentId(studentId); - } - - private void createStudentContactList(Long studentId, List list) { - list.forEach(o -> o.setStudentId(studentId)); - studentContactMapper.insertBatch(list); - } - - private void updateStudentContactList(Long studentId, List list) { - deleteStudentContactByStudentId(studentId); - list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 - createStudentContactList(studentId, list); - } - - private void deleteStudentContactByStudentId(Long studentId) { - studentContactMapper.deleteByStudentId(studentId); - } - - // ==================== 子表(学生班主任) ==================== - - @Override - public InfraStudentTeacherDO getStudentTeacherByStudentId(Long studentId) { - return studentTeacherMapper.selectByStudentId(studentId); - } - - private void createStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacherMapper.insert(studentTeacher); - } - - private void updateStudentTeacher(Long studentId, InfraStudentTeacherDO studentTeacher) { - if (studentTeacher == null) { - return; - } - studentTeacher.setStudentId(studentId); - studentTeacher.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新 - studentTeacherMapper.insertOrUpdate(studentTeacher); - } - - private void deleteStudentTeacherByStudentId(Long studentId) { - studentTeacherMapper.deleteByStudentId(studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherDO deleted file mode 100644 index c19cf9fab..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherDO +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生班主任 DO - * - * @author 芋道源码 - */ -@TableName("infra_student_teacher") -@KeySequence("infra_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentTeacherDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 学生编号 - */ - private Long studentId; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherMapper deleted file mode 100644 index 0521bbaf4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/java/InfraStudentTeacherMapper +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentTeacherDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 学生班主任 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentTeacherMapper extends BaseMapperX { - - default InfraStudentTeacherDO selectByStudentId(Long studentId) { - return selectOne(InfraStudentTeacherDO::getStudentId, studentId); - } - - default int deleteByStudentId(Long studentId) { - return delete(InfraStudentTeacherDO::getStudentId, studentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/ts/index deleted file mode 100644 index 6112800a9..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/ts/index +++ /dev/null @@ -1,57 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} - -// ==================== 子表(学生联系人) ==================== - -// 获得学生联系人列表 -export const getStudentContactListByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-contact/list-by-student-id?studentId=` + studentId }) -} - -// ==================== 子表(学生班主任) ==================== - -// 获得学生班主任 -export const getStudentTeacherByStudentId = async (studentId) => { - return await request.get({ url: `/infra/student/student-teacher/get-by-student-id?studentId=` + studentId }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentContactForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentContactForm deleted file mode 100644 index 55ca9945e..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentContactForm +++ /dev/null @@ -1,174 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentForm deleted file mode 100644 index d8e7bc3d0..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentForm +++ /dev/null @@ -1,184 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentTeacherForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentTeacherForm deleted file mode 100644 index b22a4801f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/StudentTeacherForm +++ /dev/null @@ -1,122 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/index deleted file mode 100644 index b115b13de..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/vue/index +++ /dev/null @@ -1,252 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_master_normal/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/assert.json deleted file mode 100644 index 5a0eebdeb..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraStudentPageReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentPageReqVO.java" -}, { - "contentPath" : "java/InfraStudentRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentRespVO.java" -}, { - "contentPath" : "java/InfraStudentSaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraStudentSaveReqVO.java" -}, { - "contentPath" : "java/InfraStudentController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraStudentController.java" -}, { - "contentPath" : "java/InfraStudentDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraStudentDO.java" -}, { - "contentPath" : "java/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraStudentMapper.java" -}, { - "contentPath" : "xml/InfraStudentMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraStudentMapper.xml" -}, { - "contentPath" : "java/InfraStudentServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImpl.java" -}, { - "contentPath" : "java/InfraStudentService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentService.java" -}, { - "contentPath" : "java/InfraStudentServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraStudentServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/StudentForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/StudentForm.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index f8be66202..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,3 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 学生 TODO 补充编号 ========== -ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(TODO 补充编号, "学生不存在"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentController deleted file mode 100644 index 3796982c4..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentController +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraStudentService; - -@Tag(name = "管理后台 - 学生") -@RestController -@RequestMapping("/infra/student") -@Validated -public class InfraStudentController { - - @Resource - private InfraStudentService studentService; - - @PostMapping("/create") - @Operation(summary = "创建学生") - @PreAuthorize("@ss.hasPermission('infra:student:create')") - public CommonResult createStudent(@Valid @RequestBody InfraStudentSaveReqVO createReqVO) { - return success(studentService.createStudent(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新学生") - @PreAuthorize("@ss.hasPermission('infra:student:update')") - public CommonResult updateStudent(@Valid @RequestBody InfraStudentSaveReqVO updateReqVO) { - studentService.updateStudent(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除学生") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:student:delete')") - public CommonResult deleteStudent(@RequestParam("id") Long id) { - studentService.deleteStudent(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得学生") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult getStudent(@RequestParam("id") Long id) { - InfraStudentDO student = studentService.getStudent(id); - return success(BeanUtils.toBean(student, InfraStudentRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得学生分页") - @PreAuthorize("@ss.hasPermission('infra:student:query')") - public CommonResult> getStudentPage(@Valid InfraStudentPageReqVO pageReqVO) { - PageResult pageResult = studentService.getStudentPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, InfraStudentRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出学生 Excel") - @PreAuthorize("@ss.hasPermission('infra:student:export')") - @OperateLog(type = EXPORT) - public void exportStudentExcel(@Valid InfraStudentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = studentService.getStudentPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "学生.xls", "数据", InfraStudentRespVO.class, - BeanUtils.toBean(list, InfraStudentRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentDO deleted file mode 100644 index b0d4bd216..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentDO +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 学生 DO - * - * @author 芋道源码 - */ -@TableName("infra_student") -@KeySequence("infra_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraStudentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 简介 - */ - private String description; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 性别 - * - * 枚举 {@link TODO system_user_sex 对应的类} - */ - private Integer sex; - /** - * 是否有效 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} - */ - private Boolean enabled; - /** - * 头像 - */ - private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentMapper deleted file mode 100644 index 34e70a082..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentMapper +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 学生 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraStudentMapper extends BaseMapperX { - - default PageResult selectPage(InfraStudentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(InfraStudentDO::getName, reqVO.getName()) - .eqIfPresent(InfraStudentDO::getBirthday, reqVO.getBirthday()) - .eqIfPresent(InfraStudentDO::getSex, reqVO.getSex()) - .eqIfPresent(InfraStudentDO::getEnabled, reqVO.getEnabled()) - .betweenIfPresent(InfraStudentDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(InfraStudentDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentPageReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentPageReqVO deleted file mode 100644 index 41a373012..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentPageReqVO +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 学生分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfraStudentPageReqVO extends PageParam { - - @Schema(description = "名字", example = "芋头") - private String name; - - @Schema(description = "出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", example = "1") - private Integer sex; - - @Schema(description = "是否有效", example = "true") - private Boolean enabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentRespVO deleted file mode 100644 index c41a5501f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentRespVO +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - -@Schema(description = "管理后台 - 学生 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraStudentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @ExcelProperty("简介") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出生日期") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "性别", converter = DictConvert.class) - @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "是否有效", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @ExcelProperty("头像") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @ExcelProperty("附件") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @ExcelProperty("备注") - private String memo; - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentSaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentSaveReqVO deleted file mode 100644 index 43e7f147d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentSaveReqVO +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 学生新增/修改 Request VO") -@Data -public class InfraStudentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") - @NotEmpty(message = "简介不能为空") - private String description; - - @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出生日期不能为空") - private LocalDateTime birthday; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "性别不能为空") - private Integer sex; - - @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否有效不能为空") - private Boolean enabled; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotEmpty(message = "头像不能为空") - private String avatar; - - @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.mp4") - @NotEmpty(message = "附件不能为空") - private String video; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") - @NotEmpty(message = "备注不能为空") - private String memo; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentService deleted file mode 100644 index c4a0e1792..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 学生 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraStudentService { - - /** - * 创建学生 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStudent(@Valid InfraStudentSaveReqVO createReqVO); - - /** - * 更新学生 - * - * @param updateReqVO 更新信息 - */ - void updateStudent(@Valid InfraStudentSaveReqVO updateReqVO); - - /** - * 删除学生 - * - * @param id 编号 - */ - void deleteStudent(Long id); - - /** - * 获得学生 - * - * @param id 编号 - * @return 学生 - */ - InfraStudentDO getStudent(Long id); - - /** - * 获得学生分页 - * - * @param pageReqVO 分页查询 - * @return 学生分页 - */ - PageResult getStudentPage(InfraStudentPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImpl deleted file mode 100644 index 2292a66f3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImpl +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 学生 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraStudentServiceImpl implements InfraStudentService { - - @Resource - private InfraStudentMapper studentMapper; - - @Override - public Long createStudent(InfraStudentSaveReqVO createReqVO) { - // 插入 - InfraStudentDO student = BeanUtils.toBean(createReqVO, InfraStudentDO.class); - studentMapper.insert(student); - // 返回 - return student.getId(); - } - - @Override - public void updateStudent(InfraStudentSaveReqVO updateReqVO) { - // 校验存在 - validateStudentExists(updateReqVO.getId()); - // 更新 - InfraStudentDO updateObj = BeanUtils.toBean(updateReqVO, InfraStudentDO.class); - studentMapper.updateById(updateObj); - } - - @Override - public void deleteStudent(Long id) { - // 校验存在 - validateStudentExists(id); - // 删除 - studentMapper.deleteById(id); - } - - private void validateStudentExists(Long id) { - if (studentMapper.selectById(id) == null) { - throw exception(STUDENT_NOT_EXISTS); - } - } - - @Override - public InfraStudentDO getStudent(Long id) { - return studentMapper.selectById(id); - } - - @Override - public PageResult getStudentPage(InfraStudentPageReqVO pageReqVO) { - return studentMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImplTest deleted file mode 100644 index b5f4bf0ff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/java/InfraStudentServiceImplTest +++ /dev/null @@ -1,146 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraStudentDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraStudentMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraStudentServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraStudentServiceImpl.class) -public class InfraStudentServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraStudentServiceImpl studentService; - - @Resource - private InfraStudentMapper studentMapper; - - @Test - public void testCreateStudent_success() { - // 准备参数 - InfraStudentSaveReqVO createReqVO = randomPojo(InfraStudentSaveReqVO.class).setId(null); - - // 调用 - Long studentId = studentService.createStudent(createReqVO); - // 断言 - assertNotNull(studentId); - // 校验记录的属性是否正确 - InfraStudentDO student = studentMapper.selectById(studentId); - assertPojoEquals(createReqVO, student, "id"); - } - - @Test - public void testUpdateStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class, o -> { - o.setId(dbStudent.getId()); // 设置更新的 ID - }); - - // 调用 - studentService.updateStudent(updateReqVO); - // 校验是否更新正确 - InfraStudentDO student = studentMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, student); - } - - @Test - public void testUpdateStudent_notExists() { - // 准备参数 - InfraStudentSaveReqVO updateReqVO = randomPojo(InfraStudentSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.updateStudent(updateReqVO), STUDENT_NOT_EXISTS); - } - - @Test - public void testDeleteStudent_success() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class); - studentMapper.insert(dbStudent);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbStudent.getId(); - - // 调用 - studentService.deleteStudent(id); - // 校验数据不存在了 - assertNull(studentMapper.selectById(id)); - } - - @Test - public void testDeleteStudent_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> studentService.deleteStudent(id), STUDENT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetStudentPage() { - // mock 数据 - InfraStudentDO dbStudent = randomPojo(InfraStudentDO.class, o -> { // 等会查询到 - o.setName(null); - o.setBirthday(null); - o.setSex(null); - o.setEnabled(null); - o.setCreateTime(null); - }); - studentMapper.insert(dbStudent); - // 测试 name 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setName(null))); - // 测试 birthday 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setBirthday(null))); - // 测试 sex 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setSex(null))); - // 测试 enabled 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setEnabled(null))); - // 测试 createTime 不匹配 - studentMapper.insert(cloneIgnoreId(dbStudent, o -> o.setCreateTime(null))); - // 准备参数 - InfraStudentPageReqVO reqVO = new InfraStudentPageReqVO(); - reqVO.setName(null); - reqVO.setBirthday(null); - reqVO.setSex(null); - reqVO.setEnabled(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = studentService.getStudentPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbStudent, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/h2 deleted file mode 100644 index 6c1875f60..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/h2 +++ /dev/null @@ -1,17 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_student" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" varchar NOT NULL, - "birthday" varchar NOT NULL, - "sex" int NOT NULL, - "enabled" bit NOT NULL, - "avatar" varchar NOT NULL, - "video" varchar NOT NULL, - "memo" varchar NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY ("id") -) COMMENT '学生表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_student"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/sql deleted file mode 100644 index 83df27926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '学生管理', '', 2, 0, 888, - 'student', '', 'infra/demo/index', 0, 'InfraStudent' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生查询', 'infra:student:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生创建', 'infra:student:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生更新', 'infra:student:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生删除', 'infra:student:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '学生导出', 'infra:student:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/ts/index deleted file mode 100644 index 8cdf2548d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/ts/index +++ /dev/null @@ -1,43 +0,0 @@ -import request from '@/config/axios' - -export interface StudentVO { - id: number - name: string - description: string - birthday: Date - sex: number - enabled: boolean - avatar: string - video: string - memo: string -} - -// 查询学生分页 -export const getStudentPage = async (params) => { - return await request.get({ url: `/infra/student/page`, params }) -} - -// 查询学生详情 -export const getStudent = async (id: number) => { - return await request.get({ url: `/infra/student/get?id=` + id }) -} - -// 新增学生 -export const createStudent = async (data: StudentVO) => { - return await request.post({ url: `/infra/student/create`, data }) -} - -// 修改学生 -export const updateStudent = async (data: StudentVO) => { - return await request.put({ url: `/infra/student/update`, data }) -} - -// 删除学生 -export const deleteStudent = async (id: number) => { - return await request.delete({ url: `/infra/student/delete?id=` + id }) -} - -// 导出学生 Excel -export const exportStudent = async (params) => { - return await request.download({ url: `/infra/student/export-excel`, params }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/StudentForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/StudentForm deleted file mode 100644 index 0dabcb5f3..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/StudentForm +++ /dev/null @@ -1,152 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/index deleted file mode 100644 index b115b13de..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/vue/index +++ /dev/null @@ -1,252 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/xml/InfraStudentMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/xml/InfraStudentMapper deleted file mode 100644 index 155aa5c27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_one/xml/InfraStudentMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/assert.json b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/assert.json deleted file mode 100644 index 357df0080..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/assert.json +++ /dev/null @@ -1,49 +0,0 @@ -[ { - "contentPath" : "java/InfraCategoryListReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryListReqVO.java" -}, { - "contentPath" : "java/InfraCategoryRespVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategoryRespVO.java" -}, { - "contentPath" : "java/InfraCategorySaveReqVO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/vo/InfraCategorySaveReqVO.java" -}, { - "contentPath" : "java/InfraCategoryController", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/InfraCategoryController.java" -}, { - "contentPath" : "java/InfraCategoryDO", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/InfraCategoryDO.java" -}, { - "contentPath" : "java/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/InfraCategoryMapper.java" -}, { - "contentPath" : "xml/InfraCategoryMapper", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo/InfraCategoryMapper.xml" -}, { - "contentPath" : "java/InfraCategoryServiceImpl", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImpl.java" -}, { - "contentPath" : "java/InfraCategoryService", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryService.java" -}, { - "contentPath" : "java/InfraCategoryServiceImplTest", - "filePath" : "yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/demo/InfraCategoryServiceImplTest.java" -}, { - "contentPath" : "java/ErrorCodeConstants_手动操作", - "filePath" : "yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants_手动操作.java" -}, { - "contentPath" : "sql/sql", - "filePath" : "sql/sql.sql" -}, { - "contentPath" : "sql/h2", - "filePath" : "sql/h2.sql" -}, { - "contentPath" : "vue/index", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/index.vue" -}, { - "contentPath" : "vue/CategoryForm", - "filePath" : "yudao-ui-admin-vue3/src/views/infra/demo/CategoryForm.vue" -}, { - "contentPath" : "ts/index", - "filePath" : "yudao-ui-admin-vue3/src/api/infra/demo/index.ts" -} ] \ No newline at end of file diff --git "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" "b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" deleted file mode 100644 index 36df6752e..000000000 --- "a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/ErrorCodeConstants_\346\211\213\345\212\250\346\223\215\344\275\234" +++ /dev/null @@ -1,8 +0,0 @@ -// TODO 待办:请将下面的错误码复制到 yudao-module-infra-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! -// ========== 分类 TODO 补充编号 ========== -ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(TODO 补充编号, "分类不存在"); -ErrorCode CATEGORY_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子分类,无法删除"); -ErrorCode CATEGORY_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级分类不存在"); -ErrorCode CATEGORY_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父分类"); -ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该名字的分类"); -ErrorCode CATEGORY_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子InfraCategory为父InfraCategory"); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryController b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryController deleted file mode 100644 index a7b2f8163..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryController +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.service.demo.InfraCategoryService; - -@Tag(name = "管理后台 - 分类") -@RestController -@RequestMapping("/infra/category") -@Validated -public class InfraCategoryController { - - @Resource - private InfraCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建分类") - @PreAuthorize("@ss.hasPermission('infra:category:create')") - public CommonResult createCategory(@Valid @RequestBody InfraCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新分类") - @PreAuthorize("@ss.hasPermission('infra:category:update')") - public CommonResult updateCategory(@Valid @RequestBody InfraCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - InfraCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, InfraCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得分类列表") - @PreAuthorize("@ss.hasPermission('infra:category:query')") - public CommonResult> getCategoryList(@Valid InfraCategoryListReqVO listReqVO) { - List list = categoryService.getCategoryList(listReqVO); - return success(BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出分类 Excel") - @PreAuthorize("@ss.hasPermission('infra:category:export')") - @OperateLog(type = EXPORT) - public void exportCategoryExcel(@Valid InfraCategoryListReqVO listReqVO, - HttpServletResponse response) throws IOException { - List list = categoryService.getCategoryList(listReqVO); - // 导出 Excel - ExcelUtils.write(response, "分类.xls", "数据", InfraCategoryRespVO.class, - BeanUtils.toBean(list, InfraCategoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryDO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryDO deleted file mode 100644 index 9bf21c08b..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryDO +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.dataobject.demo; - -import lombok.*; -import java.util.*; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; - -/** - * 分类 DO - * - * @author 芋道源码 - */ -@TableName("infra_category") -@KeySequence("infra_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfraCategoryDO extends BaseDO { - - public static final Long PARENT_ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名字 - */ - private String name; - /** - * 父编号 - */ - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryListReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryListReqVO deleted file mode 100644 index e5c6f181f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryListReqVO +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -@Schema(description = "管理后台 - 分类列表 Request VO") -@Data -public class InfraCategoryListReqVO { - - @Schema(description = "名字", example = "芋头") - private String name; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryMapper deleted file mode 100644 index 9dadbf1d9..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryMapper +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.infra.dal.mysql.demo; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; - -/** - * 分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfraCategoryMapper extends BaseMapperX { - - default List selectList(InfraCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(InfraCategoryDO::getName, reqVO.getName()) - .orderByDesc(InfraCategoryDO::getId)); - } - - default InfraCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(InfraCategoryDO::getParentId, parentId, InfraCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(InfraCategoryDO::getParentId, parentId); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryRespVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryRespVO deleted file mode 100644 index 6325d866c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryRespVO +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.util.*; -import com.alibaba.excel.annotation.*; - -@Schema(description = "管理后台 - 分类 Response VO") -@Data -@ExcelIgnoreUnannotated -public class InfraCategoryRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @ExcelProperty("名字") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @ExcelProperty("父编号") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategorySaveReqVO b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategorySaveReqVO deleted file mode 100644 index 3c03b977f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategorySaveReqVO +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.infra.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; -import java.util.*; - -@Schema(description = "管理后台 - 分类新增/修改 Request VO") -@Data -public class InfraCategorySaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") - @NotEmpty(message = "名字不能为空") - private String name; - - @Schema(description = "父编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "父编号不能为空") - private Long parentId; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryService b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryService deleted file mode 100644 index 9d0ae1afa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryService +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; - -/** - * 分类 Service 接口 - * - * @author 芋道源码 - */ -public interface InfraCategoryService { - - /** - * 创建分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid InfraCategorySaveReqVO createReqVO); - - /** - * 更新分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid InfraCategorySaveReqVO updateReqVO); - - /** - * 删除分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得分类 - * - * @param id 编号 - * @return 分类 - */ - InfraCategoryDO getCategory(Long id); - - /** - * 获得分类列表 - * - * @param listReqVO 查询条件 - * @return 分类列表 - */ - List getCategoryList(InfraCategoryListReqVO listReqVO); - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImpl b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImpl deleted file mode 100644 index 351568b18..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImpl +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; - -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; - -/** - * 分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class InfraCategoryServiceImpl implements InfraCategoryService { - - @Resource - private InfraCategoryMapper categoryMapper; - - @Override - public Long createCategory(InfraCategorySaveReqVO createReqVO) { - // 校验父编号的有效性 - validateParentCategory(null, createReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); - - // 插入 - InfraCategoryDO category = BeanUtils.toBean(createReqVO, InfraCategoryDO.class); - categoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(InfraCategorySaveReqVO updateReqVO) { - // 校验存在 - validateCategoryExists(updateReqVO.getId()); - // 校验父编号的有效性 - validateParentCategory(updateReqVO.getId(), updateReqVO.getParentId()); - // 校验名字的唯一性 - validateCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 更新 - InfraCategoryDO updateObj = BeanUtils.toBean(updateReqVO, InfraCategoryDO.class); - categoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验存在 - validateCategoryExists(id); - // 校验是否有子分类 - if (categoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXITS_CHILDREN); - } - // 删除 - categoryMapper.deleteById(id); - } - - private void validateCategoryExists(Long id) { - if (categoryMapper.selectById(id) == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - private void validateParentCategory(Long id, Long parentId) { - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - return; - } - // 1. 不能设置自己为父分类 - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_ERROR); - } - // 2. 父分类不存在 - CategoryDO parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - throw exception(CATEGORY_PARENT_NOT_EXITS); - } - // 3. 递归校验父分类,如果父分类是自己的子分类,则报错,避免形成环路 - if (id == null) { // id 为空,说明新增,不需要考虑环路 - return; - } - for (int i = 0; i < Short.MAX_VALUE; i++) { - // 3.1 校验环路 - parentId = parentCategory.getParentId(); - if (Objects.equals(id, parentId)) { - throw exception(CATEGORY_PARENT_IS_CHILD); - } - // 3.2 继续递归下一级父分类 - if (parentId == null || CategoryDO.PARENT_ID_ROOT.equals(parentId)) { - break; - } - parentCategory = categoryMapper.selectById(parentId); - if (parentCategory == null) { - break; - } - } - } - - private void validateCategoryNameUnique(Long id, Long parentId, String name) { - CategoryDO category = categoryMapper.selectByParentIdAndName(parentId, name); - if (category == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的分类 - if (id == null) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - if (!Objects.equals(category.getId(), id)) { - throw exception(CATEGORY_NAME_DUPLICATE); - } - } - - @Override - public InfraCategoryDO getCategory(Long id) { - return categoryMapper.selectById(id); - } - - @Override - public List getCategoryList(InfraCategoryListReqVO listReqVO) { - return categoryMapper.selectList(listReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImplTest b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImplTest deleted file mode 100644 index efb70fd33..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/java/InfraCategoryServiceImplTest +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.infra.service.demo; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.infra.controller.admin.demo.vo.*; -import cn.iocoder.yudao.module.infra.dal.dataobject.demo.InfraCategoryDO; -import cn.iocoder.yudao.module.infra.dal.mysql.demo.InfraCategoryMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InfraCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(InfraCategoryServiceImpl.class) -public class InfraCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private InfraCategoryServiceImpl categoryService; - - @Resource - private InfraCategoryMapper categoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - InfraCategorySaveReqVO createReqVO = randomPojo(InfraCategorySaveReqVO.class).setId(null); - - // 调用 - Long categoryId = categoryService.createCategory(createReqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - InfraCategoryDO category = categoryMapper.selectById(categoryId); - assertPojoEquals(createReqVO, category, "id"); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - }); - - // 调用 - categoryService.updateCategory(updateReqVO); - // 校验是否更新正确 - InfraCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - InfraCategorySaveReqVO updateReqVO = randomPojo(InfraCategorySaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - categoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(categoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCategoryList() { - // mock 数据 - InfraCategoryDO dbCategory = randomPojo(InfraCategoryDO.class, o -> { // 等会查询到 - o.setName(null); - }); - categoryMapper.insert(dbCategory); - // 测试 name 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); - // 准备参数 - InfraCategoryListReqVO reqVO = new InfraCategoryListReqVO(); - reqVO.setName(null); - - // 调用 - List list = categoryService.getCategoryList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbCategory, list.get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/h2 b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/h2 deleted file mode 100644 index 4141766cf..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/h2 +++ /dev/null @@ -1,10 +0,0 @@ --- 将该建表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "infra_category" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "description" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '分类表'; - --- 将该删表 SQL 语句,添加到 yudao-module-infra-biz 模块的 test/resources/sql/clean.sql 文件里 -DELETE FROM "infra_category"; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/sql deleted file mode 100644 index 81409488a..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/sql/sql +++ /dev/null @@ -1,55 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '分类管理', '', 2, 0, 888, - 'category', '', 'infra/demo/index', 0, 'InfraCategory' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类查询', 'infra:category:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类创建', 'infra:category:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类更新', 'infra:category:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类删除', 'infra:category:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '分类导出', 'infra:category:export', 3, 5, @parentId, - '', '', '', 0 -); \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/ts/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/ts/index deleted file mode 100644 index 453c885c1..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/ts/index +++ /dev/null @@ -1,37 +0,0 @@ -import request from '@/config/axios' - -export interface CategoryVO { - id: number - name: string - parentId: number -} - -// 查询分类列表 -export const getCategoryList = async (params) => { - return await request.get({ url: `/infra/category/list`, params }) -} - -// 查询分类详情 -export const getCategory = async (id: number) => { - return await request.get({ url: `/infra/category/get?id=` + id }) -} - -// 新增分类 -export const createCategory = async (data: CategoryVO) => { - return await request.post({ url: `/infra/category/create`, data }) -} - -// 修改分类 -export const updateCategory = async (data: CategoryVO) => { - return await request.put({ url: `/infra/category/update`, data }) -} - -// 删除分类 -export const deleteCategory = async (id: number) => { - return await request.delete({ url: `/infra/category/delete?id=` + id }) -} - -// 导出分类 Excel -export const exportCategory = async (params) => { - return await request.download({ url: `/infra/category/export-excel`, params }) -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/CategoryForm b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/CategoryForm deleted file mode 100644 index 8e139fb13..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/CategoryForm +++ /dev/null @@ -1,114 +0,0 @@ - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/index b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/index deleted file mode 100644 index 46902e73c..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/vue/index +++ /dev/null @@ -1,185 +0,0 @@ - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/xml/InfraCategoryMapper b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/xml/InfraCategoryMapper deleted file mode 100644 index 025ac8507..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/windows10/vue3_tree/xml/InfraCategoryMapper +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/logback.xml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 58345edd8..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,11 +0,0 @@ -DELETE FROM "infra_config"; -DELETE FROM "infra_file_config"; -DELETE FROM "infra_file"; -DELETE FROM "infra_job"; -DELETE FROM "infra_job_log"; -DELETE FROM "infra_api_access_log"; -DELETE FROM "infra_api_error_log"; -DELETE FROM "infra_file_config"; -DELETE FROM "infra_data_source_config"; -DELETE FROM "infra_codegen_table"; -DELETE FROM "infra_codegen_column"; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index d4b19c926..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,216 +0,0 @@ - -CREATE TABLE IF NOT EXISTS "infra_config" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号', - "category" varchar(50) NOT NULL, - "type" tinyint NOT NULL, - "name" varchar(100) NOT NULL DEFAULT '' COMMENT '名字', - "config_key" varchar(100) NOT NULL DEFAULT '', - "value" varchar(500) NOT NULL DEFAULT '', - "visible" bit NOT NULL, - "remark" varchar(500) DEFAULT 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 '参数配置表'; - -CREATE TABLE IF NOT EXISTS "infra_file_config" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "storage" tinyint NOT NULL, - "remark" varchar(255), - "master" bit(1) NOT NULL, - "config" varchar(4096) 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 NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '文件配置表'; - -CREATE TABLE IF NOT EXISTS "infra_file" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "config_id" bigint NOT NULL, - "name" varchar(256), - "path" varchar(512), - "url" varchar(1024), - "type" varchar(63) DEFAULT NULL, - "size" bigint 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, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '文件表'; - -CREATE TABLE IF NOT EXISTS "infra_job" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号', - "name" varchar(32) NOT NULL COMMENT '任务名称', - "status" tinyint(4) NOT NULL COMMENT '任务状态', - "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', - "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', - "cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式', - "retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数', - "retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔', - "monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除', - PRIMARY KEY ("id") -) COMMENT='定时任务表'; - -CREATE TABLE IF NOT EXISTS "infra_job_log" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号', - "job_id" bigint(20) NOT NULL COMMENT '任务编号', - "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', - "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', - "execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行', - "begin_time" datetime NOT NULL COMMENT '开始执行时间', - "end_time" datetime DEFAULT NULL COMMENT '结束执行时间', - "duration" int(11) DEFAULT NULL COMMENT '执行时长', - "status" tinyint(4) NOT NULL COMMENT '任务状态', - "result" varchar(4000) DEFAULT '' COMMENT '结果数据', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除', - PRIMARY KEY ("id") -)COMMENT='定时任务日志表'; - -CREATE TABLE IF NOT EXISTS "infra_api_access_log" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "trace_id" varchar(64) not null default '', - "user_id" bigint not null default '0', - "user_type" tinyint not null default '0', - "application_name" varchar(50) not null, - "request_method" varchar(16) not null default '', - "request_url" varchar(255) not null default '', - "request_params" varchar(8000) not null default '', - "response_body" varchar(8000) not null default '', - "user_ip" varchar(50) not null, - "user_agent" varchar(512) not null, - `operate_module` varchar(50) NOT NULL, - `operate_name` varchar(50) NOT NULL, - `operate_type` bigint(4) NOT NULL DEFAULT '0', - "begin_time" timestamp not null, - "end_time" timestamp not null, - "duration" integer not null, - "result_code" integer not null default '0', - "result_msg" varchar(512) default '', - "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, - "tenant_id" bigint not null default '0', - primary key ("id") -) COMMENT 'API 访问日志表'; - -CREATE TABLE IF NOT EXISTS "infra_api_error_log" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "trace_id" varchar(64) not null, - "user_id" bigint not null default '0', - "user_type" tinyint not null default '0', - "application_name" varchar(50) not null, - "request_method" varchar(16) not null, - "request_url" varchar(255) not null, - "request_params" varchar(8000) not null, - "user_ip" varchar(50) not null, - "user_agent" varchar(512) not null, - "exception_time" timestamp not null, - "exception_name" varchar(128) not null default '', - "exception_message" clob not null, - "exception_root_cause_message" clob not null, - "exception_stack_trace" clob not null, - "exception_class_name" varchar(512) not null, - "exception_file_name" varchar(512) not null, - "exception_method_name" varchar(512) not null, - "exception_line_number" integer not null, - "process_status" tinyint not null, - "process_time" timestamp default null, - "process_user_id" bigint default '0', - "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, - "tenant_id" bigint not null default '0', - primary key ("id") -) COMMENT '系统异常日志'; - -CREATE TABLE IF NOT EXISTS "infra_data_source_config" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(100) NOT NULL, - "url" varchar(1024) NOT NULL, - "username" varchar(255) NOT NULL, - "password" varchar(255) 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 NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '数据源配置表'; - -CREATE TABLE IF NOT EXISTS "infra_codegen_table" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "data_source_config_id" bigint not null, - "scene" tinyint not null DEFAULT 1, - "table_name" varchar(200) NOT NULL, - "table_comment" varchar(500) NOT NULL, - "remark" varchar(500) NOT NULL, - "module_name" varchar(30) NOT NULL, - "business_name" varchar(30) NOT NULL, - "class_name" varchar(100) NOT NULL, - "class_comment" varchar(50) NOT NULL, - "author" varchar(50) NOT NULL, - "template_type" tinyint not null DEFAULT 1, - "front_type" tinyint not null, - "parent_menu_id" bigint not null, - "master_table_id" bigint not null, - "sub_join_column_id" bigint not null, - "sub_join_many" bit not null, - "tree_parent_column_id" bigint not null, - "tree_name_column_id" bigint 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 NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '代码生成表定义表'; - -CREATE TABLE IF NOT EXISTS "infra_codegen_column" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "table_id" bigint not null, - "column_name" varchar(200) NOT NULL, - "data_type" varchar(100) NOT NULL, - "column_comment" varchar(500) NOT NULL, - "nullable" tinyint not null, - "primary_key" tinyint not null, - "ordinal_position" int not null, - "java_type" varchar(32) NOT NULL, - "java_field" varchar(64) NOT NULL, - "dict_type" varchar(200) NOT NULL, - "example" varchar(64) NOT NULL, - "create_operation" bit not null, - "update_operation" bit not null, - "list_operation" bit not null, - "list_operation_condition" varchar(32) not null, - "list_operation_result" bit not null, - "html_type" varchar(32) 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 NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '代码生成表字段定义表'; \ No newline at end of file diff --git a/yudao-module-mall/pom.xml b/yudao-module-mall/pom.xml deleted file mode 100644 index 8cb649739..000000000 --- a/yudao-module-mall/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - yudao - cn.iocoder.cloud - ${revision} - - 4.0.0 - - yudao-module-mall - pom - - ${project.artifactId} - - - 商城大模块,由 product 商品、promotion 营销、trade 交易、statistics 统计等组成 - - - yudao-module-promotion-api - yudao-module-promotion-biz - yudao-module-product-api - yudao-module-product-biz - yudao-module-trade-api - yudao-module-trade-biz - yudao-module-statistics-api - yudao-module-statistics-biz - - - diff --git a/yudao-module-mall/yudao-module-product-api/pom.xml b/yudao-module-mall/yudao-module-product-api/pom.xml deleted file mode 100644 index 3404a06d0..000000000 --- a/yudao-module-mall/yudao-module-product-api/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - - yudao-module-product-api - jar - - ${project.artifactId} - - product 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java deleted file mode 100644 index 5e58b0483..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.product.api.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 商品分类") -public interface ProductCategoryApi { - - String PREFIX = ApiConstants.PREFIX + "/category"; - - @GetMapping(PREFIX + "/valid") - @Operation(summary = "校验部门是否合法") - @Parameter(name = "ids", description = "商品分类编号数组", example = "1,2", required = true) - CommonResult validateCategoryList(@RequestParam("ids") Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java deleted file mode 100644 index fe4d00ade..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 产品评论") -public interface ProductCommentApi { - - String PREFIX = ApiConstants.PREFIX + "/comment"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建评论") - CommonResult createComment(@RequestBody @Valid ProductCommentCreateReqDTO createReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java deleted file mode 100644 index 158ab1dc4..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "RPC 服务 - 商品评论创建 Request DTO") -@Data -public class ProductCommentCreateReqDTO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - @Schema(description = "订单编号", example = "223") - private Long orderId; - @Schema(description = "交易订单项编号", example = "666") - private Long orderItemId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级不能为空") - private Integer descriptionScores; - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级不能为空") - private Integer benefitScores; - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "好评") - @NotNull(message = "评论内容不能为空") - private String content; - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", example = "https://www.iocoder.cn/xxx.jpg,http://www.iocoder.cn/yyy.jpg") - private List picUrls; - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否匿名不能为空") - private Boolean anonymous; - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "评价人不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index b19092853..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java deleted file mode 100644 index ed32028cc..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.api.property.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 商品属性项的明细 Response DTO") -@Data -public class ProductPropertyValueDetailRespDTO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long propertyId; - @Schema(description = "属性的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long valueId; - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java deleted file mode 100644 index 7f365e7bc..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 商品 SKU") -public interface ProductSkuApi { - - String PREFIX = ApiConstants.PREFIX + "/sku"; - - @GetMapping(PREFIX + "/get") - @Operation(summary = "查询 SKU 信息") - @Parameter(name = "id", description = "SKU 编号", required = true, example = "1024") - CommonResult getSku(@RequestParam("id") Long id); - - @GetMapping(PREFIX + "/list") - @Operation(summary = "批量查询 SKU 信息") - @Parameter(name = "ids", description = "SKU 编号列表", required = true, example = "1024,2048") - CommonResult> getSkuList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/list-by-spu-id") - @Operation(summary = "批量查询 SKU 信息") - @Parameter(name = "spuIds", description = "SPU 编号列表", required = true, example = "1024,2048") - CommonResult> getSkuListBySpuId(@RequestParam("spuIds") Collection spuIds); - - @PostMapping(PREFIX + "/update-stock") - @Operation(summary = "更新 SKU 库存(增加 or 减少)") - CommonResult updateSkuStock(@RequestBody @Valid ProductSkuUpdateStockReqDTO updateStockReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java deleted file mode 100644 index 149bcd276..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "RPC 服务 - 商品 SKU 信息 Response DTO") -@Data -public class ProductSkuRespDTO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - @Schema(description = "SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "属性数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List properties; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - @Schema(description = "市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer marketPrice; - @Schema(description = "成本价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer costPrice; - @Schema(description = "SKU 的条形码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456789") - private String barCode; - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer stock; - @Schema(description = "商品重量,单位:kg 千克", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.5") - private Double weight; - @Schema(description = "商品体积,单位:m^3 平米", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.0") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "550") - private Integer firstBrokeragePrice; - @Schema(description = "二级分销的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "250") - private Integer secondBrokeragePrice; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java deleted file mode 100644 index 0b1c63aca..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "RPC 服务 - 商品 SKU 更新库存 Request DTO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuUpdateStockReqDTO { - - @Schema(description = "商品 SKU 数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商品 SKU 不能为空") - private List items; - - @Data - public static class Item { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long id; - - @Schema(description = "库存变化数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "库存变化数量不能为空") - private Integer incrCount; // 正数:增加库存;负数:扣减库存 - - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java deleted file mode 100644 index cc381c23e..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 商品 SPU") -public interface ProductSpuApi { - - String PREFIX = ApiConstants.PREFIX + "/spu"; - - @GetMapping(PREFIX + "/list") - @Schema(description = "批量查询 SPU 数组") - @Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5") - CommonResult> getSpuList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/valid") - @Schema(description = "批量查询 SPU 数组,并且校验是否 SPU 是否有效") - @Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5") - CommonResult> validateSpuList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/get") - @Schema(description = "获得 SPU") - @Parameter(name = "id", description = "SPU 编号", required = true, example = "1") - CommonResult getSpu(@RequestParam("id") Long id); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java deleted file mode 100644 index 078c20d6e..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu.dto; - -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import lombok.Data; - -// TODO @LeeYan9: ProductSpuRespDTO - -/** - * 商品 SPU 信息 Response DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -public class ProductSpuRespDTO { - - /** - * 商品 SPU 编号,自增 - */ - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 单位 - * - * 对应 product_unit 数据字典 - */ - private Integer unit; - - /** - * 商品分类编号 - */ - private Long categoryId; - /** - * 商品封面图 - */ - private String picUrl; - - /** - * 商品状态 - *

- * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * false - 单规格 - * true - 多规格 - */ - private Boolean specType; - /** - * 商品价格,单位使用:分 - */ - private Integer price; - /** - * 市场价,单位使用:分 - */ - private Integer marketPrice; - /** - * 成本价,单位使用:分 - */ - private Integer costPrice; - /** - * 库存 - */ - private Integer stock; - - // ========== 物流相关字段 ========= - - /** - * 物流配置模板编号 - * - * 对应 TradeDeliveryExpressTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - /** - * 赠送积分 - */ - private Integer giveIntegral; - - // ========== 分销相关字段 ========= - - /** - * 分销类型 - * - * false - 默认 - * true - 自行设置 - */ - private Boolean subCommissionType; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ApiConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ApiConstants.java deleted file mode 100644 index 1846e69da..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "product-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/product"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java deleted file mode 100644 index b96dde169..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -/** - * product 字典类型的枚举类 - * - * @author HUIHUI - */ -public interface DictTypeConstants { - - String PRODUCT_SPU_STATUS = "product_spu_status"; // 商品 SPU 状态 - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java deleted file mode 100644 index 1d0ea189f..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Product 错误码枚举类 - * - * product 系统,使用 1-008-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 商品分类相关 1-008-001-000 ============ - ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1_008_001_000, "商品分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_008_001_001, "父分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_008_001_002, "父分类不能是二级分类"); - ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_008_001_003, "存在子分类,无法删除"); - ErrorCode CATEGORY_DISABLED = new ErrorCode(1_008_001_004, "商品分类({})已禁用,无法使用"); - ErrorCode CATEGORY_HAVE_BIND_SPU = new ErrorCode(1_008_001_005, "类别下存在商品,无法删除"); - - // ========== 商品品牌相关编号 1-008-002-000 ========== - ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1_008_002_000, "品牌不存在"); - ErrorCode BRAND_DISABLED = new ErrorCode(1_008_002_001, "品牌已禁用"); - ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1_008_002_002, "品牌名称已存在"); - - // ========== 商品属性项 1-008-003-000 ========== - ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1_008_003_000, "属性项不存在"); - ErrorCode PROPERTY_EXISTS = new ErrorCode(1_008_003_001, "属性项的名称已存在"); - ErrorCode PROPERTY_DELETE_FAIL_VALUE_EXISTS = new ErrorCode(1_008_003_002, "属性项下存在属性值,无法删除"); - - // ========== 商品属性值 1-008-004-000 ========== - ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1_008_004_000, "属性值不存在"); - ErrorCode PROPERTY_VALUE_EXISTS = new ErrorCode(1_008_004_001, "属性值的名称已存在"); - - // ========== 商品 SPU 1-008-005-000 ========== - ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在"); - ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下"); - ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在"); - ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_003, "商品 SPU【{}】不处于上架状态"); - ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_004, "商品 SPU 不处于回收站状态"); - - // ========== 商品 SKU 1-008-006-000 ========== - ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在"); - ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1_008_006_001, "商品 SKU 的属性组合存在重复"); - ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1_008_006_002, "一个 SPU 下的每个 SKU,其属性项必须一致"); - ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1_008_006_003, "一个 SPU 下的每个 SKU,必须不重复"); - ErrorCode SKU_STOCK_NOT_ENOUGH = new ErrorCode(1_008_006_004, "商品 SKU 库存不足"); - - // ========== 商品 评价 1-008-007-000 ========== - ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_008_007_000, "商品评价不存在"); - ErrorCode COMMENT_ORDER_EXISTS = new ErrorCode(1_008_007_001, "订单的商品评价已存在"); - - // ========== 商品 收藏 1-008-008-000 ========== - ErrorCode FAVORITE_EXISTS = new ErrorCode(1_008_008_000, "该商品已经被收藏"); - ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在"); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java deleted file mode 100644 index f3570c589..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -/** - * Product 常量 - * - * @author HUIHUI - */ -public interface ProductConstants { - - /** - * 警戒库存 TODO 警戒库存暂时为 10,后期需要使用常量或者数据库配置替换 - */ - int ALERT_STOCK = 10; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java deleted file mode 100644 index 276839daf..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的审批状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductCommentAuditStatusEnum implements IntArrayValuable { - - NONE(1, "待审核"), - APPROVE(2, "审批通过"), - REJECT(2, "审批不通过"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray(); - - /** - * 审批状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java deleted file mode 100644 index a114e1ab8..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的星级枚举 - * - * @author wangzhs - */ -@Getter -@AllArgsConstructor -public enum ProductCommentScoresEnum implements IntArrayValuable { - - ONE(1, "1星"), - TWO(2, "2星"), - THREE(3, "3星"), - FOUR(4, "4星"), - FIVE(5, "5星"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentScoresEnum::getScores).toArray(); - - /** - * 星级 - */ - private final Integer scores; - - /** - * 星级名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java deleted file mode 100644 index 4ba6124e0..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.spu; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品 SPU 状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductSpuStatusEnum implements IntArrayValuable { - - RECYCLE(-1, "回收站"), - DISABLE(0, "下架"), - ENABLE(1, "上架"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断是否处于【上架】状态 - * - * @param status 状态 - * @return 是否处于【上架】状态 - */ - public static boolean isEnable(Integer status) { - return ENABLE.getStatus().equals(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/Dockerfile b/yudao-module-mall/yudao-module-product-biz/Dockerfile deleted file mode 100644 index c375d0d56..000000000 --- a/yudao-module-mall/yudao-module-product-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-product-biz -WORKDIR /yudao-module-product-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-product-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48100 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml deleted file mode 100644 index 7295e2153..000000000 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-product-biz - jar - - ${project.artifactId} - - product 模块,主要实现商品相关功能 - 例如:品牌、商品分类、spu、sku等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/ProductServerApplication.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/ProductServerApplication.java deleted file mode 100644 index 651481ba0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/ProductServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class ProductServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(ProductServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java deleted file mode 100644 index cd8e141f0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.product.api.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品分类 API 接口实现类 - * - * @author owen - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductCategoryApiImpl implements ProductCategoryApi { - - @Resource - private ProductCategoryService productCategoryService; - - @Override - public CommonResult validateCategoryList(Collection ids) { - productCategoryService.validateCategoryList(ids); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java deleted file mode 100644 index 37bcdc4d6..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品评论 API 实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductCommentApiImpl implements ProductCommentApi { - - @Resource - private ProductCommentService productCommentService; - - @Override - public CommonResult createComment(ProductCommentCreateReqDTO createReqDTO) { - return success(productCommentService.createComment(createReqDTO)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index 162453c3c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.product.api; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java deleted file mode 100644 index 41d1506b3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品 SKU API 实现类 - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductSkuApiImpl implements ProductSkuApi { - - @Resource - private ProductSkuService productSkuService; - - @Override - public CommonResult getSku(Long id) { - ProductSkuDO sku = productSkuService.getSku(id); - return success(BeanUtils.toBean(sku, ProductSkuRespDTO.class)); - } - - @Override - public CommonResult> getSkuList(Collection ids) { - List skus = productSkuService.getSkuList(ids); - return success(BeanUtils.toBean(skus, ProductSkuRespDTO.class)); - } - - @Override - public CommonResult> getSkuListBySpuId(Collection spuIds) { - List skus = productSkuService.getSkuListBySpuId(spuIds); - return success(BeanUtils.toBean(skus, ProductSkuRespDTO.class)); - } - - @Override - public CommonResult updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - productSkuService.updateSkuStock(updateStockReqDTO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java deleted file mode 100644 index 890f4f8a9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品 SPU API 接口实现类 - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductSpuApiImpl implements ProductSpuApi { - - @Resource - private ProductSpuService spuService; - - @Override - public CommonResult> getSpuList(Collection ids) { - List spus = spuService.getSpuList(ids); - return success(BeanUtils.toBean(spus, ProductSpuRespDTO.class)); - } - - @Override - public CommonResult> validateSpuList(Collection ids) { - List spus = spuService.validateSpuList(ids); - return success(BeanUtils.toBean(spus, ProductSpuRespDTO.class)); - } - - @Override - public CommonResult getSpu(Long id) { - ProductSpuDO spu = spuService.getSpu(id); - return success(BeanUtils.toBean(spu, ProductSpuRespDTO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java deleted file mode 100644 index a7c954124..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品品牌") -@RestController -@RequestMapping("/product/brand") -@Validated -public class ProductBrandController { - - @Resource - private ProductBrandService brandService; - - @PostMapping("/create") - @Operation(summary = "创建品牌") - @PreAuthorize("@ss.hasPermission('product:brand:create')") - public CommonResult createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) { - return success(brandService.createBrand(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新品牌") - @PreAuthorize("@ss.hasPermission('product:brand:update')") - public CommonResult updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) { - brandService.updateBrand(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:delete')") - public CommonResult deleteBrand(@RequestParam("id") Long id) { - brandService.deleteBrand(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult getBrand(@RequestParam("id") Long id) { - ProductBrandDO brand = brandService.getBrand(id); - return success(ProductBrandConvert.INSTANCE.convert(brand)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleBrandList() { - // 获取品牌列表,只要开启状态的 - List list = brandService.getBrandListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 排序后,返回给前端 - return success(ProductBrandConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得品牌分页") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandPage(@Valid ProductBrandPageReqVO pageVO) { - PageResult pageResult = brandService.getBrandPage(pageVO); - return success(ProductBrandConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得品牌列表") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandList(@Valid ProductBrandListReqVO listVO) { - List list = brandService.getBrandList(listVO); - list.sort(Comparator.comparing(ProductBrandDO::getSort)); - return success(ProductBrandConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java deleted file mode 100644 index a148d52de..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 商品品牌 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductBrandBaseVO { - - @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @NotNull(message = "品牌名称不能为空") - private String name; - - @Schema(description = "品牌图片", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "品牌图片不能为空") - private String picUrl; - - @Schema(description = "品牌排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "品牌排序不能为空") - private Integer sort; - - @Schema(description = "品牌描述", example = "描述") - private String description; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java deleted file mode 100644 index dc85a476b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品品牌创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandCreateReqVO extends ProductBrandBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java deleted file mode 100644 index ed93ff090..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -public class ProductBrandListReqVO { - - @Schema(description = "品牌名称", example = "苹果") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java deleted file mode 100644 index 3a6efc93f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandPageReqVO extends PageParam { - - @Schema(description = "品牌名称", example = "苹果") - private String name; - - @Schema(description = "状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java deleted file mode 100644 index 486fe764b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 品牌 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandRespVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java deleted file mode 100644 index 6379a5fb1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 品牌精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandSimpleRespVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java deleted file mode 100644 index a39a6830d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品品牌更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandUpdateReqVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "品牌编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java deleted file mode 100644 index d2343e81a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class ProductCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建商品分类") - @PreAuthorize("@ss.hasPermission('product:category:create')") - public CommonResult createCategory(@Valid @RequestBody ProductCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品分类") - @PreAuthorize("@ss.hasPermission('product:category:update')") - public CommonResult updateCategory(@Valid @RequestBody ProductCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - ProductCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, ProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) { - List list = categoryService.getCategoryList(listReqVO); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(BeanUtils.toBean(list, ProductCategoryRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java deleted file mode 100644 index 9e5364c90..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.Collection; - -@Schema(description = "管理后台 - 商品分类列表查询 Request VO") -@Data -public class ProductCategoryListReqVO { - - @Schema(description = "分类名称", example = "办公文具") - private String name; - - @Schema(description = "开启状态", example = "0") - private Integer status; - - @Schema(description = "父分类编号", example = "1") - private Long parentId; - - @Schema(description = "父分类编号数组", example = "1,2,3") - private Collection parentIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java deleted file mode 100644 index c8ef92e17..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品分类 Response VO") -@Data -public class ProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - private String name; - - @Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "分类描述", example = "描述") - private String description; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java deleted file mode 100644 index a637fde6c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品分类新增/更新 Request VO") -@Data -public class ProductCategorySaveReqVO { - - @Schema(description = "分类编号", example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "移动端分类图不能为空") - private String picUrl; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "开启状态不能为空") - private Integer status; - - @Schema(description = "分类描述", example = "描述") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.http deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java deleted file mode 100644 index ea74713f0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 商品评价") -@RestController -@RequestMapping("/product/comment") -@Validated -public class ProductCommentController { - - @Resource - private ProductCommentService productCommentService; - - @GetMapping("/page") - @Operation(summary = "获得商品评价分页") - @PreAuthorize("@ss.hasPermission('product:comment:query')") - public CommonResult> getCommentPage(@Valid ProductCommentPageReqVO pageVO) { - PageResult pageResult = productCommentService.getCommentPage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductCommentRespVO.class)); - } - - @PutMapping("/update-visible") - @Operation(summary = "显示 / 隐藏评论") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult updateCommentVisible(@Valid @RequestBody ProductCommentUpdateVisibleReqVO updateReqVO) { - productCommentService.updateCommentVisible(updateReqVO); - return success(true); - } - - @PutMapping("/reply") - @Operation(summary = "商家回复") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult commentReply(@Valid @RequestBody ProductCommentReplyReqVO replyVO) { - productCommentService.replyComment(replyVO, getLoginUserId()); - return success(true); - } - - @PostMapping("/create") - @Operation(summary = "添加自评") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) { - productCommentService.createComment(createReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java deleted file mode 100644 index 8fd8e64e9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -@Schema(description = "管理后台 - 商品评价创建 Request VO") -@Data -public class ProductCommentCreateReqVO { - - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868") - private Long userId; - - @Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292") - private Long orderItemId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉") - @NotNull(message = "评价人名称不能为空") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "评价人头像不能为空") - private String userAvatar; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, - example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java deleted file mode 100644 index 3791f572e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCommentPageReqVO extends PageParam { - - @Schema(description = "评价人名称", example = "王二狗") - private String userNickname; - - @Schema(description = "交易订单编号", example = "24428") - private Long orderId; - - @Schema(description = "商品SPU编号", example = "29502") - private Long spuId; - - @Schema(description = "商品SPU名称", example = "感冒药") - private String spuName; - - @Schema(description = "评分星级 1-5 分", example = "5") - @InEnum(ProductCommentScoresEnum.class) - private Integer scores; - - @Schema(description = "商家是否回复", example = "true") - private Boolean replyStatus; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java deleted file mode 100644 index 97ad39d7a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品评价的商家回复 Request VO") -@Data -@ToString(callSuper = true) -public class ProductCommentReplyReqVO { - - @Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - @NotNull(message = "评价编号不能为空") - private Long id; - - @Schema(description = "商家回复内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "谢谢亲") - @NotEmpty(message = "商家回复内容不能为空") - private String replyContent; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java deleted file mode 100644 index 605019a19..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商品评价 Response VO") -@Data -public class ProductCommentRespVO { - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965") - private Long id; - - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868") - private Long userId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String userAvatar; - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean anonymous; - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") - private Long orderId; - - @Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑透气小短袖") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String spuName; - - @Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg") - private String skuPicUrl; - - @Schema(description = "商品 SKU 规格值数组") - private List skuProperties; - - @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean visible; - - @Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer scores; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - private List picUrls; - - @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean replyStatus; - - @Schema(description = "回复管理员编号", example = "9527") - private Long replyUserId; - - @Schema(description = "商家回复内容", example = "感谢好评哦亲(づ ̄3 ̄)づ╭❤~") - private String replyContent; - - @Schema(description = "商家回复时间", example = "2023-08-08 12:20:55") - private LocalDateTime replyTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java deleted file mode 100644 index c88fbaf34..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品评价可见修改 Request VO") -@Data -@ToString(callSuper = true) -public class ProductCommentUpdateVisibleReqVO { - - @Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - @NotNull(message = "评价编号不能为空") - private Long id; - - @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - @NotNull(message = "是否可见不能为空") - private Boolean visible; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java deleted file mode 100644 index 721cf19c0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品收藏") -@RestController -@RequestMapping("/product/favorite") -@Validated -public class ProductFavoriteController { - - @Resource - private ProductFavoriteService productFavoriteService; - - @Resource - private ProductSpuService productSpuService; - - @GetMapping("/page") - @Operation(summary = "获得商品收藏分页") - @PreAuthorize("@ss.hasPermission('product:favorite:query')") - public CommonResult> getFavoritePage(@Valid ProductFavoritePageReqVO pageVO) { - PageResult pageResult = productFavoriteService.getFavoritePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 拼接数据 - List spuList = productSpuService.getSpuList(convertSet(pageResult.getList(), ProductFavoriteDO::getSpuId)); - return success(ProductFavoriteConvert.INSTANCE.convertPage(pageResult, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java deleted file mode 100644 index 68b0a0a16..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 商品收藏 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ProductFavoriteBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5036") - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java deleted file mode 100644 index 3d78883ec..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品收藏分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductFavoritePageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "5036") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java deleted file mode 100644 index 3c2222643..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品收藏的单个 Response VO") -@Data -@ToString(callSuper = true) -public class ProductFavoriteReqVO extends ProductFavoriteBaseVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32734") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java deleted file mode 100644 index 3c09aa8fc..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品收藏 Response VO") -@Data -@ToString(callSuper = true) -public class ProductFavoriteRespVO extends ProductSpuRespVO { - - @Schema(description = "userId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long userId; - - @Schema(description = "spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java deleted file mode 100644 index e0d47f409..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.history; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品浏览记录") -@RestController -@RequestMapping("/product/browse-history") -@Validated -public class ProductBrowseHistoryController { - - @Resource - private ProductBrowseHistoryService browseHistoryService; - - @GetMapping("/page") - @Operation(summary = "获得商品浏览记录分页") - @PreAuthorize("@ss.hasPermission('product:browse-history:query')") - public CommonResult> getBrowseHistoryPage(@Valid ProductBrowseHistoryPageReqVO pageReqVO) { - PageResult pageResult = browseHistoryService.getBrowseHistoryPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryPageReqVO.java deleted file mode 100644 index aa3010212..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.history.vo; - -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品浏览记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrowseHistoryPageReqVO extends SortablePageParam { - - @Schema(description = "用户编号", example = "4314") - private Long userId; - - @Schema(description = "用户是否删除", example = "false") - private Boolean userDeleted; - - @Schema(description = "商品 SPU 编号", example = "42") - private Long spuId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java deleted file mode 100644 index 0e2e0cbed..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.history.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品浏览记录 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ProductBrowseHistoryRespVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26055") - @ExcelProperty("记录编号") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4314") - @ExcelProperty("用户编号") - private Long userId; - - @Schema(description = "用户是否删除", example = "false") - private Boolean userDeleted; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "42") - @ExcelProperty("商品 SPU 编号") - private Long spuId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java deleted file mode 100644 index ee9bf556e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品属性项") -@RestController -@RequestMapping("/product/property") -@Validated -public class ProductPropertyController { - - @Resource - private ProductPropertyService productPropertyService; - - @PostMapping("/create") - @Operation(summary = "创建属性项") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createProperty(@Valid @RequestBody ProductPropertySaveReqVO createReqVO) { - return success(productPropertyService.createProperty(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性项") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updateProperty(@Valid @RequestBody ProductPropertySaveReqVO updateReqVO) { - productPropertyService.updateProperty(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性项") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deleteProperty(@RequestParam("id") Long id) { - productPropertyService.deleteProperty(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性项") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getProperty(@RequestParam("id") Long id) { - ProductPropertyDO property = productPropertyService.getProperty(id); - return success(BeanUtils.toBean(property, ProductPropertyRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得属性项分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { - PageResult pageResult = productPropertyService.getPropertyPage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductPropertyRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java deleted file mode 100644 index d372a63da..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品属性值") -@RestController -@RequestMapping("/product/property/value") -@Validated -public class ProductPropertyValueController { - - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建属性值") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createPropertyValue(@Valid @RequestBody ProductPropertyValueSaveReqVO createReqVO) { - return success(productPropertyValueService.createPropertyValue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性值") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updatePropertyValue(@Valid @RequestBody ProductPropertyValueSaveReqVO updateReqVO) { - productPropertyValueService.updatePropertyValue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deletePropertyValue(@RequestParam("id") Long id) { - productPropertyValueService.deletePropertyValue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getPropertyValue(@RequestParam("id") Long id) { - ProductPropertyValueDO value = productPropertyValueService.getPropertyValue(id); - return success(BeanUtils.toBean(value, ProductPropertyValueRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得属性值分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) { - PageResult pageResult = productPropertyValueService.getPropertyValuePage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductPropertyValueRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java deleted file mode 100644 index 97b959d6a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 属性项 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyPageReqVO extends PageParam { - - @Schema(description = "名称", example = "颜色") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java deleted file mode 100644 index 82a3a0cac..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 属性项 Response VO") -@Data -public class ProductPropertyRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java deleted file mode 100644 index a96568c43..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -@Schema(description = "管理后台 - 属性项新增/更新 Request VO") -@Data -public class ProductPropertySaveReqVO { - - @Schema(description = "主键", example = "1") - private Long id; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - @NotBlank(message = "名称不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java deleted file mode 100644 index ff0c32614..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品属性值分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValuePageReqVO extends PageParam { - - @Schema(description = "属性项的编号", example = "1024") - private String propertyId; - - @Schema(description = "名称", example = "红色") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java deleted file mode 100644 index d401df170..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品属性值 Response VO") -@Data -public class ProductPropertyValueRespVO { - - @Schema(description = "主键", example = "1024") - private Long id; - - @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "属性项的编号不能为空") - private Long propertyId; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - @NotEmpty(message = "名称名字不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java deleted file mode 100644 index 1a33f7124..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品属性值新增/更新 Request VO") -@Data -public class ProductPropertyValueSaveReqVO { - - @Schema(description = "主键", example = "1024") - private Long id; - - @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "属性项的编号不能为空") - private Long propertyId; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - @NotEmpty(message = "名称名字不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http deleted file mode 100644 index 4ab7b4f71..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 获得商品 SPU 明细 -GET {{baseUrl}}/product/spu/get-detail?id=4 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java deleted file mode 100755 index 0c3089781..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; - -@Tag(name = "管理后台 - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class ProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - - @PostMapping("/create") - @Operation(summary = "创建商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:create')") - public CommonResult createProductSpu(@Valid @RequestBody ProductSpuSaveReqVO createReqVO) { - return success(productSpuService.createSpu(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateSpu(@Valid @RequestBody ProductSpuSaveReqVO updateReqVO) { - productSpuService.updateSpu(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新商品 SPU Status") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateStatus(@Valid @RequestBody ProductSpuUpdateStatusReqVO updateReqVO) { - productSpuService.updateSpuStatus(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品 SPU") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:delete')") - public CommonResult deleteSpu(@RequestParam("id") Long id) { - productSpuService.deleteSpu(id); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - return success(null); - } - // 查询商品 SKU - List skus = productSkuService.getSkuListBySpuId(spu.getId()); - return success(ProductSpuConvert.INSTANCE.convert(spu, skus)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得商品 SPU 精简列表") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuSimpleList() { - List list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - // 降序排序后,返回给前端 - list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed()); - return success(BeanUtils.toBean(list, ProductSpuSimpleRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品 SPU 详情列表") - @Parameter(name = "spuIds", description = "spu 编号列表", required = true, example = "[1,2,3]") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuList(@RequestParam("spuIds") Collection spuIds) { - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespListVO( - productSpuService.getSpuList(spuIds), productSkuService.getSkuListBySpuId(spuIds))); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { - PageResult pageResult = productSpuService.getSpuPage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductSpuRespVO.class)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得商品 SPU 分页 tab count") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuCount() { - return success(productSpuService.getTabsCount()); - } - - @GetMapping("/export") - @Operation(summary = "导出商品") - @PreAuthorize("@ss.hasPermission('product:spu:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSpuList(@Validated ProductSpuPageReqVO reqVO, - HttpServletResponse response) throws IOException { - reqVO.setPageSize(PAGE_SIZE_NONE); - List list = productSpuService.getSpuPage(reqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "商品列表.xls", "数据", ProductSpuRespVO.class, - BeanUtils.toBean(list, ProductSpuRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java deleted file mode 100755 index f977d33c9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU Response VO") -@Data -public class ProductSkuRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - private String name; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer price; - - @Schema(description = "市场价", example = "2999") - private Integer marketPrice; - - @Schema(description = "成本价", example = "19") - private Integer costPrice; - - @Schema(description = "条形码", example = "15156165456") - private String barCode; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer stock; - - @Schema(description = "商品重量,单位:kg 千克", example = "1.2") - private Double weight; - - @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", example = "199") - private Integer firstBrokeragePrice; - - @Schema(description = "二级分销的佣金,单位:分", example = "19") - private Integer secondBrokeragePrice; - - @Schema(description = "属性数组") - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java deleted file mode 100755 index 6aa703bb7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO") -@Data -public class ProductSkuSaveReqVO { - - @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @NotEmpty(message = "商品 SKU 名字不能为空") - private String name; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - @NotNull(message = "销售价格,单位:分不能为空") - private Integer price; - - @Schema(description = "市场价", example = "2999") - private Integer marketPrice; - - @Schema(description = "成本价", example = "19") - private Integer costPrice; - - @Schema(description = "条形码", example = "15156165456") - private String barCode; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - @NotNull(message = "库存不能为空") - private Integer stock; - - @Schema(description = "商品重量,单位:kg 千克", example = "1.2") - private Double weight; - - @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", example = "199") - private Integer firstBrokeragePrice; - - @Schema(description = "二级分销的佣金,单位:分", example = "19") - private Integer secondBrokeragePrice; - - @Schema(description = "属性数组") - private List properties; - - @Schema(description = "商品属性") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - @Schema(description = "属性编号", example = "10") - private Long propertyId; - - @Schema(description = "属性名字", example = "颜色") - private String propertyName; - - @Schema(description = "属性值编号", example = "10") - private Long valueId; - - @Schema(description = "属性值名字", example = "红色") - private String valueName; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java deleted file mode 100755 index 81cff4210..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuPageReqVO extends PageParam { - - /** - * 出售中商品 - */ - public static final Integer FOR_SALE = 0; - - /** - * 仓库中商品 - */ - public static final Integer IN_WAREHOUSE = 1; - - /** - * 已售空商品 - */ - public static final Integer SOLD_OUT = 2; - - /** - * 警戒库存 - */ - public static final Integer ALERT_STOCK = 3; - - /** - * 商品回收站 - */ - public static final Integer RECYCLE_BIN = 4; - - @Schema(description = "商品名称", example = "清凉小短袖") - private String name; - - @Schema(description = "前端请求的tab类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer tabType; - - @Schema(description = "商品分类编号", example = "1") - private Long categoryId; - - @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java deleted file mode 100755 index fbc75522a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU Response VO") -@Data -@ExcelIgnoreUnannotated -public class ProductSpuRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @ExcelProperty("商品编号") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @ExcelProperty("商品名称") - private String name; - - @Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗") - @ExcelProperty("关键字") - private String keyword; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - @ExcelProperty("商品简介") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情") - @ExcelProperty("商品详情") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("商品分类编号") - private Long categoryId; - - @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("商品品牌编号") - private Long brandId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @ExcelProperty("商品封面图") - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List sliderPicUrls; - - @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("排序字段") - private Integer sort; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "商品状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS) - private Integer status; - - @Schema(description = "商品创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-05-24 00:00:00") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty("规格类型") - private Boolean specType; - - @Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - @ExcelProperty(value = "商品价格", converter = MoneyConvert.class) - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") - @ExcelProperty(value = "市场价", converter = MoneyConvert.class) - private Integer marketPrice; - - @Schema(description = "成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") - @ExcelProperty(value = "成本价", converter = MoneyConvert.class) - private Integer costPrice; - - @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @ExcelProperty("库存") - private Integer stock; - - @Schema(description = "SKU 数组") - private List skus; - - // ========== 物流相关字段 ========= - - @Schema(description = "配送方式数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List deliveryTypes; - - @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @ExcelProperty("物流配置模板编号") - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @ExcelProperty("赠送积分") - private Integer giveIntegral; - - @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty("分销类型") - private Boolean subCommissionType; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - @ExcelProperty("商品销量") - private Integer salesCount; - - @Schema(description = "虚拟销量", example = "66") - @ExcelProperty("虚拟销量") - private Integer virtualSalesCount; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @ExcelProperty("商品点击量") - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java deleted file mode 100755 index 340814507..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 新增/更新 Request VO") -@Data -public class ProductSpuSaveReqVO { - - @Schema(description = "商品编号", example = "1") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @NotEmpty(message = "商品名称不能为空") - private String name; - - @Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗") - @NotEmpty(message = "商品关键字不能为空") - private String keyword; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - @NotEmpty(message = "商品简介不能为空") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情") - @NotEmpty(message = "商品详情不能为空") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品分类不能为空") - private Long categoryId; - - @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品品牌不能为空") - private Long brandId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotEmpty(message = "商品封面图不能为空") - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, - example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List sliderPicUrls; - - @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品排序字段不能为空") - private Integer sort; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品规格类型不能为空") - private Boolean specType; - - // ========== 物流相关字段 ========= - - @Schema(description = "配送方式数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "配送方式不能为空") - private List deliveryTypes; - - @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @NotNull(message = "商品赠送积分不能为空") - private Integer giveIntegral; - - @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品分销类型不能为空") - private Boolean subCommissionType; - - // ========== 统计相关字段 ========= - - @Schema(description = "虚拟销量", example = "66") - private Integer virtualSalesCount; - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer salesCount; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer browseCount; - - // ========== SKU 相关字段 ========= - - @Schema(description = "SKU 数组") - @Valid - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java deleted file mode 100755 index 7d9d0d05d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品 SPU 精简 Response VO") -@Data -@ToString(callSuper = true) -public class ProductSpuSimpleRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "213") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - private String name; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer price; - - @Schema(description = "商品市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") - private Integer marketPrice; - - @Schema(description = "商品成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") - private Integer costPrice; - - @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer stock; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer salesCount; - - @Schema(description = "商品虚拟销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20000") - private Integer virtualSalesCount; - - @Schema(description = "商品浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java deleted file mode 100644 index e36e68466..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品 SPU Status 更新 Request VO") -@Data -public class ProductSpuUpdateStatusReqVO{ - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品编号不能为空") - private Long id; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品状态不能为空") - @InEnum(ProductSpuStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java deleted file mode 100644 index eb651e747..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class AppCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - public CommonResult> getProductCategoryList() { - List list = categoryService.getEnableCategoryList(); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(BeanUtils.toBean(list, AppCategoryRespVO.class)); - } - - @GetMapping("/list-by-ids") - @Operation(summary = "获得商品分类列表,指定编号") - @Parameter(name = "ids", description = "商品分类编号数组", required = true) - public CommonResult> getProductCategoryList(@RequestParam("ids") List ids) { - if (CollUtil.isEmpty(ids)) { - return success(Collections.emptyList()); - } - List list = categoryService.getEnableCategoryList(ids); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(BeanUtils.toBean(list, AppCategoryRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java deleted file mode 100644 index 02e5f171a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Data -@Schema(description = "用户 APP - 商品分类 Response VO") -public class AppCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类图片", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "分类图片不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.http deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java deleted file mode 100644 index e6e332a83..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 商品评价") -@RestController -@RequestMapping("/product/comment") -@Validated -public class AppProductCommentController { - - @Resource - private ProductCommentService productCommentService; - - @GetMapping("/page") - @Operation(summary = "获得商品评价分页") - public CommonResult> getCommentPage(@Valid AppCommentPageReqVO pageVO) { - // 查询评论分页 - PageResult pageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - pageResult.getList().forEach(item -> { - if (Boolean.TRUE.equals(item.getAnonymous())) { - item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS); - } - }); - return success(BeanUtils.toBean(pageResult, AppProductCommentRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java deleted file mode 100644 index 8a3cf5e0b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCommentPageReqVO extends PageParam { - - /** - * 好评 - */ - public static final Integer GOOD_COMMENT = 1; - /** - * 中评 - */ - public static final Integer MEDIOCRE_COMMENT = 2; - /** - * 差评 - */ - public static final Integer NEGATIVE_COMMENT = 3; - - @Schema(description = "商品 SPU 编号", example = "29502") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "app 评论页 tab 类型 (0 全部、1 好评、2 中评、3 差评)", example = "0") - @NotNull(message = "商品 SPU 编号不能为空") - private Integer type; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java deleted file mode 100644 index 5a77d8786..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 商品评价详情 Response VO") -@Data -@ToString(callSuper = true) -public class AppProductCommentRespVO { - - @Schema(description = "评价人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long userId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String userAvatar; - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965") - private Long id; - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean anonymous; - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") - private Long orderId; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8233") - private Long orderItemId; - - @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean replyStatus; - - @Schema(description = "回复管理员编号", example = "22212") - private Long replyUserId; - - @Schema(description = "商家回复内容", example = "亲,你的好评就是我的动力(*^▽^*)") - private String replyContent; - - @Schema(description = "商家回复时间") - private LocalDateTime replyTime; - - @Schema(description = "追加评价内容", example = "穿了很久都很丝滑诶") - private String additionalContent; - - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传 9 张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List additionalPicUrls; - - @Schema(description = "追加评价时间") - private LocalDateTime additionalTime; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "91192") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑小短袖") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "81192") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品 SKU 属性", requiredMode = Schema.RequiredMode.REQUIRED) - private List skuProperties; - - @Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "评分星级 1-5 分不能为空") - private Integer scores; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级 1-5 分不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级 1-5 分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "哇,真的很丝滑凉快诶,好评") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, - example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java deleted file mode 100644 index fb76e5252..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 商品收藏") -@RestController -@RequestMapping("/product/favorite") -public class AppFavoriteController { - - @Resource - private ProductFavoriteService productFavoriteService; - @Resource - private ProductSpuService productSpuService; - - @PostMapping(value = "/create") - @Operation(summary = "添加商品收藏") - @PreAuthenticated - public CommonResult createFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) { - return success(productFavoriteService.createFavorite(getLoginUserId(), reqVO.getSpuId())); - } - - @DeleteMapping(value = "/delete") - @Operation(summary = "取消单个商品收藏") - @PreAuthenticated - public CommonResult deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) { - productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(Boolean.TRUE); - } - - @GetMapping(value = "/page") - @Operation(summary = "获得商品收藏分页") - @PreAuthenticated - public CommonResult> getFavoritePage(AppFavoritePageReqVO reqVO) { - PageResult favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO); - if (CollUtil.isEmpty(favoritePage.getList())) { - return success(PageResult.empty()); - } - - // 得到商品 spu 信息 - List favorites = favoritePage.getList(); - List spuIds = convertList(favorites, ProductFavoriteDO::getSpuId); - List spus = productSpuService.getSpuList(spuIds); - - // 转换 VO 结果 - PageResult pageResult = new PageResult<>(favoritePage.getTotal()); - pageResult.setList(ProductFavoriteConvert.INSTANCE.convertList(favorites, spus)); - return success(pageResult); - } - - @GetMapping(value = "/exits") - @Operation(summary = "检查是否收藏过商品") - @PreAuthenticated - public CommonResult isFavoriteExists(AppFavoriteReqVO reqVO) { - ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(favorite != null); - } - - @GetMapping(value = "/get-count") - @Operation(summary = "获得商品收藏数量") - @PreAuthenticated - public CommonResult getFavoriteCount() { - return success(productFavoriteService.getFavoriteCount(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java deleted file mode 100644 index fbb1afb9e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏 -@Data -public class AppFavoriteBatchReqVO { - - @Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502") - @NotEmpty(message = "商品 SPU 编号数组不能为空") - private List spuIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java deleted file mode 100644 index 2aacc3e54..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品收藏分页查询 Request VO") -@Data -public class AppFavoritePageReqVO extends PageParam { -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java deleted file mode 100644 index 4f95a6bf0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏 -@Data -public class AppFavoriteReqVO { - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java deleted file mode 100644 index 306e50048..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 App - 商品收藏 Response VO") -@Data -public class AppFavoriteRespVO { - - @Schema(description = "编号", requiredMode = REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - private Long spuId; - - // ========== 商品相关字段 ========== - - @Schema(description = "商品 SPU 名称", example = "赵六") - private String spuName; - - @Schema(description = "商品封面图", example = "https://domain/pic.png") - private String picUrl; - - @Schema(description = "商品单价", example = "100") - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java deleted file mode 100644 index b275151f4..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryDeleteReqVO; -import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 商品浏览记录") -@RestController -@RequestMapping("/product/browse-history") -public class AppProductBrowseHistoryController { - - @Resource - private ProductBrowseHistoryService productBrowseHistoryService; - @Resource - private ProductSpuService productSpuService; - - @DeleteMapping(value = "/delete") - @Operation(summary = "删除商品浏览记录") - @PreAuthenticated - public CommonResult deleteBrowseHistory(@RequestBody @Valid AppProductBrowseHistoryDeleteReqVO reqVO) { - productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), reqVO.getSpuIds()); - return success(Boolean.TRUE); - } - - @DeleteMapping(value = "/clean") - @Operation(summary = "清空商品浏览记录") - @PreAuthenticated - public CommonResult deleteBrowseHistory() { - productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), null); - return success(Boolean.TRUE); - } - - @GetMapping(value = "/page") - @Operation(summary = "获得商品浏览记录分页") - @PreAuthenticated - public CommonResult> getBrowseHistoryPage(AppProductBrowseHistoryPageReqVO reqVO) { - ProductBrowseHistoryPageReqVO pageReqVO = BeanUtils.toBean(reqVO, ProductBrowseHistoryPageReqVO.class) - .setUserId(getLoginUserId()) - .setUserDeleted(false); // 排除用户已删除的(隐藏的) - PageResult pageResult = productBrowseHistoryService.getBrowseHistoryPage(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 得到商品 spu 信息 - Set spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId); - Map spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); - return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class, - vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) - .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice())))); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryDeleteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryDeleteReqVO.java deleted file mode 100644 index 13eb7dd61..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryDeleteReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 删除商品浏览记录的 Request VO") -@Data -public class AppProductBrowseHistoryDeleteReqVO { - - @Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502") - @NotEmpty(message = "商品 SPU 编号数组不能为空") - private List spuIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryPageReqVO.java deleted file mode 100644 index f959fd0d1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "用户 APP - 商品浏览记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppProductBrowseHistoryPageReqVO extends PageParam { - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java deleted file mode 100644 index 05b528cdb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 App - 商品浏览记录 Response VO") -@Data -public class AppProductBrowseHistoryRespVO { - - @Schema(description = "编号", requiredMode = REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - private Long spuId; - - // ========== 商品相关字段 ========== - - @Schema(description = "商品 SPU 名称", example = "赵六") - private String spuName; - - @Schema(description = "商品封面图", example = "https://domain/pic.png") - private String picUrl; - - @Schema(description = "商品单价", example = "100") - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java deleted file mode 100644 index 379e85180..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java deleted file mode 100644 index 6538bea3c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property.vo.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 5cac09143..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http deleted file mode 100644 index c391b5873..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http +++ /dev/null @@ -1,18 +0,0 @@ -### 获得订单交易的分页(默认) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的分页(价格) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=price&sortAsc=true -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的分页(销售) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=salesCount&sortAsc=true -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得商品 SPU 明细 -GET {{appApi}}/product/spu/get-detail?id=102 -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java deleted file mode 100644 index b1cfc69c5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; - -@Tag(name = "用户 APP - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class AppProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - @Resource - private ProductBrowseHistoryService productBrowseHistoryService; - - @Resource - private MemberLevelApi memberLevelApi; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/list-by-ids") - @Operation(summary = "获得商品 SPU 列表") - @Parameter(name = "ids", description = "编号列表", required = true) - public CommonResult> getSpuList(@RequestParam("ids") Set ids) { - List list = productSpuService.getSpuList(ids); - if (CollUtil.isEmpty(list)) { - return success(Collections.emptyList()); - } - - // 拼接返回 - list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); - List voList = BeanUtils.toBean(list, AppProductSpuRespVO.class); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voList); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { - PageResult pageResult = productSpuService.getSpuPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - pageResult.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); - PageResult voPageResult = BeanUtils.toBean(pageResult, AppProductSpuRespVO.class); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voPageResult); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", description = "编号", required = true) - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE, spu.getName()); - } - // 获得商品 SKU - List skus = productSkuService.getSkuListBySpuId(spu.getId()); - - // 增加浏览量 - productSpuService.updateBrowseCount(id, 1); - // 保存浏览记录 - productBrowseHistoryService.createBrowseHistory(getLoginUserId(), id); - - // 拼接返回 - spu.setBrowseCount(spu.getBrowseCount() + spu.getVirtualSalesCount()); - AppProductSpuDetailRespVO spuVO = BeanUtils.toBean(spu, AppProductSpuDetailRespVO.class) - .setSkus(BeanUtils.toBean(skus, AppProductSpuDetailRespVO.Sku.class)); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - spuVO.setVipPrice(calculateVipPrice(spuVO.getPrice(), memberLevel)); - return success(spuVO); - } - - private MemberLevelRespDTO getMemberLevel() { - Long userId = getLoginUserId(); - if (userId == null) { - return null; - } - MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData(); - if (user.getLevelId() == null || user.getLevelId() <= 0) { - return null; - } - return memberLevelApi.getMemberLevel(user.getLevelId()).getCheckedData(); - } - - /** - * 计算会员 VIP 优惠价格 - * - * @param price 原价 - * @param memberLevel 会员等级 - * @return 优惠价格 - */ - public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) { - if (memberLevel == null || memberLevel.getDiscountPercent() == null) { - return 0; - } - Integer newPrice = price * memberLevel.getDiscountPercent() / 100; - return price - newPrice; - } - - // TODO 芋艿:商品的浏览记录; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java deleted file mode 100644 index f1ee49b10..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU 明细 Response VO") -@Data -public class AppProductSpuDetailRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - // ========== 基本信息 ========= - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是一个快乐简介") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是商品描述") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long categoryId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - - // ========== 营销相关字段 ========= - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean specType; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer stock; - - /** - * SKU 数组 - */ - private List skus; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer salesCount; - - @Schema(description = "用户 App - 商品 SPU 明细的 SKU 信息") - @Data - public static class Sku { - - @Schema(description = "商品 SKU 编号", example = "1") - private Long id; - - /** - * 商品属性数组 - */ - private List properties; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer stock; - - @Schema(description = "商品重量", example = "1") // 单位:kg 千克 - private Double weight; - - @Schema(description = "商品体积", example = "1024") // 单位:m^3 平米 - private Double volume; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java deleted file mode 100644 index 1584dc6f3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.AssertTrue; -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppProductSpuPageReqVO extends PageParam { - - public static final String SORT_FIELD_PRICE = "price"; - public static final String SORT_FIELD_SALES_COUNT = "salesCount"; - public static final String SORT_FIELD_CREATE_TIME = "createTime"; - - @Schema(description = "商品 SPU 编号数组", example = "1,3,5") - private List ids; - - @Schema(description = "分类编号", example = "1") - private Long categoryId; - - @Schema(description = "分类编号数组", example = "1,2,3") - private List categoryIds; - - @Schema(description = "关键字", example = "好看") - private String keyword; - - @Schema(description = "排序字段", example = "price") // 参见 AppProductSpuPageReqVO.SORT_FIELD_XXX 常量 - private String sortField; - - @Schema(description = "排序方式", example = "true") - private Boolean sortAsc; - - @AssertTrue(message = "排序字段不合法") - @JsonIgnore - public boolean isSortFieldValid() { - if (StrUtil.isEmpty(sortField)) { - return true; - } - return StrUtil.equalsAny(sortField, SORT_FIELD_PRICE, SORT_FIELD_SALES_COUNT); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java deleted file mode 100644 index df61090bb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU Response VO") -@Data -public class AppProductSpuRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - private String introduction; - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long categoryId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean specType; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer stock; - - // ========== 营销相关字段 ========= - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer salesCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java deleted file mode 100644 index e6c72fb49..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandSimpleRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 品牌 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductBrandConvert { - - ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class); - - ProductBrandDO convert(ProductBrandCreateReqVO bean); - - ProductBrandDO convert(ProductBrandUpdateReqVO bean); - - ProductBrandRespVO convert(ProductBrandDO bean); - - List convertList1(List list); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java deleted file mode 100644 index 7a3a3c011..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.comment; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -/** - * 商品评价 Convert - * - * @author wangzhs - */ -@Mapper -public interface ProductCommentConvert { - - ProductCommentConvert INSTANCE = Mappers.getMapper(ProductCommentConvert.class); - - default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, - ProductSpuDO spu, ProductSkuDO sku, MemberUserRespDTO user) { - ProductCommentDO comment = BeanUtils.toBean(createReqDTO, ProductCommentDO.class) - .setScores(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores())); - if (user != null) { - comment.setUserId(user.getId()).setUserNickname(user.getNickname()).setUserAvatar(user.getAvatar()); - } - if (spu != null) { - comment.setSpuId(spu.getId()).setSpuName(spu.getName()); - } - if (sku != null) { - comment.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); - } - return comment; - } - - default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) { - ProductCommentDO comment = BeanUtils.toBean(createReq, ProductCommentDO.class) - .setVisible(true).setUserId(0L).setAnonymous(false) - .setScores(convertScores(createReq.getDescriptionScores(), createReq.getBenefitScores())); - if (spu != null) { - comment.setSpuId(spu.getId()).setSpuName(spu.getName()); - } - if (sku != null) { - comment.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); - } - return comment; - } - - default Integer convertScores(Integer descriptionScores, Integer benefitScores) { - // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 - BigDecimal sumScore = new BigDecimal(descriptionScores + benefitScores); - BigDecimal divide = sumScore.divide(BigDecimal.valueOf(2L), 0, RoundingMode.DOWN); - return divide.intValue(); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java deleted file mode 100644 index 7b419b6a8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface ProductFavoriteConvert { - - ProductFavoriteConvert INSTANCE = Mappers.getMapper(ProductFavoriteConvert.class); - - ProductFavoriteDO convert(Long userId, Long spuId); - - @Mapping(target = "id", source = "favorite.id") - @Mapping(target = "spuName", source = "spu.name") - AppFavoriteRespVO convert(ProductSpuDO spu, ProductFavoriteDO favorite); - - default List convertList(List favorites, List spus) { - List resultList = new ArrayList<>(favorites.size()); - Map spuMap = convertMap(spus, ProductSpuDO::getId); - for (ProductFavoriteDO favorite : favorites) { - ProductSpuDO spuDO = spuMap.get(favorite.getSpuId()); - resultList.add(convert(spuDO, favorite)); - } - return resultList; - } - - default PageResult convertPage(PageResult pageResult, List spuList) { - Map spuMap = convertMap(spuList, ProductSpuDO::getId); - List voList = CollectionUtils.convertList(pageResult.getList(), favorite -> { - ProductSpuDO spu = spuMap.get(favorite.getSpuId()); - return convert02(spu, favorite); - }); - return new PageResult<>(voList, pageResult.getTotal()); - } - @Mapping(target = "id", source = "favorite.id") - @Mapping(target = "userId", source = "favorite.userId") - @Mapping(target = "spuId", source = "favorite.spuId") - @Mapping(target = "createTime", source = "favorite.createTime") - ProductFavoriteRespVO convert02(ProductSpuDO spu, ProductFavoriteDO favorite); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java deleted file mode 100755 index 492f483c0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SKU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSkuConvert { - - ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); - - /** - * 获得 SPU 的库存变化 Map - * - * @param items SKU 库存变化 - * @param skus SKU 列表 - * @return SPU 的库存变化 Map - */ - default Map convertSpuStockMap(List items, - List skus) { - Map skuIdAndSpuIdMap = convertMap(skus, ProductSkuDO::getId, ProductSkuDO::getSpuId); // SKU 与 SKU 编号的 Map 关系 - Map spuIdAndStockMap = new HashMap<>(); // SPU 的库存变化 Map 关系 - items.forEach(item -> { - Long spuId = skuIdAndSpuIdMap.get(item.getId()); - if (spuId == null) { - return; - } - Integer stock = spuIdAndStockMap.getOrDefault(spuId, 0) + item.getIncrCount(); - spuIdAndStockMap.put(spuId, stock); - }); - return spuIdAndStockMap; - } - - default String buildPropertyKey(ProductSkuDO bean) { - if (CollUtil.isEmpty(bean.getProperties())) { - return StrUtil.EMPTY; - } - List properties = new ArrayList<>(bean.getProperties()); - properties.sort(Comparator.comparing(ProductSkuDO.Property::getValueId)); - return properties.stream().map(m -> String.valueOf(m.getValueId())).collect(Collectors.joining()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java deleted file mode 100755 index 364434241..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.spu; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; - -/** - * 商品 SPU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSpuConvert { - - ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); - - ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); - - default ProductSpuRespVO convert(ProductSpuDO spu, List skus) { - ProductSpuRespVO spuVO = BeanUtils.toBean(spu, ProductSpuRespVO.class); - spuVO.setSkus(BeanUtils.toBean(skus, ProductSkuRespVO.class)); - return spuVO; - } - - default List convertForSpuDetailRespListVO(List spus, List skus) { - Map> skuMultiMap = convertMultiMap(skus, ProductSkuDO::getSpuId); - return CollectionUtils.convertList(spus, spu -> convert(spu, skuMultiMap.get(spu.getId()))); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java deleted file mode 100644 index 9775f36a5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品品牌 DO - * - * @author 芋道源码 - */ -@TableName("product_brand") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandDO extends BaseDO { - - /** - * 品牌编号 - */ - @TableId - private Long id; - /** - * 品牌名称 - */ - private String name; - /** - * 品牌图片 - */ - private String picUrl; - /** - * 品牌排序 - */ - private Integer sort; - /** - * 品牌描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:firstLetter 首字母 - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java deleted file mode 100644 index 78e35d6f5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品分类 DO - * - * @author 芋道源码 - */ -@TableName("product_category") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - /** - * 限定分类层级 - */ - public static final int CATEGORY_LEVEL = 2; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 父分类编号 - */ - private Long parentId; - /** - * 分类名称 - */ - private String name; - /** - * 移动端分类图 - * - * 建议 180*180 分辨率 - */ - private String picUrl; - /** - * 分类排序 - */ - private Integer sort; - /** - * 开启状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java deleted file mode 100644 index 40b04caf0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.comment; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 商品评论 DO - * - * @author 芋道源码 - */ -@TableName(value = "product_comment", autoResultMap = true) -@KeySequence("product_comment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCommentDO extends BaseDO { - - /** - * 默认匿名昵称 - */ - public static final String NICKNAME_ANONYMOUS = "匿名用户"; - - /** - * 评论编号,主键自增 - */ - @TableId - private Long id; - - /** - * 评价人的用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 评价人名称 - */ - private String userNickname; - /** - * 评价人头像 - */ - private String userAvatar; - /** - * 是否匿名 - */ - private Boolean anonymous; - - /** - * 交易订单编号 - * - * 关联 TradeOrderDO 的 id 编号 - */ - private Long orderId; - /** - * 交易订单项编号 - * - * 关联 TradeOrderItemDO 的 id 编号 - */ - private Long orderItemId; - - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 {@link ProductSpuDO#getName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 {@link ProductSkuDO#getId()} - */ - private Long skuId; - /** - * 商品 SKU 图片地址 - * - * 关联 {@link ProductSkuDO#getPicUrl()} - */ - private String skuPicUrl; - /** - * 属性数组,JSON 格式 - * - * 关联 {@link ProductSkuDO#getProperties()} - */ - @TableField(typeHandler = ProductSkuDO.PropertyTypeHandler.class) - private List skuProperties; - - /** - * 是否可见 - * - * true:显示 - * false:隐藏 - */ - private Boolean visible; - /** - * 评分星级 - * - * 1-5 分 - */ - private Integer scores; - /** - * 描述星级 - * - * 1-5 星 - */ - private Integer descriptionScores; - /** - * 服务星级 - * - * 1-5 星 - */ - private Integer benefitScores; - /** - * 评论内容 - */ - private String content; - /** - * 评论图片地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List picUrls; - - /** - * 商家是否回复 - */ - private Boolean replyStatus; - /** - * 回复管理员编号 - * 关联 AdminUserDO 的 id 编号 - */ - private Long replyUserId; - /** - * 商家回复内容 - */ - private String replyContent; - /** - * 商家回复时间 - */ - private LocalDateTime replyTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java deleted file mode 100644 index 6e00eaa6c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.favorite; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品收藏 DO - * - * @author 芋道源码 - */ -@TableName("product_favorite") -@KeySequence("product_favorite_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductFavoriteDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/history/ProductBrowseHistoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/history/ProductBrowseHistoryDO.java deleted file mode 100644 index 472574bd9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/history/ProductBrowseHistoryDO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.history; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品浏览记录 DO - * - * @author owen - */ -@TableName("product_browse_history") -@KeySequence("product_browse_history_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrowseHistoryDO extends BaseDO { - - /** - * 记录编号 - */ - @TableId - private Long id; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 用户编号 - */ - private Long userId; - /** - * 用户是否删除 - */ - private Boolean userDeleted; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java deleted file mode 100644 index 8cc646bd5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品属性项 DO - * - * @author 芋道源码 - */ -@TableName("product_property") -@KeySequence("product_property_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyDO extends BaseDO { - - /** - * SPU 单规格时,默认属性 id - */ - public static final Long ID_DEFAULT = 0L; - /** - * SPU 单规格时,默认属性名字 - */ - public static final String NAME_DEFAULT = "默认"; - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 名称 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java deleted file mode 100644 index cefa2d958..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - - -/** - * 商品属性值 DO - * - * @author 芋道源码 - */ -@TableName("product_property_value") -@KeySequence("product_property_value_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyValueDO extends BaseDO { - - /** - * SPU 单规格时,默认属性值 id - */ - public static final Long ID_DEFAULT = 0L; - /** - * SPU 单规格时,默认属性值名字 - */ - public static final String NAME_DEFAULT = "默认"; - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 属性项的编号 - * - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 名称 - */ - private String name; - /** - * 备注 - * - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java deleted file mode 100755 index dacb02ec8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ /dev/null @@ -1,156 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.sku; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SKU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_sku", autoResultMap = true) -@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuDO extends BaseDO { - - /** - * 商品 SKU 编号,自增 - */ - @TableId - private Long id; - /** - * SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 属性数组,JSON 格式 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品价格,单位:分 - */ - private Integer price; - /** - * 市场价,单位:分 - */ - private Integer marketPrice; - /** - * 成本价,单位:分 - */ - private Integer costPrice; - /** - * 商品条码 - */ - private String barCode; - /** - * 图片地址 - */ - private String picUrl; - /** - * 库存 - */ - private Integer stock; - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 一级分销的佣金,单位:分 - */ - private Integer firstBrokeragePrice; - /** - * 二级分销的佣金,单位:分 - */ - private Integer secondBrokeragePrice; - - // ========== 营销相关字段 ========= - - // ========== 统计相关字段 ========= - /** - * 商品销量 - */ - private Integer salesCount; - - /** - * 商品属性 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - /** - * 属性编号 - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 属性名字 - * 冗余 {@link ProductPropertyDO#getName()} - * - * 注意:每次属性名字发生变化时,需要更新该冗余 - */ - private String propertyName; - - /** - * 属性值编号 - * 关联 {@link ProductPropertyValueDO#getId()} - */ - private Long valueId; - /** - * 属性值名字 - * 冗余 {@link ProductPropertyValueDO#getName()} - * - * 注意:每次属性值名字发生变化时,需要更新该冗余 - */ - private String valueName; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler { - - @Override - protected Object parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - - } - - // TODO 芋艿:integral from y - // TODO 芋艿:pinkPrice from y - // TODO 芋艿:seckillPrice from y - // TODO 芋艿:pinkStock from y - // TODO 芋艿:seckillStock from y - -} - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java deleted file mode 100755 index d2b519596..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.spu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SPU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_spu", autoResultMap = true) -@KeySequence("product_spu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSpuDO extends BaseDO { - - /** - * 商品 SPU 编号,自增 - */ - @TableId - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 关键字 - */ - private String keyword; - /** - * 商品简介 - */ - private String introduction; - /** - * 商品详情 - */ - private String description; - - /** - * 商品分类编号 - * - * 关联 {@link ProductCategoryDO#getId()} - */ - private Long categoryId; - /** - * 商品品牌编号 - * - * 关联 {@link ProductBrandDO#getId()} - */ - private Long brandId; - /** - * 商品封面图 - */ - private String picUrl; - /** - * 商品轮播图 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List sliderPicUrls; - - /** - * 排序字段 - */ - private Integer sort; - /** - * 商品状态 - * - * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * false - 单规格 - * true - 多规格 - */ - private Boolean specType; - /** - * 商品价格,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getPrice()} sku单价最低的商品的 - */ - private Integer price; - /** - * 市场价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getMarketPrice()} sku单价最低的商品的 - */ - private Integer marketPrice; - /** - * 成本价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getCostPrice()} sku单价最低的商品的 - */ - private Integer costPrice; - /** - * 库存 - * - * 基于其对应的 {@link ProductSkuDO#getStock()} 求和 - */ - private Integer stock; - - // ========== 物流相关字段 ========= - - /** - * 配送方式数组 - * - * 对应 DeliveryTypeEnum 枚举 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List deliveryTypes; - /** - * 物流配置模板编号 - * - * 对应 TradeDeliveryExpressTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - /** - * 赠送积分 - */ - private Integer giveIntegral; - - // TODO @puhui999:字段估计要改成 brokerageType - /** - * 分销类型 - * - * false - 默认 - * true - 自行设置 - */ - private Boolean subCommissionType; - - // ========== 统计相关字段 ========= - - /** - * 商品销量 - */ - private Integer salesCount; - /** - * 虚拟销量 - */ - private Integer virtualSalesCount; - /** - * 浏览量 - */ - private Integer browseCount; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java deleted file mode 100644 index b2c4bd5fb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ProductBrandMapper extends BaseMapperX { - - default PageResult selectPage(ProductBrandPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName()) - .eqIfPresent(ProductBrandDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ProductBrandDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductBrandDO::getId)); - } - - - default List selectList(ProductBrandListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName())); - } - - default ProductBrandDO selectByName(String name) { - return selectOne(ProductBrandDO::getName, name); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductBrandDO::getStatus, status); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java deleted file mode 100644 index 4c212de94..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.category; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 商品分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ProductCategoryMapper extends BaseMapperX { - - default List selectList(ProductCategoryListReqVO listReqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductCategoryDO::getName, listReqVO.getName()) - .eqIfPresent(ProductCategoryDO::getParentId, listReqVO.getParentId()) - .inIfPresent(ProductCategoryDO::getId, listReqVO.getParentIds()) - .eqIfPresent(ProductCategoryDO::getStatus, listReqVO.getStatus()) - .orderByDesc(ProductCategoryDO::getId)); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(ProductCategoryDO::getParentId, parentId); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductCategoryDO::getStatus, status); - } - - default List selectListByIdAndStatus(Collection ids, Integer status) { - return selectList(new LambdaQueryWrapperX() - .in(ProductCategoryDO::getId, ids) - .eq(ProductCategoryDO::getStatus, status)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java deleted file mode 100644 index 9191b9ec8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.comment; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductCommentMapper extends BaseMapperX { - - default PageResult selectPage(ProductCommentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductCommentDO::getUserNickname, reqVO.getUserNickname()) - .eqIfPresent(ProductCommentDO::getOrderId, reqVO.getOrderId()) - .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductCommentDO::getScores, reqVO.getScores()) - .eqIfPresent(ProductCommentDO::getReplyStatus, reqVO.getReplyStatus()) - .betweenIfPresent(ProductCommentDO::getCreateTime, reqVO.getCreateTime()) - .likeIfPresent(ProductCommentDO::getSpuName, reqVO.getSpuName()) - .orderByDesc(ProductCommentDO::getId)); - } - - static void appendTabQuery(LambdaQueryWrapperX queryWrapper, Integer type) { - // 构建好评查询语句:好评计算 总评 >= 4 - if (ObjectUtil.equal(type, AppCommentPageReqVO.GOOD_COMMENT)) { - queryWrapper.ge(ProductCommentDO::getScores, 4); - } - // 构建中评查询语句:中评计算 总评 >= 3 且 总评 < 4 - if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) { - queryWrapper.ge(ProductCommentDO::getScores, 3); - queryWrapper.lt(ProductCommentDO::getScores, 4); - } - // 构建差评查询语句:差评计算 总评 < 3 - if (ObjectUtil.equal(type, AppCommentPageReqVO.NEGATIVE_COMMENT)) { - queryWrapper.lt(ProductCommentDO::getScores, 3); - } - } - - default PageResult selectPage(AppCommentPageReqVO reqVO, Boolean visible) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductCommentDO::getVisible, visible); - // 构建评价查询语句 - appendTabQuery(queryWrapper, reqVO.getType()); - // 按评价时间排序最新的显示在前面 - queryWrapper.orderByDesc(ProductCommentDO::getCreateTime); - return selectPage(reqVO, queryWrapper); - } - - default ProductCommentDO selectByUserIdAndOrderItemId(Long userId, Long orderItemId) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductCommentDO::getUserId, userId) - .eq(ProductCommentDO::getOrderItemId, orderItemId)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java deleted file mode 100644 index a681d42a7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductFavoriteMapper extends BaseMapperX { - - default ProductFavoriteDO selectByUserIdAndSpuId(Long userId, Long spuId) { - return selectOne(ProductFavoriteDO::getUserId, userId, - ProductFavoriteDO::getSpuId, spuId); - } - - default PageResult selectPageByUserAndType(Long userId, AppFavoritePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapper() - .eq(ProductFavoriteDO::getUserId, userId) - .orderByDesc(ProductFavoriteDO::getId)); - } - - default PageResult selectPageByUserId(ProductFavoritePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductFavoriteDO::getUserId, reqVO.getUserId()) - .orderByDesc(ProductFavoriteDO::getId)); - } - - default Long selectCountByUserId(Long userId) { - return selectCount(ProductFavoriteDO::getUserId, userId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/history/ProductBrowseHistoryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/history/ProductBrowseHistoryMapper.java deleted file mode 100644 index 124357cac..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/history/ProductBrowseHistoryMapper.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.history; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; - -/** - * 商品浏览记录 Mapper - * - * @author owen - */ -@Mapper -public interface ProductBrowseHistoryMapper extends BaseMapperX { - - default ProductBrowseHistoryDO selectByUserIdAndSpuId(Long userId, Long spuId) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductBrowseHistoryDO::getUserId, userId) - .eq(ProductBrowseHistoryDO::getSpuId, spuId)); - } - - default PageResult selectPage(ProductBrowseHistoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductBrowseHistoryDO::getUserId, reqVO.getUserId()) - .eqIfPresent(ProductBrowseHistoryDO::getUserDeleted, reqVO.getUserDeleted()) - .eqIfPresent(ProductBrowseHistoryDO::getSpuId, reqVO.getSpuId()) - .betweenIfPresent(ProductBrowseHistoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductBrowseHistoryDO::getId)); - } - - default void updateUserDeletedByUserId(Long userId, Collection spuIds, Boolean userDeleted) { - update(new LambdaUpdateWrapper() - .eq(ProductBrowseHistoryDO::getUserId, userId) - .in(CollUtil.isNotEmpty(spuIds), ProductBrowseHistoryDO::getSpuId, spuIds) - .set(ProductBrowseHistoryDO::getUserDeleted, userDeleted)); - } - - default Page selectPageByUserIdOrderByCreateTimeAsc(Long userId, Integer pageNo, Integer pageSize) { - Page page = Page.of(pageNo, pageSize); - return selectPage(page, new LambdaQueryWrapperX() - .eqIfPresent(ProductBrowseHistoryDO::getUserId, userId) - .orderByAsc(ProductBrowseHistoryDO::getCreateTime)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java deleted file mode 100644 index 8a55eaf48..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductPropertyMapper extends BaseMapperX { - - default PageResult selectPage(ProductPropertyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) - .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductPropertyDO::getId)); - } - - default ProductPropertyDO selectByName(String name) { - return selectOne(ProductPropertyDO::getName, name); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java deleted file mode 100644 index 402df51e7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductPropertyValueMapper extends BaseMapperX { - - default List selectListByPropertyId(Collection propertyIds) { - return selectList(new LambdaQueryWrapperX() - .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds)); - } - - default ProductPropertyValueDO selectByName(Long propertyId, String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId) - .eq(ProductPropertyValueDO::getName, name)); - } - - default void deleteByPropertyId(Long propertyId) { - delete(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId)); - } - - default PageResult selectPage(ProductPropertyValuePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductPropertyValueDO::getPropertyId, reqVO.getPropertyId()) - .likeIfPresent(ProductPropertyValueDO::getName, reqVO.getName()) - .orderByDesc(ProductPropertyValueDO::getId)); - } - - default Integer selectCountByPropertyId(Long propertyId) { - return selectCount(ProductPropertyValueDO::getPropertyId, propertyId).intValue(); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java deleted file mode 100755 index 82bfc87fa..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.sku; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductSkuMapper extends BaseMapperX { - - default List selectListBySpuId(Long spuId) { - return selectList(ProductSkuDO::getSpuId, spuId); - } - - default List selectListBySpuId(Collection spuIds) { - return selectList(ProductSkuDO::getSpuId, spuIds); - } - - default void deleteBySpuId(Long spuId) { - delete(new LambdaQueryWrapperX().eq(ProductSkuDO::getSpuId, spuId)); - } - - /** - * 更新 SKU 库存(增加) - * - * @param id 编号 - * @param incrCount 增加库存(正数) - */ - default void updateStockIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) - .eq(ProductSkuDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新 SKU 库存(减少) - * - * @param id 编号 - * @param incrCount 减少库存(负数) - * @return 更新条数 - */ - default int updateStockDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) // 负数,所以使用 + 号 - .eq(ProductSkuDO::getId, id) - .ge(ProductSkuDO::getStock, -incrCount); // cas 逻辑 - return update(null, updateWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java deleted file mode 100755 index 68f2d210f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.spu; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.ProductConstants; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; -import java.util.Set; - -@Mapper -public interface ProductSpuMapper extends BaseMapperX { - - /** - * 获取商品 SPU 分页列表数据 - * - * @param reqVO 分页请求参数 - * @return 商品 SPU 分页列表数据 - */ - default PageResult selectPage(ProductSpuPageReqVO reqVO) { - Integer tabType = reqVO.getTabType(); - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) - .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) - .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductSpuDO::getSort); - appendTabQuery(tabType, queryWrapper); - return selectPage(reqVO, queryWrapper); - } - - /** - * 查询触发警戒库存的 SPU 数量 - * - * @return 触发警戒库存的 SPU 数量 - */ - default Long selectCount() { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); - // 库存小于等于警戒库存 - queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数 - .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - return selectCount(queryWrapper); - } - - /** - * 获得商品 SPU 分页,提供给用户 App 使用 - */ - default PageResult selectPage(AppProductSpuPageReqVO pageReqVO, Set categoryIds) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - // 关键字匹配,目前只匹配商品名 - .likeIfPresent(ProductSpuDO::getName, pageReqVO.getKeyword()) - // 分类 - .inIfPresent(ProductSpuDO::getCategoryId, categoryIds); - // 上架状态 且有库存 - query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - - // 排序逻辑 - if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { - query.last(String.format(" ORDER BY (sales_count + virtual_sales_count) %s, sort DESC, id DESC", - pageReqVO.getSortAsc() ? "ASC" : "DESC")); - } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getPrice) - .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_CREATE_TIME)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getCreateTime) - .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } else { - query.orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } - return selectPage(pageReqVO, query); - } - - /** - * 更新商品 SPU 库存 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的库存数量 - */ - default void updateStock(Long id, Integer incrCount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - // 负数,所以使用 + 号 - .setSql(" stock = stock +" + incrCount) - .eq(ProductSpuDO::getId, id); - update(null, updateWrapper); - } - - /** - * 添加后台 Tab 选项的查询条件 - * - * @param tabType 标签类型 - * @param query 查询条件 - */ - static void appendTabQuery(Integer tabType, LambdaQueryWrapperX query) { - // 出售中商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.FOR_SALE, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - } - // 仓储中商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.IN_WAREHOUSE, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()); - } - // 已售空商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.SOLD_OUT, tabType)) { - query.eqIfPresent(ProductSpuDO::getStock, 0); - } - // 警戒库存 - if (ObjectUtil.equals(ProductSpuPageReqVO.ALERT_STOCK, tabType)) { - query.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // 如果库存触发警戒库存且状态为回收站的话则不在警戒库存列表展示 - .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - } - // 回收站 - if (ObjectUtil.equals(ProductSpuPageReqVO.RECYCLE_BIN, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - } - } - - /** - * 更新商品 SPU 浏览量 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的数量 - */ - default void updateBrowseCount(Long id, int incrCount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" browse_count = browse_count +" + incrCount) - .eq(ProductSpuDO::getId, id); - update(null, updateWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java deleted file mode 100644 index d2e1c934a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 product 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.product.framework; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index a5f8aff4b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.product.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {MemberUserApi.class, MemberLevelApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/package-info.java deleted file mode 100644 index c15de0c2a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.framework.rpc; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index dbfb9f445..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Member 模块的 Security 配置 - */ -@Configuration("productSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("productAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/core/package-info.java deleted file mode 100644 index 8eb5274b2..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.framework.security.core; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java deleted file mode 100644 index e32942933..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * product 模块,主要实现交易相关功能 - * 例如:订单、退款、购物车等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.product; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java deleted file mode 100644 index 70ee4a3d0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品品牌 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductBrandService { - - /** - * 创建品牌 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBrand(@Valid ProductBrandCreateReqVO createReqVO); - - /** - * 更新品牌 - * - * @param updateReqVO 更新信息 - */ - void updateBrand(@Valid ProductBrandUpdateReqVO updateReqVO); - - /** - * 删除品牌 - * - * @param id 编号 - */ - void deleteBrand(Long id); - - /** - * 获得品牌 - * - * @param id 编号 - * @return 品牌 - */ - ProductBrandDO getBrand(Long id); - - /** - * 获得品牌列表 - * - * @param ids 编号 - * @return 品牌列表 - */ - List getBrandList(Collection ids); - - /** - * 获得品牌列表 - * - * @param listReqVO 请求参数 - * @return 品牌列表 - */ - List getBrandList(ProductBrandListReqVO listReqVO); - - /** - * 验证选择的商品分类是否合法 - * - * @param id 分类编号 - */ - void validateProductBrand(Long id); - - /** - * 获得品牌分页 - * - * @param pageReqVO 分页查询 - * @return 品牌分页 - */ - PageResult getBrandPage(ProductBrandPageReqVO pageReqVO); - - /** - * 获取指定状态的品牌列表 - * - * @param status 状态 - * @return 返回品牌列表 - */ - List getBrandListByStatus(Integer status); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java deleted file mode 100644 index b97123f6a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.mysql.brand.ProductBrandMapper; -import com.google.common.annotations.VisibleForTesting; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 品牌 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductBrandServiceImpl implements ProductBrandService { - - @Resource - private ProductBrandMapper brandMapper; - - @Override - public Long createBrand(ProductBrandCreateReqVO createReqVO) { - // 校验 - validateBrandNameUnique(null, createReqVO.getName()); - - // 插入 - ProductBrandDO brand = ProductBrandConvert.INSTANCE.convert(createReqVO); - brandMapper.insert(brand); - // 返回 - return brand.getId(); - } - - @Override - public void updateBrand(ProductBrandUpdateReqVO updateReqVO) { - // 校验存在 - validateBrandExists(updateReqVO.getId()); - validateBrandNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - ProductBrandDO updateObj = ProductBrandConvert.INSTANCE.convert(updateReqVO); - brandMapper.updateById(updateObj); - } - - @Override - public void deleteBrand(Long id) { - // 校验存在 - validateBrandExists(id); - // 删除 - brandMapper.deleteById(id); - } - - private void validateBrandExists(Long id) { - if (brandMapper.selectById(id) == null) { - throw exception(BRAND_NOT_EXISTS); - } - } - - @VisibleForTesting - public void validateBrandNameUnique(Long id, String name) { - ProductBrandDO brand = brandMapper.selectByName(name); - if (brand == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 - if (id == null) { - throw exception(BRAND_NAME_EXISTS); - } - if (!brand.getId().equals(id)) { - throw exception(BRAND_NAME_EXISTS); - } - } - - @Override - public ProductBrandDO getBrand(Long id) { - return brandMapper.selectById(id); - } - - @Override - public List getBrandList(Collection ids) { - return brandMapper.selectBatchIds(ids); - } - - @Override - public List getBrandList(ProductBrandListReqVO listReqVO) { - return brandMapper.selectList(listReqVO); - } - - @Override - public void validateProductBrand(Long id) { - ProductBrandDO brand = brandMapper.selectById(id); - if (brand == null) { - throw exception(BRAND_NOT_EXISTS); - } - if (brand.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BRAND_DISABLED); - } - } - - @Override - public PageResult getBrandPage(ProductBrandPageReqVO pageReqVO) { - return brandMapper.selectPage(pageReqVO); - } - - @Override - public List getBrandListByStatus(Integer status) { - return brandMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java deleted file mode 100644 index 52959a800..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品分类 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductCategoryService { - - /** - * 创建商品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid ProductCategorySaveReqVO createReqVO); - - /** - * 更新商品分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid ProductCategorySaveReqVO updateReqVO); - - /** - * 删除商品分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得商品分类 - * - * @param id 编号 - * @return 商品分类 - */ - ProductCategoryDO getCategory(Long id); - - /** - * 校验商品分类 - * - * @param id 分类编号 - */ - void validateCategory(Long id); - - /** - * 获得商品分类的层级 - * - * @param id 编号 - * @return 商品分类的层级 - */ - Integer getCategoryLevel(Long id); - - /** - * 获得商品分类列表 - * - * @param listReqVO 查询条件 - * @return 商品分类列表 - */ - List getCategoryList(ProductCategoryListReqVO listReqVO); - - /** - * 获得开启状态的商品分类列表 - * - * @return 商品分类列表 - */ - List getEnableCategoryList(); - - /** - * 获得开启状态的商品分类列表,指定编号 - * - * @param ids 商品分类编号数组 - * @return 商品分类列表 - */ - List getEnableCategoryList(List ids); - - /** - * 校验商品分类是否有效。如下情况,视为无效: - * 1. 商品分类编号不存在 - * 2. 商品分类被禁用 - * - * @param ids 商品分类编号数组 - */ - void validateCategoryList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java deleted file mode 100644 index 1dbf62fb9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductCategoryServiceImpl implements ProductCategoryService { - - @Resource - private ProductCategoryMapper productCategoryMapper; - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - - @Override - public Long createCategory(ProductCategorySaveReqVO createReqVO) { - // 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - - // 插入 - ProductCategoryDO category = BeanUtils.toBean(createReqVO, ProductCategoryDO.class); - productCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(ProductCategorySaveReqVO updateReqVO) { - // 校验分类是否存在 - validateProductCategoryExists(updateReqVO.getId()); - // 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - - // 更新 - ProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, ProductCategoryDO.class); - productCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验分类是否存在 - validateProductCategoryExists(id); - // 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXISTS_CHILDREN); - } - // 校验分类是否绑定了 SPU - Long spuCount = productSpuService.getSpuCountByCategoryId(id); - if (spuCount > 0) { - throw exception(CATEGORY_HAVE_BIND_SPU); - } - // 删除 - productCategoryMapper.deleteById(id); - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (!Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - throw exception(CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductCategoryExists(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - @Override - public void validateCategoryList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得商品分类信息 - List list = productCategoryMapper.selectBatchIds(ids); - Map categoryMap = CollectionUtils.convertMap(list, ProductCategoryDO::getId); - // 校验 - ids.forEach(id -> { - ProductCategoryDO category = categoryMap.get(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(category.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - }); - } - - @Override - public ProductCategoryDO getCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public void validateCategory(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (Objects.equals(category.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - } - - @Override - public Integer getCategoryLevel(Long id) { - if (Objects.equals(id, PARENT_ID_NULL)) { - return 0; - } - int level = 1; - // for 的原因,是因为避免脏数据,导致可能的死循环。一般不会超过 100 层哈 - for (int i = 0; i < Byte.MAX_VALUE; i++) { - // 如果没有父节点,break 结束 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null - || Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - break; - } - // 继续递归父节点 - level++; - id = category.getParentId(); - } - return level; - } - - @Override - public List getCategoryList(ProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getEnableCategoryList() { - return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public List getEnableCategoryList(List ids) { - return productCategoryMapper.selectListByIdAndStatus(ids, CommonStatusEnum.ENABLE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java deleted file mode 100644 index b54e21918..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -/** - * 商品评论 Service 接口 - * - * @author wangzhs - */ -@Service -@Validated -public interface ProductCommentService { - - /** - * 创建商品评论 - * 后台管理员创建评论使用 - * - * @param createReqVO 商品评价创建 Request VO 对象 - */ - void createComment(ProductCommentCreateReqVO createReqVO); - - /** - * 创建评论 - * 创建商品评论 APP 端创建商品评论使用 - * - * @param createReqDTO 创建请求 dto - * @return 返回评论 id - */ - Long createComment(ProductCommentCreateReqDTO createReqDTO); - - /** - * 修改评论是否可见 - * - * @param updateReqVO 修改评论可见 - */ - void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO); - - /** - * 商家回复 - * - * @param replyVO 商家回复 - * @param userId 管理后台商家登陆人 ID - */ - void replyComment(ProductCommentReplyReqVO replyVO, Long userId); - - /** - * 【管理员】获得商品评价分页 - * - * @param pageReqVO 分页查询 - * @return 商品评价分页 - */ - PageResult getCommentPage(ProductCommentPageReqVO pageReqVO); - - /** - * 【会员】获得商品评价分页 - * - * @param pageVO 分页查询 - * @param visible 是否可见 - * @return 商品评价分页 - */ - PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java deleted file mode 100644 index 6ce9bfc59..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品评论 Service 实现类 - * - * @author wangzhs - */ -@Service -@Validated -public class ProductCommentServiceImpl implements ProductCommentService { - - @Resource - private ProductCommentMapper productCommentMapper; - - @Resource - private ProductSpuService productSpuService; - - @Resource - @Lazy - private ProductSkuService productSkuService; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public void createComment(ProductCommentCreateReqVO createReqVO) { - // 校验 SKU - ProductSkuDO sku = validateSku(createReqVO.getSkuId()); - // 校验 SPU - ProductSpuDO spu = validateSpu(sku.getSpuId()); - - // 创建评论 - ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqVO, spu, sku); - productCommentMapper.insert(comment); - } - - @Override - public Long createComment(ProductCommentCreateReqDTO createReqDTO) { - // 校验 SKU - ProductSkuDO sku = validateSku(createReqDTO.getSkuId()); - // 校验 SPU - ProductSpuDO spu = validateSpu(sku.getSpuId()); - // 校验评论 - validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderId()); - // 获取用户详细信息 - MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId()).getCheckedData(); - - // 创建评论 - ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqDTO, spu, sku, user); - productCommentMapper.insert(comment); - return comment.getId(); - } - - /** - * 判断当前订单的当前商品用户是否评价过 - * - * @param userId 用户编号 - * @param orderItemId 订单项编号 - */ - private void validateCommentExists(Long userId, Long orderItemId) { - ProductCommentDO exist = productCommentMapper.selectByUserIdAndOrderItemId(userId, orderItemId); - if (exist != null) { - throw exception(COMMENT_ORDER_EXISTS); - } - } - - private ProductSkuDO validateSku(Long skuId) { - ProductSkuDO sku = productSkuService.getSku(skuId); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - return sku; - } - - private ProductSpuDO validateSpu(Long spuId) { - ProductSpuDO spu = productSpuService.getSpu(spuId); - if (null == spu) { - throw exception(SPU_NOT_EXISTS); - } - return spu; - } - - @Override - public void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO) { - // 校验评论是否存在 - validateCommentExists(updateReqVO.getId()); - - // 更新可见状态 - productCommentMapper.updateById(new ProductCommentDO().setId(updateReqVO.getId()) - .setVisible(updateReqVO.getVisible())); - } - - @Override - public void replyComment(ProductCommentReplyReqVO replyVO, Long userId) { - // 校验评论是否存在 - validateCommentExists(replyVO.getId()); - // 回复评论 - productCommentMapper.updateById(new ProductCommentDO().setId(replyVO.getId()) - .setReplyTime(LocalDateTime.now()).setReplyUserId(userId) - .setReplyStatus(Boolean.TRUE).setReplyContent(replyVO.getReplyContent())); - } - - private ProductCommentDO validateCommentExists(Long id) { - ProductCommentDO productComment = productCommentMapper.selectById(id); - if (productComment == null) { - throw exception(COMMENT_NOT_EXISTS); - } - return productComment; - } - - @Override - public PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) { - return productCommentMapper.selectPage(pageVO, visible); - } - - @Override - public PageResult getCommentPage(ProductCommentPageReqVO pageReqVO) { - return productCommentMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java deleted file mode 100644 index 3dd3bd59e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.product.service.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; - -import javax.validation.Valid; - -/** - * 商品收藏 Service 接口 - * - * @author jason - */ -public interface ProductFavoriteService { - - /** - * 创建商品收藏 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - Long createFavorite(Long userId, Long spuId); - - /** - * 取消商品收藏 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - void deleteFavorite(Long userId, Long spuId); - - /** - * 分页查询用户收藏列表 - * - * @param userId 用户编号 - * @param reqVO 请求 vo - */ - PageResult getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO); - - /** - * 分页查询用户收藏列表 - * - * @param reqVO 请求 vo - */ - PageResult getFavoritePage(@Valid ProductFavoritePageReqVO reqVO); - - /** - * 获取收藏过商品 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - ProductFavoriteDO getFavorite(Long userId, Long spuId); - - /** - * 获取用户收藏数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getFavoriteCount(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java deleted file mode 100644 index 927d030d5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.service.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.mysql.favorite.ProductFavoriteMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_NOT_EXISTS; - -/** - * 商品收藏 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class ProductFavoriteServiceImpl implements ProductFavoriteService { - - @Resource - private ProductFavoriteMapper productFavoriteMapper; - - @Override - public Long createFavorite(Long userId, Long spuId) { - ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - if (favorite != null) { - throw exception(FAVORITE_EXISTS); - } - - ProductFavoriteDO entity = ProductFavoriteConvert.INSTANCE.convert(userId, spuId); - productFavoriteMapper.insert(entity); - return entity.getId(); - } - - @Override - public void deleteFavorite(Long userId, Long spuId) { - ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - if (favorite == null) { - throw exception(FAVORITE_NOT_EXISTS); - } - - productFavoriteMapper.deleteById(favorite.getId()); - } - - @Override - public PageResult getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO) { - return productFavoriteMapper.selectPageByUserAndType(userId, reqVO); - } - - @Override - public PageResult getFavoritePage(@Valid ProductFavoritePageReqVO reqVO) { - return productFavoriteMapper.selectPageByUserId(reqVO); - } - - @Override - public ProductFavoriteDO getFavorite(Long userId, Long spuId) { - return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - } - - @Override - public Long getFavoriteCount(Long userId) { - return productFavoriteMapper.selectCountByUserId(userId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java deleted file mode 100644 index 10f3a71d5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.product.service.history; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import org.springframework.scheduling.annotation.Async; - -import java.util.Collection; - -/** - * 商品浏览记录 Service 接口 - * - * @author owen - */ -public interface ProductBrowseHistoryService { - - /** - * 创建商品浏览记录 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - @Async - void createBrowseHistory(Long userId, Long spuId); - - /** - * 隐藏用户商品浏览记录 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - void hideUserBrowseHistory(Long userId, Collection spuId); - - /** - * 获得商品浏览记录分页 - * - * @param pageReqVO 分页查询 - * @return 商品浏览记录分页 - */ - PageResult getBrowseHistoryPage(ProductBrowseHistoryPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java deleted file mode 100644 index 8645be72c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.product.service.history; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.history.ProductBrowseHistoryMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; - -/** - * 商品浏览记录 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryService { - - private static final int USER_STORE_MAXIMUM = 100; - - @Resource - private ProductBrowseHistoryMapper browseHistoryMapper; - - @Override - public void createBrowseHistory(Long userId, Long spuId) { - // 用户未登录时不记录 - if (userId == null) { - return; - } - - // 情况一:同一个商品,只保留最新的一条记录 - ProductBrowseHistoryDO history = browseHistoryMapper.selectByUserIdAndSpuId(userId, spuId); - if (history != null) { - browseHistoryMapper.deleteById(history); - } else { - // 情况二:限制每个用户的浏览记录的条数(只查一条最早地记录、记录总数) - // TODO @疯狂:这里最好先查询一次数量。如果发现超过了,再删除;主要考虑,可能有部分不超过,提前就多了一次 sql 查询了 - Page pageResult = browseHistoryMapper.selectPageByUserIdOrderByCreateTimeAsc(userId, 1, 1); - if (pageResult.getTotal() >= USER_STORE_MAXIMUM) { - browseHistoryMapper.deleteById(CollUtil.getFirst(pageResult.getRecords())); - } - } - - // 插入 - ProductBrowseHistoryDO browseHistory = new ProductBrowseHistoryDO() - .setUserId(userId) - .setSpuId(spuId); - browseHistoryMapper.insert(browseHistory); - } - - @Override - public void hideUserBrowseHistory(Long userId, Collection spuIds) { - browseHistoryMapper.updateUserDeletedByUserId(userId, spuIds, true); - } - - @Override - public PageResult getBrowseHistoryPage(ProductBrowseHistoryPageReqVO pageReqVO) { - return browseHistoryMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java deleted file mode 100644 index c65d150d9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品属性项 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductPropertyService { - - /** - * 创建属性项 - * 注意,如果已经存在该属性项,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProperty(@Valid ProductPropertySaveReqVO createReqVO); - - /** - * 更新属性项 - * - * @param updateReqVO 更新信息 - */ - void updateProperty(@Valid ProductPropertySaveReqVO updateReqVO); - - /** - * 删除属性项 - * - * @param id 编号 - */ - void deleteProperty(Long id); - - /** - * 获取属性名称分页 - * - * @param pageReqVO 分页条件 - * @return 属性项分页 - */ - PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); - - /** - * 获得指定编号的属性项 - * - * @param id 编号 - * @return 属性项 - */ - ProductPropertyDO getProperty(Long id); - - /** - * 根据属性项的编号的集合,获得对应的属性项数组 - * - * @param ids 属性项的编号的集合 - * @return 属性项数组 - */ - List getPropertyList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java deleted file mode 100644 index 8843640fa..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品属性项 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductPropertyServiceImpl implements ProductPropertyService { - - @Resource - private ProductPropertyMapper productPropertyMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ProductPropertyValueService productPropertyValueService; - - @Resource - private ProductSkuService productSkuService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createProperty(ProductPropertySaveReqVO createReqVO) { - // 如果已经添加过该属性项,直接返回 - ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName()); - if (dbProperty != null) { - return dbProperty.getId(); - } - - // 插入 - ProductPropertyDO property = BeanUtils.toBean(createReqVO, ProductPropertyDO.class); - productPropertyMapper.insert(property); - // 返回 - return property.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateProperty(ProductPropertySaveReqVO updateReqVO) { - validatePropertyExists(updateReqVO.getId()); - // 校验名字重复 - ProductPropertyDO property = productPropertyMapper.selectByName(updateReqVO.getName()); - if (property != null && - ObjUtil.notEqual(property.getId(), updateReqVO.getId())) { - throw exception(PROPERTY_EXISTS); - } - - // 更新 - ProductPropertyDO updateObj = BeanUtils.toBean(updateReqVO, ProductPropertyDO.class); - productPropertyMapper.updateById(updateObj); - // 更新 sku 相关属性 - productSkuService.updateSkuProperty(updateObj.getId(), updateObj.getName()); - } - - @Override - public void deleteProperty(Long id) { - // 校验存在 - validatePropertyExists(id); - // 校验其下是否有规格值 - if (productPropertyValueService.getPropertyValueCountByPropertyId(id) > 0) { - throw exception(PROPERTY_DELETE_FAIL_VALUE_EXISTS); - } - - // 删除 - productPropertyMapper.deleteById(id); - // 同步删除属性值 - productPropertyValueService.deletePropertyValueByPropertyId(id); - } - - private void validatePropertyExists(Long id) { - if (productPropertyMapper.selectById(id) == null) { - throw exception(PROPERTY_NOT_EXISTS); - } - } - - @Override - public PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO) { - return productPropertyMapper.selectPage(pageReqVO); - } - - @Override - public ProductPropertyDO getProperty(Long id) { - return productPropertyMapper.selectById(id); - } - - @Override - public List getPropertyList(Collection ids) { - return productPropertyMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java deleted file mode 100644 index aaa7ff12a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品属性值 Service 接口 - * - * @author LuoWenFeng - */ -public interface ProductPropertyValueService { - - /** - * 创建属性值 - * 注意,如果已经存在该属性值,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO); - - /** - * 更新属性值 - * - * @param updateReqVO 更新信息 - */ - void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO); - - /** - * 删除属性值 - * - * @param id 编号 - */ - void deletePropertyValue(Long id); - - /** - * 获得属性值 - * - * @param id 编号 - * @return 属性值 - */ - ProductPropertyValueDO getPropertyValue(Long id); - - /** - * 根据属性项编号数组,获得属性值列表 - * - * @param propertyIds 属性项目编号数组 - * @return 属性值列表 - */ - List getPropertyValueListByPropertyId(Collection propertyIds); - - /** - * 根据属性项编号,活的属性值数量 - * - * @param propertyId 属性项编号数 - * @return 属性值数量 - */ - Integer getPropertyValueCountByPropertyId(Long propertyId); - - /** - * 获取属性值的分页 - * - * @param pageReqVO 查询条件 - * @return 属性值的分页 - */ - PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO); - - /** - * 删除指定属性项编号下的属性值们 - * - * @param propertyId 属性项的编号 - */ - void deletePropertyValueByPropertyId(Long propertyId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java deleted file mode 100644 index 6ef001181..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; - -/** - * 商品属性值 Service 实现类 - * - * @author LuoWenFeng - */ -@Service -@Validated -public class ProductPropertyValueServiceImpl implements ProductPropertyValueService { - - @Resource - private ProductPropertyValueMapper productPropertyValueMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ProductSkuService productSkuService; - - @Override - public Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO) { - // 如果已经添加过该属性值,直接返回 - ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName( - createReqVO.getPropertyId(), createReqVO.getName()); - if (dbValue != null) { - return dbValue.getId(); - } - - // 新增 - ProductPropertyValueDO value = BeanUtils.toBean(createReqVO, ProductPropertyValueDO.class); - productPropertyValueMapper.insert(value); - return value.getId(); - } - - @Override - public void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO) { - validatePropertyValueExists(updateReqVO.getId()); - // 校验名字唯一 - ProductPropertyValueDO value = productPropertyValueMapper.selectByName - (updateReqVO.getPropertyId(), updateReqVO.getName()); - if (value != null && !value.getId().equals(updateReqVO.getId())) { - throw exception(PROPERTY_VALUE_EXISTS); - } - - // 更新 - ProductPropertyValueDO updateObj = BeanUtils.toBean(updateReqVO, ProductPropertyValueDO.class); - productPropertyValueMapper.updateById(updateObj); - // 更新 sku 相关属性 - productSkuService.updateSkuPropertyValue(updateObj.getId(), updateObj.getName()); - } - - @Override - public void deletePropertyValue(Long id) { - validatePropertyValueExists(id); - productPropertyValueMapper.deleteById(id); - } - - private void validatePropertyValueExists(Long id) { - if (productPropertyValueMapper.selectById(id) == null) { - throw exception(PROPERTY_VALUE_NOT_EXISTS); - } - } - - @Override - public ProductPropertyValueDO getPropertyValue(Long id) { - return productPropertyValueMapper.selectById(id); - } - - @Override - public List getPropertyValueListByPropertyId(Collection propertyIds) { - return productPropertyValueMapper.selectListByPropertyId(propertyIds); - } - - @Override - public Integer getPropertyValueCountByPropertyId(Long propertyId) { - return productPropertyValueMapper.selectCountByPropertyId(propertyId); - } - - @Override - public PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO) { - return productPropertyValueMapper.selectPage(pageReqVO); - } - - @Override - public void deletePropertyValueByPropertyId(Long propertyId) { - productPropertyValueMapper.deleteByPropertyId(propertyId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java deleted file mode 100755 index a6d3f02b5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSkuService { - - /** - * 删除商品 SKU - * - * @param id 编号 - */ - void deleteSku(Long id); - - /** - * 获得商品 SKU 信息 - * - * @param id 编号 - * @return 商品 SKU 信息 - */ - ProductSkuDO getSku(Long id); - - /** - * 获得商品 SKU 列表 - * - * @param ids 编号 - * @return 商品sku列表 - */ - List getSkuList(Collection ids); - - /** - * 对 sku 的组合的属性等进行合法性校验 - * - * @param list sku组合的集合 - */ - void validateSkuList(List list, Boolean specType); - - /** - * 批量创建 SKU - * - * @param spuId 商品 SPU 编号 - * @param list SKU 对象集合 - */ - void createSkuList(Long spuId, List list); - - /** - * 根据 SPU 编号,批量更新它的 SKU 信息 - * - * @param spuId SPU 编码 - * @param skus SKU 的集合 - */ - void updateSkuList(Long spuId, List skus); - - /** - * 更新 SKU 库存(增量) - *

- * 如果更新的库存不足,会抛出异常 - * - * @param updateStockReqDTO 更行请求 - */ - void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); - - /** - * 获得商品 SKU 集合 - * - * @param spuId spu 编号 - * @return 商品sku 集合 - */ - List getSkuListBySpuId(Long spuId); - - /** - * 获得 spu 对应的 SKU 集合 - * - * @param spuIds spu 编码集合 - * @return 商品 sku 集合 - */ - List getSkuListBySpuId(Collection spuIds); - - /** - * 通过 spuId 删除 sku 信息 - * - * @param spuId spu 编码 - */ - void deleteSkuBySpuId(Long spuId); - - /** - * 更新 sku 属性 - * - * @param propertyId 属性 id - * @param propertyName 属性名 - * @return int 影响的行数 - */ - int updateSkuProperty(Long propertyId, String propertyName); - - /** - * 更新 sku 属性值 - * - * @param propertyValueId 属性值 id - * @param propertyValueName 属性值名字 - * @return int 影响的行数 - */ - int updateSkuPropertyValue(Long propertyValueId, String propertyValueName); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java deleted file mode 100755 index 4d07f7ec1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ /dev/null @@ -1,270 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SKU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSkuServiceImpl implements ProductSkuService { - - @Resource - private ProductSkuMapper productSkuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - @Resource - @Lazy // 循环依赖,避免报错 - private ProductPropertyService productPropertyService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @Override - public void deleteSku(Long id) { - // 校验存在 - validateSkuExists(id); - // 删除 - productSkuMapper.deleteById(id); - } - - private void validateSkuExists(Long id) { - if (productSkuMapper.selectById(id) == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - public ProductSkuDO getSku(Long id) { - return productSkuMapper.selectById(id); - } - - @Override - public List getSkuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return productSkuMapper.selectBatchIds(ids); - } - - @Override - public void validateSkuList(List skus, Boolean specType) { - // 0、校验skus是否为空 - if (CollUtil.isEmpty(skus)) { - throw exception(SKU_NOT_EXISTS); - } - // 单规格,赋予单规格默认属性 - if (ObjectUtil.equal(specType, false)) { - ProductSkuSaveReqVO skuVO = skus.get(0); - List properties = new ArrayList<>(); - ProductSkuSaveReqVO.Property property = new ProductSkuSaveReqVO.Property() - .setPropertyId(ProductPropertyDO.ID_DEFAULT).setPropertyName(ProductPropertyDO.NAME_DEFAULT) - .setValueId(ProductPropertyValueDO.ID_DEFAULT).setValueName(ProductPropertyValueDO.NAME_DEFAULT); - properties.add(property); - skuVO.setProperties(properties); - return; // 单规格不需要后续的校验 - } - - // 1、校验属性项存在 - Set propertyIds = skus.stream().filter(p -> p.getProperties() != null) - // 遍历多个 Property 属性 - .flatMap(p -> p.getProperties().stream()) - // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .map(ProductSkuSaveReqVO.Property::getPropertyId) - .collect(Collectors.toSet()); - List propertyList = productPropertyService.getPropertyList(propertyIds); - if (propertyList.size() != propertyIds.size()) { - throw exception(PROPERTY_NOT_EXISTS); - } - - // 2. 校验,一个 SKU 下,没有重复的属性。校验方式是,遍历每个 SKU ,看看是否有重复的属性 propertyId - Map propertyValueMap = convertMap(productPropertyValueService.getPropertyValueListByPropertyId(propertyIds), ProductPropertyValueDO::getId); - skus.forEach(sku -> { - Set skuPropertyIds = convertSet(sku.getProperties(), propertyItem -> propertyValueMap.get(propertyItem.getValueId()).getPropertyId()); - if (skuPropertyIds.size() != sku.getProperties().size()) { - throw exception(SKU_PROPERTIES_DUPLICATED); - } - }); - - // 3. 再校验,每个 Sku 的属性值的数量,是一致的。 - int attrValueIdsSize = skus.get(0).getProperties().size(); - for (int i = 1; i < skus.size(); i++) { - if (attrValueIdsSize != skus.get(i).getProperties().size()) { - throw exception(SPU_ATTR_NUMBERS_MUST_BE_EQUALS); - } - } - - // 4. 最后校验,每个 Sku 之间不是重复的 - // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的. - Set> skuAttrValues = new HashSet<>(); - for (ProductSkuSaveReqVO sku : skus) { - // 添加失败,说明重复 - if (!skuAttrValues.add(convertSet(sku.getProperties(), ProductSkuSaveReqVO.Property::getValueId))) { - throw exception(SPU_SKU_NOT_DUPLICATE); - } - } - } - - @Override - public void createSkuList(Long spuId, List skuCreateReqList) { - List skus = BeanUtils.toBean(skuCreateReqList, ProductSkuDO.class, sku -> sku.setSpuId(spuId)); - productSkuMapper.insertBatch(skus); - } - - @Override - public List getSkuListBySpuId(Long spuId) { - return productSkuMapper.selectListBySpuId(spuId); - } - - @Override - public List getSkuListBySpuId(Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return Collections.emptyList(); - } - return productSkuMapper.selectListBySpuId(spuIds); - } - - @Override - public void deleteSkuBySpuId(Long spuId) { - productSkuMapper.deleteBySpuId(spuId); - } - - @Override - public int updateSkuProperty(Long propertyId, String propertyName) { - // 获取所有的 sku - List skuDOList = productSkuMapper.selectList(); - // 处理后需要更新的 sku - List updateSkus = new ArrayList<>(); - if (CollUtil.isEmpty(skuDOList)) { - return 0; - } - skuDOList.stream().filter(sku -> sku.getProperties() != null) - .forEach(sku -> sku.getProperties().forEach(property -> { - if (property.getPropertyId().equals(propertyId)) { - property.setPropertyName(propertyName); - updateSkus.add(sku); - } - })); - if (CollUtil.isEmpty(updateSkus)) { - return 0; - } - - productSkuMapper.updateBatch(updateSkus); - return updateSkus.size(); - } - - @Override - public int updateSkuPropertyValue(Long propertyValueId, String propertyValueName) { - // 获取所有的 sku - List skuDOList = productSkuMapper.selectList(); - // 处理后需要更新的 sku - List updateSkus = new ArrayList<>(); - if (CollUtil.isEmpty(skuDOList)) { - return 0; - } - skuDOList.stream() - .filter(sku -> sku.getProperties() != null) - .forEach(sku -> sku.getProperties().forEach(property -> { - if (property.getValueId().equals(propertyValueId)) { - property.setValueName(propertyValueName); - updateSkus.add(sku); - } - })); - if (CollUtil.isEmpty(updateSkus)) { - return 0; - } - - productSkuMapper.updateBatch(updateSkus); - return updateSkus.size(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuList(Long spuId, List skus) { - // 构建属性与 SKU 的映射关系; - Map existsSkuMap = convertMap(productSkuMapper.selectListBySpuId(spuId), - ProductSkuConvert.INSTANCE::buildPropertyKey, ProductSkuDO::getId); - - // 拆分三个集合,新插入的、需要更新的、需要删除的 - List insertSkus = new ArrayList<>(); - List updateSkus = new ArrayList<>(); - List allUpdateSkus = BeanUtils.toBean(skus, ProductSkuDO.class, sku -> sku.setSpuId(spuId)); - allUpdateSkus.forEach(sku -> { - String propertiesKey = ProductSkuConvert.INSTANCE.buildPropertyKey(sku); - // 1、找得到的,进行更新 - Long existsSkuId = existsSkuMap.remove(propertiesKey); - if (existsSkuId != null) { - sku.setId(existsSkuId); - updateSkus.add(sku); - return; - } - // 2、找不到,进行插入 - sku.setSpuId(spuId); - insertSkus.add(sku); - }); - - // 执行最终的批量操作 - if (CollUtil.isNotEmpty(insertSkus)) { - productSkuMapper.insertBatch(insertSkus); - } - if (CollUtil.isNotEmpty(updateSkus)) { - updateSkus.forEach(sku -> productSkuMapper.updateById(sku)); - } - if (CollUtil.isNotEmpty(existsSkuMap)) { - productSkuMapper.deleteBatchIds(existsSkuMap.values()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - // 更新 SKU 库存 - updateStockReqDTO.getItems().forEach(item -> { - if (item.getIncrCount() > 0) { - productSkuMapper.updateStockIncr(item.getId(), item.getIncrCount()); - } else if (item.getIncrCount() < 0) { - int updateStockIncr = productSkuMapper.updateStockDecr(item.getId(), item.getIncrCount()); - if (updateStockIncr == 0) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - } - }); - - // 更新 SPU 库存 - List skus = productSkuMapper.selectBatchIds( - convertSet(updateStockReqDTO.getItems(), ProductSkuUpdateStockReqDTO.Item::getId)); - Map spuStockIncrCounts = ProductSkuConvert.INSTANCE.convertSpuStockMap( - updateStockReqDTO.getItems(), skus); - productSpuService.updateSpuStock(spuStockIncrCounts); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java deleted file mode 100755 index 63b5dd6ba..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ /dev/null @@ -1,134 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.springframework.scheduling.annotation.Async; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 商品 SPU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSpuService { - - /** - * 创建商品 SPU - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSpu(@Valid ProductSpuSaveReqVO createReqVO); - - /** - * 更新商品 SPU - * - * @param updateReqVO 更新信息 - */ - void updateSpu(@Valid ProductSpuSaveReqVO updateReqVO); - - /** - * 删除商品 SPU - * - * @param id 编号 - */ - void deleteSpu(Long id); - - /** - * 获得商品 SPU - * - * @param id 编号 - * @return 商品 SPU - */ - ProductSpuDO getSpu(Long id); - - /** - * 获得商品 SPU 列表 - * - * @param ids 编号数组 - * @return 商品 SPU 列表 - */ - List getSpuList(Collection ids); - - /** - * 获得指定状态的商品 SPU 列表 - * - * @param status 状态 - * @return 商品 SPU 列表 - */ - List getSpuListByStatus(Integer status); - - /** - * 获得商品 SPU 分页,提供给挂你兰后台使用 - * - * @param pageReqVO 分页查询 - * @return 商品spu分页 - */ - PageResult getSpuPage(ProductSpuPageReqVO pageReqVO); - - /** - * 获得商品 SPU 分页,提供给用户 App 使用 - * - * @param pageReqVO 分页查询 - * @return 商品 SPU 分页 - */ - PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO); - - /** - * 更新商品 SPU 库存(增量) - * - * @param stockIncrCounts SPU 编号与库存变化(增量)的映射 - */ - void updateSpuStock(Map stockIncrCounts); - - /** - * 更新 SPU 状态 - * - * @param updateReqVO 更新请求 - */ - void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO); - - /** - * 获取 SPU 列表标签对应的 Count 数量 - * - * @return Count 数量 - */ - Map getTabsCount(); - - /** - * 通过分类 categoryId 查询 SPU 个数 - * - * @param categoryId 分类 categoryId - * @return SPU 数量 - */ - Long getSpuCountByCategoryId(Long categoryId); - - - /** - * 校验商品是否有效。如下情况,视为无效: - * 1. 商品编号不存在 - * 2. 商品被禁用 - * - * @param ids 商品编号数组 - * @return 商品 SPU 列表 - */ - List validateSpuList(Collection ids); - - /** - * 更新商品 SPU 浏览量 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的数量 - */ - @Async - void updateBrowseCount(Long id, int incrCount); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java deleted file mode 100755 index 3a6cb2dcb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ /dev/null @@ -1,274 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import com.google.common.collect.Maps; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SPU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSpuServiceImpl implements ProductSpuService { - - @Resource - private ProductSpuMapper productSpuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSkuService productSkuService; - @Resource - private ProductBrandService brandService; - @Resource - private ProductCategoryService categoryService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSpu(ProductSpuSaveReqVO createReqVO) { - // 校验分类、品牌 - validateCategory(createReqVO.getCategoryId()); - brandService.validateProductBrand(createReqVO.getBrandId()); - // 校验 SKU - List skuSaveReqList = createReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); - - ProductSpuDO spu = BeanUtils.toBean(createReqVO, ProductSpuDO.class); - // 初始化 SPU 中 SKU 相关属性 - initSpuFromSkus(spu, skuSaveReqList); - // 插入 SPU - productSpuMapper.insert(spu); - // 插入 SKU - productSkuService.createSkuList(spu.getId(), skuSaveReqList); - // 返回 - return spu.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpu(ProductSpuSaveReqVO updateReqVO) { - // 校验 SPU 是否存在 - validateSpuExists(updateReqVO.getId()); - // 校验分类、品牌 - validateCategory(updateReqVO.getCategoryId()); - brandService.validateProductBrand(updateReqVO.getBrandId()); - // 校验SKU - List skuSaveReqList = updateReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); - - // 更新 SPU - ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class); - initSpuFromSkus(updateObj, skuSaveReqList); - productSpuMapper.updateById(updateObj); - // 批量更新 SKU - productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); - } - - /** - * 基于 SKU 的信息,初始化 SPU 的信息 - * 主要是计数相关的字段,例如说市场价、最大最小价、库存等等 - * - * @param spu 商品 SPU - * @param skus 商品 SKU 数组 - */ - private void initSpuFromSkus(ProductSpuDO spu, List skus) { - // sku 单价最低的商品的价格 - spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice)); - // sku 单价最低的商品的市场价格 - spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice)); - // sku 单价最低的商品的成本价格 - spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice)); - // skus 库存总数 - spu.setStock(getSumValue(skus, ProductSkuSaveReqVO::getStock, Integer::sum)); - // 若是 spu 已有状态则不处理 - if (spu.getStatus() == null) { - spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); // 默认状态为上架 - spu.setSalesCount(0); // 默认商品销量 - spu.setBrowseCount(0); // 默认商品浏览量 - } - } - - /** - * 校验商品分类是否合法 - * - * @param id 商品分类编号 - */ - private void validateCategory(Long id) { - categoryService.validateCategory(id); - // 校验层级 - if (categoryService.getCategoryLevel(id) < CATEGORY_LEVEL) { - throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR); - } - } - - @Override - public List validateSpuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - // 获得商品信息 - List list = productSpuMapper.selectBatchIds(ids); - Map spuMap = CollectionUtils.convertMap(list, ProductSpuDO::getId); - // 校验 - ids.forEach(id -> { - ProductSpuDO spu = spuMap.get(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE, spu.getName()); - } - }); - return list; - } - - @Override - public void updateBrowseCount(Long id, int incrCount) { - productSpuMapper.updateBrowseCount(id , incrCount); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSpu(Long id) { - // 校验存在 - validateSpuExists(id); - // 校验商品状态不是回收站不能删除 - ProductSpuDO spuDO = productSpuMapper.selectById(id); - // 判断 SPU 状态是否为回收站 - if (ObjectUtil.notEqual(spuDO.getStatus(), ProductSpuStatusEnum.RECYCLE.getStatus())) { - throw exception(SPU_NOT_RECYCLE); - } - // TODO 芋艿:【可选】参与活动中的商品,不允许删除??? - - // 删除 SPU - productSpuMapper.deleteById(id); - // 删除关联的 SKU - productSkuService.deleteSkuBySpuId(id); - } - - private void validateSpuExists(Long id) { - if (productSpuMapper.selectById(id) == null) { - throw exception(SPU_NOT_EXISTS); - } - } - - @Override - public ProductSpuDO getSpu(Long id) { - return productSpuMapper.selectById(id); - } - - @Override - public List getSpuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - Map spuMap = convertMap(productSpuMapper.selectBatchIds(ids), ProductSpuDO::getId); - // 需要按照 ids 顺序返回。例如说:店铺装修选择了 [3, 1, 2] 三个商品,返回结果还是 [3, 1, 2] 这样的顺序 - return convertList(ids, spuMap::get); - } - - @Override - public List getSpuListByStatus(Integer status) { - return productSpuMapper.selectList(ProductSpuDO::getStatus, status); - } - - @Override - public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { - return productSpuMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO) { - // 查找时,如果查找某个分类编号,则包含它的子分类。因为顶级分类不包含商品 - Set categoryIds = new HashSet<>(); - if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) { - categoryIds.add(pageReqVO.getCategoryId()); - List categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO() - .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentId(pageReqVO.getCategoryId())); - categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId)); - } - if (CollUtil.isNotEmpty(pageReqVO.getCategoryIds())) { - categoryIds.addAll(pageReqVO.getCategoryIds()); - List categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO() - .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentIds(pageReqVO.getCategoryIds())); - categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId)); - } - // 分页查询 - return productSpuMapper.selectPage(pageReqVO, categoryIds); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStock(Map stockIncrCounts) { - stockIncrCounts.forEach((id, incCount) -> productSpuMapper.updateStock(id, incCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO) { - // 校验存在 - validateSpuExists(updateReqVO.getId()); - // TODO 芋艿:【可选】参与活动中的商品,不允许下架??? - - // 更新状态 - ProductSpuDO productSpuDO = productSpuMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus()); - productSpuMapper.updateById(productSpuDO); - } - - @Override - public Map getTabsCount() { - Map counts = Maps.newLinkedHashMapWithExpectedSize(5); - // 查询销售中的商品数量 - counts.put(ProductSpuPageReqVO.FOR_SALE, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus())); - // 查询仓库中的商品数量 - counts.put(ProductSpuPageReqVO.IN_WAREHOUSE, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus())); - // 查询售空的商品数量 - counts.put(ProductSpuPageReqVO.SOLD_OUT, - productSpuMapper.selectCount(ProductSpuDO::getStock, 0)); - // 查询触发警戒库存的商品数量 - counts.put(ProductSpuPageReqVO.ALERT_STOCK, - productSpuMapper.selectCount()); - // 查询回收站中的商品数量 - counts.put(ProductSpuPageReqVO.RECYCLE_BIN, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); - return counts; - } - - @Override - public Long getSpuCountByCategoryId(Long categoryId) { - return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application.yaml deleted file mode 100644 index dedaffc2e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.product - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index b724707d1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: product-server - - profiles: - active: local - -server: - port: 48100 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index b337d1ece..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,48 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.product diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index e9616cd0d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM "product_sku"; -DELETE FROM "product_spu"; -DELETE FROM "product_category"; -DELETE FROM "product_brand"; -DELETE FROM "product_property"; -DELETE FROM "product_property_value"; -DELETE FROM "product_comment"; diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index f0f0c70ee..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,157 +0,0 @@ -CREATE TABLE IF NOT EXISTS `product_sku` ( - `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `spu_id` bigint NOT NULL COMMENT 'spu编号', - `properties` varchar(512) DEFAULT NULL COMMENT '属性数组,JSON 格式', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位:分', - `market_price` int DEFAULT NULL COMMENT '市场价,单位:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `bar_code` varchar(64) DEFAULT NULL COMMENT 'SKU 的条形码', - `pic_url` varchar(256) NOT NULL COMMENT '图片地址', - `stock` int DEFAULT NULL COMMENT '库存', - `weight` double DEFAULT NULL COMMENT '商品重量,单位:kg 千克', - `volume` double DEFAULT NULL COMMENT '商品体积,单位:m^3 平米', - `sub_commission_first_price` int DEFAULT NULL COMMENT '一级分销的佣金,单位:分', - `sub_commission_second_price` int DEFAULT NULL COMMENT '二级分销的佣金,单位:分', - `sales_count` int DEFAULT NULL COMMENT '商品销量', - "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, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品sku'; - -CREATE TABLE IF NOT EXISTS `product_spu` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品 SPU 编号,自增', - `name` varchar(128) NOT NULL COMMENT '商品名称', - `keyword` varchar(256) NOT NULL COMMENT '关键字', - `introduction` varchar(256) NOT NULL COMMENT '商品简介', - `description` text NOT NULL COMMENT '商品详情', - `bar_code` varchar(64) NOT NULL COMMENT '条形码', - `category_id` bigint NOT NULL COMMENT '商品分类编号', - `brand_id` int DEFAULT NULL COMMENT '商品品牌编号', - `pic_url` varchar(256) NOT NULL COMMENT '商品封面图', - `slider_pic_urls` varchar(2000) DEFAULT '' COMMENT '商品轮播图地址\n 数组,以逗号分隔\n 最多上传15张', - `video_url` varchar(256) DEFAULT NULL COMMENT '商品视频', - `unit` tinyint NOT NULL COMMENT '单位', - `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段', - `status` tinyint NOT NULL COMMENT '商品状态: 0 上架(开启) 1 下架(禁用)-1 回收', - `spec_type` bit(1) NOT NULL COMMENT '规格类型:0 单规格 1 多规格', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位使用:分', - `market_price` int NOT NULL COMMENT '市场价,单位使用:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `stock` int NOT NULL DEFAULT '0' COMMENT '库存', - `delivery_template_id` bigint NOT NULL COMMENT '物流配置模板编号', - `recommend_hot` bit(1) NOT NULL COMMENT '是否热卖推荐: 0 默认 1 热卖', - `recommend_benefit` bit(1) NOT NULL COMMENT '是否优惠推荐: 0 默认 1 优选', - `recommend_best` bit(1) NOT NULL COMMENT '是否精品推荐: 0 默认 1 精品', - `recommend_new` bit(1) NOT NULL COMMENT '是否新品推荐: 0 默认 1 新品', - `recommend_good` bit(1) NOT NULL COMMENT '是否优品推荐', - `give_integral` int NOT NULL COMMENT '赠送积分', - `give_coupon_template_ids` varchar(512) DEFAULT '' COMMENT '赠送的优惠劵编号的数组', - `sub_commission_type` bit(1) NOT NULL COMMENT '分销类型', - `activity_orders` varchar(16) NOT NULL DEFAULT '' COMMENT '活动显示排序0=默认, 1=秒杀,2=砍价,3=拼团', - `sales_count` int DEFAULT '0' COMMENT '商品销量', - `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量', - `browse_count` int DEFAULT '0' COMMENT '商品点击量', - "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, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品spu'; - -CREATE TABLE IF NOT EXISTS `product_category` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', - `parent_id` bigint NOT NULL COMMENT '父分类编号', - `name` varchar(255) NOT NULL COMMENT '分类名称', - `pic_url` varchar(255) NOT NULL COMMENT '移动端分类图', - `big_pic_url` varchar(255) DEFAULT NULL COMMENT 'PC 端分类图', - `sort` int DEFAULT '0' COMMENT '分类排序', - `status` tinyint NOT NULL COMMENT '开启状态', - "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, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品分类'; - -CREATE TABLE IF NOT EXISTS `product_brand` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号', - `name` varchar(255) NOT NULL COMMENT '品牌名称', - `pic_url` varchar(255) NOT NULL COMMENT '品牌图片', - `sort` int DEFAULT '0' COMMENT '品牌排序', - `description` varchar(1024) DEFAULT NULL COMMENT '品牌描述', - `status` tinyint NOT NULL COMMENT '状态', - "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, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品品牌'; - -CREATE TABLE IF NOT EXISTS `product_property` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) DEFAULT NULL COMMENT '规格名称', - `status` tinyint DEFAULT NULL COMMENT '状态: 0 开启 ,1 禁用', - "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, - "tenant_id" bigint not null default '0', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - PRIMARY KEY("id") -) COMMENT '规格名称'; - -CREATE TABLE IF NOT EXISTS `product_property_value` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `property_id` bigint DEFAULT NULL COMMENT '规格键id', - `name` varchar(128) DEFAULT NULL COMMENT '规格值名字', - `status` tinyint DEFAULT NULL COMMENT '状态: 1 开启 ,2 禁用', - "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, - "tenant_id" bigint not null default '0', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - PRIMARY KEY("id") -) COMMENT '规格值'; - -DROP TABLE IF EXISTS `product_comment` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论编号,主键自增', - `user_id` bigint DEFAULT NULL COMMENT '评价人的用户编号关联 MemberUserDO 的 id 编号', - `user_nickname` varchar(255) DEFAULT NULL COMMENT '评价人名称', - `user_avatar` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评价人头像', - `anonymous` bit(1) DEFAULT NULL COMMENT '是否匿名', - `order_id` bigint DEFAULT NULL COMMENT '交易订单编号关联 TradeOrderDO 的 id 编号', - `order_item_id` bigint DEFAULT NULL COMMENT '交易订单项编号关联 TradeOrderItemDO 的 id 编号', - `spu_id` bigint DEFAULT NULL COMMENT '商品 SPU 编号关联 ProductSpuDO 的 id', - `spu_name` varchar(255) DEFAULT NULL COMMENT '商品 SPU 名称', - `sku_id` bigint DEFAULT NULL COMMENT '商品 SKU 编号关联 ProductSkuDO 的 id 编号', - `visible` bit(1) DEFAULT NULL COMMENT '是否可见true:显示false:隐藏', - `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5分', - `description_scores` tinyint DEFAULT NULL COMMENT '描述星级1-5 星', - `benefit_scores` tinyint DEFAULT NULL COMMENT '服务星级1-5 星', - `content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评论内容', - `pic_urls` varchar(4096) DEFAULT NULL COMMENT '评论图片地址数组', - `reply_status` bit(1) DEFAULT NULL COMMENT '商家是否回复', - `reply_user_id` bigint DEFAULT NULL COMMENT '回复管理员编号关联 AdminUserDO 的 id 编号', - `reply_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '商家回复内容', - `reply_time` datetime DEFAULT NULL COMMENT '商家回复时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '商品评论'; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-api/pom.xml b/yudao-module-mall/yudao-module-promotion-api/pom.xml deleted file mode 100644 index 1b7a05b3f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-promotion-api - jar - - ${project.artifactId} - - promotion 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java deleted file mode 100644 index c0a0cfcdc..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 砍价活动") -public interface BargainActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/bargain-activity"; - - @PutMapping(PREFIX + "/update-stock") - @Operation(summary = "更新砍价活动库存") - @Parameters({ - @Parameter(name = "id", description = "砍价活动编号", required = true, example = "1024"), - @Parameter(name = "count", description = "购买数量", required = true, example = "1"), - }) - CommonResult updateBargainActivityStock(@RequestParam("id") Long id, - @RequestParam("count") Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java deleted file mode 100644 index 5b8eed59b..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 砍价记录") -public interface BargainRecordApi { - - String PREFIX = ApiConstants.PREFIX + "/bargain-record"; - - @GetMapping(PREFIX + "/validate-join") - @Operation(summary = "【下单前】校验是否参与砍价活动") // 如果校验失败,则抛出业务异常 - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "bargainRecordId", description = "砍价记录编号", required = true, example = "2048"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "4096"), - }) - CommonResult validateJoinBargain(@RequestParam("userId") Long userId, - @RequestParam("bargainRecordId") Long bargainRecordId, - @RequestParam("skuId") Long skuId); - - @PutMapping(PREFIX + "/update-order-id") - @Operation(summary = "更新砍价记录的订单编号") // 在砍价成功后,用户发起订单后,会记录该订单编号 - @Parameters({ - @Parameter(name = "id", description = "砍价记录编号", required = true, example = "1024"), - @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), - }) - CommonResult updateBargainRecordOrderId(@RequestParam("id") Long id, - @RequestParam("oderId") Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java deleted file mode 100644 index a64e923f5..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain.dto; - -import lombok.Data; - -/** - * 校验参与砍价 Response DTO - */ -@Data -public class BargainValidateJoinRespDTO { - - /** - * 砍价活动编号 - */ - private Long activityId; - /** - * 砍价活动名称 - */ - private String name; - - /** - * 砍价金额 - */ - private Integer bargainPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java deleted file mode 100644 index acd9d935f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 拼团记录") -public interface CombinationRecordApi { - - String PREFIX = ApiConstants.PREFIX + "/combination-record"; - - @GetMapping(PREFIX + "/validate") - @Operation(summary = "校验是否满足拼团条件") - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "activityId", description = "活动编号", required = true, example = "2048"), - @Parameter(name = "headId", description = "团长编号", required = true, example = "4096"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"), - @Parameter(name = "count", description = "数量", required = true, example = "1"), - }) - CommonResult validateCombinationRecord(@RequestParam("userId") Long userId, - @RequestParam("activityId") Long activityId, - @RequestParam("headId") Long headId, - @RequestParam("skuId") Long skuId, - @RequestParam("count") Integer count); - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建开团记录") - CommonResult createCombinationRecord( - @RequestBody @Valid CombinationRecordCreateReqDTO reqDTO); - - @GetMapping(PREFIX + "/is-success") - @Operation(summary = "查询拼团记录是否成功") - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), - }) - CommonResult isCombinationRecordSuccess(@RequestParam("userId") Long userId, - @RequestParam("orderId") Long orderId); - - @GetMapping(PREFIX + "/validate-join") - @Operation(summary = "【下单前】校验是否满足拼团活动条件") // 如果校验失败,则抛出业务异常 - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "activityId", description = "活动编号", required = true, example = "2048"), - @Parameter(name = "headId", description = "团长编号", example = "4096"), // 如果新发起的团,headId 不用传递 - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"), - @Parameter(name = "count", description = "数量", required = true, example = "1"), - }) - CommonResult validateJoinCombination(@RequestParam("userId") Long userId, - @RequestParam("activityId") Long activityId, - @RequestParam(value = "headId", required = false) Long headId, - @RequestParam("skuId") Long skuId, - @RequestParam("count") Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java deleted file mode 100644 index ac86c45ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 拼团记录的创建 Request DTO - * - * @author HUIHUI - */ -@Data -public class CombinationRecordCreateReqDTO { - - /** - * 拼团活动编号 - */ - @NotNull(message = "拼团活动编号不能为空") - private Long activityId; - /** - * spu 编号 - */ - @NotNull(message = "spu 编号不能为空") - private Long spuId; - /** - * sku 编号 - */ - @NotNull(message = "sku 编号不能为空") - private Long skuId; - /** - * 购买的商品数量 - */ - @NotNull(message = "购买数量不能为空") - private Integer count; - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 团长编号 - */ - private Long headId; - /** - * 拼团商品单价 - */ - @NotNull(message = "拼团商品单价不能为空") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java deleted file mode 100644 index 5f4ea2afd..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -/** - * 拼团记录的创建 Response DTO - * - * @author HUIHUI - */ -@Data -public class CombinationRecordCreateRespDTO { - - /** - * 拼团活动编号 - * - * 关联 CombinationActivityDO 的 id 字段 - */ - private Long combinationActivityId; - /** - * 拼团团长编号 - * - * 关联 CombinationRecordDO 的 headId 字段 - */ - private Long combinationHeadId; - /** - * 拼团记录编号 - * - * 关联 CombinationRecordDO 的 id 字段 - */ - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java deleted file mode 100644 index 86fe00a5f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -/** - * 校验参与拼团 Response DTO - * - * @author HUIHUI - */ -@Data -public class CombinationValidateJoinRespDTO { - - /** - * 砍价活动编号 - */ - private Long activityId; - /** - * 砍价活动名称 - */ - private String name; - - /** - * 拼团金额 - */ - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java deleted file mode 100644 index a73991a3d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.SpringQueryMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 优惠劵") -public interface CouponApi { - - String PREFIX = ApiConstants.PREFIX + "/coupon"; - - @PutMapping(PREFIX + "/use") - @Operation(summary = "使用优惠劵") - CommonResult useCoupon(@RequestBody @Valid CouponUseReqDTO useReqDTO); - - @PutMapping(PREFIX + "/return-used") - @Parameter(name = "id", description = "优惠券编号", required = true, example = "1") - CommonResult returnUsedCoupon(@RequestParam("id") Long id); - - @GetMapping(PREFIX + "/validate") - @Operation(summary = "校验优惠劵") - CommonResult validateCoupon(@Valid @SpringQueryMap CouponValidReqDTO validReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java deleted file mode 100644 index a404bf27d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 Response DTO - * - * @author 芋道源码 - */ -@Data -public class CouponRespDTO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - */ - private Integer templateId; - /** - * 优惠劵名 - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - */ - private Integer productScope; - /** - * 商品范围编号的数组 - */ - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java deleted file mode 100644 index a54ccf2b0..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import lombok.Data; - -/** - * 优惠券模版 Response DTO - * - * @author HUIHUI - */ -@Data -public class CouponTemplateRespDTO { - /** - * 模板编号,自增唯一 - */ - - private Long id; - /** - * 优惠劵名 - */ - private String name; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java deleted file mode 100644 index 9323ab553..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponUseReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java deleted file mode 100644 index dd25c6408..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponValidReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java deleted file mode 100644 index e446f6414..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 限时折扣") -public interface DiscountActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/discount-activity"; - - @GetMapping(PREFIX + "/list-by-sku-id") - @Operation(summary = "获得商品匹配的的限时折扣信息") - @Parameter(name = "skuIds", description = "商品 SKU 编号数组", required = true, example = "[1, 2]") - CommonResult> getMatchDiscountProductList(@RequestParam("skuIds") Collection skuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java deleted file mode 100644 index 52dfdbe27..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount.dto; - -import lombok.Data; - -/** - * 限时折扣活动商品 Response DTO - * - * @author 芋道源码 - */ -@Data -public class DiscountProductRespDTO { - - /** - * 编号,主键自增 - */ - private Long id; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - - // ========== 活动字段 ========== - /** - * 限时折扣活动的编号 - */ - private Long activityId; - /** - * 活动标题 - */ - private String activityName; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java deleted file mode 100644 index 1e81950d8..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 满减送") -public interface RewardActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/reward-activity"; - - @GetMapping(PREFIX + "/list-by-spu-id") - @Operation(summary = "获得商品匹配的的满减送活动信息") - @Parameter(name = "spuIds", description = "商品 SPU 编号数组", required = true, example = "[1, 2]") - CommonResult> getMatchRewardActivityList(@RequestParam("spuIds") Collection spuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java deleted file mode 100644 index 6ae71a1d9..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 满减送活动的匹配 Response DTO - * - * @author 芋道源码 - */ -@Data -public class RewardActivityMatchRespDTO { - - /** - * 活动编号,主键自增 - */ - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 优惠规则的数组 - */ - private List rules; - - /** - * 商品 SPU 编号的数组 - */ - private List spuIds; - - // TODO 芋艿:后面 RewardActivityRespDTO 有了之后,Rule 可以放过去 - /** - * 优惠规则 - */ - @Data - public static class Rule { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠券数量的数组 - */ - private List couponCounts; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java deleted file mode 100644 index e077d0544..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 秒杀活动") -public interface SeckillActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/discount-activity"; - - @PutMapping(PREFIX + "/update-stock-decr") - @Operation(summary = "更新秒杀库存(减少)") - @Parameters({ - @Parameter(name = "id", description = "活动编号", required = true, example = "1"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), - @Parameter(name = "count", description = "数量", required = true, example = "3"), - }) - CommonResult updateSeckillStockDecr(@RequestParam("id") Long id, - @RequestParam("skuId") Long skuId, - @RequestParam("count")Integer count); - - @PutMapping(PREFIX + "/update-stock-incr") - @Operation(summary = "更新秒杀库存(增加)") - @Parameters({ - @Parameter(name = "id", description = "活动编号", required = true, example = "1"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), - @Parameter(name = "count", description = "数量", required = true, example = "3"), - }) - CommonResult updateSeckillStockIncr(@RequestParam("id") Long id, - @RequestParam("skuId") Long skuId, - @RequestParam("count")Integer count); - - @GetMapping("/validate-join") - @Operation(summary = "【下单前】校验是否参与秒杀活动") // 如果校验失败,则抛出业务异常 - @Parameters({ - @Parameter(name = "activityId", description = "活动编号", required = true, example = "1"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), - @Parameter(name = "count", description = "数量", required = true, example = "3"), - }) - CommonResult validateJoinSeckill(@RequestParam("activityId") Long activityId, - @RequestParam("skuId") Long skuId, - @RequestParam("count")Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java deleted file mode 100644 index aae89a415..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill.dto; - -import lombok.Data; - -/** - * 校验参与秒杀 Response DTO - */ -@Data -public class SeckillValidateJoinRespDTO { - - /** - * 秒杀活动名称 - */ - private String name; - /** - * 总限购数量 - * - * 目的:目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - */ - private Integer totalLimitCount; - - /** - * 秒杀金额 - */ - private Integer seckillPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java deleted file mode 100644 index 2de4351cf..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "promotion-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/promotion"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java deleted file mode 100644 index f377ca239..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -/** - * promotion 字典类型的枚举类 - * - * @author HUIHUI - */ -public class DictTypeConstants { - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java deleted file mode 100644 index 3b19d616a..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Promotion 错误码枚举类 - *

- * promotion 系统,使用 1-013-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 促销活动相关 1-013-001-000 ============ - ErrorCode DISCOUNT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_001_000, "限时折扣活动不存在"); - ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_001_001, "存在商品参加了其它限时折扣活动"); - ErrorCode DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_002, "限时折扣活动已关闭,不能修改"); - ErrorCode DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_001_003, "限时折扣活动未关闭,不能删除"); - ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_004, "限时折扣活动已关闭,不能重复关闭"); - - // ========== Banner 相关 1-013-002-000 ============ - ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1_013_002_000, "Banner 不存在"); - - // ========== Coupon 相关 1-013-003-000 ============ - ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1_013_003_000, "优惠劵没有可使用的商品!"); - ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1_013_003_001, "所结算的商品中未满足使用的金额"); - - // ========== 优惠劵模板 1-013-004-000 ========== - ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_004_000, "优惠劵模板不存在"); - ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1_013_004_001, "发放数量不能小于已领取数量({})"); - ErrorCode COUPON_TEMPLATE_NOT_ENOUGH = new ErrorCode(1_013_004_002, "当前剩余数量不够领取"); - ErrorCode COUPON_TEMPLATE_USER_ALREADY_TAKE = new ErrorCode(1_013_004_003, "用户已领取过此优惠券"); - ErrorCode COUPON_TEMPLATE_EXPIRED = new ErrorCode(1_013_004_004, "优惠券已过期"); - ErrorCode COUPON_TEMPLATE_CANNOT_TAKE = new ErrorCode(1_013_004_005, "领取方式不正确"); - - // ========== 优惠劵 1-013-005-000 ========== - ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1_013_005_000, "优惠券不存在"); - ErrorCode COUPON_DELETE_FAIL_USED = new ErrorCode(1_013_005_001, "回收优惠劵失败,优惠劵已被使用"); - ErrorCode COUPON_STATUS_NOT_UNUSED = new ErrorCode(1_013_005_002, "优惠劵不处于待使用状态"); - ErrorCode COUPON_VALID_TIME_NOT_NOW = new ErrorCode(1_013_005_003, "优惠券不在使用时间范围内"); - ErrorCode COUPON_STATUS_NOT_USED = new ErrorCode(1_013_005_004, "优惠劵不是已使用状态"); - - // ========== 满减送活动 1-013-006-000 ========== - ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_006_000, "满减送活动不存在"); - ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_006_001, "存在商品参加了其它满减送活动"); - ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改"); - ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1_013_006_005, "满减送活动已结束,不能关闭"); - - // ========== TODO 空着 1-013-007-000 ============ - - // ========== 秒杀活动 1-013-008-000 ========== - ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在"); - ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_008_002, "存在商品参加了其它秒杀活动,秒杀时段冲突"); - ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_008_003, "秒杀活动已关闭,不能修改"); - ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_008_004, "秒杀活动未关闭或未结束,不能删除"); - ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_008_005, "秒杀活动已关闭,不能重复关闭"); - ErrorCode SECKILL_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_008_006, "秒杀失败,原因:秒杀库存不足"); - ErrorCode SECKILL_JOIN_ACTIVITY_TIME_ERROR = new ErrorCode(1_013_008_007, "秒杀失败,原因:不在活动时间范围内"); - ErrorCode SECKILL_JOIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_008_008, "秒杀失败,原因:秒杀活动已关闭"); - ErrorCode SECKILL_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_008_009, "秒杀失败,原因:单次限购超出"); - ErrorCode SECKILL_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_008_010, "秒杀失败,原因:商品不存在"); - - // ========== 秒杀时段 1-013-009-000 ========== - ErrorCode SECKILL_CONFIG_NOT_EXISTS = new ErrorCode(1_013_009_000, "秒杀时段不存在"); - ErrorCode SECKILL_CONFIG_TIME_CONFLICTS = new ErrorCode(1_013_009_001, "秒杀时段冲突"); - ErrorCode SECKILL_CONFIG_DISABLE = new ErrorCode(1_013_009_004, "秒杀时段已关闭"); - - // ========== 拼团活动 1-013-010-000 ========== - ErrorCode COMBINATION_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_010_000, "拼团活动不存在"); - ErrorCode COMBINATION_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_010_001, "存在商品参加了其它拼团活动"); - ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE = new ErrorCode(1_013_010_002, "拼团活动已关闭不能修改"); - ErrorCode COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_010_003, "拼团活动未关闭或未结束,不能删除"); - ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE = new ErrorCode(1_013_010_004, "拼团失败,原因:拼团活动已关闭"); - ErrorCode COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_010_005, "拼团失败,原因:拼团活动商品不存在"); - ErrorCode COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_010_006, "拼团失败,原因:拼团活动商品库存不足"); - - // ========== 拼团记录 1-013-011-000 ========== - ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1_013_011_000, "拼团不存在"); - ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1_013_011_001, "拼团失败,已参与过该拼团"); - ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1_013_011_002, "拼团失败,父拼团不存在"); - ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1_013_011_003, "拼团失败,拼团人数已满"); - ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1_013_011_004, "拼团失败,原因:存在该活动正在进行的拼团记录"); - ErrorCode COMBINATION_RECORD_FAILED_TIME_NOT_START = new ErrorCode(1_013_011_005, "拼团失败,活动未开始"); - ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1_013_011_006, "拼团失败,活动已经结束"); - ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_011_007, "拼团失败,原因:单次限购超出"); - ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_011_008, "拼团失败,原因:超出总购买次数"); - ErrorCode COMBINATION_RECORD_FAILED_ORDER_STATUS_UNPAID = new ErrorCode(1_013_011_009, "拼团失败,原因:存在未支付订单,请先支付"); - - // ========== 砍价活动 1-013-012-000 ========== - ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_012_000, "砍价活动不存在"); - ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_012_001, "存在商品参加了其它砍价活动"); - ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1_013_012_002, "砍价活动已关闭,不能修改"); - ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_012_003, "砍价活动未关闭或未结束,不能删除"); - ErrorCode BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH = new ErrorCode(1_013_012_004, "砍价活动库存不足"); - ErrorCode BARGAIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_012_005, "砍价活动已关闭"); - ErrorCode BARGAIN_ACTIVITY_TIME_END = new ErrorCode(1_013_012_006, "砍价活动已经结束"); - - // ========== 砍价记录 1-013-013-000 ========== - ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1_013_013_000, "砍价记录不存在"); - ErrorCode BARGAIN_RECORD_CREATE_FAIL_EXISTS = new ErrorCode(1_013_013_001, "参与失败,您已经参与当前砍价活动"); - ErrorCode BARGAIN_RECORD_CREATE_FAIL_LIMIT = new ErrorCode(1_013_013_002, "参与失败,您已达到当前砍价活动的参与上限"); - ErrorCode BARGAIN_JOIN_RECORD_NOT_SUCCESS = new ErrorCode(1_013_013_004, "下单失败,砍价未成功"); - ErrorCode BARGAIN_JOIN_RECORD_ALREADY_ORDER = new ErrorCode(1_013_013_005, "下单失败,该砍价已经下单"); - - // ========== 砍价助力 1-013-014-000 ========== - ErrorCode BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS = new ErrorCode(1_013_014_000, "助力失败,砍价记录不处于进行中"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_RECORD_SELF = new ErrorCode(1_013_014_001, "助力失败,不能助力自己"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_LIMIT = new ErrorCode(1_013_014_002, "助力失败,您已达到当前砍价活动的助力上限"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_CONFLICT = new ErrorCode(1_013_014_003, "助力失败,请重试"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); - - // ========== 文章分类 1-013-015-000 ========== - ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "文章分类不存在"); - ErrorCode ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES = new ErrorCode(1_013_015_001, "文章分类删除失败,存在关联文章"); - - // ========== 文章管理 1-013-016-000 ========== - ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在"); - - // ========== 装修模板 1-013-017-000 ========== - ErrorCode DIY_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_017_000, "装修模板不存在"); - ErrorCode DIY_TEMPLATE_NAME_USED = new ErrorCode(1_013_017_001, "装修模板名称({})已经被使用"); - ErrorCode DIY_TEMPLATE_USED_CANNOT_DELETE = new ErrorCode(1_013_017_002, "不能删除正在使用的装修模板"); - - // ========== 装修页面 1-013-018-000 ========== - ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); - ErrorCode DIY_PAGE_NAME_USED = new ErrorCode(1_013_018_001, "装修页面名称({})已经被使用"); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java deleted file mode 100644 index 8a8338c8a..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.banner; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * Banner Position 枚举 - * - * @author HUIHUI - */ -@AllArgsConstructor -@Getter -public enum BannerPositionEnum implements IntArrayValuable { - - HOME_POSITION(1, "首页"), - SECKILL_POSITION(2, "秒杀活动页"), - COMBINATION_POSITION(3, "砍价活动页"), - DISCOUNT_POSITION(4, "限时折扣页"), - REWARD_POSITION(5, "满减送页"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BannerPositionEnum::getPosition).toArray(); - - /** - * 值 - */ - private final Integer position; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java deleted file mode 100644 index d5c22a7c5..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.bargain; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 砍价记录的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum BargainRecordStatusEnum implements IntArrayValuable { - - IN_PROGRESS(1, "砍价中"), - SUCCESS(2, "砍价成功"), - FAILED(3, "砍价失败"), // 活动到期时,会自动将到期的砍价全部设置为过期 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BargainRecordStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java deleted file mode 100644 index 627e13946..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.combination; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 拼团状态枚举 - * - * @author HUIHUI - */ -@AllArgsConstructor -@Getter -public enum CombinationRecordStatusEnum implements IntArrayValuable { - - IN_PROGRESS(0, "进行中"), - SUCCESS(1, "拼团成功"), - FAILED(2, "拼团失败"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CombinationRecordStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isSuccess(Integer status) { - return ObjectUtil.equal(status, SUCCESS.getStatus()); - } - - public static boolean isInProgress(Integer status) { - return ObjectUtil.equal(status, IN_PROGRESS.getStatus()); - } - - public static boolean isFailed(Integer status) { - return ObjectUtil.equal(status, FAILED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java deleted file mode 100644 index e45e37beb..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO 芋艿:弱化这个状态 -/** - * 促销活动的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionActivityStatusEnum implements IntArrayValuable { - - WAIT(10, "未开始"), - RUN(20, "进行中"), - END(30, "已结束"), - CLOSE(40, "已关闭"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java deleted file mode 100644 index 05e62e399..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的条件类型枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionConditionTypeEnum implements IntArrayValuable { - - PRICE(10, "满 N 元"), - COUNT(20, "满 N 件"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java deleted file mode 100644 index 7da6b4b08..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionDiscountTypeEnum implements IntArrayValuable { - - PRICE(1, "满减"), // 具体金额 - PERCENT(2, "折扣"), // 百分比 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionDiscountTypeEnum::getType).toArray(); - - /** - * 优惠类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java deleted file mode 100644 index 882dc4aee..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的商品范围枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionProductScopeEnum implements IntArrayValuable { - - ALL(1, "通用券"), // 全部商品 - SPU(2, "商品券"), // 指定商品 - CATEGORY(3, "品类券"), // 指定品类 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray(); - - /** - * 范围值 - */ - private final Integer scope; - /** - * 范围名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java deleted file mode 100644 index 4524c198d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionTypeEnum implements IntArrayValuable { - - SECKILL_ACTIVITY(1, "秒杀活动"), - BARGAIN_ACTIVITY(2, "砍价活动"), - COMBINATION_ACTIVITY(3, "拼团活动"), - - DISCOUNT_ACTIVITY(4, "限时折扣"), - REWARD_ACTIVITY(5, "满减送"), - - MEMBER_LEVEL(6, "会员折扣"), - COUPON(7, "优惠劵"), - POINT(8, "积分") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java deleted file mode 100644 index 320345d85..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponStatusEnum implements IntArrayValuable { - - UNUSED(1, "未使用"), - USED(2, "已使用"), - EXPIRE(3, "已过期"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java deleted file mode 100644 index 1513e62ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵领取方式 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTakeTypeEnum implements IntArrayValuable { - - USER(1, "直接领取"), // 用户可在首页、每日领劵直接领取 - ADMIN(2, "指定发放"), // 后台指定会员赠送优惠劵 - REGISTER(3, "新人券"), // 注册时自动领取 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java deleted file mode 100644 index 391515de3..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵模板的有限期类型的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTemplateValidityTypeEnum implements IntArrayValuable { - - DATE(1, "固定日期"), - TERM(2, "领取之后"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateValidityTypeEnum::getType).toArray(); - - /** - * 值 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java deleted file mode 100644 index 45bc1fe4d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.decorate; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 页面组件枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -@SuppressWarnings("JavadocLinkAsPlainText") -public enum DecorateComponentEnum { - - /** - * 格式:[{ - * "name": "标题" - * "picUrl": "https://www.iocoder.cn/xxx.png", - * "url": "/pages/users/index" - * }] - * - * 最多 10 个 - */ - MENU("menu", "菜单"), - /** - * 格式:[{ - * "name": "标题" - * "url": "/pages/users/index" - * }] - */ - ROLLING_NEWS("scrolling-news", "滚动新闻"), - /** - * 格式:[{ - * "picUrl": "https://www.iocoder.cn/xxx.png", - * "url": "/pages/users/index" - * }] - */ - SLIDE_SHOW("slide-show", "轮播图"), - /** - * 格式:[{ - * "name": "标题" - * "type": "类型", // best、hot、new、benefit、good - * "tag": "标签" // 例如说:多买多省 - * }] - * - * 最多 4 个 - */ - PRODUCT_RECOMMEND("product-recommend", "商品推荐"); - - /** - * 页面组件代码 - */ - private final String code; - - /** - * 页面组件说明 - */ - private final String desc; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java deleted file mode 100644 index 3b662db7a..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.decorate; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 装修页面枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DecoratePageEnum implements IntArrayValuable { - - INDEX(1, "首页"), - MY(2, "个人中心"), - ; - - private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray(); - - /** - * 页面编号 - */ - private final Integer page; - - /** - * 页面名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/diy/DiyPageEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/diy/DiyPageEnum.java deleted file mode 100644 index fa00adaad..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/diy/DiyPageEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.diy; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 装修页面枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DiyPageEnum implements IntArrayValuable { - - INDEX(1, "首页"), - MY(2, "我的"), - ; - - private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DiyPageEnum::getPage).toArray(); - - /** - * 页面编号 - */ - private final Integer page; - - /** - * 页面名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/Dockerfile b/yudao-module-mall/yudao-module-promotion-biz/Dockerfile deleted file mode 100644 index e507655d9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-promotion-biz -WORKDIR /yudao-module-promotion-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-promotion-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48101 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mall/yudao-module-promotion-biz/pom.xml b/yudao-module-mall/yudao-module-promotion-biz/pom.xml deleted file mode 100644 index 9996af44b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/pom.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - jar - yudao-module-promotion-biz - - ${project.artifactId} - - - promotion 模块,主要实现营销相关功能 - 例如:营销活动、banner 广告、优惠券、优惠码等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-promotion-api - ${revision} - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-trade-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mq - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - io.vavr - vavr - 0.10.2 - compile - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/PromotionServerApplication.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/PromotionServerApplication.java deleted file mode 100644 index e552de3ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/PromotionServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class PromotionServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(PromotionServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java deleted file mode 100644 index 97ff41d9a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 砍价活动 Api 接口实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class BargainActivityApiImpl implements BargainActivityApi { - - @Resource - private BargainActivityService bargainActivityService; - - @Override - public CommonResult updateBargainActivityStock(Long id, Integer count) { - bargainActivityService.updateBargainActivityStock(id, count); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java deleted file mode 100644 index b4412e96d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 砍价活动 API 实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class BargainRecordApiImpl implements BargainRecordApi { - - @Resource - private BargainRecordService bargainRecordService; - - @Override - public CommonResult validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { - return success(bargainRecordService.validateJoinBargain(userId, bargainRecordId, skuId)); - } - - @Override - public CommonResult updateBargainRecordOrderId(Long id, Long orderId) { - bargainRecordService.updateBargainRecordOrderId(id, orderId); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java deleted file mode 100644 index 5a55a7737..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_NOT_EXISTS; - -/** - * 拼团活动 API 实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class CombinationRecordApiImpl implements CombinationRecordApi { - - @Resource - private CombinationRecordService combinationRecordService; - - @Override - public CommonResult validateCombinationRecord(Long userId, Long activityId, Long headId, Long skuId, Integer count) { - combinationRecordService.validateCombinationRecord(userId, activityId, headId, skuId, count); - return success(true); - } - - @Override - public CommonResult createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { - return success(CombinationActivityConvert.INSTANCE.convert4(combinationRecordService.createCombinationRecord(reqDTO))); - } - - @Override - public CommonResult isCombinationRecordSuccess(Long userId, Long orderId) { - CombinationRecordDO record = combinationRecordService.getCombinationRecord(userId, orderId); - if (record == null) { - throw exception(COMBINATION_RECORD_NOT_EXISTS); - } - return success(CombinationRecordStatusEnum.isSuccess(record.getStatus())); - } - - @Override - public CommonResult validateJoinCombination( - Long userId, Long activityId, Long headId, Long skuId, Integer count) { - return success(combinationRecordService.validateJoinCombination(userId, activityId, headId, skuId, count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java deleted file mode 100644 index e3d268985..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 优惠劵 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class CouponApiImpl implements CouponApi { - - @Resource - private CouponService couponService; - - @Override - public CommonResult useCoupon(CouponUseReqDTO useReqDTO) { - couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), useReqDTO.getOrderId()); - return success(true); - } - - @Override - public CommonResult returnUsedCoupon(Long id) { - couponService.returnUsedCoupon(id); - return success(true); - } - - @Override - public CommonResult validateCoupon(CouponValidReqDTO validReqDTO) { - CouponDO coupon = couponService.validCoupon(validReqDTO.getId(), validReqDTO.getUserId()); - return success(CouponConvert.INSTANCE.convert(coupon)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java deleted file mode 100644 index 232ab25ee..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 限时折扣 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class DiscountActivityApiImpl implements DiscountActivityApi { - - @Resource - private DiscountActivityService discountActivityService; - - @Override - public CommonResult> getMatchDiscountProductList(Collection skuIds) { - return success(DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds))); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java deleted file mode 100644 index 45d33adae..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 满减送活动 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class RewardActivityApiImpl implements RewardActivityApi { - - @Resource - private RewardActivityService rewardActivityService; - - @Override - public CommonResult> getMatchRewardActivityList(Collection spuIds) { - return success(rewardActivityService.getMatchRewardActivityList(spuIds)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java deleted file mode 100644 index f8dfb14d7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 秒杀活动接口 Api 接口实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class SeckillActivityApiImpl implements SeckillActivityApi { - - @Resource - private SeckillActivityService activityService; - - @Override - public CommonResult updateSeckillStockDecr(Long id, Long skuId, Integer count) { - activityService.updateSeckillStockDecr(id, skuId, count); - return success(true); - } - - @Override - public CommonResult updateSeckillStockIncr(Long id, Long skuId, Integer count) { - activityService.updateSeckillStockIncr(id, skuId, count); - return success(true); - } - - @Override - public CommonResult validateJoinSeckill(Long activityId, Long skuId, Integer count) { - return success(activityService.validateJoinSeckill(activityId, skuId, count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java deleted file mode 100644 index 245e6950c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 文章分类") -@RestController -@RequestMapping("/promotion/article-category") -@Validated -public class ArticleCategoryController { - - @Resource - private ArticleCategoryService articleCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建文章分类") - @PreAuthorize("@ss.hasPermission('promotion:article-category:create')") - public CommonResult createArticleCategory(@Valid @RequestBody ArticleCategoryCreateReqVO createReqVO) { - return success(articleCategoryService.createArticleCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新文章分类") - @PreAuthorize("@ss.hasPermission('promotion:article-category:update')") - public CommonResult updateArticleCategory(@Valid @RequestBody ArticleCategoryUpdateReqVO updateReqVO) { - articleCategoryService.updateArticleCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除文章分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:article-category:delete')") - public CommonResult deleteArticleCategory(@RequestParam("id") Long id) { - articleCategoryService.deleteArticleCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得文章分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") - public CommonResult getArticleCategory(@RequestParam("id") Long id) { - ArticleCategoryDO category = articleCategoryService.getArticleCategory(id); - return success(ArticleCategoryConvert.INSTANCE.convert(category)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") - public CommonResult> getSimpleDeptList() { - // 获得分类列表,只要开启状态的 - List list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 降序排序后,返回给前端 - list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); - return success(ArticleCategoryConvert.INSTANCE.convertList03(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得文章分类分页") - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") - public CommonResult> getArticleCategoryPage(@Valid ArticleCategoryPageReqVO pageVO) { - PageResult pageResult = articleCategoryService.getArticleCategoryPage(pageVO); - return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java deleted file mode 100644 index f6dea04e3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 文章管理") -@RestController -@RequestMapping("/promotion/article") -@Validated -public class ArticleController { - - @Resource - private ArticleService articleService; - - @PostMapping("/create") - @Operation(summary = "创建文章管理") - @PreAuthorize("@ss.hasPermission('promotion:article:create')") - public CommonResult createArticle(@Valid @RequestBody ArticleCreateReqVO createReqVO) { - return success(articleService.createArticle(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新文章管理") - @PreAuthorize("@ss.hasPermission('promotion:article:update')") - public CommonResult updateArticle(@Valid @RequestBody ArticleUpdateReqVO updateReqVO) { - articleService.updateArticle(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除文章管理") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:article:delete')") - public CommonResult deleteArticle(@RequestParam("id") Long id) { - articleService.deleteArticle(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得文章管理") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:article:query')") - public CommonResult getArticle(@RequestParam("id") Long id) { - ArticleDO article = articleService.getArticle(id); - return success(ArticleConvert.INSTANCE.convert(article)); - } - - @GetMapping("/page") - @Operation(summary = "获得文章管理分页") - @PreAuthorize("@ss.hasPermission('promotion:article:query')") - public CommonResult> getArticlePage(@Valid ArticlePageReqVO pageVO) { - PageResult pageResult = articleService.getArticlePage(pageVO); - return success(ArticleConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java deleted file mode 100644 index 4c07e86a9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 文章管理 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ArticleBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15458") - @NotNull(message = "文章分类编号不能为空") - private Long categoryId; - - @Schema(description = "关联商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22378") - @NotNull(message = "关联商品不能为空") - private Long spuId; - - @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个标题") - @NotNull(message = "文章标题不能为空") - private String title; - - @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String author; - - @Schema(description = "文章封面图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - @NotNull(message = "文章封面图片地址不能为空") - private String picUrl; - - @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") - private String introduction; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "是否热门(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否热门(小程序)不能为空") - private Boolean recommendHot; - - @Schema(description = "是否轮播图(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否轮播图(小程序)不能为空") - private Boolean recommendBanner; - - @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是文章内容") - @NotNull(message = "文章内容不能为空") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java deleted file mode 100644 index d598dd768..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 文章管理创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCreateReqVO extends ArticleBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java deleted file mode 100644 index 9c7539585..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 文章管理分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticlePageReqVO extends PageParam { - - @Schema(description = "文章分类编号", example = "15458") - private Long categoryId; - - @Schema(description = "关联商品编号", example = "22378") - private Long spuId; - - @Schema(description = "文章标题") - private String title; - - @Schema(description = "文章作者") - private String author; - - @Schema(description = "状态", example = "2") - private Integer status; - - @Schema(description = "是否热门(小程序)") - private Boolean recommendHot; - - @Schema(description = "是否轮播图(小程序)") - private Boolean recommendBanner; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java deleted file mode 100644 index 3f9281a17..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 文章管理 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleRespVO extends ArticleBaseVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") - private Long id; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "99999") - private Integer browseCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java deleted file mode 100644 index 3efd59334..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 文章管理更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleUpdateReqVO extends ArticleBaseVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") - @NotNull(message = "文章编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java deleted file mode 100644 index 42bf116c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 文章分类 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ArticleCategoryBaseVO { - - @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") - @NotNull(message = "文章分类名称不能为空") - private String name; - - @Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java deleted file mode 100644 index a8dc1f2e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 文章分类创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryCreateReqVO extends ArticleCategoryBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java deleted file mode 100644 index b161aae08..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 文章分类分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryPageReqVO extends PageParam { - - @Schema(description = "文章分类名称", example = "秒杀") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java deleted file mode 100644 index af4b045a7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 文章分类 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryRespVO extends ArticleCategoryBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java deleted file mode 100644 index 4e43326c9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 文章分类精简信息 Response VO") -@Data -public class ArticleCategorySimpleRespVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - private Long id; - - @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java deleted file mode 100644 index 72a1b3506..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 文章分类更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryUpdateReqVO extends ArticleCategoryBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - @NotNull(message = "文章分类编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java deleted file mode 100644 index 8b6dae9cf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - Banner 管理") -@RestController -@RequestMapping("/promotion/banner") -@Validated -public class BannerController { - - @Resource - private BannerService bannerService; - - @PostMapping("/create") - @Operation(summary = "创建 Banner") - @PreAuthorize("@ss.hasPermission('promotion:banner:create')") - public CommonResult createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) { - return success(bannerService.createBanner(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新 Banner") - @PreAuthorize("@ss.hasPermission('promotion:banner:update')") - public CommonResult updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) { - bannerService.updateBanner(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 Banner") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:banner:delete')") - public CommonResult deleteBanner(@RequestParam("id") Long id) { - bannerService.deleteBanner(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得 Banner") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:banner:query')") - public CommonResult getBanner(@RequestParam("id") Long id) { - BannerDO banner = bannerService.getBanner(id); - return success(BannerConvert.INSTANCE.convert(banner)); - } - - @GetMapping("/page") - @Operation(summary = "获得 Banner 分页") - @PreAuthorize("@ss.hasPermission('promotion:banner:query')") - public CommonResult> getBannerPage(@Valid BannerPageReqVO pageVO) { - PageResult pageResult = bannerService.getBannerPage(pageVO); - return success(BannerConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java deleted file mode 100644 index 0818257ef..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * Banner Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * @author xia - */ -@Data -public class BannerBaseVO { - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "position", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "position 不能为空") - @InEnum(BannerPositionEnum.class) - private Integer position; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注") - private String memo; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java deleted file mode 100644 index 180cdfe87..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerCreateReqVO extends BannerBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java deleted file mode 100644 index c2ac49d71..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - Banner 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerPageReqVO extends PageParam { - - @Schema(description = "标题", example = "这是一个标题") - private String title; - - @Schema(description = "状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java deleted file mode 100644 index 2eee606e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - Banner Response VO") -@Data -@ToString(callSuper = true) -public class BannerRespVO extends BannerBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java deleted file mode 100644 index 266f28c1b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerUpdateReqVO extends BannerBaseVO { - - @Schema(description = "banner 编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "banner 编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java deleted file mode 100644 index d76b90e9a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 砍价活动") -@RestController -@RequestMapping("/promotion/bargain-activity") -@Validated -public class BargainActivityController { - - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private ProductSpuApi spuApi; - - @PostMapping("/create") - @Operation(summary = "创建砍价活动") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')") - public CommonResult createBargainActivity(@Valid @RequestBody BargainActivityCreateReqVO createReqVO) { - return success(bargainActivityService.createBargainActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新砍价活动") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:update')") - public CommonResult updateBargainActivity(@Valid @RequestBody BargainActivityUpdateReqVO updateReqVO) { - bargainActivityService.updateBargainActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭砍价活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - bargainActivityService.closeBargainActivityById(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除砍价活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:delete')") - public CommonResult deleteBargainActivity(@RequestParam("id") Long id) { - bargainActivityService.deleteBargainActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得砍价活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") - public CommonResult getBargainActivity(@RequestParam("id") Long id) { - return success(BargainActivityConvert.INSTANCE.convert(bargainActivityService.getBargainActivity(id))); - } - - @GetMapping("/page") - @Operation(summary = "获得砍价活动分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") - public CommonResult> getBargainActivityPage( - @Valid BargainActivityPageReqVO pageVO) { - // 查询砍价活动 - PageResult pageResult = bargainActivityService.getBargainActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), BargainActivityDO::getSpuId)).getCheckedData(); - // 统计数据 - Collection activityIds = convertList(pageResult.getList(), BargainActivityDO::getId); - Map recordUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, null); - Map recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, - BargainRecordStatusEnum.SUCCESS.getStatus()); - Map helpUserCountMap = bargainHelpService.getBargainHelpUserCountMapByActivity(activityIds); - return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList, - recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java deleted file mode 100644 index 14265e0b3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 砍价助力") -@RestController -@RequestMapping("/promotion/bargain-help") -@Validated -public class BargainHelpController { - - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得砍价助力分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-help:query')") - public CommonResult> getBargainHelpPage(@Valid BargainHelpPageReqVO pageVO) { - PageResult pageResult = bargainHelpService.getBargainHelpPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BargainHelpDO::getUserId)); - return success(BargainHelpConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java deleted file mode 100644 index 69781b3b5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 砍价记录") -@RestController -@RequestMapping("/promotion/bargain-record") -@Validated -public class BargainRecordController { - - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得砍价记录分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-record:query')") - public CommonResult> getBargainRecordPage(@Valid BargainRecordPageReqVO pageVO) { - PageResult pageResult = bargainRecordService.getBargainRecordPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BargainRecordDO::getUserId)); - List activityList = bargainActivityService.getBargainActivityList( - convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); - Map helpCountMap = bargainHelpService.getBargainHelpUserCountMapByRecord( - convertSet(pageResult.getList(), BargainRecordDO::getId)); - return success(BargainRecordConvert.INSTANCE.convertPage(pageResult, helpCountMap, activityList, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java deleted file mode 100644 index 9f7113fbb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 砍价活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class BargainActivityBaseVO { - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "砍得越多省得越多,是兄弟就来砍我") - @NotNull(message = "砍价名称不能为空") - private String name; - - @Schema(description = "商品 SPU 编号", example = "1") - @NotNull(message = "砍价商品不能为空") - private Long spuId; - - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "商品 skuId 不能为空") - private Long skuId; - - @Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "砍价起始价格不能为空") - private Integer bargainFirstPrice; - - @Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "砍价底价不能为空") - private Integer bargainMinPrice; - - @Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "活动库存不能为空") - private Integer stock; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") - @NotNull(message = "总限购数量不能为空") - private Integer totalLimitCount; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "最大助力次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "最大助力次数不能为空") - private Integer helpMaxCount; - - @Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "最大帮砍次数不能为空") - private Integer bargainCount; - - @Schema(description = "用户每次砍价的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "用户每次砍价的最小金额不能为空") - private Integer randomMinPrice; - - @Schema(description = "用户每次砍价的最大金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "用户每次砍价的最大金额不能为空") - private Integer randomMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java deleted file mode 100644 index 83cb5eaf9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityCreateReqVO extends BargainActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java deleted file mode 100644 index 721a31ca6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价活动的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityPageItemRespVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "活动总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer totalStock; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - - // ========== 统计字段 ========== - - @Schema(description = "总砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "999") - private Integer recordUserCount; - - @Schema(description = "成功砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer recordSuccessUserCount; - - @Schema(description = "帮助砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer helpUserCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java deleted file mode 100644 index 66f23730f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityPageReqVO extends PageParam { - - @Schema(description = "砍价名称", example = "赵六") - private String name; - - @Schema(description = "活动状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java deleted file mode 100644 index 0295fddc5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -@Schema(description = "管理后台 - 砍价活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityRespVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java deleted file mode 100644 index b7470293f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 砍价活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityUpdateReqVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java deleted file mode 100644 index 41dd1c246..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 砍价助力 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BargainHelpBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5402") - private Long userId; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "16825") - private Long activityId; - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1800") - private Long recordId; - - @Schema(description = "减少砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "32300") - private Integer reducePrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java deleted file mode 100644 index 8afbe3ff6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价助力分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainHelpPageReqVO extends PageParam { - - @Schema(description = "砍价记录编号", example = "1800") - private Long recordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java deleted file mode 100644 index 151594477..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价助力 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainHelpRespVO extends BargainHelpBaseVO { - - @Schema(description = "砍价助力编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25860") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 用户相关 ========== - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java deleted file mode 100644 index 31650f10d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 砍价记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BargainRecordBaseVO { - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "22690") - @NotNull(message = "砍价活动名称不能为空") - private Long activityId; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "31160") - @NotNull(message = "砍价起始价格,单位:分不能为空") - private Integer bargainFirstPrice; - - @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22743") - @NotNull(message = "当前砍价,单位:分不能为空") - private Integer bargainPrice; - - @Schema(description = "砍价状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "砍价状态不能为空") - private Integer status; - - @Schema(description = "订单编号", example = "27845") - private Long orderId; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java deleted file mode 100644 index 608ed3090..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价记录的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainRecordPageItemRespVO extends BargainRecordBaseVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - - @Schema(description = "帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer helpCount; - - // ========== 用户相关 ========== - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - // ========== 活动相关 ========== - - private BargainActivityRespVO activity; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java deleted file mode 100644 index 47b671877..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 砍价记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainRecordPageReqVO extends PageParam { - - @Schema(description = "砍价状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java deleted file mode 100644 index 69e31099b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.hutool.core.collection.CollectionUtil.newArrayList; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-activity") -@Validated -public class CombinationActivityController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private CombinationRecordService combinationRecordService; - - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建拼团活动") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:create')") - public CommonResult createCombinationActivity(@Valid @RequestBody CombinationActivityCreateReqVO createReqVO) { - return success(combinationActivityService.createCombinationActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新拼团活动") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:update')") - public CommonResult updateCombinationActivity(@Valid @RequestBody CombinationActivityUpdateReqVO updateReqVO) { - combinationActivityService.updateCombinationActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭拼团活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')") - public CommonResult closeCombinationActivity(@RequestParam("id") Long id) { - combinationActivityService.closeCombinationActivityById(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除拼团活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:delete')") - public CommonResult deleteCombinationActivity(@RequestParam("id") Long id) { - combinationActivityService.deleteCombinationActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得拼团活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") - public CommonResult getCombinationActivity(@RequestParam("id") Long id) { - CombinationActivityDO activity = combinationActivityService.getCombinationActivity(id); - List products = combinationActivityService.getCombinationProductListByActivityIds(newArrayList(id)); - return success(CombinationActivityConvert.INSTANCE.convert(activity, products)); - } - - @GetMapping("/page") - @Operation(summary = "获得拼团活动分页") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") - public CommonResult> getCombinationActivityPage( - @Valid CombinationActivityPageReqVO pageVO) { - // 查询拼团活动 - PageResult pageResult = combinationActivityService.getCombinationActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 统计数据 - Set activityIds = convertSet(pageResult.getList(), CombinationActivityDO::getId); - Map groupCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, null, CombinationRecordDO.HEAD_ID_GROUP); - Map groupSuccessCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, CombinationRecordStatusEnum.SUCCESS.getStatus(), CombinationRecordDO.HEAD_ID_GROUP); - Map recordCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, null, null); - // 拼接数据 - List products = combinationActivityService.getCombinationProductListByActivityIds( - convertSet(pageResult.getList(), CombinationActivityDO::getId)); - List spus = productSpuApi.getSpuList( - convertSet(pageResult.getList(), CombinationActivityDO::getSpuId)).getCheckedData(); - return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products, - groupCountMap, groupSuccessCountMap, recordCountMap, spus)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java deleted file mode 100644 index 45ad4e02d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 拼团记录") -@RestController -@RequestMapping("/promotion/combination-record") -@Validated -public class CombinationRecordController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - @Lazy - private CombinationRecordService combinationRecordService; - - @GetMapping("/page") - @Operation(summary = "获得拼团记录分页") - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult> getCombinationRecordPage( - @Valid CombinationRecordReqPageVO pageVO) { - PageResult recordPage = combinationRecordService.getCombinationRecordPage(pageVO); - // 拼接数据 - List activities = combinationActivityService.getCombinationActivityListByIds( - convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); - List products = combinationActivityService.getCombinationProductListByActivityIds( - convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); - return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities, products)); - } - - @GetMapping("/get-summary") - @Operation(summary = "获得拼团记录的概要信息", description = "用于拼团记录页面展示") - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult getCombinationRecordSummary() { - CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO(); - summaryVO.setUserCount(combinationRecordService.getCombinationUserCount()); // 获取拼团用户参与数量 - summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录 - CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP)); - summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录 - null, Boolean.TRUE, CombinationRecordDO.HEAD_ID_GROUP)); - return success(summaryVO); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java deleted file mode 100644 index 4b3abeab4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 拼团活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CombinationActivityBaseVO { - - @Schema(description = "拼团名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱") - @NotNull(message = "拼团名称不能为空") - private String name; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "拼团商品不能为空") - private Long spuId; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") - @NotNull(message = "总限购数量不能为空") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "28265") - @NotNull(message = "单次限购数量不能为空") - private Integer singleLimitCount; - - @Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "开团人数不能为空") - private Integer userSize; - - @Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - @NotNull(message = "虚拟成团不能为空") - private Boolean virtualGroup; - - @Schema(description = "限制时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "限制时长不能为空") - private Integer limitDuration; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java deleted file mode 100644 index dff1a6cdb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityCreateReqVO extends CombinationActivityBaseVO { - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java deleted file mode 100644 index 0151adfb9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityPageItemRespVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - // ========== 商品字段 ========== - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - // ========== 统计字段 ========== - - @Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33") - private Integer groupCount; - - @Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer groupSuccessCount; - - @Schema(description = "购买次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer recordCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java deleted file mode 100644 index bfb54b730..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 拼团活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityPageReqVO extends PageParam { - - @Schema(description = "拼团名称", example = "赵六") - private String name; - - @Schema(description = "活动状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java deleted file mode 100644 index 0ac77c559..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityRespVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer userSize; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java deleted file mode 100644 index f4483cee1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityUpdateReqVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - @NotNull(message = "活动编号不能为空") - private Long id; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java deleted file mode 100644 index 452fb38ff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 拼团商品 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CombinationProductBaseVO { - - @Schema(description = "商品 spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品 spuId 不能为空") - private Long spuId; - - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品 skuId 不能为空") - private Long skuId; - - @Schema(description = "拼团价格,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "27682") - @NotNull(message = "拼团价格不能为空") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java deleted file mode 100644 index 02bcc070c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 拼团商品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationProductPageReqVO extends PageParam { - - @Schema(description = "拼团活动编号", example = "6829") - private Long activityId; - - @Schema(description = "商品 SPU 编号", example = "18731") - private Long spuId; - - @Schema(description = "商品 SKU 编号", example = "31675") - private Long skuId; - - @Schema(description = "拼团商品状态", example = "2") - private Integer activityStatus; - - @Schema(description = "活动开始时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityStartTime; - - @Schema(description = "活动结束时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityEndTime; - - @Schema(description = "拼团价格,单位分", example = "27682") - private Integer activePrice; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java deleted file mode 100644 index eeac5c3b5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 拼团商品 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationProductRespVO extends CombinationProductBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28322") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java deleted file mode 100644 index 18c754dc5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 拼团记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CombinationRecordBaseVO { - - @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long activityId; - - @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long headId; - - // ========== 用户相关 ========== - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - // ========== 商品相关 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") - private String spuName; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime expireTime; - - @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer userSize; - - @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer userCount; - - @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "是否虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean virtualGroup; - - @Schema(description = "开始时间 (订单付款后开始的时间)", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间(成团时间/失败时间)", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java deleted file mode 100644 index 7b1b10bac..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 拼团记录的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordPageItemRespVO extends CombinationRecordBaseVO { - - // ========== 活动相关 ========== - - private CombinationActivityRespVO activity; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java deleted file mode 100644 index 9e6fe9159..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordReqPage2VO extends PageParam { - - @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "团长编号不能为空") - private Long headId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java deleted file mode 100644 index a66795d64..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordReqPageVO extends PageParam { - - @Schema(description = "活动状态", example = "1") - @InEnum(BargainRecordStatusEnum.class) - private Integer status; - - @Schema(description = "团长编号", example = "1024") - private Long headId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java deleted file mode 100644 index 64d63afe0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 拼团记录信息统计 Response VO") -@Data -public class CombinationRecordSummaryVO { - - @Schema(description = "所有拼团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userCount; - - @Schema(description = "成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long successCount; - - @Schema(description = "虚拟成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long virtualGroupCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java deleted file mode 100755 index 8e0a9bd2b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponSendReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class CouponController { - - @Resource - private CouponService couponService; - @Resource - private MemberUserApi memberUserApi; - - @DeleteMapping("/delete") - @Operation(summary = "回收优惠劵") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon:delete')") - public CommonResult deleteCoupon(@RequestParam("id") Long id) { - couponService.deleteCoupon(id); - return success(true); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon:query')") - public CommonResult> getCouponPage(@Valid CouponPageReqVO pageVO) { - PageResult pageResult = couponService.getCouponPage(pageVO); - PageResult pageResulVO = CouponConvert.INSTANCE.convertPage(pageResult); - if (CollUtil.isEmpty(pageResulVO.getList())) { - return success(pageResulVO); - } - - // 读取用户信息,进行拼接 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), CouponDO::getUserId)); - pageResulVO.getList().forEach(itemRespVO -> MapUtils.findAndThen(userMap, itemRespVO.getUserId(), - userRespDTO -> itemRespVO.setNickname(userRespDTO.getNickname()))); - return success(pageResulVO); - } - - @PostMapping("/send") - @Operation(summary = "发送优惠劵") - @PreAuthorize("@ss.hasPermission('promotion:coupon:send')") - public CommonResult sendCoupon(@Valid @RequestBody CouponSendReqVO reqVO) { - couponService.takeCouponByAdmin(reqVO.getTemplateId(), reqVO.getUserIds()); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java deleted file mode 100755 index c94756049..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class CouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:create')") - public CommonResult createCouponTemplate(@Valid @RequestBody CouponTemplateCreateReqVO createReqVO) { - return success(couponTemplateService.createCouponTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplate(@Valid @RequestBody CouponTemplateUpdateReqVO updateReqVO) { - couponTemplateService.updateCouponTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新优惠劵模板状态") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplateStatus(@Valid @RequestBody CouponTemplateUpdateStatusReqVO reqVO) { - couponTemplateService.updateCouponTemplateStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除优惠劵模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:delete')") - public CommonResult deleteCouponTemplate(@RequestParam("id") Long id) { - couponTemplateService.deleteCouponTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得优惠劵模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult getCouponTemplate(@RequestParam("id") Long id) { - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(id); - return success(CouponTemplateConvert.INSTANCE.convert(couponTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模板分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplatePage(@Valid CouponTemplatePageReqVO pageVO) { - PageResult pageResult = couponTemplateService.getCouponTemplatePage(pageVO); - return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得优惠劵模板列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplateList(@RequestParam("ids") Collection ids) { - List list = couponTemplateService.getCouponTemplateList(ids); - return success(CouponTemplateConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java deleted file mode 100755 index 0d7459867..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponBaseVO { - - // ========== 基本信息 BEGIN ========== - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "优惠码状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "领取方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品范围编号的数组", example = "1,3") - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - - @Schema(description = "使用订单号", example = "4096") - private Long useOrderId; - - @Schema(description = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java deleted file mode 100755 index 118736ef6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵分页的每一项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageItemRespVO extends CouponRespVO { - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java deleted file mode 100755 index 75aa2f74b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵模板编号", example = "2048") - private Long templateId; - - @Schema(description = "优惠码状态", example = "1") - @InEnum(value = CouponStatusEnum.class, message = "优惠劵状态,必须是 {value}") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户昵称", example = "芋艿") - private String nickname; - - @Schema(description = "用户编号", example = "1") - private Collection userIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java deleted file mode 100755 index 7c0fa6c86..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponRespVO extends CouponBaseVO { - - @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java deleted file mode 100644 index bac879f9c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Set; - -@Schema(description = "管理后台 - 优惠劵发放 Request VO") -@Data -@ToString(callSuper = true) -public class CouponSendReqVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - - @Schema(description = "用户编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "用户编号列表不能为空") - private Set userIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java deleted file mode 100755 index 2529f79ac..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponTemplateBaseVO { - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量 - @NotNull(message = "发行总量不能为空") - private Integer totalCount; - - @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 - @NotNull(message = "每人限领个数不能为空") - private Integer takeLimitCount; - - @Schema(description = "领取方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品范围编号的数组", example = "[1, 3]") - private List productScopeValues; - - @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "生效日期类型不能为空") - @InEnum(CouponTemplateValidityTypeEnum.class) - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - - @AssertTrue(message = "商品范围编号的数组不能为空") - @JsonIgnore - public boolean isProductScopeValuesValid() { - return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 - || CollUtil.isNotEmpty(productScopeValues); - } - - @AssertTrue(message = "生效开始时间不能为空") - @JsonIgnore - public boolean isValidStartTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validStartTime != null; - } - - @AssertTrue(message = "生效结束时间不能为空") - @JsonIgnore - public boolean isValidEndTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validEndTime != null; - } - - @AssertTrue(message = "开始天数不能为空") - @JsonIgnore - public boolean isFixedStartTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedStartTerm != null; - } - - @AssertTrue(message = "结束天数不能为空") - @JsonIgnore - public boolean isFixedEndTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedEndTerm != null; - } - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - @AssertTrue(message = "折扣上限不能为空") - @JsonIgnore - public boolean isDiscountLimitPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || discountLimitPrice != null; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java deleted file mode 100755 index d9c5c326d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateCreateReqVO extends CouponTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java deleted file mode 100755 index 1dad778f5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplatePageReqVO extends PageParam { - - @Schema(description = "优惠劵名", example = "你好") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "优惠类型", example = "1") - private Integer discountType; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "可以领取的类型", example = "[1, 2, 3]") - @InEnum(value = CouponTakeTypeEnum.class, message = "可以领取的类型,必须是 {value}") - private List canTakeTypes; - - @Schema(description = "商品范围", example = "1") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}") - private Integer productScope; - - @Schema(description = "商品范围编号", example = "1") - private Long productScopeValue; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java deleted file mode 100755 index d2c9d710a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateRespVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "领取优惠券的数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer takeCount; - - @Schema(description = "使用优惠券的次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Integer useCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java deleted file mode 100755 index e57bf6209..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateUpdateReqVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java deleted file mode 100644 index a2234e3c5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新状态 Request VO") -@Data -public class CouponTemplateUpdateStatusReqVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java deleted file mode 100755 index 620e54c2b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 限时折扣活动") -@RestController -@RequestMapping("/promotion/discount-activity") -@Validated -public class DiscountActivityController { - - @Resource - private DiscountActivityService discountActivityService; - - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:create')") - public CommonResult createDiscountActivity(@Valid @RequestBody DiscountActivityCreateReqVO createReqVO) { - return success(discountActivityService.createDiscountActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:update')") - public CommonResult updateDiscountActivity(@Valid @RequestBody DiscountActivityUpdateReqVO updateReqVO) { - discountActivityService.updateDiscountActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - discountActivityService.closeDiscountActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:delete')") - public CommonResult deleteDiscountActivity(@RequestParam("id") Long id) { - discountActivityService.deleteDiscountActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得限时折扣活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult getDiscountActivity(@RequestParam("id") Long id) { - DiscountActivityDO discountActivity = discountActivityService.getDiscountActivity(id); - if (discountActivity == null) { - return success(null); - } - // 拼接结果 - List discountProducts = discountActivityService.getDiscountProductsByActivityId(id); - return success(DiscountActivityConvert.INSTANCE.convert(discountActivity, discountProducts)); - } - - @GetMapping("/page") - @Operation(summary = "获得限时折扣活动分页") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult> getDiscountActivityPage(@Valid DiscountActivityPageReqVO pageVO) { - PageResult pageResult = discountActivityService.getDiscountActivityPage(pageVO); - - if (CollUtil.isEmpty(pageResult.getList())) { // TODO @zhangshuai:方法里的空行,目的是让代码分块,可以更清晰;所以上面这个空格可以不要,而下面判断之后的,空格,其实加下比较好;类似的还有 spuList、以及后面的 convert - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接数据 - List products = discountActivityService.getDiscountProductsByActivityId( - convertSet(pageResult.getList(), DiscountActivityDO::getId)); - - List spuList = productSpuApi.getSpuList( - convertSet(products, DiscountProductDO::getSpuId)).getCheckedData(); - - return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult, products, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java deleted file mode 100755 index a72990531..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 限时折扣活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DiscountActivityBaseVO { - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "一个标题") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "备注", example = "我是备注") - private String remark; - - @Schema(description = "商品") - @Data - public static class Product { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java deleted file mode 100755 index 4da80a1b9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityCreateReqVO extends DiscountActivityBaseVO { - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java deleted file mode 100755 index 85a989c05..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityDetailRespVO extends DiscountActivityRespVO { - - /** - * 商品列表 - */ - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java deleted file mode 100755 index 4463555ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 限时折扣活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "一个标题") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java deleted file mode 100755 index 232454a98..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityRespVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") // TODO @zhangshuai:属性和属性之间,最多空一行噢; - private Long spuId; - - @Schema(description = "限时折扣商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - // ========== 商品字段 ========== - - // TODO @zhangshuai:一个优惠活动,会关联多个商品,所以它不用返回 spuName 哈; - // TODO 最终界面展示字段就:编号、活动名称、参与商品数、活动状态、开始时间、结束时间、操作 - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java deleted file mode 100755 index 83ff6d1e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java deleted file mode 100644 index 4da7064d0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 装修页面") -@RestController -@RequestMapping("/promotion/diy-page") -@Validated -public class DiyPageController { - - @Resource - private DiyPageService diyPageService; - - @PostMapping("/create") - @Operation(summary = "创建装修页面") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:create')") - public CommonResult createDiyPage(@Valid @RequestBody DiyPageCreateReqVO createReqVO) { - return success(diyPageService.createDiyPage(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新装修页面") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") - public CommonResult updateDiyPage(@Valid @RequestBody DiyPageUpdateReqVO updateReqVO) { - diyPageService.updateDiyPage(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除装修页面") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:diy-page:delete')") - public CommonResult deleteDiyPage(@RequestParam("id") Long id) { - diyPageService.deleteDiyPage(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得装修页面") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult getDiyPage(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(DiyPageConvert.INSTANCE.convert(diyPage)); - } - - @GetMapping("/list") - @Operation(summary = "获得装修页面列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult> getDiyPageList(@RequestParam("ids") Collection ids) { - List list = diyPageService.getDiyPageList(ids); - return success(DiyPageConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得装修页面分页") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult> getDiyPagePage(@Valid DiyPagePageReqVO pageVO) { - PageResult pageResult = diyPageService.getDiyPagePage(pageVO); - return success(DiyPageConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get-property") - @Operation(summary = "获得装修页面属性") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult getDiyPageProperty(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(DiyPageConvert.INSTANCE.convertPropertyVo(diyPage)); - } - - @PutMapping("/update-property") - @Operation(summary = "更新装修页面属性") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") - public CommonResult updateDiyPageProperty(@Valid @RequestBody DiyPagePropertyUpdateRequestVO updateReqVO) { - diyPageService.updateDiyPageProperty(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java deleted file mode 100644 index 2ec8f2ea0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 装修模板") -@RestController -@RequestMapping("/promotion/diy-template") -@Validated -public class DiyTemplateController { - - @Resource - private DiyTemplateService diyTemplateService; - @Resource - private DiyPageService diyPageService; - - @PostMapping("/create") - @Operation(summary = "创建装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:create')") - public CommonResult createDiyTemplate(@Valid @RequestBody DiyTemplateCreateReqVO createReqVO) { - return success(diyTemplateService.createDiyTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") - public CommonResult updateDiyTemplate(@Valid @RequestBody DiyTemplateUpdateReqVO updateReqVO) { - diyTemplateService.updateDiyTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/use") - @Operation(summary = "使用装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:use')") - public CommonResult useDiyTemplate(@RequestParam("id") Long id) { - diyTemplateService.useDiyTemplate(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除装修模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:diy-template:delete')") - public CommonResult deleteDiyTemplate(@RequestParam("id") Long id) { - diyTemplateService.deleteDiyTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得装修模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult getDiyTemplate(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - return success(DiyTemplateConvert.INSTANCE.convert(diyTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得装修模板分页") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult> getDiyTemplatePage(@Valid DiyTemplatePageReqVO pageVO) { - PageResult pageResult = diyTemplateService.getDiyTemplatePage(pageVO); - return success(DiyTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - // TODO @疯狂:这个要不和 getDiyTemplate 合并,然后 DiyTemplateRespVO 里面直接把 DiyPagePropertyRespVO 也加上。减少 VO 好了,管理后台 get 多返回点数据,也问题不大的。目的,还是想尽可能降低大家的理解成本哈; - @GetMapping("/get-property") - @Operation(summary = "获得装修模板属性") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult getDiyTemplateProperty(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - List pages = diyPageService.getDiyPageByTemplateId(id); - return success(DiyTemplateConvert.INSTANCE.convertPropertyVo(diyTemplate, pages)); - } - - // TODO @疯狂:这个接口,要不和 useDiyTemplate 合并成一个,然后 VO 改成我们新的 VO 规范。不改的字段,就不传递。 - @PutMapping("/update-property") - @Operation(summary = "更新装修模板属性") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") - public CommonResult updateDiyTemplateProperty(@Valid @RequestBody DiyTemplatePropertyUpdateRequestVO updateReqVO) { - diyTemplateService.updateDiyTemplateProperty(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java deleted file mode 100644 index 66186b1eb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 装修页面 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class DiyPageBaseVO { - - @Schema(description = "装修模板编号", example = "26179") - private Long templateId; - - @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "页面名称不能为空") - private String name; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "预览图") - private List previewPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java deleted file mode 100644 index 17d3b35cb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修页面创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageCreateReqVO extends DiyPageBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java deleted file mode 100644 index 5c81b9f93..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 装修页面分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPagePageReqVO extends PageParam { - - @Schema(description = "页面名称", example = "王五") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java deleted file mode 100644 index 2fdd54682..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修页面属性 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPagePropertyRespVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "页面属性", example = "[]") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java deleted file mode 100644 index ebfa36420..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修页面属性更新 Request VO") -@Data -@ToString(callSuper = true) -public class DiyPagePropertyUpdateRequestVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修页面编号不能为空") - private Long id; - - @Schema(description = "页面属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @NotBlank(message = "页面属性不能为空") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java deleted file mode 100644 index 9e2d9af86..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 装修页面 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageRespVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java deleted file mode 100644 index 9909b57f9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修页面更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageUpdateReqVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") - @NotNull(message = "装修页面编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java deleted file mode 100644 index 2f7769cbe..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -/** - * 装修模板 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class DiyTemplateBaseVO { - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - @NotEmpty(message = "模板名称不能为空") - private String name; - - @Schema(description = "备注", example = "默认主题") - private String remark; - - @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") - private List previewPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java deleted file mode 100644 index 659f9c590..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateCreateReqVO extends DiyTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java deleted file mode 100644 index 1099226f9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 装修模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplatePageReqVO extends PageParam { - - @Schema(description = "模板名称", example = "默认主题") - private String name; - - @Schema(description = "是否使用", example = "true") - private Boolean used; - - @Schema(description = "使用时间", example = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] usedTime; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java deleted file mode 100644 index 21dd46f3f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 装修模板属性 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplatePropertyRespVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - private String property; - - @Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") - private List pages; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java deleted file mode 100644 index 84b80f227..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修模板属性更新 Request VO") -@Data -@ToString(callSuper = true) -public class DiyTemplatePropertyUpdateRequestVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修模板编号不能为空") - private Long id; - - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @NotBlank(message = "模板属性不能为空") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java deleted file mode 100644 index e19089e6a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 装修模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateRespVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "是否使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean used; - - @Schema(description = "使用时间", example = "使用时间") - private LocalDateTime usedTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java deleted file mode 100644 index 887f2f9dd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateUpdateReqVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java deleted file mode 100755 index 7827fd114..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 满减送活动") -@RestController -@RequestMapping("/promotion/reward-activity") -@Validated -public class RewardActivityController { - - @Resource - private RewardActivityService rewardActivityService; - - @PostMapping("/create") - @Operation(summary = "创建满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:create')") - public CommonResult createRewardActivity(@Valid @RequestBody RewardActivityCreateReqVO createReqVO) { - return success(rewardActivityService.createRewardActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:update')") - public CommonResult updateRewardActivity(@Valid @RequestBody RewardActivityUpdateReqVO updateReqVO) { - rewardActivityService.updateRewardActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.closeRewardActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:delete')") - public CommonResult deleteRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.deleteRewardActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得满减送活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult getRewardActivity(@RequestParam("id") Long id) { - RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id); - return success(RewardActivityConvert.INSTANCE.convert(rewardActivity)); - } - - @GetMapping("/page") - @Operation(summary = "获得满减送活动分页") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult> getRewardActivityPage(@Valid RewardActivityPageReqVO pageVO) { - PageResult pageResult = rewardActivityService.getRewardActivityPage(pageVO); - return success(RewardActivityConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java deleted file mode 100755 index 01d1c80b3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Future; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 满减送活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class RewardActivityBaseVO { - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Future(message = "结束时间必须大于当前时间") - private LocalDateTime endTime; - - @Schema(description = "备注", example = "biubiubiu") - private String remark; - - @Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "条件类型不能为空") - @InEnum(value = PromotionConditionTypeEnum.class, message = "条件类型必须是 {value}") - private Integer conditionType; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围必须是 {value}") - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,2,3") - private List productSpuIds; - - /** - * 优惠规则的数组 - */ - @Valid // 校验下子对象 - private List rules; - - @Schema(description = "优惠规则") - @Data - public static class Rule { - - @Schema(description = "优惠门槛", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 1. 满 N 元,单位:分; 2. 满 N 件 - @Min(value = 1L, message = "优惠门槛必须大于等于 1") - private Integer limit; - - @Schema(description = "优惠价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @Min(value = 1L, message = "优惠价格必须大于等于 1") - private Integer discountPrice; - - @Schema(description = "是否包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean freeDelivery; - - @Schema(description = "赠送的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @Min(value = 1L, message = "赠送的积分必须大于等于 1") - private Integer point; - - @Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3") - private List couponIds; - - @Schema(description = "赠送的优惠券数量的数组", example = "1,2,3") - private List couponCounts; - - @AssertTrue(message = "优惠劵和数量必须一一对应") - @JsonIgnore - public boolean isCouponCountsValid() { - return CollUtil.size(couponCounts) == CollUtil.size(couponCounts); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java deleted file mode 100755 index 0710e46a4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 满减送活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityCreateReqVO extends RewardActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java deleted file mode 100755 index 7052c9c66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 满减送活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "满啦满啦") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java deleted file mode 100755 index 67bf12153..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 满减送活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityRespVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java deleted file mode 100755 index 3185ec81d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 满减送活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityUpdateReqVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java deleted file mode 100644 index 623697fba..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class SeckillActivityController { - - @Resource - private SeckillActivityService seckillActivityService; - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:create')") - public CommonResult createSeckillActivity(@Valid @RequestBody SeckillActivityCreateReqVO createReqVO) { - return success(seckillActivityService.createSeckillActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:update')") - public CommonResult updateSeckillActivity(@Valid @RequestBody SeckillActivityUpdateReqVO updateReqVO) { - seckillActivityService.updateSeckillActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭秒杀活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.closeSeckillActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除秒杀活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:delete')") - public CommonResult deleteSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.deleteSeckillActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得秒杀活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - SeckillActivityDO activity = seckillActivityService.getSeckillActivity(id); - List products = seckillActivityService.getSeckillProductListByActivityId(id); - return success(SeckillActivityConvert.INSTANCE.convert(activity, products)); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀活动分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillActivityPageReqVO pageVO) { - // 查询活动列表 - PageResult pageResult = seckillActivityService.getSeckillActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List products = seckillActivityService.getSeckillProductListByActivityId( - convertSet(pageResult.getList(), SeckillActivityDO::getId)); - List spuList = productSpuApi.getSpuList( - convertSet(pageResult.getList(), SeckillActivityDO::getSpuId)).getCheckedData(); - return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, products, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java deleted file mode 100644 index 56d6db2e8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 秒杀时段") -@RestController -@RequestMapping("/promotion/seckill-config") -@Validated -public class SeckillConfigController { - - @Resource - private SeckillConfigService seckillConfigService; - - @PostMapping("/create") - @Operation(summary = "创建秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:create')") - public CommonResult createSeckillConfig(@Valid @RequestBody SeckillConfigCreateReqVO createReqVO) { - return success(seckillConfigService.createSeckillConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:update')") - public CommonResult updateSeckillConfig(@Valid @RequestBody SeckillConfigUpdateReqVO updateReqVO) { - seckillConfigService.updateSeckillConfig(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "修改时段配置状态") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:update')") - public CommonResult updateSeckillConfigStatus(@Valid @RequestBody SeckillConfigUpdateStatusReqVo reqVO) { - seckillConfigService.updateSeckillConfigStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除秒杀时段") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:delete')") - public CommonResult deleteSeckillConfig(@RequestParam("id") Long id) { - seckillConfigService.deleteSeckillConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得秒杀时段") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult getSeckillConfig(@RequestParam("id") Long id) { - SeckillConfigDO seckillConfig = seckillConfigService.getSeckillConfig(id); - return success(SeckillConfigConvert.INSTANCE.convert(seckillConfig)); - } - - @GetMapping("/list") - @Operation(summary = "获得所有秒杀时段列表") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult> getSeckillConfigList() { - List list = seckillConfigService.getSeckillConfigList(); - return success(SeckillConfigConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得所有开启状态的秒杀时段精简列表", description = "主要用于前端的下拉选项") - public CommonResult> getListAllSimple() { - List list = seckillConfigService.getSeckillConfigListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(SeckillConfigConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀时间段分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillConfigPageReqVO pageVO) { - PageResult pageResult = seckillConfigService.getSeckillConfigPage(pageVO); - return success(SeckillConfigConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java deleted file mode 100644 index 8aada5a1f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 秒杀活动基地签证官 - * 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillActivityBaseVO { - - @Schema(description = "秒杀活动商品 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "[121,1212]") - @NotNull(message = "秒杀活动商品不能为空") - private Long spuId; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") - @NotNull(message = "秒杀活动名称不能为空") - private String name; - - @Schema(description = "备注", example = "清仓大甩卖割韭菜") - private String remark; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "秒杀时段 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2,3]") - @NotNull(message = "秒杀时段不能为空") - private List configIds; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "12877") - private Integer totalLimitCount; - - @Schema(description = "单次限够数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "31683") - private Integer singleLimitCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java deleted file mode 100644 index 9b6e7291a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java deleted file mode 100644 index c3cc2ebf0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动的详细 Response VO") -@Data -@ToString(callSuper = true) -public class SeckillActivityDetailRespVO extends SeckillActivityBaseVO{ - - @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java deleted file mode 100644 index ac634a7b2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@Schema(description = "管理后台 - 秒杀活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityPageReqVO extends PageParam { - - @Schema(description = "秒杀活动名称", example = "晚九点限时秒杀") - private String name; - - @Schema(description = "活动状态", example = "进行中") - private Integer status; - - @Schema(description = "秒杀时段id", example = "1") - private Long configId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java deleted file mode 100644 index 742c73ba6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityRespVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "订单实付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22354") - private Integer totalPrice; - - @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer stock; - - @Schema(description = "秒杀总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer totalStock; - - @Schema(description = "新增订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer orderCount; - - @Schema(description = "付款人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer userCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 商品字段 ========== - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java deleted file mode 100644 index bf2ca35bb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java deleted file mode 100644 index 78a1c51df..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import java.time.LocalTime; -import java.util.List; - -/** - * 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillConfigBaseVO { - - @Schema(description = "秒杀时段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "早上场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") - @NotNull(message = "开始时间点不能为空") - private String startTime; - - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00") - @NotNull(message = "结束时间点不能为空") - private String endTime; - - @Schema(description = "秒杀轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @NotNull(message = "秒杀轮播图不能为空") - private List sliderPicUrls; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - - @AssertTrue(message = "秒杀时段开始时间和结束时间不能相等") - @JsonIgnore - public boolean isValidStartTimeValid() { - return !LocalTime.parse(startTime).equals(LocalTime.parse(endTime)); - } - - @AssertTrue(message = "秒杀时段开始时间不能在结束时间之后") - @JsonIgnore - public boolean isValidEndTimeValid() { - return !LocalTime.parse(startTime).isAfter(LocalTime.parse(endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java deleted file mode 100644 index 979ee699d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 秒杀时段创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigCreateReqVO extends SeckillConfigBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java deleted file mode 100644 index 92211385a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 秒杀时段分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigPageReqVO extends PageParam { - - @Schema(description = "秒杀时段名称", example = "上午场") - private String name; - - @Schema(description = "状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java deleted file mode 100644 index 5411536c9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 秒杀时段 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigRespVO extends SeckillConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀活动数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillActivityCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java deleted file mode 100644 index 069f39e31..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 秒杀时段配置精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class SeckillConfigSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "秒杀时段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "早上场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") - private String startTime; - - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00") - private String endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java deleted file mode 100644 index 5b11dc4fc..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 秒杀时段更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigUpdateReqVO extends SeckillConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java deleted file mode 100644 index 0547cb1de..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 修改时段配置状态 Request VO") -@Data -public class SeckillConfigUpdateStatusReqVo { - - @Schema(description = "时段配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "时段配置编号不能为空") - private Long id; - - @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java deleted file mode 100644 index 6584b79cb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 秒杀参与商品 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillProductBaseVO { - - @Schema(description = "商品sku_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品sku_id不能为空") - private Long skuId; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "6689") - @NotNull(message = "秒杀金额,单位:分不能为空") - private Integer seckillPrice; - - @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "秒杀库存不能为空") - private Integer stock; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java deleted file mode 100644 index 96b7eec4c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 秒杀参与商品 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillProductRespVO extends SeckillProductBaseVO { - - @Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http deleted file mode 100644 index 0dda88c7d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http +++ /dev/null @@ -1,5 +0,0 @@ -### /promotion/activity/list-by-spu-ids 获得多个商品,近期参与的每个活动 -GET {{appApi}}/promotion/activity/list-by-spu-ids?spuIds=222&spuIds=633 -Authorization: Bearer {{appToken}} -Content-Type: application/json -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java deleted file mode 100644 index 38dd72ba3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.activity; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "用户 APP - 营销活动") // 用于提供跨多个活动的 HTTP 接口 -@RestController -@RequestMapping("/promotion/activity") -@Validated -public class AppActivityController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private SeckillActivityService seckillActivityService; - @Resource - private BargainActivityService bargainActivityService; - @Resource - private DiscountActivityService discountActivityService; - @Resource - private RewardActivityService rewardActivityService; - - @GetMapping("/list-by-spu-id") - @Operation(summary = "获得单个商品,近期参与的每个活动") - @Parameter(name = "spuId", description = "商品编号", required = true) - public CommonResult> getActivityListBySpuId(@RequestParam("spuId") Long spuId) { - // 每种活动,只返回一个 - return success(getAppActivityList(Collections.singletonList(spuId))); - } - - @GetMapping("/list-by-spu-ids") - @Operation(summary = "获得多个商品,近期参与的每个活动") - @Parameter(name = "spuIds", description = "商品编号数组", required = true) - public CommonResult>> getActivityListBySpuIds(@RequestParam("spuIds") List spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return success(MapUtil.empty()); - } - // 每种活动,只返回一个;key 为 SPU 编号 - return success(convertMultiMap(getAppActivityList(spuIds), AppActivityRespVO::getSpuId)); - } - - private List getAppActivityList(Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return new ArrayList<>(); - } - // 获取开启的且开始的且没有结束的活动 - List activityList = new ArrayList<>(); - LocalDateTime now = LocalDateTime.now(); - // 1. 拼团活动 - getCombinationActivities(spuIds, now, activityList); - // 2. 秒杀活动 - getSeckillActivities(spuIds, now, activityList); - // 3. 砍价活动 - getBargainActivities(spuIds, now, activityList); - // 4. 限时折扣活动 - getDiscountActivities(spuIds, now, activityList); - // 5. 满减送活动 - getRewardActivities(spuIds, now, activityList); - return activityList; - } - - private void getCombinationActivities(Collection spuIds, LocalDateTime now, List activityList) { - List combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isEmpty(combinationActivities)) { - return; - } - - combinationActivities.forEach(item -> { - activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(), - item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime())); - }); - } - - private void getSeckillActivities(Collection spuIds, LocalDateTime now, List activityList) { - List seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isEmpty(seckillActivities)) { - return; - } - - seckillActivities.forEach(item -> { - activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(), - item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime())); - }); - } - - private void getBargainActivities(Collection spuIds, LocalDateTime now, List activityList) { - List bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isNotEmpty(bargainActivities)) { - return; - } - - bargainActivities.forEach(item -> { - activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(), - item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime())); - }); - } - - private void getDiscountActivities(Collection spuIds, LocalDateTime now, List activityList) { - List discountActivities = discountActivityService.getDiscountActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isEmpty(discountActivities)) { - return; - } - - List products = discountActivityService.getDiscountProductsByActivityId( - convertSet(discountActivities, DiscountActivityDO::getId)); - Map productMap = convertMap(products, DiscountProductDO::getActivityId, DiscountProductDO::getSpuId); - discountActivities.forEach(item -> activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), - item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime()))); - } - - private void getRewardActivities(Collection spuIds, LocalDateTime now, List activityList) { - // TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部 - List rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now); - if (CollUtil.isEmpty(rewardActivityList)) { - return; - } - - Map> spuIdAndActivityMap = spuIds.stream() - .collect(Collectors.toMap( - spuId -> spuId, - spuId -> rewardActivityList.stream() - .filter(activity -> activity.getProductSpuIds().contains(spuId)) - .max(Comparator.comparing(RewardActivityDO::getCreateTime)))); - for (Long supId : spuIdAndActivityMap.keySet()) { - if (!spuIdAndActivityMap.get(supId).isPresent()) { - continue; - } - - RewardActivityDO rewardActivityDO = spuIdAndActivityMap.get(supId).get(); - activityList.add(new AppActivityRespVO(rewardActivityDO.getId(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - rewardActivityDO.getName(), supId, rewardActivityDO.getStartTime(), rewardActivityDO.getEndTime())); - } - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java deleted file mode 100644 index 6a67a669d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.activity.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 营销活动 Response VO") -@AllArgsConstructor -@NoArgsConstructor -@Data -public class AppActivityRespVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "活动类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; // 对应 PromotionTypeEnum 枚举 - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大促") - private String name; - - @Schema(description = "spu 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "618") - private Long spuId; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java deleted file mode 100644 index 482b497d9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 文章分类") -@RestController -@RequestMapping("/promotion/article-category") -@Validated -public class AppArticleCategoryController { - - @Resource - private ArticleCategoryService articleCategoryService; - - @RequestMapping("/list") - @Operation(summary = "获得文章分类列表") - public CommonResult> getArticleCategoryList() { - List categoryList = articleCategoryService.getArticleCategoryListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - categoryList.sort(Comparator.comparing(ArticleCategoryDO::getSort)); // 按 sort 降序排列 - return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java deleted file mode 100644 index a318bfd8a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 文章") -@RestController -@RequestMapping("/promotion/article") -@Validated -public class AppArticleController { - - @Resource - private ArticleService articleService; - - @RequestMapping("/list") - @Operation(summary = "获得文章详情列表") - @Parameters({ - @Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章 - @Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章 - }) - public CommonResult> getArticleList( - @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, - @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { - return success(ArticleConvert.INSTANCE.convertList03( - articleService.getArticleCategoryListByRecommend(recommendHot, recommendBanner))); - } - - @RequestMapping("/page") - @Operation(summary = "获得文章详情分页") - public CommonResult> getArticlePage(AppArticlePageReqVO pageReqVO) { - return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO))); - } - - @RequestMapping("/get") - @Operation(summary = "获得文章详情") - @Parameters({ - @Parameter(name = "id", description = "文章编号", example = "1024"), - @Parameter(name = "title", description = "文章标题", example = "1024"), - }) - public CommonResult getArticle(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "title", required = false) String title) { - ArticleDO article = id != null ? articleService.getArticle(id) - : articleService.getLastArticleByTitle(title); - return success(BeanUtils.toBean(article, AppArticleRespVO.class)); - } - - @PutMapping("/add-browse-count") - @Operation(summary = "增加文章浏览量") - @Parameter(name = "id", description = "文章编号", example = "1024") - public CommonResult addBrowseCount(@RequestParam("id") Long id) { - articleService.addArticleBrowseCount(id); - return success(true); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java deleted file mode 100644 index f548ae9bd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 文章的分页 Request VO") -@Data -public class AppArticlePageReqVO extends PageParam { - - @Schema(description = "分类编号", example = "2048") - private Long categoryId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java deleted file mode 100644 index 2c77fdc34..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "应用 App - 文章 Response VO") -@Data -public class AppArticleRespVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码 - 促销模块") - private String title; - - @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String author; - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long categoryId; - - @Schema(description = "图文封面", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是简介") - private String introduction; - - @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是详细") - private String content; - - @Schema(description = "发布时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer browseCount; - - @Schema(description = "关联的商品 SPU 编号", example = "1024") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java deleted file mode 100644 index e0f34e95d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 文章分类 Response VO") -@Data -public class AppArticleCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "技术") - private String name; - - @Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java deleted file mode 100644 index 4ccaa2c12..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController -@RequestMapping("/promotion/banner") -@Tag(name = "用户 APP - 首页 Banner") -@Validated -public class AppBannerController { - - @Resource - private BannerService bannerService; - - @GetMapping("/list") - @Operation(summary = "获得 banner 列表") - @Parameter(name = "position", description = "Banner position", example = "1") - public CommonResult> getBannerList(@RequestParam("position") Integer position) { - List bannerList = bannerService.getBannerListByPosition(position); - return success(BannerConvert.INSTANCE.convertList01(bannerList)); - } - - @PutMapping("/add-browse-count") - @Operation(summary = "增加 Banner 点击量") - @Parameter(name = "id", description = "Banner 编号", example = "1024") - public CommonResult addBrowseCount(@RequestParam("id") Long id) { - bannerService.addBannerBrowseCount(id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java deleted file mode 100644 index cc36d87d4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - Banner Response VO") -@Data -public class AppBannerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "图片地址不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java deleted file mode 100644 index 47a7fdcc4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "用户 App - 砍价活动") -@RestController -@RequestMapping("/promotion/bargain-activity") -@Validated -public class AppBargainActivityController { - - /** - * {@link AppBargainActivityRespVO} 缓存,通过它异步刷新 {@link #getBargainActivityList0(Integer)} 所要的首页数据 - */ - private final LoadingCache> bargainActivityListCache = buildCache(Duration.ofSeconds(10L), - new CacheLoader>() { - - @Override - public List load(Integer count) { - return getBargainActivityList0(count); - } - - }); - - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainRecordService bargainRecordService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/list") - @Operation(summary = "获得砍价活动列表", description = "用于小程序首页") - @Parameter(name = "count", description = "需要展示的数量", example = "6") - public CommonResult> getBargainActivityList( - @RequestParam(name = "count", defaultValue = "6") Integer count) { - return success(bargainActivityListCache.getUnchecked(count)); - } - - private ListgetBargainActivityList0(Integer count) { - List list = bargainActivityService.getBargainActivityListByCount(count); - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId)).getCheckedData(); - return BargainActivityConvert.INSTANCE.convertAppList(list, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得砍价活动分页") - public CommonResult> getBargainActivityPage(PageParam pageReqVO) { - PageResult result = bargainActivityService.getBargainActivityPage(pageReqVO); - if (CollUtil.isEmpty(result.getList())) { - return success(PageResult.empty(result.getTotal())); - } - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(result.getList(), BargainActivityDO::getSpuId)).getCheckedData(); - return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得砍价活动详情") - @Parameter(name = "id", description = "活动编号", example = "1") - public CommonResult getBargainActivityDetail(@RequestParam("id") Long id) { - BargainActivityDO activity = bargainActivityService.getBargainActivity(id); - if (activity == null) { - return success(null); - } - // 拼接数据 - Integer successUserCount = bargainRecordService.getBargainRecordUserCount(id, BargainRecordStatusEnum.SUCCESS.getStatus()); - ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId()).getCheckedData(); - return success(BargainActivityConvert.INSTANCE.convert(activity, successUserCount, spu)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http deleted file mode 100644 index 2e401e9d6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http +++ /dev/null @@ -1,9 +0,0 @@ -### /promotion/bargain-record/create 创建砍价助力 -POST {{appApi}}/promotion/bargain-help/create -Authorization: Bearer test248 -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "recordId": 26 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java deleted file mode 100644 index 48d19ff7f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 砍价助力") -@RestController -@RequestMapping("/promotion/bargain-help") -@Validated -public class AppBargainHelpController { - - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @PostMapping("/create") - @Operation(summary = "创建砍价助力", description = "给拼团记录砍一刀") // 返回结果为砍价金额,单位:分 - public CommonResult createBargainHelp(@RequestBody AppBargainHelpCreateReqVO reqVO) { - BargainHelpDO help = bargainHelpService.createBargainHelp(getLoginUserId(), reqVO); - return success(help.getReducePrice()); - } - - @GetMapping("/list") - @Operation(summary = "获得砍价助力列表") - @Parameter(name = "recordId", description = "砍价记录编号", required = true, example = "111") - public CommonResult> getBargainHelpList(@RequestParam("recordId") Long recordId) { - List helps = bargainHelpService.getBargainHelpListByRecordId(recordId); - if (CollUtil.isEmpty(helps)) { - return success(Collections.emptyList()); - } - helps.sort((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())); // 倒序展示 - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(helps, BargainHelpDO::getUserId)); - return success(BargainHelpConvert.INSTANCE.convertList(helps, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http deleted file mode 100644 index 46cbe3c8e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http +++ /dev/null @@ -1,9 +0,0 @@ -### /promotion/bargain-record/create 创建砍价记录 -POST {{appApi}}/promotion/bargain-record/create -Authorization: Bearer {{appToken}} -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "activityId": 1 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java deleted file mode 100644 index 5cf3a38df..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 砍价记录") -@RestController -@RequestMapping("/promotion/bargain-record") -@Validated -public class AppBargainRecordController { - - @Resource - private BargainHelpService bargainHelpService; - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - - @Resource - private TradeOrderApi tradeOrderApi; - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/get-summary") - @Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页") - public CommonResult getBargainRecordSummary() { - // 砍价成功的用户数量 - Integer successUserCount = bargainRecordService.getBargainRecordUserCount( - BargainRecordStatusEnum.SUCCESS.getStatus()); - if (successUserCount == 0) { - return success(new AppBargainRecordSummaryRespVO().setSuccessUserCount(0) - .setSuccessList(Collections.emptyList())); - } - // 砍价成功的用户列表 - List successList = bargainRecordService.getBargainRecordList( - BargainRecordStatusEnum.SUCCESS.getStatus(), 7); - List activityList = bargainActivityService.getBargainActivityList( - convertSet(successList, BargainRecordDO::getActivityId)); - Map userMap = memberUserApi.getUserMap( - convertSet(successList, BargainRecordDO::getUserId)); - // 拼接返回 - return success(BargainRecordConvert.INSTANCE.convert(successUserCount, successList, activityList, userMap)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得砍价记录的明细") - @Parameters({ - @Parameter(name = "id", description = "砍价记录编号", example = "111"), // 场景一:查看指定的砍价记录 - @Parameter(name = "activityId", description = "砍价活动编号", example = "222") // 场景二:查看指定的砍价活动 - }) - public CommonResult getBargainRecordDetail( - @RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "activityId", required = false) Long activityId) { - // 1. 查询砍价记录 + 砍价活动 - Assert.isTrue(id != null || activityId != null, "砍价记录编号和活动编号不能同时为空"); - BargainRecordDO record = id != null ? bargainRecordService.getBargainRecord(id) - : bargainRecordService.getLastBargainRecord(getLoginUserId(), activityId); - if (activityId == null || record != null) { - activityId = record.getActivityId(); - } - // 2. 查询助力记录 - Long userId = getLoginUserId(); - Integer helpAction = getHelpAction(userId, record, activityId); - // 3. 如果是自己的订单,则查询订单信息 - TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId()) - ? tradeOrderApi.getOrder(record.getOrderId()).getCheckedData() : null; - // TODO 继续查询别的字段 - - // 拼接返回 - return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction, order)); - } - - private Integer getHelpAction(Long userId, BargainRecordDO record, Long activityId) { - // 0.1 如果没有活动,无法帮砍 - if (activityId == null) { - return null; - } - // 0.2 如果是自己的砍价记录,无法帮砍 - if (record != null && record.getUserId().equals(userId)) { - return null; - } - - // 1. 判断是否已经助力 - if (record != null - && bargainHelpService.getBargainHelp(record.getId(), userId) != null) { - return AppBargainRecordDetailRespVO.HELP_ACTION_SUCCESS; - } - // 2. 判断是否满助力 - BargainActivityDO activity = bargainActivityService.getBargainActivity(activityId); - if (activity != null - && bargainHelpService.getBargainHelpCountByActivity(activityId, userId) >= activity.getBargainCount()) { - return AppBargainRecordDetailRespVO.HELP_ACTION_FULL; - } - // 3. 允许助力 - return AppBargainRecordDetailRespVO.HELP_ACTION_NONE; - } - - @GetMapping("/page") - @Operation(summary = "获得砍价记录的分页") - public CommonResult> getBargainRecordPage(PageParam pageParam) { - PageResult pageResult = bargainRecordService.getBargainRecordPage(getLoginUserId(), pageParam); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List activityList = bargainActivityService.getBargainActivityList( - convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); - List spuList = productSpuApi.getSpuList( - convertSet(pageResult.getList(), BargainRecordDO::getSpuId)).getCheckedData(); - List orderList = tradeOrderApi.getOrderList( - convertSet(pageResult.getList(), BargainRecordDO::getOrderId)).getCheckedData(); - return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList)); - } - - @PostMapping("/create") - @Operation(summary = "创建砍价记录", description = "参与砍价活动") - @PreAuthenticated - public CommonResult createBargainRecord(@RequestBody AppBargainRecordCreateReqVO reqVO) { - Long recordId = bargainRecordService.createBargainRecord(getLoginUserId(), reqVO); - return success(recordId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java deleted file mode 100644 index 78322f49e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价活动的明细 Response VO") -@Data -public class AppBargainActivityDetailRespVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大砍价") - private String name; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long skuId; - - @Schema(description = "商品价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "商品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我要吃西红柿") - private String description; - - @Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer stock; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") // 从 SPU 的 picUrl 读取 - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") // 从 SPU 的 marketPrice 读取 - private Integer marketPrice; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer bargainFirstPrice; - - @Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer bargainMinPrice; - - @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer successUserCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java deleted file mode 100644 index f6e0193a5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价活动 Response VO") -@Data -public class AppBargainActivityRespVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大砍价") - private String name; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long skuId; - - @Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer stock; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "4096") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - @Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer bargainMinPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java deleted file mode 100644 index 369926677..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 砍价助力的创建 Request VO") -@Data -public class AppBargainHelpCreateReqVO { - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "砍价记录编号不能为空") - private Long recordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java deleted file mode 100644 index c7bb20fea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价助力 Response VO") -@Data -public class AppBargainHelpRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "助力用户的昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String nickname; - - @Schema(description = "助力用户的头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String avatar; - - @Schema(description = "助力用户的砍价金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer reducePrice; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java deleted file mode 100644 index cc1e448dd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 砍价记录的创建 Request VO") -@Data -public class AppBargainRecordCreateReqVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "砍价活动编号不能为空") - private Long activityId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java deleted file mode 100644 index 2f408b2c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 砍价记录的明细 Response VO") -@Data -public class AppBargainRecordDetailRespVO { - - public static final int HELP_ACTION_NONE = 1; // 帮砍动作 - 未帮砍,可以帮砍 - public static final int HELP_ACTION_FULL = 2; // 帮砍动作 - 未帮砍,无法帮砍(可帮砍次数已满) - public static final int HELP_ACTION_SUCCESS = 3; // 帮砍动作 - 已帮砍 - - // ========== 砍价记录 ========== - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Long userId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long skuId; - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private Long activityId; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer bargainFirstPrice; - - @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer bargainPrice; - - @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - // ========== 订单相关 ========== 注意:只有是自己的砍价记录,才会返回,保证隐私性 - - @Schema(description = "订单编号", example = "1024") - private Long orderId; - - @Schema(description = "支付状态", example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "1024") - private Long payOrderId; - - // ========== 助力记录 ========== - - private Integer helpAction; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java deleted file mode 100644 index 6aa6cd909..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价记录的 Response VO") -@Data -public class AppBargainRecordRespVO { - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long skuId; - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long activityId; - - @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "当前价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "102") - private Integer bargainPrice; - - // ========== 活动相关 ========== - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String activityName; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - // ========== 订单相关 ========== - - @Schema(description = "订单编号", example = "1024") - private Long orderId; - - @Schema(description = "支付状态", example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "1024") - private Long payOrderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java deleted file mode 100644 index 8523e00a0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 砍价记录的简要概括 Response VO") -@Data -public class AppBargainRecordSummaryRespVO { - - @Schema(description = "砍价用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer successUserCount; - - @Schema(description = "成功砍价的记录", requiredMode = Schema.RequiredMode.REQUIRED) // 只返回最近的 7 个 - private List successList; - - @Schema(description = "成功砍价记录") - @Data - public static class Record { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "天蚕土豆") - private String activityName; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java deleted file mode 100644 index b311f05c0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "用户 APP - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-activity") -@Validated -public class AppCombinationActivityController { - - /** - * {@link AppCombinationActivityRespVO} 缓存,通过它异步刷新 {@link #getCombinationActivityList0(Integer)} 所要的首页数据 - */ - private final LoadingCache> combinationActivityListCache = buildCache(Duration.ofSeconds(10L), - new CacheLoader>() { - - @Override - public List load(Integer count) { - return getCombinationActivityList0(count); - } - - }); - - @Resource - private CombinationActivityService activityService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/list") - @Operation(summary = "获得拼团活动列表", description = "用于小程序首页") - @Parameter(name = "count", description = "需要展示的数量", example = "6") - public CommonResult> getCombinationActivityList( - @RequestParam(name = "count", defaultValue = "6") Integer count) { - return success(combinationActivityListCache.getUnchecked(count)); - } - - private List getCombinationActivityList0(Integer count) { - List activityList = activityService.getCombinationActivityListByCount(count); - if (CollUtil.isEmpty(activityList)) { - return Collections.emptyList(); - } - // 拼接返回 - List productList = activityService.getCombinationProductListByActivityIds( - convertList(activityList, CombinationActivityDO::getId)); - List spuList = spuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId)).getCheckedData(); - return CombinationActivityConvert.INSTANCE.convertAppList(activityList, productList, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得拼团活动分页") - public CommonResult> getCombinationActivityPage(PageParam pageParam) { - PageResult pageResult = activityService.getCombinationActivityPage(pageParam); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接返回 - List productList = activityService.getCombinationProductListByActivityIds( - convertList(pageResult.getList(), CombinationActivityDO::getId)); - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), CombinationActivityDO::getSpuId)).getCheckedData(); - return success(CombinationActivityConvert.INSTANCE.convertAppPage(pageResult, productList, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得拼团活动明细") - @Parameter(name = "id", description = "活动编号", required = true, example = "1024") - public CommonResult getCombinationActivityDetail(@RequestParam("id") Long id) { - // 1. 获取活动 - CombinationActivityDO activity = activityService.getCombinationActivity(id); - if (activity == null - || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - return success(null); - } - - // 2. 获取活动商品 - List products = activityService.getCombinationProductsByActivityId(activity.getId()); - return success(CombinationActivityConvert.INSTANCE.convert3(activity, products)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java deleted file mode 100644 index 7901eb1db..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import javax.validation.constraints.Max; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-record") -@Validated -public class AppCombinationRecordController { - - @Resource - private CombinationRecordService combinationRecordService; - @Resource - @Lazy - private TradeOrderApi tradeOrderApi; - - @GetMapping("/get-summary") - @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") - public CommonResult getCombinationRecordSummary() { - AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); - // 1. 获得拼团参与用户数量 - Long userCount = combinationRecordService.getCombinationUserCount(); - if (userCount == 0) { - summary.setAvatars(Collections.emptyList()); - summary.setUserCount(userCount); - return success(summary); - } - summary.setUserCount(userCount); - - // 2. 获得拼团记录头像 - List records = combinationRecordService.getLatestCombinationRecordList( - AppCombinationRecordSummaryRespVO.AVATAR_COUNT); - summary.setAvatars(convertList(records, CombinationRecordDO::getAvatar)); - return success(summary); - } - - @GetMapping("/get-head-list") - @Operation(summary = "获得最近 n 条拼团记录(团长发起的)") - @Parameters({ - @Parameter(name = "activityId", description = "拼团活动编号"), - @Parameter(name = "status", description = "拼团状态"), // 对应 CombinationRecordStatusEnum 枚举 - @Parameter(name = "count", description = "数量") - }) - public CommonResult> getHeadCombinationRecordList( - @RequestParam(value = "activityId", required = false) Long activityId, - @RequestParam("status") Integer status, - @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { - List list = combinationRecordService.getHeadCombinationRecordList(activityId, status, count); - return success(BeanUtils.toBean(list, AppCombinationRecordRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得我的拼团记录分页") - @PreAuthenticated - public CommonResult> getCombinationRecordPage( - @Valid AppCombinationRecordPageReqVO pageReqVO) { - PageResult pageResult = combinationRecordService.getCombinationRecordPage( - getLoginUserId(), pageReqVO); - return success(BeanUtils.toBean(pageResult, AppCombinationRecordRespVO.class)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得拼团记录明细") - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") - public CommonResult getCombinationRecordDetail(@RequestParam("id") Long id) { - // 1. 查找这条拼团记录 - CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id); - if (record == null) { - return success(null); - } - - // 2. 查找该拼团的参团记录 - CombinationRecordDO headRecord; - List memberRecords; - if (Objects.equals(record.getHeadId(), CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 - headRecord = record; - memberRecords = combinationRecordService.getCombinationRecordListByHeadId(record.getId()); - } else { // 情况二:团员 - headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId()); - memberRecords = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId()); - } - - // 3. 拼接数据 - return success(CombinationActivityConvert.INSTANCE.convert(getLoginUserId(), headRecord, memberRecords)); - } - - @GetMapping("/cancel") - @Operation(summary = "取消拼团") - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") - public CommonResult cancelCombinationRecord(@RequestParam("id") Long id) { - Long userId = getLoginUserId(); - // 1、查找这条拼团记录 - CombinationRecordDO record = combinationRecordService.getCombinationRecordByIdAndUser(userId, id); - if (record == null) { - return success(Boolean.FALSE); - } - // 1.1、需要先校验拼团记录未完成; - if (!CombinationRecordStatusEnum.isInProgress(record.getStatus())) { - return success(Boolean.FALSE); - } - - // 2. 取消已支付的订单 - tradeOrderApi.cancelPaidOrder(userId, record.getOrderId()); - // 3. 取消拼团记录 - combinationRecordService.cancelCombinationRecord(userId, record.getId(), record.getHeadId()); - return success(Boolean.TRUE); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java deleted file mode 100644 index e2996b89b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 拼团活动明细 Response VO") -@Data -public class AppCombinationActivityDetailRespVO { - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大拼团") - private String name; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "拼团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer userSize; - - @Schema(description = "成功的拼团数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer successCount; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "总共限购数量", example = "10") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", example = "5") - private Integer singleLimitCount; - - @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "商品信息") - @Data - public static class Product { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private Long skuId; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java deleted file mode 100644 index 64462a377..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 拼团活动 Response VO") -@Data -public class AppCombinationActivityRespVO { - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大拼团") - private String name; - - @Schema(description = "拼团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer userSize; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - // 从 SPU 的 picUrl 读取 - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - // 从 SPU 的 marketPrice 读取 - private Integer marketPrice; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java deleted file mode 100644 index 7c310a670..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 拼团记录详细 Response VO") -@Data -public class AppCombinationRecordDetailRespVO { - - @Schema(description = "团长的拼团记录", requiredMode = Schema.RequiredMode.REQUIRED) - private AppCombinationRecordRespVO headRecord; - - @Schema(description = "成员的拼团记录", requiredMode = Schema.RequiredMode.REQUIRED) - private List memberRecords; - - @Schema(description = "当前用户参团记录对应的订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java deleted file mode 100644 index 7f7169bb9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCombinationRecordPageReqVO extends PageParam { - - @Schema(description = "拼团状态", example = "1") - @InEnum(value = CombinationRecordStatusEnum.class, message = "拼团状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java deleted file mode 100644 index 8e4496a66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 拼团记录 Response VO") -@Data -public class AppCombinationRecordRespVO { - - @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long activityId; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String avatar; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime expireTime; - - @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer userSize; - - @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer userCount; - - @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long orderId; - - @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") - private String spuName; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer count; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java deleted file mode 100644 index d9ea03d6f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 拼团记录的简要概括 Response VO") -@Data -public class AppCombinationRecordSummaryRespVO { - - /** - * 加载 {@link #avatars} 的数量 - */ - public static final Integer AVATAR_COUNT = 7; - - @Schema(description = "拼团用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userCount; - - @Schema(description = "拼团用户头像列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List avatars; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java deleted file mode 100755 index 5320c4ae6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class AppCouponController { - - @Resource - private CouponService couponService; - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/take") - @Operation(summary = "领取优惠劵") - @Parameter(name = "templateId", description = "优惠券模板编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult takeCoupon(@Valid @RequestBody AppCouponTakeReqVO reqVO) { - // 1. 领取优惠劵 - Long userId = getLoginUserId(); - couponService.takeCoupon(reqVO.getTemplateId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER); - - // 2. 检查是否可以继续领取 - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(reqVO.getTemplateId()); - boolean canTakeAgain = true; - if (couponTemplate.getTakeLimitCount() != null && couponTemplate.getTakeLimitCount() > 0) { - Integer takeCount = couponService.getTakeCount(reqVO.getTemplateId(), userId); - canTakeAgain = takeCount < couponTemplate.getTakeLimitCount(); - } - return success(canTakeAgain); - } - - @GetMapping("/match-list") - @Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表") - public CommonResult> getMatchCouponList(AppCouponMatchReqVO matchReqVO) { - // todo: 优化:优惠金额倒序 - List list = couponService.getMatchCouponList(getLoginUserId(), matchReqVO); - return success(BeanUtils.toBean(list, AppCouponMatchRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "我的优惠劵列表") - @PreAuthenticated - public CommonResult> getCouponPage(AppCouponPageReqVO pageReqVO) { - PageResult pageResult = couponService.getCouponPage( - CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId()))); - return success(BeanUtils.toBean(pageResult, AppCouponRespVO.class)); - } - - @GetMapping("/get") - @Operation(summary = "获得优惠劵") - @Parameter(name = "id", description = "优惠劵编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult getCoupon(@RequestParam("id") Long id) { - CouponDO coupon = couponService.getCoupon(getLoginUserId(), id); - return success(BeanUtils.toBean(coupon, AppCouponRespVO.class)); - } - - @GetMapping(value = "/get-unused-count") - @Operation(summary = "获得未使用的优惠劵数量") - @PreAuthenticated - public CommonResult getUnusedCouponCount() { - return success(couponService.getUnusedCouponCount(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java deleted file mode 100755 index 5aa9db97e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "用户 App - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class AppCouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - @Resource - private CouponService couponService; - - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/get") - @Operation(summary = "获得优惠劵模版") - @Parameter(name = "id", description = "优惠券模板编号", required = true, example = "1024") - public CommonResult getCouponTemplate(Long id) { - CouponTemplateDO template = couponTemplateService.getCouponTemplate(id); - if (template == null) { - return success(null); - } - // 处理是否可领取 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), singletonList(template)); - return success(BeanUtils.toBean(template, AppCouponTemplateRespVO.class) - .setCanTake(canCanTakeMap.get(template.getId()))); - } - - @GetMapping("/list") - @Operation(summary = "获得优惠劵模版列表") - @Parameters({ - @Parameter(name = "spuId", description = "商品 SPU 编号"), // 目前主要给商品详情使用 - @Parameter(name = "productScope", description = "使用类型"), - @Parameter(name = "count", description = "数量", required = true) - }) - public CommonResult> getCouponTemplateList( - @RequestParam(value = "spuId", required = false) Long spuId, - @RequestParam(value = "productScope", required = false) Integer productScope, - @RequestParam(value = "count", required = false, defaultValue = "10") Integer count) { - // 1.1 处理查询条件:商品范围编号 - Long productScopeValue = getProductScopeValue(productScope, spuId); - // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); - - // 2. 查询 - List list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope, - productScopeValue, count); - - // 3.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list); - // 3.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap)); - } - - @GetMapping("/list-by-ids") - @Operation(summary = "获得优惠劵模版列表") - @Parameter(name = "ids", description = "优惠券模板编号列表") - public CommonResult> getCouponTemplateList( - @RequestParam(value = "ids", required = false) Set ids) { - // 1. 查询 - List list = couponTemplateService.getCouponTemplateList(ids); - - // 2.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list); - // 2.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模版分页") - public CommonResult> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) { - // 1.1 处理查询条件:商品范围编号 - Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId()); - // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); - - // 2. 分页查询 - PageResult pageResult = couponTemplateService.getCouponTemplatePage( - CouponTemplateConvert.INSTANCE.convert(pageReqVO, canTakeTypes, pageReqVO.getProductScope(), productScopeValue)); - - // 3.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), pageResult.getList()); - // 3.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppPage(pageResult, canCanTakeMap)); - } - - /** - * 获得商品的使用范围编号 - * - * @param productScope 商品范围 - * @param spuId 商品 SPU 编号 - * @return 商品范围编号 - */ - private Long getProductScopeValue(Integer productScope, Long spuId) { - // 通用券:没有商品范围 - if (ObjectUtils.equalsAny(productScope, PromotionProductScopeEnum.ALL.getScope(), null)) { - return null; - } - // 品类券:查询商品的品类编号 - if (Objects.equals(productScope, PromotionProductScopeEnum.CATEGORY.getScope()) && spuId != null) { - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - return spu != null ? spu.getCategoryId() : null; - } - // 商品卷:直接返回 - return spuId; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java deleted file mode 100755 index 9d36e3a4e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵的匹配 Request VO") -@Data -public class AppCouponMatchReqVO { - - @Schema(description = "商品金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品金额不能为空") - private Integer price; - - @Schema(description = "商品 SPU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "商品 SPU 编号不能为空") - private List spuIds; - - @Schema(description = "商品 SKU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "商品 SKU 编号不能为空") - private List skuIds; - - @Schema(description = "分类编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[10, 20]") - @NotEmpty(message = "分类编号不能为空") - private List categoryIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java deleted file mode 100755 index da60390fe..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 优惠劵 Response VO") -@Data -public class AppCouponMatchRespVO extends AppCouponRespVO { - - @Schema(description = "是否匹配", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean match; - - @Schema(description = "匹配条件的提示", example = "所结算商品没有符合条件的商品") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java deleted file mode 100644 index 0c423959b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵状态", example = "1") - @InEnum(value = CouponStatusEnum.class, message = "优惠劵状态,必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java deleted file mode 100755 index 7a5f249e4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵 Response VO") -@Data -public class AppCouponRespVO { - - @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - @Schema(description = "优惠劵状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 CouponStatusEnum 枚举 - private Integer status; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer productScope; - - @Schema(description = "商品范围编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List productScopeValues; - - @Schema(description = "固定日期 - 生效开始时间") - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - private LocalDateTime validEndTime; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java deleted file mode 100644 index 0f71fe2bf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 优惠劵领取 Request VO") -@Data -public class AppCouponTakeReqVO { - - @Schema(description = "优惠劵模板编号", example = "1") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java deleted file mode 100644 index d98b2f161..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCouponTemplatePageReqVO extends PageParam { - - @Schema(description = "商品范围", example = "1") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}") - private Integer productScope; - - @Schema(description = "商品标号", example = "1") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java deleted file mode 100755 index bb3a26eb9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵模板 Response VO") -@Data -public class AppCouponTemplateRespVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 - private Integer takeLimitCount; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer productScope; - - @Schema(description = "商品范围编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List productScopeValues; - - @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - - // ========== 用户相关字段 ========== - - @Schema(description = "是否可以领取", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean canTake; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java deleted file mode 100644 index 384dea400..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyPagePropertyRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 装修页面") -@RestController -@RequestMapping("/promotion/diy-page") -@Validated -public class AppDiyPageController { - - @Resource - private DiyPageService diyPageService; - - @GetMapping("/get") - @Operation(summary = "获得装修页面") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getDiyPage(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(BeanUtils.toBean(diyPage, AppDiyPagePropertyRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java deleted file mode 100644 index 0bf37c9e6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.diy.DiyPageEnum; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; - -@Tag(name = "用户 APP - 装修模板") -@RestController -@RequestMapping("/promotion/diy-template") -@Validated -public class AppDiyTemplateController { - - @Resource - private DiyTemplateService diyTemplateService; - @Resource - private DiyPageService diyPageService; - - // TODO @疯狂:要不要把 used 和 get 接口合并哈;不传递 id,直接拿默认; - @GetMapping("/used") - @Operation(summary = "使用中的装修模板") - public CommonResult getUsedDiyTemplate() { - DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate(); - return success(buildVo(diyTemplate)); - } - - @GetMapping("/get") - @Operation(summary = "获得装修模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getDiyTemplate(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - return success(buildVo(diyTemplate)); - } - - private AppDiyTemplatePropertyRespVO buildVo(DiyTemplateDO diyTemplate) { - if (diyTemplate == null) { - return null; - } - // 查询模板下的页面 - List pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); - String home = findFirst(pages, page -> DiyPageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty); - String user = findFirst(pages, page -> DiyPageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty); - // 拼接返回 - return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java deleted file mode 100644 index fb896d797..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; - -import com.fasterxml.jackson.annotation.JsonRawValue; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "用户 App - 装修页面属性 Response VO") -@Data -@ToString(callSuper = true) -public class AppDiyPagePropertyRespVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "页面属性", example = "[]") - @JsonRawValue - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java deleted file mode 100644 index aa237e088..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; - -import com.fasterxml.jackson.annotation.JsonRawValue; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "用户 App - 装修模板属性 Response VO") -@Data -@ToString(callSuper = true) -public class AppDiyTemplatePropertyRespVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - private String name; - - @Schema(description = "模板属性", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String property; - - @Schema(description = "首页", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String home; - - @Schema(description = "我的", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String user; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java deleted file mode 100755 index 1607a4b3c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.app.reward.vo.AppRewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 满减送活动") -@RestController -@RequestMapping("/promotion/reward-activity") -@Validated -public class AppRewardActivityController { - - @Resource - private RewardActivityService rewardActivityService; - - @GetMapping("/get") - @Operation(summary = "获得满减送活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getRewardActivity(@RequestParam("id") Long id) { - RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id); - return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java deleted file mode 100755 index acaa5225d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.reward.vo; - -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 满减送活动 Response VO") -@Data -public class AppRewardActivityRespVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦") - private String name; - - @Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer conditionType; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,2,3") - private List productSpuIds; - - @Schema(description = "优惠规则的数组") - private List rules; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java deleted file mode 100644 index a51a50da4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; - -@Tag(name = "用户 App - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class AppSeckillActivityController { - - /** - * {@link AppSeckillActivityNowRespVO} 缓存,通过它异步刷新 {@link #getNowSeckillActivity()} 所要的首页数据 - */ - private final LoadingCache nowSeckillActivityCache = buildCache(Duration.ofSeconds(10L), - new CacheLoader() { - - @Override - public AppSeckillActivityNowRespVO load(String key) { - return getNowSeckillActivity0(); - } - - }); - - @Resource - private SeckillActivityService activityService; - @Resource - @Lazy - private SeckillConfigService configService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/get-now") - @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用") - public CommonResult getNowSeckillActivity() { - return success(nowSeckillActivityCache.getUnchecked("")); // 缓存 - } - - private AppSeckillActivityNowRespVO getNowSeckillActivity0() { - // 1. 获取当前时间处在哪个秒杀阶段 - SeckillConfigDO config = configService.getCurrentSeckillConfig(); - if (config == null) { // 时段不存在直接返回 null - return new AppSeckillActivityNowRespVO(); - } - - // 2.1 查询满足当前阶段的活动 - List activityList = activityService.getSeckillActivityListByConfigIdAndStatus(config.getId(), CommonStatusEnum.ENABLE.getStatus()); - List productList = activityService.getSeckillProductListByActivityId( - convertList(activityList, SeckillActivityDO::getId)); - // 2.2 获取 spu 信息 - List spuList = spuApi.getSpuList(convertList(activityList, SeckillActivityDO::getSpuId)).getCheckedData(); - return SeckillActivityConvert.INSTANCE.convert(config, activityList, productList, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀活动分页") - public CommonResult> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) { - // 1. 查询满足当前阶段的活动 - PageResult pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - List productList = activityService.getSeckillProductListByActivityId( - convertList(pageResult.getList(), SeckillActivityDO::getId)); - - // 2. 拼接数据 - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId)).getCheckedData(); - return success(SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得秒杀活动明细") - @Parameter(name = "id", description = "活动编号", required = true, example = "1024") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - // 1. 获取活动 - SeckillActivityDO activity = activityService.getSeckillActivity(id); - if (activity == null - || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - return success(null); - } - - // 2. 获取时间段 - List configs = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); - configs.removeIf(config -> !CollUtil.contains(activity.getConfigIds(), config.getId())); - // 2.1 优先使用当前时间段 - SeckillConfigDO config = findFirst(configs, config0 -> isBetween(config0.getStartTime(), config0.getEndTime())); - // 2.2 如果没有,则获取最后一个,因为倾向优先展示“未开始” > “已结束” - if (config == null) { - config = CollUtil.getLast(configs); - } - if (config == null) { - return null; - } - // 3. 计算开始时间、结束时间 - LocalDate nowDate; - // 3.1 如果在活动日期范围内,则以今天为 nowDate - if (LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - nowDate = LocalDate.now(); - } else { - // 3.2 如果不在活动时间范围内,则直接以活动的 endTime 作为 nowDate,因为还是倾向优先展示“未开始” > “已结束” - nowDate = activity.getEndTime().toLocalDate(); - } - LocalDateTime startTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getStartTime())); - LocalDateTime endTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getEndTime())); - - // 4. 拼接数据 - List productList = activityService.getSeckillProductListByActivityId(activity.getId()); - return success(SeckillActivityConvert.INSTANCE.convert3(activity, productList, startTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java deleted file mode 100644 index 12ff30944..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 秒杀时间段") -@RestController -@RequestMapping("/promotion/seckill-config") -@Validated -public class AppSeckillConfigController { - @Resource - private SeckillConfigService configService; - - @GetMapping("/list") - @Operation(summary = "获得秒杀时间段列表") - public CommonResult> getSeckillConfigList() { - List list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(SeckillConfigConvert.INSTANCE.convertList2(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java deleted file mode 100644 index ebb5ac54d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 秒杀活动的详细 Response VO") -@Data -public class AppSeckillActivityDetailRespVO { - - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") - private String name; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "总共限购数量", example = "10") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", example = "5") - private Integer singleLimitCount; - - @Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer stock; - - @Schema(description = "秒杀库存(总计)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer totalStock; - - @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "商品信息") - @Data - public static class Product { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private Long skuId; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillPrice; - - @Schema(description = "秒杀限量库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer stock; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java deleted file mode 100644 index 5dad12904..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 当前秒杀活动 Response VO") -@Data -public class AppSeckillActivityNowRespVO { - - @Schema(description = "秒杀时间段", requiredMode = Schema.RequiredMode.REQUIRED) - private AppSeckillConfigRespVO config; - - @Schema(description = "秒杀活动数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List activities; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java deleted file mode 100644 index 158f11fd3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppSeckillActivityPageReqVO extends PageParam { - - @Schema(description = "秒杀配置编号", example = "1024") - private Long configId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java deleted file mode 100644 index 68e7ff829..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 秒杀活动 Response VO") -@Data -public class AppSeckillActivityRespVO { - - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") - private String name; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - @Schema(description = "秒杀活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer stock; - @Schema(description = "秒杀库存(总共)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalStock; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java deleted file mode 100644 index c981f8429..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 秒杀时间段 Response VO") -@Data -public class AppSeckillConfigRespVO { - - @Schema(description = "秒杀时间段编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00") - private String startTime; - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:59") - private String endTime; - - @Schema(description = "轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java deleted file mode 100644 index 05ad935f7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategorySimpleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 文章分类 Convert - * - * @author HUIHUI - */ -@Mapper -public interface ArticleCategoryConvert { - - ArticleCategoryConvert INSTANCE = Mappers.getMapper(ArticleCategoryConvert.class); - - ArticleCategoryDO convert(ArticleCategoryCreateReqVO bean); - - ArticleCategoryDO convert(ArticleCategoryUpdateReqVO bean); - - ArticleCategoryRespVO convert(ArticleCategoryDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList03(List list); - - List convertList04(List categoryList); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java deleted file mode 100644 index 7f4867f5d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 文章管理 Convert - * - * @author HUIHUI - */ -@Mapper -public interface ArticleConvert { - - ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class); - - ArticleDO convert(ArticleCreateReqVO bean); - - ArticleDO convert(ArticleUpdateReqVO bean); - - ArticleRespVO convert(ArticleDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - AppArticleRespVO convert01(ArticleDO article); - - PageResult convertPage02(PageResult articlePage); - - List convertList03(List articleCategoryListByRecommendHotAndRecommendBanner); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java deleted file mode 100644 index d2d75362e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface BannerConvert { - - BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class); - - List convertList(List list); - - PageResult convertPage(PageResult pageResult); - - BannerRespVO convert(BannerDO banner); - - BannerDO convert(BannerCreateReqVO createReqVO); - - BannerDO convert(BannerUpdateReqVO updateReqVO); - - List convertList01(List bannerList); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java deleted file mode 100644 index 69f1ce2ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 拼团活动 Convert - * - * @author HUIHUI - */ -@Mapper -public interface BargainActivityConvert { - - BargainActivityConvert INSTANCE = Mappers.getMapper(BargainActivityConvert.class); - - BargainActivityDO convert(BargainActivityBaseVO bean); - - BargainActivityDO convert(BargainActivityUpdateReqVO bean); - - BargainActivityRespVO convert(BargainActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, List spuList, - Map recordUserCountMap, Map recordSuccessUserCountMap, - Map helpUserCountMap) { - PageResult result = convertPage(page); - // 拼接关联属性 - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - result.getList().forEach(item -> { - findAndThen(spuMap, item.getSpuId(), spu -> { - item.setPicUrl(spu.getPicUrl()).setSpuName(spu.getName()); - }); - // 设置统计字段 - item.setRecordUserCount(recordUserCountMap.getOrDefault(item.getId(), 0)) - .setRecordSuccessUserCount(recordSuccessUserCountMap.getOrDefault(item.getId(), 0)) - .setHelpUserCount(helpUserCountMap.getOrDefault(item.getId(), 0)); - }); - return result; - } - - AppBargainActivityDetailRespVO convert1(BargainActivityDO bean); - - default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, Integer successUserCount, ProductSpuRespDTO spu) { - AppBargainActivityDetailRespVO detail = convert1(bean).setSuccessUserCount(successUserCount); - if (spu != null) { - detail.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()); - } - return detail; - } - - PageResult convertAppPage(PageResult page); - - default PageResult convertAppPage(PageResult page, List spuList) { - PageResult result = convertAppPage(page); - // 拼接关联属性 - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - List list = CollectionUtils.convertList(result.getList(), item -> { - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - result.setList(list); - return result; - } - - List convertAppList(List list); - - default List convertAppList(List list, List spuList) { - List activityList = convertAppList(list); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - return CollectionUtils.convertList(activityList, item -> { - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java deleted file mode 100644 index 6ec71ce7c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 砍价助力 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BargainHelpConvert { - - BargainHelpConvert INSTANCE = Mappers.getMapper(BargainHelpConvert.class); - - default PageResult convertPage(PageResult page, - Map userMap) { - PageResult pageResult = convertPage(page); - // 拼接数据 - pageResult.getList().forEach(record -> - MapUtils.findAndThen(userMap, record.getUserId(), - user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return pageResult; - } - PageResult convertPage(PageResult page); - - default List convertList(List helps, - Map userMap) { - List helpVOs = convertList02(helps); - helpVOs.forEach(help -> - MapUtils.findAndThen(userMap, help.getUserId(), - user -> help.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return helpVOs; - } - List convertList02(List helps); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java deleted file mode 100644 index 5c1bf75a3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 砍价记录 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BargainRecordConvert { - - BargainRecordConvert INSTANCE = Mappers.getMapper(BargainRecordConvert.class); - - default PageResult convertPage(PageResult page, - Map helpCountMap, - List activityList, - Map userMap) { - PageResult pageResult = convertPage(page); - // 拼接数据 - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - pageResult.getList().forEach(record -> { - MapUtils.findAndThen(userMap, record.getUserId(), - user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - record.setActivity(BargainActivityConvert.INSTANCE.convert(activityMap.get(record.getActivityId()))) - .setHelpCount(helpCountMap.getOrDefault(record.getId(), 0)); - }); - return pageResult; - } - PageResult convertPage(PageResult page); - - default PageResult convertPage02(PageResult page, - List activityList, - List spuList, - List orderList) { - PageResult pageResult = convertPage02(page); - // 拼接数据 - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map orderMap = convertMap(orderList, TradeOrderRespDTO::getId); - pageResult.getList().forEach(record -> { - MapUtils.findAndThen(activityMap, record.getActivityId(), - activity -> record.setActivityName(activity.getName()).setEndTime(activity.getEndTime())); - MapUtils.findAndThen(spuMap, record.getSpuId(), - spu -> record.setPicUrl(record.getPicUrl())); - MapUtils.findAndThen(orderMap, record.getOrderId(), - order -> record.setPayStatus(order.getPayStatus()).setPayOrderId(order.getPayOrderId())); - }); - return pageResult; - } - PageResult convertPage02(PageResult page); - - default AppBargainRecordSummaryRespVO convert(Integer successUserCount, List successList, - List activityList, Map userMap) { - AppBargainRecordSummaryRespVO summary = new AppBargainRecordSummaryRespVO().setSuccessUserCount(successUserCount); - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - summary.setSuccessList(CollectionUtils.convertList(successList, record -> { - AppBargainRecordSummaryRespVO.Record recordVO = new AppBargainRecordSummaryRespVO.Record(); - MapUtils.findAndThen(userMap, record.getUserId(), - user -> recordVO.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - MapUtils.findAndThen(activityMap, record.getActivityId(), - activity -> recordVO.setActivityName(activity.getName())); - return recordVO; - })); - return summary; - } - - @Mapping(source = "record.id", target = "id") - @Mapping(source = "record.userId", target = "userId") - @Mapping(source = "record.status", target = "status") - AppBargainRecordDetailRespVO convert02(BargainRecordDO record, Integer helpAction, TradeOrderRespDTO order); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java deleted file mode 100644 index 965459b77..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ /dev/null @@ -1,227 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.combination; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 拼团活动 Convert - * - * @author HUIHUI - */ -@Mapper -public interface CombinationActivityConvert { - - CombinationActivityConvert INSTANCE = Mappers.getMapper(CombinationActivityConvert.class); - - CombinationActivityDO convert(CombinationActivityCreateReqVO bean); - - CombinationActivityDO convert(CombinationActivityUpdateReqVO bean); - - CombinationActivityRespVO convert(CombinationActivityDO bean); - - CombinationProductRespVO convert(CombinationProductDO bean); - - default CombinationActivityRespVO convert(CombinationActivityDO activity, List products) { - return convert(activity).setProducts(convertList2(products)); - } - - List convertList(List list); - - default PageResult convertPage(PageResult page, - List productList, - Map groupCountMap, - Map groupSuccessCountMap, - Map recordCountMap, - List spuList) { - PageResult pageResult = convertPage(page); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()) - .setMarketPrice(spu.getMarketPrice())); - item.setProducts(convertList2(productList)); - // 设置统计字段 - item.setGroupCount(groupCountMap.getOrDefault(item.getId(), 0)) - .setGroupSuccessCount(groupSuccessCountMap.getOrDefault(item.getId(), 0)) - .setRecordCount(recordCountMap.getOrDefault(item.getId(), 0)); - }); - return pageResult; - } - - PageResult convertPage(PageResult page); - - List convertList2(List productDOs); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "activityId", source = "activity.id"), - @Mapping(target = "spuId", source = "activity.spuId"), - @Mapping(target = "skuId", source = "product.skuId"), - @Mapping(target = "combinationPrice", source = "product.combinationPrice"), - @Mapping(target = "activityStartTime", source = "activity.startTime"), - @Mapping(target = "activityEndTime", source = "activity.endTime") - }) - CombinationProductDO convert(CombinationActivityDO activity, CombinationProductBaseVO product); - - default List convertList(List products, CombinationActivityDO activity) { - return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); - } - - default List convertList(List updateProductVOs, - List products, CombinationActivityDO activity) { - Map productMap = convertMap(products, CombinationProductDO::getSkuId, CombinationProductDO::getId); - return CollectionUtils.convertList(updateProductVOs, updateProductVO -> convert(activity, updateProductVO) - .setId(productMap.get(updateProductVO.getSkuId())) - .setActivityStatus(activity.getStatus())); - } - - CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); - - default CombinationRecordCreateRespDTO convert4(CombinationRecordDO combinationRecord) { - return new CombinationRecordCreateRespDTO().setCombinationActivityId(combinationRecord.getActivityId()) - .setCombinationRecordId(combinationRecord.getId()).setCombinationHeadId(combinationRecord.getHeadId()); - } - - default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, - CombinationActivityDO activity, MemberUserRespDTO user, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { - return convert(reqDTO).setVirtualGroup(false) - .setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()) // 创建后默认状态为进行中 - .setUserSize(activity.getUserSize()).setUserCount(1) // 默认就是 1 插入后会接着更新一次所有的拼团记录 - // 用户信息 - .setNickname(user.getNickname()).setAvatar(user.getAvatar()) - // 商品信息 - .setSpuName(spu.getName()).setPicUrl(sku.getPicUrl()); - } - - List convertAppList(List list); - - default List convertAppList(List list, - List productList, - List spuList) { - List activityList = convertAppList(list); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId); - return CollectionUtils.convertList(activityList, item -> { - // 设置 product 信息 - item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice)); - // 设置 SPU 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - } - - PageResult convertAppPage(PageResult result); - - default PageResult convertAppPage(PageResult result, - List productList, - List spuList) { - PageResult appPage = convertAppPage(result); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId); - List list = CollectionUtils.convertList(appPage.getList(), item -> { - // 设置 product 信息 - item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice)); - // 设置 SPU 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - appPage.setList(list); - return appPage; - } - - AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity); - - List convertList1(List products); - - default AppCombinationActivityDetailRespVO convert3(CombinationActivityDO combinationActivity, List products) { - return convert2(combinationActivity).setProducts(convertList1(products)); - } - - List convertList3(List records); - - AppCombinationRecordRespVO convert(CombinationRecordDO record); - - PageResult convert(PageResult result); - - default PageResult convert(PageResult recordPage, List activities, List products) { - PageResult result = convert(recordPage); - // 拼接关联属性 - Map activityMap = convertMap(activities, CombinationActivityDO::getId); - Map> productsMap = convertMultiMap(products, CombinationProductDO::getActivityId); - result.setList(CollectionUtils.convertList(result.getList(), item -> { - findAndThen(activityMap, item.getActivityId(), activity -> { - item.setActivity(convert(activity).setProducts(convertList2(productsMap.get(item.getActivityId())))); - }); - return item; - })); - return result; - } - - default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List memberRecords) { - AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO() - .setHeadRecord(convert(headRecord)).setMemberRecords(convertList3(memberRecords)); - // 处理自己参与拼团的 orderId - CombinationRecordDO userRecord = CollectionUtils.findFirst(memberRecords, r -> ObjectUtil.equal(r.getUserId(), userId)); - if (userRecord == null && ObjectUtil.equal(headRecord.getUserId(), userId)) { - userRecord = headRecord; - } - respVO.setOrderId(userRecord == null ? null : userRecord.getOrderId()); - return respVO; - } - - /** - * 转换生成虚拟成团虚拟记录 - * - * @param headRecord 虚拟成团团长记录 - * @return 虚拟记录列表 - */ - default List convertVirtualRecordList(CombinationRecordDO headRecord) { - int count = headRecord.getUserSize() - headRecord.getUserCount(); - List createRecords = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - // 基础信息和团长保持一致 - CombinationRecordDO newRecord = convert5(headRecord); - // 虚拟信息 - newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 - .setUserId(0L).setNickname("").setAvatar("").setOrderId(0L); - createRecords.add(newRecord); - } - return createRecords; - } - @Mapping(target = "id", ignore = true) - CombinationRecordDO convert5(CombinationRecordDO headRecord); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java deleted file mode 100755 index 0ac9c58da..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.Collection; - -/** - * 优惠劵 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponConvert { - - CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class); - - PageResult convertPage(PageResult page); - - CouponRespDTO convert(CouponDO bean); - - default CouponDO convert(CouponTemplateDO template, Long userId) { - CouponDO couponDO = new CouponDO() - .setTemplateId(template.getId()) - .setName(template.getName()) - .setTakeType(template.getTakeType()) - .setUsePrice(template.getUsePrice()) - .setProductScope(template.getProductScope()) - .setProductScopeValues(template.getProductScopeValues()) - .setDiscountType(template.getDiscountType()) - .setDiscountPercent(template.getDiscountPercent()) - .setDiscountPrice(template.getDiscountPrice()) - .setDiscountLimitPrice(template.getDiscountLimitPrice()) - .setStatus(CouponStatusEnum.UNUSED.getStatus()) - .setUserId(userId); - if (CouponTemplateValidityTypeEnum.DATE.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(template.getValidStartTime()); - couponDO.setValidEndTime(template.getValidEndTime()); - } else if (CouponTemplateValidityTypeEnum.TERM.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(LocalDateTime.now().plusDays(template.getFixedStartTerm())); - couponDO.setValidEndTime(LocalDateTime.now().plusDays(template.getFixedEndTerm())); - } - return couponDO; - } - - CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection userIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java deleted file mode 100755 index c6b86da38..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 优惠劵模板 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateConvert { - - CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); - - CouponTemplateDO convert(CouponTemplateCreateReqVO bean); - - CouponTemplateDO convert(CouponTemplateUpdateReqVO bean); - - CouponTemplateRespVO convert(CouponTemplateDO bean); - - PageResult convertPage(PageResult page); - - CouponTemplatePageReqVO convert(AppCouponTemplatePageReqVO pageReqVO, List canTakeTypes, Integer productScope, Long productScopeValue); - - PageResult convertAppPage(PageResult pageResult); - - List convertAppList(List list); - - default PageResult convertAppPage(PageResult pageResult, Map userCanTakeMap) { - PageResult result = convertAppPage(pageResult); - copyTo(result.getList(), userCanTakeMap); - return result; - } - - default List convertAppList(List list, Map userCanTakeMap) { - List result = convertAppList(list); - copyTo(result, userCanTakeMap); - return result; - } - - default void copyTo(List list, Map userCanTakeMap) { - for (AppCouponTemplateRespVO template : list) { - // 检查已领取数量是否超过限领数量 - template.setCanTake(MapUtil.getBool(userCanTakeMap, template.getId(), false)); - } - } - - List convertList(List list); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java deleted file mode 100755 index 0ecbd92ef..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.discount; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 限时折扣活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityConvert { - - DiscountActivityConvert INSTANCE = Mappers.getMapper(DiscountActivityConvert.class); - - DiscountActivityDO convert(DiscountActivityCreateReqVO bean); - - DiscountActivityDO convert(DiscountActivityUpdateReqVO bean); - - DiscountActivityRespVO convert(DiscountActivityDO bean); - - List convertList(List list); - List convertList2(List list); - - List convertList02(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, - List discountProductDOList, - List spuList) { - PageResult pageResult = convertPage(page); - - // 拼接商品 TODO @zhangshuai:类似空行的问题,也可以看看 - Map discountActivityMap = CollectionUtils.convertMap(discountProductDOList, DiscountProductDO::getActivityId); - Map spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - item.setProducts(convertList2(discountProductDOList)); - item.setSpuId(discountActivityMap.get(item.getId())==null?null: discountActivityMap.get(item.getId()).getSpuId()); - if (item.getSpuId() != null) { - MapUtils.findAndThen(spuMap, item.getSpuId(), - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - } - - }); - return pageResult; - } - - DiscountProductDO convert(DiscountActivityBaseVO.Product bean); - - default DiscountActivityDetailRespVO convert(DiscountActivityDO activity, List products){ - if ( activity == null && products == null ) { - return null; - } - - DiscountActivityDetailRespVO discountActivityDetailRespVO = new DiscountActivityDetailRespVO(); - - if ( activity != null ) { - discountActivityDetailRespVO.setName( activity.getName() ); - discountActivityDetailRespVO.setStartTime( activity.getStartTime() ); - discountActivityDetailRespVO.setEndTime( activity.getEndTime() ); - discountActivityDetailRespVO.setRemark( activity.getRemark() ); - discountActivityDetailRespVO.setId( activity.getId() ); - discountActivityDetailRespVO.setStatus( activity.getStatus() ); - discountActivityDetailRespVO.setCreateTime( activity.getCreateTime() ); - } - if (!products.isEmpty()) { - discountActivityDetailRespVO.setSpuId(products.get(0).getSpuId()); - } - discountActivityDetailRespVO.setProducts( convertList2( products ) ); - - return discountActivityDetailRespVO; - } - - // =========== 比较是否相等 ========== - /** - * 比较两个限时折扣商品是否相等 - * - * @param productDO 数据库中的商品 - * @param productVO 前端传入的商品 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountActivityBaseVO.Product productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - /** - * 比较两个限时折扣商品是否相等 - * 注意,比较时忽略 id 编号 - * - * @param productDO 商品 1 - * @param productVO 商品 2 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountProductDO productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java deleted file mode 100644 index 3443fd862..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 装修页面 Convert - * - * @author owen - */ -@Mapper -public interface DiyPageConvert { - - DiyPageConvert INSTANCE = Mappers.getMapper(DiyPageConvert.class); - - DiyPageDO convert(DiyPageCreateReqVO bean); - - DiyPageDO convert(DiyPageUpdateReqVO bean); - - DiyPageRespVO convert(DiyPageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiyPageCreateReqVO convertCreateVo(Long templateId, String name, String remark); - - DiyPagePropertyRespVO convertPropertyVo(DiyPageDO diyPage); - - DiyPageDO convert(DiyPagePropertyUpdateRequestVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java deleted file mode 100644 index a579c6087..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 装修模板 Convert - * - * @author owen - */ -@Mapper -public interface DiyTemplateConvert { - - DiyTemplateConvert INSTANCE = Mappers.getMapper(DiyTemplateConvert.class); - - DiyTemplateDO convert(DiyTemplateCreateReqVO bean); - - DiyTemplateDO convert(DiyTemplateUpdateReqVO bean); - - DiyTemplateRespVO convert(DiyTemplateDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List pages); - - AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, String home, String user); - - DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java deleted file mode 100755 index 5343656ed..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 满减送活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityConvert { - - RewardActivityConvert INSTANCE = Mappers.getMapper(RewardActivityConvert.class); - - RewardActivityDO convert(RewardActivityCreateReqVO bean); - - RewardActivityDO convert(RewardActivityUpdateReqVO bean); - - RewardActivityRespVO convert(RewardActivityDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java deleted file mode 100644 index 4f53cf3dc..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 秒杀活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillActivityConvert { - - SeckillActivityConvert INSTANCE = Mappers.getMapper(SeckillActivityConvert.class); - - SeckillActivityDO convert(SeckillActivityCreateReqVO bean); - - SeckillActivityDO convert(SeckillActivityUpdateReqVO bean); - - SeckillActivityRespVO convert(SeckillActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, - List seckillProducts, - List spuList) { - PageResult pageResult = convertPage(page); - // 拼接商品 - Map spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - item.setProducts(convertList2(seckillProducts)); - MapUtils.findAndThen(spuMap, item.getSpuId(), - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - }); - return pageResult; - } - - SeckillActivityDetailRespVO convert1(SeckillActivityDO activity); - - default SeckillActivityDetailRespVO convert(SeckillActivityDO activity, List products) { - return convert1(activity).setProducts(convertList2(products)); - } - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "activityId", source = "activity.id"), - @Mapping(target = "configIds", source = "activity.configIds"), - @Mapping(target = "spuId", source = "activity.spuId"), - @Mapping(target = "skuId", source = "product.skuId"), - @Mapping(target = "seckillPrice", source = "product.seckillPrice"), - @Mapping(target = "stock", source = "product.stock"), - @Mapping(target = "activityStartTime", source = "activity.startTime"), - @Mapping(target = "activityEndTime", source = "activity.endTime") - }) - SeckillProductDO convert(SeckillActivityDO activity, SeckillProductBaseVO product); - - default List convertList(List products, SeckillActivityDO activity) { - return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); - } - - List convertList2(List list); - - List convertList3(List activityList); - - default AppSeckillActivityNowRespVO convert(SeckillConfigDO filteredConfig, List activityList, - List productList, List spuList) { - AppSeckillActivityNowRespVO respVO = new AppSeckillActivityNowRespVO(); - respVO.setConfig(SeckillConfigConvert.INSTANCE.convert1(filteredConfig)); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, SeckillProductDO::getActivityId); - respVO.setActivities(CollectionUtils.convertList(convertList3(activityList), item -> { - // product 信息 - item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice)); - // spu 信息 - findAndThen(spuMap, item.getSpuId(), spu -> - item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - })); - return respVO; - } - - PageResult convertPage1(PageResult pageResult); - - default PageResult convertPage02(PageResult pageResult, List productList, List spuList) { - PageResult result = convertPage1(pageResult); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, SeckillProductDO::getActivityId); - List list = CollectionUtils.convertList(result.getList(), item -> { - // product 信息 - item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice)); - // spu 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - result.setList(list); - return result; - } - - AppSeckillActivityDetailRespVO convert2(SeckillActivityDO seckillActivity); - - List convertList1(List products); - - default AppSeckillActivityDetailRespVO convert3(SeckillActivityDO activity, List products, - LocalDateTime startTime, LocalDateTime endTime) { - return convert2(activity) - .setProducts(convertList1(products)) - .setStartTime(startTime).setEndTime(endTime); - } - - SeckillValidateJoinRespDTO convert02(SeckillActivityDO activity, SeckillProductDO product); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java deleted file mode 100644 index f8dd77440..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigSimpleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 秒杀时段 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillConfigConvert { - - SeckillConfigConvert INSTANCE = Mappers.getMapper(SeckillConfigConvert.class); - - SeckillConfigDO convert(SeckillConfigCreateReqVO bean); - - SeckillConfigDO convert(SeckillConfigUpdateReqVO bean); - - SeckillConfigRespVO convert(SeckillConfigDO bean); - - List convertList(List list); - - List convertList1(List list); - - PageResult convertPage(PageResult page); - - List convertList2(List list); - - AppSeckillConfigRespVO convert1(SeckillConfigDO filteredConfig); -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java deleted file mode 100644 index c79b86d66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 文章分类 DO - * - * @author HUIHUI - */ -@TableName("promotion_article_category") -@KeySequence("promotion_article_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ArticleCategoryDO extends BaseDO { - - /** - * 文章分类编号 - */ - @TableId - private Long id; - /** - * 文章分类名称 - */ - private String name; - /** - * 图标地址 - */ - private String picUrl; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java deleted file mode 100644 index 426d9d9c7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 文章管理 DO - * - * @author HUIHUI - */ -@TableName("promotion_article") -@KeySequence("promotion_article_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ArticleDO extends BaseDO { - - /** - * 文章管理编号 - */ - @TableId - private Long id; - /** - * 分类编号 ArticleCategoryDO#id - */ - private Long categoryId; - /** - * 关联商品编号 ProductSpuDO#id - */ - private Long spuId; - /** - * 文章标题 - */ - private String title; - /** - * 文章作者 - */ - private String author; - /** - * 文章封面图片地址 - */ - private String picUrl; - /** - * 文章简介 - */ - private String introduction; - /** - * 浏览次数 - */ - private Integer browseCount; - /** - * 排序 - */ - private Integer sort; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 是否热门(小程序) - */ - private Boolean recommendHot; - /** - * 是否轮播图(小程序) - */ - private Boolean recommendBanner; - /** - * 文章内容 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java deleted file mode 100644 index fad9385b2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.banner; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * banner DO - * - * @author xia - */ -@TableName("promotion_banner") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BannerDO extends BaseDO { - - /** - * 编号 - */ - private Long id; - /** - * 标题 - */ - private String title; - /** - * 跳转链接 - */ - private String url; - /** - * 图片链接 - */ - private String picUrl; - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 {@link CommonStatusEnum} - */ - private Integer status; - - /** - * 定位 {@link BannerPositionEnum} - */ - private Integer position; - - /** - * 备注 - */ - private String memo; - - /** - * 点击次数 - */ - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java deleted file mode 100644 index 37259ebe6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 砍价活动 DO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_activity") -@KeySequence("promotion_bargain_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainActivityDO extends BaseDO { - - /** - * 砍价活动编号 - */ - @TableId - private Long id; - - /** - * 砍价活动名称 - */ - private String name; - - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 砍价起始价格,单位:分 - */ - private Integer bargainFirstPrice; - /** - * 砍价底价,单位:分 - */ - private Integer bargainMinPrice; - - /** - * 砍价库存(剩余库存砍价时扣减) - */ - private Integer stock; - /** - * 砍价总库存 - */ - private Integer totalStock; - - /** - * 砍价人数 - * - * 需要多少人,砍价才能成功,即 {@link BargainRecordDO#getStatus()} 更新为 {@link BargainRecordDO#getStatus()} 成功状态 - */ - private Integer helpMaxCount; - /** - * 帮砍次数 - * - * 单个活动,用户可以帮砍的次数。 - * 例如说:帮砍次数为 1 时,A 和 B 同时将该活动链接发给 C,C 只能帮其中一个人砍价。 - */ - private Integer bargainCount; - - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 用户每次砍价的最小金额,单位:分 - */ - private Integer randomMinPrice; - /** - * 用户每次砍价的最大金额,单位:分 - */ - private Integer randomMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java deleted file mode 100644 index 8419f3436..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 砍价助力 DO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_help") -@KeySequence("promotion_bargain_help_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainHelpDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 砍价活动编号 - * - * 关联 {@link BargainActivityDO#getId()} 字段 - */ - private Long activityId; - /** - * 砍价记录编号 - * - * 关联 {@link BargainRecordDO#getId()} 字段 - */ - private Long recordId; - - /** - * 用户编号 - */ - private Long userId; - /** - * 减少价格,单位:分 - */ - private Integer reducePrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java deleted file mode 100644 index e5f574dd6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 砍价记录 DO TODO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_record") -@KeySequence("promotion_bargain_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - - /** - * 砍价活动编号 - * - * 关联 {@link BargainActivityDO#getId()} 字段 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - - /** - * 砍价起始价格,单位:分 - */ - private Integer bargainFirstPrice; - /** - * 当前砍价,单位:分 - */ - private Integer bargainPrice; - - /** - * 砍价状态 - * - * 砍价成功的条件是:(2 选 1) - * 1. 砍价到 {@link BargainActivityDO#getBargainMinPrice()} 底价 - * 2. 助力人数到达 {@link BargainActivityDO#getHelpMaxCount()} 人 - * - * 枚举 {@link BargainRecordStatusEnum} - */ - private Integer status; - /** - * 结束时间 - */ - private LocalDateTime endTime; - - /** - * 订单编号 - */ - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java deleted file mode 100644 index 5236b303a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 拼团活动 DO - * - * @author HUIHUI - */ -@TableName("promotion_combination_activity") -@KeySequence("promotion_combination_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationActivityDO extends BaseDO { - - /** - * 活动编号 - */ - @TableId - private Long id; - /** - * 拼团名称 - */ - private String name; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id - */ - private Long spuId; - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 单次限购数量 - */ - private Integer singleLimitCount; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 几人团 - */ - private Integer userSize; - /** - * 虚拟成团 - */ - private Boolean virtualGroup; - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 限制时长(小时) - */ - private Integer limitDuration; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java deleted file mode 100644 index d793bb63e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 拼团商品 DO - * - * @author HUIHUI - */ -@TableName("promotion_combination_product") -@KeySequence("promotion_combination_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationProductDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 拼团活动编号 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 拼团价格,单位分 - */ - private Integer combinationPrice; - - /** - * 拼团商品状态 - * - * 关联 {@link CombinationActivityDO#getStatus()} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - * - * 冗余 {@link CombinationActivityDO#getStartTime()} - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - * - * 冗余 {@link CombinationActivityDO#getEndTime()} - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java deleted file mode 100644 index e1ba90bf1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -// TODO 芋艿:把字段的顺序,和 do 顺序对齐下 -/** - * 拼团记录 DO - * - * 1. 用户参与拼团时,会创建一条记录 - * 2. 团长的拼团记录,和参团人的拼团记录,通过 {@link #headId} 关联 - * - * @author HUIHUI - */ -@TableName("promotion_combination_record") -@KeySequence("promotion_combination_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationRecordDO extends BaseDO { - - /** - * 团长编号 - 团长 - */ - public static final Long HEAD_ID_GROUP = 0L; - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 拼团活动编号 - * - * 关联 {@link CombinationActivityDO#getId()} - */ - private Long activityId; - /** - * 拼团商品单价 - * - * 冗余 {@link CombinationProductDO#getCombinationPrice()} - */ - private Integer combinationPrice; - /** - * SPU 编号 - */ - private Long spuId; - /** - * 商品名字 - */ - private String spuName; - /** - * 商品图片 - */ - private String picUrl; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买的商品数量 - */ - private Integer count; - - /** - * 用户编号 - */ - private Long userId; - - /** - * 用户昵称 - */ - private String nickname; - /** - * 用户头像 - */ - private String avatar; - - /** - * 团长编号 - * - * 关联 {@link CombinationRecordDO#getId()} - * - * 如果是团长,则它的值是 {@link #HEAD_ID_GROUP} - */ - private Long headId; - /** - * 开团状态 - * - * 关联 {@link CombinationRecordStatusEnum} - */ - private Integer status; - /** - * 订单编号 - */ - private Long orderId; - /** - * 开团需要人数 - * - * 关联 {@link CombinationActivityDO#getUserSize()} - */ - private Integer userSize; - /** - * 已加入拼团人数 - */ - private Integer userCount; - /** - * 是否虚拟成团 - * - * 默认为 false。 - * 拼团过期都还没有成功,如果 {@link CombinationActivityDO#getVirtualGroup()} 为 true,则执行虚拟成团的逻辑,才会更新该字段为 true - */ - private Boolean virtualGroup; - - /** - * 过期时间 - * - * 基于 {@link CombinationRecordDO#getStartTime()} + {@link CombinationActivityDO#getLimitDuration()} 计算 - */ - private LocalDateTime expireTime; - /** - * 开始时间 (订单付款后开始的时间) - */ - private LocalDateTime startTime; - /** - * 结束时间(成团时间/失败时间) - */ - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java deleted file mode 100644 index 31cef2e78..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon", autoResultMap = true) -@KeySequence("promotion_coupon_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - * - * 关联 {@link CouponTemplateDO#getId()} - */ - private Long templateId; - /** - * 优惠劵名 - * - * 冗余 {@link CouponTemplateDO#getName()} - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - // TODO 芋艿:已作废? - private Integer status; - - // TODO 芋艿:发放 adminid? - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 冗余 {@link CouponTemplateDO#getUsePrice()} - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品范围编号的数组 - * - * 冗余 {@link CouponTemplateDO#getProductScopeValues()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 冗余 {@link CouponTemplateDO#getDiscountType()} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 冗余 {@link CouponTemplateDO#getDiscountPercent()} - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 冗余 {@link CouponTemplateDO#getDiscountPrice()} - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 冗余 {@link CouponTemplateDO#getDiscountLimitPrice()} - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java deleted file mode 100644 index ad4ebab9b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java +++ /dev/null @@ -1,166 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵模板 DO - * - * 当用户领取时,会生成 {@link CouponDO} 优惠劵 - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon_template", autoResultMap = true) -@KeySequence("promotion_coupon_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponTemplateDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 模板编号,自增唯一 - */ - @TableId - private Long id; - /** - * 优惠劵名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - // TODO 芋艿:要不要改成 3 个状态?? - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取规则 BEGIN ========== - /** - * 发放数量 - * - * -1 - 则表示不限制发放数量 - */ - private Integer totalCount; - /** - * 每人限领个数 - * - * -1 - 则表示不限制 - */ - private Integer takeLimitCount; - /** - * 领取方式 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取规则 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 0 - 不限制 - * 大于 0 - 多少金额可用 - */ - private Integer usePrice; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品范围编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productScopeValues; - /** - * 生效日期类型 - * - * 枚举 {@link CouponTemplateValidityTypeEnum} - */ - private Integer validityType; - /** - * 固定日期 - 生效开始时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validStartTime; - /** - * 固定日期 - 生效结束时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validEndTime; - /** - * 领取日期 - 开始天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedStartTerm; - /** - * 领取日期 - 结束天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedEndTerm; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 统计信息 BEGIN ========== - /** - * 领取优惠券的数量 - */ - private Integer takeCount; - /** - * 使用优惠券的次数 - */ - private Integer useCount; - // ========== 统计信息 END ========== - - // TODO 芋艿:领取开始时间、领取结束时间 - - // TODO 芋艿:要不要加描述 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java deleted file mode 100644 index 956a223be..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣活动 DO - * - * 一个活动下,可以有 {@link DiscountProductDO} 商品; - * 一个商品,在指定时间段内,只能属于一个活动; - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_activity", autoResultMap = true) -@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - * - * 活动被关闭后,不允许再次开启。 - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java deleted file mode 100644 index 12b6822d6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣商品 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_product", autoResultMap = true) -@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountProductDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 限时折扣活动的编号 - * - * 关联 {@link DiscountActivityDO#getId()} - */ - private Long activityId; - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - - /** - * 活动状态 - * - * 关联 {@link DiscountActivityDO#getStatus()} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - * - * 冗余 {@link DiscountActivityDO#getStartTime()} - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - * - * 冗余 {@link DiscountActivityDO#getEndTime()} - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java deleted file mode 100644 index e1c0dd376..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 装修页面 DO - * - * @author owen - */ -@TableName(value = "promotion_diy_page", autoResultMap = true) -@KeySequence("promotion_diy_page_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DiyPageDO extends BaseDO { - - /** - * 装修页面编号 - */ - @TableId - private Long id; - /** - * 装修模板编号 - * - * 关联 {@link DiyTemplateDO#getId()} - */ - private Long templateId; - /** - * 页面名称 - */ - private String name; - /** - * 备注 - */ - private String remark; - /** - * 预览图,多个逗号分隔 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List previewPicUrls; - /** - * 页面属性,JSON 格式 - */ - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java deleted file mode 100644 index 1b7e1d592..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 装修模板 DO - * - * 1. 新建一个模版,下面可以包含多个 {@link DiyPageDO} 页面,例如说首页、我的 - * 2. 如果需要使用某个模版,则将 {@link #used} 设置为 true,表示已使用,有且仅有一个 - * - * @author owen - */ -@TableName(value = "promotion_diy_template", autoResultMap = true) -@KeySequence("promotion_diy_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DiyTemplateDO extends BaseDO { - - /** - * 装修模板编号 - */ - @TableId - private Long id; - /** - * 模板名称 - */ - private String name; - /** - * 是否使用 - */ - private Boolean used; - /** - * 使用时间 - */ - private LocalDateTime usedTime; - /** - * 备注 - */ - private String remark; - - /** - * 预览图 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List previewPicUrls; - /** - * uni-app 底部导航属性,JSON 格式 - */ - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java deleted file mode 100644 index 0c0b477ef..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.reward; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 满减送活动 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_reward_activity", autoResultMap = true) -@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class RewardActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link PromotionActivityStatusEnum} - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品 SPU 编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productSpuIds; - /** - * 优惠规则的数组 - */ - @TableField(typeHandler = RuleTypeHandler.class) - private List rules; - - /** - * 优惠规则 - */ - @Data - public static class Rule implements Serializable { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠券数量的数组 - */ - private List couponCounts; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class RuleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Rule.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java deleted file mode 100644 index 76a08ac70..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀活动 DO - * - * @author halfninety - */ -@TableName(value = "promotion_seckill_activity", autoResultMap = true) -@KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityDO extends BaseDO { - - /** - * 秒杀活动编号 - */ - @TableId - private Long id; - /** - * 秒杀活动商品 - */ - private Long spuId; - /** - * 秒杀活动名称 - */ - private String name; - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - /** - * 排序 - */ - private Integer sort; - /** - * 秒杀时段 id - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List configIds; - - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 单次限够数量 - */ - private Integer singleLimitCount; - - /** - * 秒杀库存(剩余库存秒杀时扣减) - */ - private Integer stock; - /** - * 秒杀总库存 - */ - private Integer totalStock; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java deleted file mode 100644 index 73efb7ad4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 秒杀时段 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_seckill_config", autoResultMap = true) -@KeySequence("promotion_seckill_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SeckillConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 秒杀时段名称 - */ - private String name; - /** - * 开始时间点 - */ - private String startTime; - /** - * 结束时间点 - */ - private String endTime; - /** - * 秒杀轮播图 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List sliderPicUrls; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java deleted file mode 100644 index 45a2d9e93..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀参与商品 DO - * - * @author HUIHUI - */ -@TableName("promotion_seckill_product") -@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SeckillProductDO extends BaseDO { - - /** - * 秒杀参与商品编号 - */ - @TableId - private Long id; - /** - * 秒杀活动 id - * - * 关联 {@link SeckillActivityDO#getId()} - */ - private Long activityId; - /** - * 秒杀时段 id - * - * 关联 {@link SeckillConfigDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List configIds; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 秒杀金额,单位:分 - */ - private Integer seckillPrice; - /** - * 秒杀库存 - */ - private Integer stock; - - /** - * 秒杀商品状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java deleted file mode 100644 index d39264b6a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 文章分类 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface ArticleCategoryMapper extends BaseMapperX { - - default PageResult selectPage(ArticleCategoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) - .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ArticleCategoryDO::getSort)); - } - - default List selectListByStatus(Integer status) { - return selectList(ArticleCategoryDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java deleted file mode 100644 index 4ee82471e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 文章管理 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface ArticleMapper extends BaseMapperX { - - default PageResult selectPage(ArticlePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) - .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) - .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) - .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) - .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) - .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ArticleDO::getId)); - } - - default List selectList(Boolean recommendHot, Boolean recommendBanner) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) - .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); - } - - default List selectListByTitle(String title) { - return selectList(ArticleDO::getTitle, title); - } - - default PageResult selectPage(AppArticlePageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); - } - - default void updateBrowseCount(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(ArticleDO::getId, id) - .setSql("browse_count = browse_count + 1")); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java deleted file mode 100644 index 74bd3c7da..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * Banner Mapper - * - * @author xia - */ -@Mapper -public interface BannerMapper extends BaseMapperX { - - default PageResult selectPage(BannerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BannerDO::getTitle, reqVO.getTitle()) - .eqIfPresent(BannerDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BannerDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BannerDO::getSort)); - } - - default void updateBrowseCount(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BannerDO::getId, id) - .setSql("browse_count = browse_count + 1")); - } - - default List selectBannerListByPosition(Integer position) { - return selectList(new LambdaQueryWrapperX().eq(BannerDO::getPosition, position)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java deleted file mode 100644 index 72d604e77..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价活动 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface BargainActivityMapper extends BaseMapperX { - - default PageResult selectPage(BargainActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BargainActivityDO::getName, reqVO.getName()) - .eqIfPresent(BargainActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(BargainActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BargainActivityDO::getStatus, status); - } - - /** - * 更新活动库存 - * - * @param id 活动编号 - * @param count 扣减的库存数量 - * @return 影响的行数 - */ - default int updateStock(Long id, int count) { - // 情况一:增加库存 - if (count > 0) { - return update(null, new LambdaUpdateWrapper() - .eq(BargainActivityDO::getId, id) - .setSql("stock = stock + " + count)); - } - // 情况二:扣减库存 - count = -count; // 取正 - return update(null, new LambdaUpdateWrapper() - .eq(BargainActivityDO::getId, id) - .ge(BargainActivityDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 查询处在 now 日期时间且是 status 状态的活动分页 - * - * @param pageReqVO 分页参数 - * @param status 状态 - * @param now 当前日期时间 - * @return 活动分页 - */ - default PageResult selectPage(PageParam pageReqVO, Integer status, LocalDateTime now) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(BargainActivityDO::getStatus, status) - .le(BargainActivityDO::getStartTime, now) - .ge(BargainActivityDO::getEndTime, now)); - } - - /** - * 查询处在 now 日期时间且是 status 状态的活动分页 - * - * @param status 状态 - * @param now 当前日期时间 - * @return 活动分页 - */ - default List selectList(Integer count, Integer status, LocalDateTime now) { - return selectList(new LambdaQueryWrapperX() - .eq(BargainActivityDO::getStatus, status) - .le(BargainActivityDO::getStartTime, now) - .ge(BargainActivityDO::getEndTime, now) - .last("LIMIT " + count)); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection spuIds, Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(BargainActivityDO::getId, ids) - .lt(BargainActivityDO::getStartTime, dateTime) - .gt(BargainActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(BargainActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java deleted file mode 100644 index 8d01ba361..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -@Mapper -public interface BargainHelpMapper extends BaseMapperX { - - default Long selectCountByUserIdAndActivityId(Long userId, Long activityId) { - return selectCount(new LambdaQueryWrapper<>(BargainHelpDO.class) - .eq(BargainHelpDO::getUserId, userId) - .eq(BargainHelpDO::getActivityId, activityId)); - } - - default Long selectUserCountMapByRecordId(Long recordId) { - return selectCount(BargainHelpDO::getRecordId, recordId); - } - - default BargainHelpDO selectByUserIdAndRecordId(Long userId, Long recordId) { - return selectOne(new LambdaQueryWrapper<>(BargainHelpDO.class) - .eq(BargainHelpDO::getUserId, userId) - .eq(BargainHelpDO::getRecordId, recordId)); - } - - default Map selectUserCountMapByActivityId(Collection activityIds) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") - .in("activity_id", activityIds) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - default Map selectUserCountMapByRecordId(Collection recordIds) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(1) AS userCount, record_id AS recordId") - .in("record_id", recordIds) - .groupBy("record_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "recordId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - default PageResult selectPage(BargainHelpPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainHelpDO::getRecordId, reqVO.getRecordId()) - .orderByDesc(BargainHelpDO::getId)); - } - - default List selectListByRecordId(Long recordId) { - return selectList(new LambdaQueryWrapperX() - .eq(BargainHelpDO::getRecordId, recordId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java deleted file mode 100644 index 17560db82..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 砍价记录 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface BargainRecordMapper extends BaseMapperX { - - default BargainRecordDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(BargainRecordDO::getId, id, - BargainRecordDO::getUserId, userId); - } - - default List selectListByUserIdAndActivityIdAndStatus( - Long userId, Long activityId, Integer status) { - return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .eq(BargainRecordDO::getStatus, status)); - } - - default BargainRecordDO selectLastByUserIdAndActivityId(Long userId, Long activityId) { - return selectOne(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .orderByDesc(BargainRecordDO::getId) - .last("LIMIT 1")); - } - - default Long selectCountByUserIdAndActivityIdAndStatus( - Long userId, Long activityId, Integer status) { - return selectCount(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .eq(BargainRecordDO::getStatus, status)); - } - - default int updateByIdAndBargainPrice(Long id, Integer whereBargainPrice, BargainRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getId, id) - .eq(BargainRecordDO::getBargainPrice, whereBargainPrice)); - } - - default Map selectUserCountByActivityIdsAndStatus(Collection activityIds, Integer status) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") - .in("activity_id", activityIds) - .eq(status != null, "status", status) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " + - "WHERE status = #{status}") - Integer selectUserCountByStatus(@Param("status") Integer status); - - @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " + - "WHERE activity_id = #{activityId} " + - "AND status = #{status}") - Integer selectUserCountByActivityIdAndStatus(@Param("activityId") Long activityId, - @Param("status") Integer status); - - default PageResult selectPage(BargainRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BargainRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BargainRecordDO::getId)); - } - - default PageResult selectBargainRecordPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(BargainRecordDO::getUserId, userId) - .orderByDesc(BargainRecordDO::getId)); - } - - default List selectListByStatusAndCount(Integer status, Integer count) { - return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getStatus, status) - .last("LIMIT " + count)); - } - - /** - * 更新砍价的订单编号,前提是 orderId 原本是空的 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - * @return 更新数量 - */ - default int updateOrderIdById(Long id, Long orderId) { - return update(new BargainRecordDO().setOrderId(orderId).setEndTime(LocalDateTime.now()), - new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getId, id) - .isNull(BargainRecordDO::getOrderId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java deleted file mode 100644 index 55e975c45..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 拼团活动 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationActivityMapper extends BaseMapperX { - - default PageResult selectPage(CombinationActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CombinationActivityDO::getName, reqVO.getName()) - .eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(CombinationActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(CombinationActivityDO::getStatus, status); - } - - default PageResult selectPage(PageParam pageParam, Integer status) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(CombinationActivityDO::getStatus, status)); - } - - default List selectListByStatus(Integer status, Integer count) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationActivityDO::getStatus, status) - .last("LIMIT " + count)); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(CombinationActivityDO::getId, ids) - .lt(CombinationActivityDO::getStartTime, dateTime) - .gt(CombinationActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(CombinationActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java deleted file mode 100644 index 5d80b6d09..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 拼团商品 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationProductMapper extends BaseMapperX { - - default PageResult selectPage(CombinationProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CombinationProductDO::getActivityId, reqVO.getActivityId()) - .eqIfPresent(CombinationProductDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(CombinationProductDO::getSkuId, reqVO.getSkuId()) - .eqIfPresent(CombinationProductDO::getActivityStatus, reqVO.getActivityStatus()) - .betweenIfPresent(CombinationProductDO::getActivityStartTime, reqVO.getActivityStartTime()) - .betweenIfPresent(CombinationProductDO::getActivityEndTime, reqVO.getActivityEndTime()) - .eqIfPresent(CombinationProductDO::getCombinationPrice, reqVO.getActivePrice()) - .betweenIfPresent(CombinationProductDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CombinationProductDO::getId)); - } - - default List selectListByActivityIds(Collection ids) { - return selectList(CombinationProductDO::getActivityId, ids); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java deleted file mode 100644 index 04c1c6157..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 拼团记录 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationRecordMapper extends BaseMapperX { - - default CombinationRecordDO selectByUserIdAndOrderId(Long userId, Long orderId) { - return selectOne(CombinationRecordDO::getUserId, userId, - CombinationRecordDO::getOrderId, orderId); - } - - /** - * 查询拼团记录 - * - * @param headId 团长编号 - * @return 拼团记录 - */ - default CombinationRecordDO selectByHeadId(Long headId, Integer status) { - return selectOne(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getId, headId) - .eq(CombinationRecordDO::getStatus, status)); - } - - /** - * 查询拼团记录 - * - * @param userId 用户 id - * @param activityId 活动 id - * @return 拼团记录 - */ - default List selectListByUserIdAndActivityId(Long userId, Long activityId) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getUserId, userId) - .eq(CombinationRecordDO::getActivityId, activityId)); - } - - /** - * 获取最近的 count 条数据 - * - * @param count 数量 - * @return 拼团记录列表 - */ - default List selectLatestList(int count) { - return selectList(new LambdaQueryWrapperX() - .orderByDesc(CombinationRecordDO::getId) - .last("LIMIT " + count)); - } - - default List selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status, - Long headId, Integer count) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getActivityId, activityId) - .eqIfPresent(CombinationRecordDO::getStatus, status) - .eq(CombinationRecordDO::getHeadId, headId) - .orderByDesc(CombinationRecordDO::getId) - .last("LIMIT " + count)); - } - - default Map selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection activityIds, - Integer status, Long headId) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId") - .in("activity_id", activityIds) - .eq(status != null, "status", status) - .eq(headId != null, "head_id", headId) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "recordCount")); - } - - default PageResult selectPage(CombinationRecordReqPageVO pageVO) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) - .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()); - // 如果 headId 非空,说明查询指定团的团长 + 团员的拼团记录 - if (pageVO.getHeadId() != null) { - queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) // 团长 - .or().eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); // 团员 - } - return selectPage(pageVO, queryWrapper); - } - - /** - * 查询指定条件的记录数 - * - * @param status 状态,可为 null - * @param virtualGroup 是否虚拟成团,可为 null - * @param headId 团长编号,可为 null - * @return 记录数 - */ - default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { - return selectCount(new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getStatus, status) - .eqIfPresent(CombinationRecordDO::getVirtualGroup, virtualGroup) - .eqIfPresent(CombinationRecordDO::getHeadId, headId)); - } - - /** - * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 - * - * @return 参加过拼团的用户数 - */ - default Long selectUserCount() { - return selectCount(new QueryWrapper() - .select("DISTINCT (user_id)")); - } - - default List selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getHeadId, headId) - .eq(CombinationRecordDO::getStatus, status) - .lt(CombinationRecordDO::getExpireTime, dateTime)); - } - - default List selectListByHeadId(Long headId) { - return selectList(CombinationRecordDO::getHeadId, headId); - } - - default PageResult selectPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getUserId, userId) - .eqIfPresent(CombinationRecordDO::getStatus, pageReqVO.getStatus()); - return selectPage(pageReqVO, queryWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java deleted file mode 100755 index e5f1daf6c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.github.yulichang.toolkit.MPJWrappers; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 优惠劵 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponMapper extends BaseMapperX { - - default PageResult selectPage(CouponPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CouponDO::getTemplateId, reqVO.getTemplateId()) - .eqIfPresent(CouponDO::getStatus, reqVO.getStatus()) - .inIfPresent(CouponDO::getUserId, reqVO.getUserIds()) - .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CouponDO::getId)); - } - - default List selectListByUserIdAndStatus(Long userId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId).eq(CouponDO::getStatus, status)); - } - - default CouponDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CouponDO::getId, id).eq(CouponDO::getUserId, userId)); - } - - default int delete(Long id, Collection whereStatuses) { - return update(null, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).in(CouponDO::getStatus, whereStatuses) - .set(CouponDO::getDeleted, 1)); - } - - default int updateByIdAndStatus(Long id, Integer status, CouponDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).eq(CouponDO::getStatus, status)); - } - - default Long selectCountByUserIdAndStatus(Long userId, Integer status) { - return selectCount(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId) - .eq(CouponDO::getStatus, status)); - } - - default List selectListByTemplateIdAndUserId(Long templateId, Collection userIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getTemplateId, templateId) - .in(CouponDO::getUserId, userIds) - ); - } - - default Map selectCountByUserIdAndTemplateIdIn(Long userId, Collection templateIds) { - String templateIdAlias = "templateId"; - String countAlias = "count"; - List> list = selectMaps(MPJWrappers.lambdaJoin(CouponDO.class) - .selectAs(CouponDO::getTemplateId, templateIdAlias) - .selectCount(CouponDO::getId, countAlias) - .eq(CouponDO::getUserId, userId) - .in(CouponDO::getTemplateId, templateIds) - .groupBy(CouponDO::getTemplateId)); - return convertMap(list, map -> MapUtil.getLong(map, templateIdAlias), map -> MapUtil.getInt(map, countAlias)); - } - - default List selectListByUserIdAndStatusAndUsePriceLeAndProductScope( - Long userId, Integer status, Integer usePrice, List spuIds, List categoryIds) { - Function, String> productScopeValuesFindInSetFunc = ids -> ids.stream() - .map(id -> StrUtil.format("FIND_IN_SET({}, product_scope_values) ", id)) - .collect(Collectors.joining(" OR ")); - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId) - .eq(CouponDO::getStatus, status) - .le(CouponDO::getUsePrice, usePrice) // 价格小于等于,满足价格使用条件 - .and(w -> w.eq(CouponDO::getProductScope, PromotionProductScopeEnum.ALL.getScope()) // 商品范围一:全部 - .or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.SPU.getScope()) // 商品范围二:满足指定商品 - .apply(productScopeValuesFindInSetFunc.apply(spuIds))) - .or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.CATEGORY.getScope()) // 商品范围三:满足指定分类 - .apply(productScopeValuesFindInSetFunc.apply(categoryIds))))); - } - - default List selectListByStatusAndValidEndTimeLe(Integer status, LocalDateTime validEndTime) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getStatus, status) - .le(CouponDO::getValidEndTime, validEndTime) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java deleted file mode 100755 index 50e3c0315..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.function.Consumer; - -/** - * 优惠劵模板 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateMapper extends BaseMapperX { - - default PageResult selectPage(CouponTemplatePageReqVO reqVO) { - // 构建可领取的查询条件 - Consumer> canTakeConsumer = buildCanTakeQueryConsumer(reqVO.getCanTakeTypes()); - // 执行分页查询 - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CouponTemplateDO::getName, reqVO.getName()) - .eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType()) - .betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(CouponTemplateDO::getProductScope, reqVO.getProductScope()) - .and(reqVO.getProductScopeValue() != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)", - reqVO.getProductScopeValue())) - .and(canTakeConsumer != null, canTakeConsumer) - .orderByDesc(CouponTemplateDO::getId)); - } - - default void updateTakeCount(Long id, Integer incrCount) { - update(null, new LambdaUpdateWrapper() - .eq(CouponTemplateDO::getId, id) - .setSql("take_count = take_count + " + incrCount)); - } - - default List selectListByTakeType(Integer takeType) { - return selectList(CouponTemplateDO::getTakeType, takeType); - } - - default List selectList(List canTakeTypes, Integer productScope, Long productScopeValue, Integer count) { - // 构建可领取的查询条件 - Consumer> canTakeConsumer = buildCanTakeQueryConsumer(canTakeTypes); - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CouponTemplateDO::getProductScope, productScope) - .and(productScopeValue != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)", - productScopeValue)) - .and(canTakeConsumer != null, canTakeConsumer) - .last(" LIMIT " + count) - .orderByDesc(CouponTemplateDO::getId)); - } - - static Consumer> buildCanTakeQueryConsumer(List canTakeTypes) { - Consumer> canTakeConsumer = null; - if (CollUtil.isNotEmpty(canTakeTypes)) { - canTakeConsumer = w -> - w.eq(CouponTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) // 1. 状态为可用的 - .in(CouponTemplateDO::getTakeType, canTakeTypes) // 2. 领取方式一致 - .and(ww -> ww.gt(CouponTemplateDO::getValidEndTime, LocalDateTime.now()) // 3.1 未过期 - .or().eq(CouponTemplateDO::getValidityType, CouponTemplateValidityTypeEnum.TERM.getType())) // 3.2 领取之后 - .apply(" (take_count < total_count OR total_count = -1 )"); // 4. 剩余数量大于 0,或者无限领取 - } - return canTakeConsumer; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java deleted file mode 100755 index efd4e4d25..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityMapper extends BaseMapperX { - - default PageResult selectPage(DiscountActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiscountActivityDO::getName, reqVO.getName()) - .eqIfPresent(DiscountActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DiscountActivityDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiscountActivityDO::getId)); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(DiscountActivityDO::getId, ids) - .lt(DiscountActivityDO::getStartTime, dateTime) - .gt(DiscountActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(DiscountActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java deleted file mode 100755 index 5257b836d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 限时折扣商城 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountProductMapper extends BaseMapperX { - - default List selectListBySkuId(Collection skuIds) { - return selectList(DiscountProductDO::getSkuId, skuIds); - } - - default List selectListByActivityId(Long activityId) { - return selectList(DiscountProductDO::getActivityId, activityId); - } - - default List selectListByActivityId(Collection activityIds) { - return selectList(DiscountProductDO::getActivityId, activityIds); - } - - // TODO @zhangshuai:逻辑里,尽量避免写 join 语句哈,你可以看看这个查询,有什么办法优化?目前的一个思路,是分 2 次查询,性能也是 ok 的 - List getMatchDiscountProductList(@Param("skuIds") Collection skuIds); - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection spuIds, Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(activity_id)) AS activityId") - .in("spu_id", spuIds) - .eq("activity_status", status) - .groupBy("spu_id")); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java deleted file mode 100644 index 979b93f25..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 装修页面 Mapper - * - * @author owen - */ -@Mapper -public interface DiyPageMapper extends BaseMapperX { - - default PageResult selectPage(DiyPagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiyPageDO::getName, reqVO.getName()) - .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime()) - // 模板下面的页面,在模板中管理 - .isNull(DiyPageDO::getTemplateId) - .orderByDesc(DiyPageDO::getId)); - } - - default List selectListByTemplateId(Long templateId) { - return selectList(DiyPageDO::getTemplateId, templateId); - } - - default DiyPageDO selectByNameAndTemplateIdIsNull(String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(DiyPageDO::getName, name) - .isNull(DiyPageDO::getTemplateId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java deleted file mode 100644 index ca3c6284e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 装修模板 Mapper - * - * @author owen - */ -@Mapper -public interface DiyTemplateMapper extends BaseMapperX { - - default PageResult selectPage(DiyTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiyTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DiyTemplateDO::getUsed, reqVO.getUsed()) - .betweenIfPresent(DiyTemplateDO::getUsedTime, reqVO.getUsedTime()) - .betweenIfPresent(DiyTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiyTemplateDO::getUsed) // 排序规则1:已使用的排到最前面 - .orderByDesc(DiyTemplateDO::getId)); // 排序规则2:新创建的排到前面 - } - - default DiyTemplateDO selectByUsed(boolean used) { - return selectOne(DiyTemplateDO::getUsed, used); - } - - default DiyTemplateDO selectByName(String name) { - return selectOne(DiyTemplateDO::getName, name); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java deleted file mode 100755 index ca9e9668f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.reward; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * 满减送活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityMapper extends BaseMapperX { - - default PageResult selectPage(RewardActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(RewardActivityDO::getName, reqVO.getName()) - .eqIfPresent(RewardActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(RewardActivityDO::getId)); - } - - default List selectListByStatus(Collection statuses) { - return selectList(RewardActivityDO::getStatus, statuses); - } - - default List selectListByProductScopeAndStatus(Integer productScope, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(RewardActivityDO::getProductScope, productScope) - .eq(RewardActivityDO::getStatus, status)); - } - - default List selectListBySpuIdsAndStatus(Collection spuIds, Integer status) { - Function, String> productScopeValuesFindInSetFunc = ids -> ids.stream() - .map(id -> StrUtil.format("FIND_IN_SET({}, product_spu_ids) ", id)) - .collect(Collectors.joining(" OR ")); - return selectList(new QueryWrapper() - .eq("status", status) - .apply(productScopeValuesFindInSetFunc.apply(spuIds))); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(RewardActivityDO::getId, ids) - .lt(RewardActivityDO::getStartTime, dateTime) - .gt(RewardActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(RewardActivityDO::getCreateTime) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java deleted file mode 100644 index ca40e7602..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 秒杀活动 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillActivityMapper extends BaseMapperX { - - default PageResult selectPage(SeckillActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillActivityDO::getName, reqVO.getName()) - .eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime()) - .apply(ObjectUtil.isNotNull(reqVO.getConfigId()), "FIND_IN_SET(" + reqVO.getConfigId() + ", config_ids) > 0") - .orderByDesc(SeckillActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(SeckillActivityDO::getStatus, status)); - } - - /** - * 更新活动库存(减少) - * - * @param id 活动编号 - * @param count 扣减的库存数量(正数) - * @return 影响的行数 - */ - default int updateStockDecr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillActivityDO::getId, id) - .gt(SeckillActivityDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 更新活动库存(增加) - * - * @param id 活动编号 - * @param count 增加的库存数量(正数) - * @return 影响的行数 - */ - default int updateStockIncr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillActivityDO::getId, id) - .setSql("stock = stock + " + count)); - } - - default PageResult selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(SeckillActivityDO::getStatus, status) - // TODO 芋艿:对 find in set 的想法; - .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(SeckillActivityDO::getId, ids) - .lt(SeckillActivityDO::getStartTime, dateTime) - .gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(SeckillActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java deleted file mode 100644 index 8fb140179..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动商品 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillProductMapper extends BaseMapperX { - - default List selectListByActivityId(Long activityId) { - return selectList(SeckillProductDO::getActivityId, activityId); - } - - default SeckillProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) { - return selectOne(SeckillProductDO::getActivityId, activityId, - SeckillProductDO::getSkuId, skuId); - } - - default List selectListByActivityId(Collection ids) { - return selectList(SeckillProductDO::getActivityId, ids); - } - - /** - * 更新活动库存(减少) - * - * @param id 活动编号 - * @param count 扣减的库存数量(减少库存) - * @return 影响的行数 - */ - default int updateStockDecr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillProductDO::getId, id) - .ge(SeckillProductDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 更新活动库存(增加) - * - * @param id 活动编号 - * @param count 需要增加的库存(增加库存) - * @return 影响的行数 - */ - default int updateStockIncr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillProductDO::getId, id) - .setSql("stock = stock + " + count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java deleted file mode 100644 index f1dcaca32..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface SeckillConfigMapper extends BaseMapperX { - - default PageResult selectPage(SeckillConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillConfigDO::getName, reqVO.getName()) - .eqIfPresent(SeckillConfigDO::getStatus, reqVO.getStatus()) - .orderByAsc(SeckillConfigDO::getStartTime)); - } - - default List selectListByStatus(Integer status) { - return selectList(SeckillConfigDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java deleted file mode 100644 index b2131910d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 promotion 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.promotion.framework; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 33c4be85b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.promotion.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {ProductSkuApi.class, ProductSpuApi.class, ProductCategoryApi.class, - MemberUserApi.class, TradeOrderApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java deleted file mode 100644 index 2484c83e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.promotion.framework.rpc; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 99f1ef547..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Promotion 模块的 Security 配置 - */ -@Configuration("promotionSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("promotionAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java deleted file mode 100644 index 72b196292..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.promotion.framework.security.core; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java deleted file mode 100644 index 9e86dfc7b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.job.combination; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:配置一个 Job -/** - * 拼团过期 Job - * - * @author HUIHUI - */ -@Component -public class CombinationRecordExpireJob { - - @Resource - private CombinationRecordService combinationRecordService; - - @XxlJob("combinationRecordExpireJob") - @TenantJob // 多租户 - public String execute() { - KeyValue keyValue = combinationRecordService.expireCombinationRecord(); - return StrUtil.format("过期拼团 {} 个, 虚拟成团 {} 个", keyValue.getKey(), keyValue.getValue()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java deleted file mode 100644 index dc0f9c3a4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.job.coupon; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:配置一个 Job -/** - * 优惠券过期 Job - * - * @author owen - */ -@Component -public class CouponExpireJob { - - @Resource - private CouponService couponService; - - @XxlJob("couponExpireJob") - @TenantJob // 多租户 - public String execute() { - int count = couponService.expireCoupon(); - return StrUtil.format("过期优惠券 {} 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java deleted file mode 100644 index 320b98aa2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无具体含义 - */ -package cn.iocoder.yudao.module.promotion.job; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java deleted file mode 100644 index 4d7a092c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.mq.consumer.coupon; - -import cn.iocoder.yudao.module.member.message.user.MemberUserCreateMessage; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 用户注册时,发送优惠劵的消费者,基 {@link MemberUserCreateMessage} 消息 - * - * @author owen - */ -@Component -@Slf4j -public class CouponTakeByRegisterConsumer { - - @Resource - private CouponService couponService; - - @EventListener - @Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步 - public void onMessage(MemberUserCreateMessage message) { - log.info("[onMessage][消息内容({})]", message); - couponService.takeCouponByRegister(message.getUserId()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java deleted file mode 100644 index 95c23df74..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消费者 - */ -package cn.iocoder.yudao.module.promotion.mq.consumer; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java deleted file mode 100644 index 912504e76..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.promotion.mq.message; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java deleted file mode 100644 index e7b8d1b4c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的生产者 - */ -package cn.iocoder.yudao.module.promotion.mq.producer; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java deleted file mode 100644 index c022c6276..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * promotion 模块,我们放营销业务。 - * 例如说:营销活动、banner、优惠券等等 - * - * 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.promotion; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java deleted file mode 100644 index 7ce7c0aa0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 文章分类 Service 接口 - * - * @author HUIHUI - */ -public interface ArticleCategoryService { - - /** - * 创建文章分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createArticleCategory(@Valid ArticleCategoryCreateReqVO createReqVO); - - /** - * 更新文章分类 - * - * @param updateReqVO 更新信息 - */ - void updateArticleCategory(@Valid ArticleCategoryUpdateReqVO updateReqVO); - - /** - * 删除文章分类 - * - * @param id 编号 - */ - void deleteArticleCategory(Long id); - - /** - * 获得文章分类 - * - * @param id 编号 - * @return 文章分类 - */ - ArticleCategoryDO getArticleCategory(Long id); - - /** - * 获得文章分类分页 - * - * @param pageReqVO 分页查询 - * @return 文章分类分页 - */ - PageResult getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); - - /** - * 获得指定状态的文章分类列表 - * - * @param status 状态 - * @return 文章分类列表 - */ - List getArticleCategoryListByStatus(Integer status); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java deleted file mode 100644 index 9375f498c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; - -/** - * 文章分类 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ArticleCategoryServiceImpl implements ArticleCategoryService { - - @Resource - private ArticleCategoryMapper articleCategoryMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ArticleService articleService; - - @Override - public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { - // 插入 - ArticleCategoryDO category = ArticleCategoryConvert.INSTANCE.convert(createReqVO); - articleCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateArticleCategory(ArticleCategoryUpdateReqVO updateReqVO) { - // 校验存在 - validateArticleCategoryExists(updateReqVO.getId()); - // 更新 - ArticleCategoryDO updateObj = ArticleCategoryConvert.INSTANCE.convert(updateReqVO); - articleCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteArticleCategory(Long id) { - // 校验存在 - validateArticleCategoryExists(id); - // 校验是不是存在关联文章 - Long count = articleService.getArticleCountByCategoryId(id); - if (count > 0) { - throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); - } - - // 删除 - articleCategoryMapper.deleteById(id); - } - - private void validateArticleCategoryExists(Long id) { - if (articleCategoryMapper.selectById(id) == null) { - throw exception(ARTICLE_CATEGORY_NOT_EXISTS); - } - } - - @Override - public ArticleCategoryDO getArticleCategory(Long id) { - return articleCategoryMapper.selectById(id); - } - - @Override - public PageResult getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { - return articleCategoryMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleCategoryListByStatus(Integer status) { - return articleCategoryMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java deleted file mode 100644 index 24b0fc9fb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 文章 Service 接口 - * - * @author HUIHUI - */ -public interface ArticleService { - - /** - * 创建文章 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createArticle(@Valid ArticleCreateReqVO createReqVO); - - /** - * 更新文章 - * - * @param updateReqVO 更新信息 - */ - void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); - - /** - * 删除文章 - * - * @param id 编号 - */ - void deleteArticle(Long id); - - /** - * 获得文章 - * - * @param id 编号 - * @return 文章 - */ - ArticleDO getArticle(Long id); - - /** - * 基于标题,获得文章 - * - * 如果有重名的文章,获取最后发布的 - * - * @param title 标题 - * @return 文章 - */ - ArticleDO getLastArticleByTitle(String title); - - /** - * 获得文章分页 - * - * @param pageReqVO 分页查询 - * @return 文章分页 - */ - PageResult getArticlePage(ArticlePageReqVO pageReqVO); - - /** - * 获得文章列表 - * - * @param recommendHot 是否热门 - * @param recommendBanner 是否轮播图 - * @return 文章列表 - */ - List getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner); - - /** - * 获得文章分页 - * - * @param pageReqVO 分页查询 - * @return 文章分页 - */ - PageResult getArticlePage(AppArticlePageReqVO pageReqVO); - - /** - * 获得指定分类的文章数量 - * - * @param categoryId 文章分类编号 - * @return 文章数量 - */ - Long getArticleCountByCategoryId(Long categoryId); - - /** - * 增加文章浏览量 - * - * @param id 文章编号 - */ - void addArticleBrowseCount(Long id); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java deleted file mode 100644 index 24883657e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; - -/** - * 文章管理 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ArticleServiceImpl implements ArticleService { - - @Resource - private ArticleMapper articleMapper; - - @Resource - private ArticleCategoryService articleCategoryService; - - @Override - public Long createArticle(ArticleCreateReqVO createReqVO) { - // 校验分类存在 - validateArticleCategoryExists(createReqVO.getCategoryId()); - - // 插入 - ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); - article.setBrowseCount(0); // 初始浏览量 - articleMapper.insert(article); - // 返回 - return article.getId(); - } - - @Override - public void updateArticle(ArticleUpdateReqVO updateReqVO) { - // 校验存在 - validateArticleExists(updateReqVO.getId()); - // 校验分类存在 - validateArticleCategoryExists(updateReqVO.getCategoryId()); - - // 更新 - ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); - articleMapper.updateById(updateObj); - } - - @Override - public void deleteArticle(Long id) { - // 校验存在 - validateArticleExists(id); - // 删除 - articleMapper.deleteById(id); - } - - private void validateArticleExists(Long id) { - if (articleMapper.selectById(id) == null) { - throw exception(ARTICLE_NOT_EXISTS); - } - } - - private void validateArticleCategoryExists(Long categoryId) { - ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(categoryId); - if (articleCategory == null) { - throw exception(ARTICLE_CATEGORY_NOT_EXISTS); - } - } - - @Override - public ArticleDO getArticle(Long id) { - return articleMapper.selectById(id); - } - - @Override - public ArticleDO getLastArticleByTitle(String title) { - List articles = articleMapper.selectListByTitle(title); - return CollUtil.getLast(articles); - } - - @Override - public PageResult getArticlePage(ArticlePageReqVO pageReqVO) { - return articleMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner) { - return articleMapper.selectList(recommendHot, recommendBanner); - } - - @Override - public PageResult getArticlePage(AppArticlePageReqVO pageReqVO) { - return articleMapper.selectPage(pageReqVO); - } - - @Override - public Long getArticleCountByCategoryId(Long categoryId) { - return articleMapper.selectCount(ArticleDO::getCategoryId, categoryId); - } - - @Override - public void addArticleBrowseCount(Long id) { - // 校验文章是否存在 - validateArticleExists(id); - // 增加浏览次数 - articleMapper.updateBrowseCount(id); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java deleted file mode 100644 index 404f7f5b2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 首页 Banner Service 接口 - * - * @author xia - */ -public interface BannerService { - - /** - * 创建 Banner - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBanner(@Valid BannerCreateReqVO createReqVO); - - /** - * 更新 Banner - * - * @param updateReqVO 更新信息 - */ - void updateBanner(@Valid BannerUpdateReqVO updateReqVO); - - /** - * 删除 Banner - * - * @param id 编号 - */ - void deleteBanner(Long id); - - /** - * 获得 Banner - * - * @param id 编号 - * @return Banner - */ - BannerDO getBanner(Long id); - - /** - * 获得 Banner 分页 - * - * @param pageReqVO 分页查询 - * @return Banner分页 - */ - PageResult getBannerPage(BannerPageReqVO pageReqVO); - - /** - * 增加 Banner 点击量 - * - * @param id Banner编号 - */ - void addBannerBrowseCount(Long id); - - /** - * 获得 Banner 列表 - * - * @param position 定位 - * @return Banner 列表 - */ - List getBannerListByPosition(Integer position); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java deleted file mode 100644 index 46c22f0e2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.banner.BannerMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.BANNER_NOT_EXISTS; - -/** - * 首页 banner 实现类 - * - * @author xia - */ -@Service -@Validated -public class BannerServiceImpl implements BannerService { - - @Resource - private BannerMapper bannerMapper; - - @Override - public Long createBanner(BannerCreateReqVO createReqVO) { - // 插入 - BannerDO banner = BannerConvert.INSTANCE.convert(createReqVO); - bannerMapper.insert(banner); - // 返回 - return banner.getId(); - } - - @Override - public void updateBanner(BannerUpdateReqVO updateReqVO) { - // 校验存在 - this.validateBannerExists(updateReqVO.getId()); - // 更新 - BannerDO updateObj = BannerConvert.INSTANCE.convert(updateReqVO); - bannerMapper.updateById(updateObj); - } - - @Override - public void deleteBanner(Long id) { - // 校验存在 - this.validateBannerExists(id); - // 删除 - bannerMapper.deleteById(id); - } - - private void validateBannerExists(Long id) { - if (bannerMapper.selectById(id) == null) { - throw exception(BANNER_NOT_EXISTS); - } - } - - @Override - public BannerDO getBanner(Long id) { - return bannerMapper.selectById(id); - } - - @Override - public PageResult getBannerPage(BannerPageReqVO pageReqVO) { - return bannerMapper.selectPage(pageReqVO); - } - - @Override - public void addBannerBrowseCount(Long id) { - // 校验 Banner 是否存在 - validateBannerExists(id); - // 增加点击次数 - bannerMapper.updateBrowseCount(id); - } - - @Override - public List getBannerListByPosition(Integer position) { - return bannerMapper.selectBannerListByPosition(position); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java deleted file mode 100644 index e1d2702b1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 砍价活动 Service 接口 - * - * @author HUIHUI - */ -public interface BargainActivityService { - - /** - * 创建砍价活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBargainActivity(@Valid BargainActivityCreateReqVO createReqVO); - - /** - * 更新砍价活动 - * - * @param updateReqVO 更新信息 - */ - void updateBargainActivity(@Valid BargainActivityUpdateReqVO updateReqVO); - - /** - * 更新砍价活动库存 - * - * 如果更新失败(库存不足),则抛出业务异常 - * - * @param id 砍价活动编号 - * @param count 购买数量 - */ - void updateBargainActivityStock(Long id, Integer count); - - /** - * 关闭砍价活动 - * - * @param id 砍价活动编号 - */ - void closeBargainActivityById(Long id); - - /** - * 删除砍价活动 - * - * @param id 编号 - */ - void deleteBargainActivity(Long id); - - /** - * 获得砍价活动 - * - * @param id 编号 - * @return 砍价活动 - */ - BargainActivityDO getBargainActivity(Long id); - - /** - * 获得砍价活动列表 - * - * @param ids 编号数组 - * @return 砍价活动列表 - */ - List getBargainActivityList(Set ids); - - /** - * 校验砍价活动,是否可以参与(发起砍价、下单、帮好友砍价) - * - * @param id 编号 - * @return 砍价活动 - */ - BargainActivityDO validateBargainActivityCanJoin(Long id); - - /** - * 获得砍价活动分页 - * - * @param pageReqVO 分页查询 - * @return 砍价活动分页 - */ - PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO); - - /** - * 获取正在进行的活动分页数据 - * - * @param pageReqVO 分页请求 - * @return 砍价活动分页 - */ - PageResult getBargainActivityPage(PageParam pageReqVO); - - /** - * 获取正在进行的活动分页数据 - * - * @param count 需要的数量 - * @return 砍价活动分页 - */ - List getBargainActivityListByCount(Integer count); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 砍价活动列表 - */ - List getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java deleted file mode 100644 index 4e30536a8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价活动 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainActivityServiceImpl implements BargainActivityService { - - @Resource - private BargainActivityMapper bargainActivityMapper; - - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) { - // 校验商品 SPU 是否存在是否参加的别的活动 - validateBargainConflict(createReqVO.getSpuId(), null); - // 校验商品 sku 是否存在 - validateSku(createReqVO.getSkuId()); - - // 插入砍价活动 - BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO) - .setTotalStock(createReqVO.getStock()) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - bargainActivityMapper.insert(activityDO); - return activityDO.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBargainActivity(BargainActivityUpdateReqVO updateReqVO) { - // 校验存在 - BargainActivityDO activity = validateBargainActivityExists(updateReqVO.getId()); - // 校验状态 - if (ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); - } - // 校验商品冲突 - validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); - // 校验商品 sku 是否存在 - validateSku(updateReqVO.getSkuId()); - - // 更新 - BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); - if (updateObj.getStock() > activity.getTotalStock()) { // 如果更新的库存大于原来的库存,则更新总库存 - updateObj.setTotalStock(updateObj.getStock()); - } - bargainActivityMapper.updateById(updateObj); - } - - @Override - public void updateBargainActivityStock(Long id, Integer count) { - if (count < 0) { - // 更新库存。如果更新失败,则抛出异常 - int updateCount = bargainActivityMapper.updateStock(id, count); - if (updateCount == 0) { - throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); - } - } else if (count > 0) { - bargainActivityMapper.updateStock(id, count); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void closeBargainActivityById(Long id) { - // 校验砍价活动是否存在 - BargainActivityDO activity = validateBargainActivityExists(id); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); - } - - bargainActivityMapper.updateById(new BargainActivityDO().setId(id) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - } - - private void validateBargainConflict(Long spuId, Long activityId) { - // 查询所有开启的砍价活动 - List activityList = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 更新时排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 校验商品 spu 是否参加了其它活动 - if (anyMatch(activityList, activity -> ObjectUtil.equal(activity.getSpuId(), spuId))) { - throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS); - } - } - - private void validateSku(Long skuId) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId).getCheckedData(); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBargainActivity(Long id) { - // 校验存在 - BargainActivityDO activityDO = validateBargainActivityExists(id); - // 校验状态 - if (CommonStatusEnum.isEnable(activityDO.getStatus())) { - throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除 - bargainActivityMapper.deleteById(id); - } - - private BargainActivityDO validateBargainActivityExists(Long id) { - BargainActivityDO activityDO = bargainActivityMapper.selectById(id); - if (activityDO == null) { - throw exception(BARGAIN_ACTIVITY_NOT_EXISTS); - } - return activityDO; - } - - @Override - public BargainActivityDO getBargainActivity(Long id) { - return bargainActivityMapper.selectById(id); - } - - @Override - public List getBargainActivityList(Set ids) { - return bargainActivityMapper.selectBatchIds(ids); - } - - @Override - public BargainActivityDO validateBargainActivityCanJoin(Long id) { - BargainActivityDO activity = bargainActivityMapper.selectById(id); - if (activity == null) { - throw exception(BARGAIN_ACTIVITY_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_CLOSED); - } - if (activity.getStock() <= 0) { - throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); - } - if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - throw exception(BARGAIN_ACTIVITY_TIME_END); - } - return activity; - } - - @Override - public PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO) { - return bargainActivityMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getBargainActivityPage(PageParam pageReqVO) { - // 只查询进行中,且在时间范围内的 - return bargainActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } - - @Override - public List getBargainActivityListByCount(Integer count) { - return bargainActivityMapper.selectList(count, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } - - @Override - public List getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = bargainActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2. 查询活动详情 - return bargainActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java deleted file mode 100644 index 8aec48597..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价助力 Service 接口 - * - * @author 芋道源码 - */ -public interface BargainHelpService { - - /** - * 创建砍价助力(帮人砍价) - * - * @param userId 用户编号 - * @param reqVO 请求信息 - * @return 砍价助力记录 - */ - BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO); - - /** - * 【砍价活动】获得助力人数 Map - * - * @param activityIds 活动编号 - * @return 助力人数 Map - */ - Map getBargainHelpUserCountMapByActivity(Collection activityIds); - - /** - * 【砍价记录】获得助力人数 Map - * - * @param recordIds 记录编号 - * @return 助力人数 Map - */ - Map getBargainHelpUserCountMapByRecord(Collection recordIds); - - /** - * 【砍价活动】获得用户的助力次数 - * - * @param activityId 活动编号 - * @param userId 用户编号 - * @return 助力次数 - */ - Long getBargainHelpCountByActivity(Long activityId, Long userId); - - /** - * 获得砍价助力分页 - * - * @param pageReqVO 分页查询 - * @return 砍价助力分页 - */ - PageResult getBargainHelpPage(BargainHelpPageReqVO pageReqVO); - - /** - * 获得指定砍价记录编号,对应的砍价助力列表 - * - * @param recordId 砍价记录编号 - * @return 砍价助力列表 - */ - List getBargainHelpListByRecordId(Long recordId); - - /** - * 获得助力记录 - * - * @param recordId 砍价记录编号 - * @param userId 用户编号 - * @return 助力记录 - */ - BargainHelpDO getBargainHelp(Long recordId, Long userId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java deleted file mode 100644 index f60ed5c0d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainHelpMapper; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import jodd.util.MathUtil; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价助力 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BargainHelpServiceImpl implements BargainHelpService { - - @Resource - private BargainHelpMapper bargainHelpMapper; - - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - - @Override - @Transactional(rollbackFor = Exception.class) - public BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO) { - // 1.1 校验砍价记录存在,并且处于进行中 - BargainRecordDO record = bargainRecordService.getBargainRecord(reqVO.getRecordId()); - if (record == null) { - throw exception(BARGAIN_RECORD_NOT_EXISTS); - } - if (ObjUtil.notEqual(record.getStatus(), BargainRecordStatusEnum.IN_PROGRESS.getStatus())) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS); - } - // 1.2 不能自己给自己砍价 - if (ObjUtil.equal(record.getUserId(), userId)) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_SELF); - } - - // 2.1 校验砍价活动 - BargainActivityDO activity = bargainActivityService.getBargainActivity(record.getActivityId()); - // 2.2 校验自己是否助力次数上限 - if (bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activity.getId()) - >= activity.getBargainCount()) { - throw exception(BARGAIN_HELP_CREATE_FAIL_LIMIT); - } - // 2.3 特殊情况:砍价已经砍到最低价,不能再砍了 - if (record.getBargainPrice() <= activity.getBargainMinPrice()) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS); - } - - // 3. 已经助力 - if (bargainHelpMapper.selectByUserIdAndRecordId(userId, record.getId()) != null) { - throw exception(BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS); - } - - // 4.1 计算砍价金额 - Integer reducePrice = calculateReducePrice(activity, record); - Assert.isTrue(reducePrice > 0, "砍价金额必须大于 0 元"); - // 4.2 创建助力记录 - BargainHelpDO help = BargainHelpDO.builder().userId(userId).activityId(activity.getId()) - .recordId(record.getId()).reducePrice(reducePrice).build(); - bargainHelpMapper.insert(help); - - // 5. 判断砍价记录是否完成 - Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价 - || bargainHelpMapper.selectUserCountMapByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限 - if (!bargainRecordService.updateBargainRecordBargainPrice( - record.getId(), record.getBargainPrice(), reducePrice, success)) { - // 多人一起砍价,需要重试 - throw exception(BARGAIN_HELP_CREATE_FAIL_CONFLICT); - } - return help; - } - - // TODO 芋艿:优化点:实现一个更随机的逻辑,可以按照你自己的业务; - private Integer calculateReducePrice(BargainActivityDO activity, BargainRecordDO record) { - // 1. 随机金额 - Integer reducePrice = MathUtil.randomInt(activity.getBargainMinPrice(), - activity.getRandomMaxPrice() + 1); // + 1 的原因是,randomInt 默认不包含第二个参数 - // 2. 校验是否超过砍价上限 - if (record.getBargainPrice() - reducePrice < activity.getBargainMinPrice()) { - reducePrice = record.getBargainPrice() - activity.getBargainMinPrice(); - } - return reducePrice; - } - - @Override - public Map getBargainHelpUserCountMapByActivity(Collection activityIds) { - return bargainHelpMapper.selectUserCountMapByActivityId(activityIds); - } - - @Override - public Map getBargainHelpUserCountMapByRecord(Collection recordIds) { - return bargainHelpMapper.selectUserCountMapByRecordId(recordIds); - } - - @Override - public Long getBargainHelpCountByActivity(Long activityId, Long userId) { - return bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activityId); - } - - @Override - public PageResult getBargainHelpPage(BargainHelpPageReqVO pageReqVO) { - return bargainHelpMapper.selectPage(pageReqVO); - } - - @Override - public List getBargainHelpListByRecordId(Long recordId) { - return bargainHelpMapper.selectListByRecordId(recordId); - } - - @Override - public BargainHelpDO getBargainHelp(Long recordId, Long userId) { - return bargainHelpMapper.selectByUserIdAndRecordId(userId, recordId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java deleted file mode 100644 index e3ba206a1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价记录 service 接口 - * - * @author HUIHUI - */ -public interface BargainRecordService { - - /** - * 【会员】创建砍价记录(参与参加活动) - * - * @param userId 用户编号 - * @param reqVO 创建信息 - * @return 砍价记录编号 - */ - Long createBargainRecord(Long userId, AppBargainRecordCreateReqVO reqVO); - - /** - * 更新砍价记录的砍价金额 - * - * 如果满足砍价成功的条件,则更新砍价记录的状态为成功 - * - * @param id 砍价记录编号 - * @param whereBargainPrice 当前的砍价金额 - * @param reducePrice 减少的砍价金额 - * @param success 是否砍价成功 - * @return 是否更新成功。注意,如果并发更新时,会更新失败 - */ - Boolean updateBargainRecordBargainPrice(Long id, Integer whereBargainPrice, - Integer reducePrice, Boolean success); - - /** - * 【下单前】校验是否参与砍价活动 - *

- * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param bargainRecordId 砍价活动编号 - * @param skuId SKU 编号 - * @return 砍价信息 - */ - BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId); - - /** - * 更新砍价记录的订单编号 - * - * 在砍价成功后,用户发起订单后,会记录该订单编号 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - */ - void updateBargainRecordOrderId(Long id, Long orderId); - - /** - * 获得砍价记录 - * - * @param id 砍价记录编号 - * @return 砍价记录 - */ - BargainRecordDO getBargainRecord(Long id); - - /** - * 获得用户在当前砍价活动中的最后一条砍价记录 - * - * @param userId 用户编号 - * @param activityId 砍价记录编号 - * @return 砍价记录 - */ - BargainRecordDO getLastBargainRecord(Long userId, Long activityId); - - /** - * 获得砍价人数 Map - * - * @param activityIds 活动编号 - * @param status 砍价记录状态 - * @return 砍价人数 Map - */ - Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status); - - /** - * 获得砍价人数 - * - * @param status 砍价记录状态 - * @return 砍价人数 - */ - Integer getBargainRecordUserCount(Integer status); - - /** - * 获得砍价人数 - * - * @param activityId 砍价活动编号 - * @param status 砍价记录状态 - * @return 砍价人数 - */ - Integer getBargainRecordUserCount(Long activityId, Integer status); - - /** - * 【管理员】获得砍价记录分页 - * - * @param pageReqVO 分页查询 - * @return 砍价记录分页 - */ - PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO); - - /** - * 【会员】获得砍价记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 砍价记录分页 - */ - PageResult getBargainRecordPage(Long userId, PageParam pageParam); - - /** - * 获得砍价记录列表 - * - * @param status 砍价记录状态 - * @param count 条数 - * @return 砍价记录列表 - */ - List getBargainRecordList(Integer status, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java deleted file mode 100644 index aa6db4a74..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Nullable; -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价记录 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainRecordServiceImpl implements BargainRecordService { - - @Resource - private BargainActivityService bargainActivityService; - - @Resource - private BargainRecordMapper bargainRecordMapper; - - @Override - public Long createBargainRecord(Long userId, AppBargainRecordCreateReqVO reqVO) { - // 1. 校验砍价活动(包括库存) - BargainActivityDO activity = bargainActivityService.validateBargainActivityCanJoin(reqVO.getActivityId()); - - // 2.1 校验当前是否已经有参与中的砍价活动 - if (CollUtil.isNotEmpty(bargainRecordMapper.selectListByUserIdAndActivityIdAndStatus( - userId, reqVO.getActivityId(), BargainRecordStatusEnum.IN_PROGRESS.getStatus()))) { - throw exception(BARGAIN_RECORD_CREATE_FAIL_EXISTS); - } - // 2.2 是否超过参与的上限 - if (bargainRecordMapper.selectCountByUserIdAndActivityIdAndStatus( - userId, reqVO.getActivityId(), BargainRecordStatusEnum.SUCCESS.getStatus()) >= activity.getTotalLimitCount()) { - throw exception(BARGAIN_RECORD_CREATE_FAIL_LIMIT); - } - - // 3. 创建砍价记录 - BargainRecordDO record = BargainRecordDO.builder().userId(userId) - .activityId(reqVO.getActivityId()).spuId(activity.getSpuId()).skuId(activity.getSkuId()) - .bargainFirstPrice(activity.getBargainFirstPrice()).bargainPrice(activity.getBargainFirstPrice()) - .status(BargainRecordStatusEnum.IN_PROGRESS.getStatus()).build(); - bargainRecordMapper.insert(record); - return record.getId(); - } - - @Override - public Boolean updateBargainRecordBargainPrice(Long id, Integer whereBargainPrice, - Integer reducePrice, Boolean success) { - BargainRecordDO updateObj = new BargainRecordDO().setBargainPrice(whereBargainPrice - reducePrice); - if (success) { - updateObj.setStatus(BargainRecordStatusEnum.SUCCESS.getStatus()); - } - return bargainRecordMapper.updateByIdAndBargainPrice(id, whereBargainPrice, updateObj) > 0; - } - - @Override - public BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { - // 1.1 砍价记录不存在 - BargainRecordDO record = bargainRecordMapper.selectByIdAndUserId(bargainRecordId, userId); - if (record == null) { - throw exception(BARGAIN_RECORD_NOT_EXISTS); - } - // 1.2 砍价记录未在进行中 - if (ObjUtil.notEqual(record.getStatus(), BargainRecordStatusEnum.SUCCESS.getStatus())) { - throw exception(BARGAIN_JOIN_RECORD_NOT_SUCCESS); - } - // 1.3 砍价记录已经下单 - if (record.getOrderId() != null) { - throw exception(BARGAIN_JOIN_RECORD_ALREADY_ORDER); - } - - // 2.1 校验砍价活动(包括库存) - BargainActivityDO activity = bargainActivityService.validateBargainActivityCanJoin(record.getActivityId()); - Assert.isTrue(Objects.equals(skuId, activity.getSkuId()), "砍价商品不匹配"); // 防御性校验 - return new BargainValidateJoinRespDTO().setActivityId(activity.getId()).setName(activity.getName()) - .setBargainPrice(record.getBargainPrice()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBargainRecordOrderId(Long id, Long orderId) { - // 更新失败,说明已经下单 - int updateCount = bargainRecordMapper.updateOrderIdById(id, orderId); - if (updateCount == 0) { - throw exception(BARGAIN_JOIN_RECORD_ALREADY_ORDER); - } - } - - @Override - public BargainRecordDO getBargainRecord(Long id) { - return bargainRecordMapper.selectById(id); - } - - @Override - public BargainRecordDO getLastBargainRecord(Long userId, Long activityId) { - return bargainRecordMapper.selectLastByUserIdAndActivityId(userId, activityId); - } - - @Override - public Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status) { - return bargainRecordMapper.selectUserCountByActivityIdsAndStatus(activityIds, status); - } - - @Override - public Integer getBargainRecordUserCount(Integer status) { - return bargainRecordMapper.selectUserCountByStatus(status); - } - - @Override - public Integer getBargainRecordUserCount(Long activityId, Integer status) { - return bargainRecordMapper.selectUserCountByActivityIdAndStatus(activityId, status); - } - - @Override - public PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO) { - return bargainRecordMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getBargainRecordPage(Long userId, PageParam pageParam) { - return bargainRecordMapper.selectBargainRecordPage(userId, pageParam); - } - - @Override - public List getBargainRecordList(Integer status, Integer count) { - return bargainRecordMapper.selectListByStatusAndCount(status, count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java deleted file mode 100644 index 23adc738e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 拼团活动 Service 接口 - * - * @author HUIHUI - */ -public interface CombinationActivityService { - - /** - * 创建拼团活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCombinationActivity(@Valid CombinationActivityCreateReqVO createReqVO); - - /** - * 更新拼团活动 - * - * @param updateReqVO 更新信息 - */ - void updateCombinationActivity(@Valid CombinationActivityUpdateReqVO updateReqVO); - - /** - * 关闭拼团活动 - * - * @param id 拼团活动编号 - */ - void closeCombinationActivityById(Long id); - - /** - * 删除拼团活动 - * - * @param id 编号 - */ - void deleteCombinationActivity(Long id); - - /** - * 校验拼团活动是否存在 - * - * @param id 编号 - * @return 拼团活动 - */ - CombinationActivityDO validateCombinationActivityExists(Long id); - - /** - * 获得拼团活动 - * - * @param id 编号 - * @return 拼团活动 - */ - CombinationActivityDO getCombinationActivity(Long id); - - /** - * 获得拼团活动分页 - * - * @param pageReqVO 分页查询 - * @return 拼团活动分页 - */ - PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO); - - /** - * 获得拼团活动商品列表 - * - * @param activityId 拼团活动 id - * @return 拼团活动的商品列表 - */ - default List getCombinationProductsByActivityId(Long activityId) { - return getCombinationProductListByActivityIds(Collections.singletonList(activityId)); - } - - /** - * 获得拼团活动商品列表 - * - * @param activityIds 拼团活动 ids - * @return 拼团活动的商品列表 - */ - List getCombinationProductListByActivityIds(Collection activityIds); - - /** - * 获得拼团活动列表 - * - * @param ids 拼团活动 ids - * @return 拼团活动的列表 - */ - List getCombinationActivityListByIds(Collection ids); - - /** - * 获取正在进行的活动分页数据 - * - * @param count 需要的数量 - * @return 拼团活动分页 - */ - List getCombinationActivityListByCount(Integer count); - - /** - * 获取正在进行的活动分页数据 - * - * @param pageParam 分页请求 - * @return 拼团活动分页 - */ - PageResult getCombinationActivityPage(PageParam pageParam); - - /** - * 获取指定活动、指定 sku 编号的商品 - * - * @param activityId 活动编号 - * @param skuId sku 编号 - * @return 活动商品信息 - */ - CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 拼团活动列表 - */ - List getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java deleted file mode 100644 index 24f8c323e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java +++ /dev/null @@ -1,257 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 拼团活动 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CombinationActivityServiceImpl implements CombinationActivityService { - - @Resource - private CombinationActivityMapper combinationActivityMapper; - @Resource - private CombinationProductMapper combinationProductMapper; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createCombinationActivity(CombinationActivityCreateReqVO createReqVO) { - // 校验商品 SPU 是否存在是否参加的别的活动 - validateProductConflict(createReqVO.getSpuId(), null); - // 校验商品是否存在 - validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); - - // 插入拼团活动 - CombinationActivityDO activity = CombinationActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - combinationActivityMapper.insert(activity); - // 插入商品 - List products = CombinationActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); - combinationProductMapper.insertBatch(products); - return activity.getId(); - } - - /** - * 校验拼团商品参与的活动是否存在冲突 - * - * @param spuId 商品 SPU 编号 - * @param activityId 拼团活动编号 - */ - private void validateProductConflict(Long spuId, Long activityId) { - // 查询所有开启的拼团活动 - List activityList = combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 时排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 查找是否有其它活动,选择了该产品 - List matchActivityList = filterList(activityList, activity -> ObjectUtil.equal(activity.getId(), spuId)); - if (CollUtil.isNotEmpty(matchActivityList)) { - throw exception(COMBINATION_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 校验拼团商品是否都存在 - * - * @param spuId 商品 SPU 编号 - * @param products 拼团商品 - */ - private void validateProductExists(Long spuId, List products) { - // 1. 校验商品 spu 是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 2. 校验商品 sku 都存在 - List skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)).getCheckedData(); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - products.forEach(product -> { - if (!skuMap.containsKey(product.getSkuId())) { - throw exception(SKU_NOT_EXISTS); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateCombinationActivity(CombinationActivityUpdateReqVO updateReqVO) { - // 校验存在 - CombinationActivityDO activityDO = validateCombinationActivityExists(updateReqVO.getId()); - // 校验状态 - if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE); - } - // 校验商品冲突 - validateProductConflict(updateReqVO.getSpuId(), updateReqVO.getId()); - // 校验商品是否存在 - validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); - - // 更新活动 - CombinationActivityDO updateObj = CombinationActivityConvert.INSTANCE.convert(updateReqVO); - combinationActivityMapper.updateById(updateObj); - // 更新商品 - updateCombinationProduct(updateObj, updateReqVO.getProducts()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void closeCombinationActivityById(Long id) { - // 校验活动是否存在 - CombinationActivityDO activity = validateCombinationActivityExists(id); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE); - } - - // 关闭活动 - combinationActivityMapper.updateById(new CombinationActivityDO().setId(id) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - } - - /** - * 更新拼团商品 - * - * @param activity 拼团活动 - * @param products 该活动的最新商品配置 - */ - private void updateCombinationProduct(CombinationActivityDO activity, List products) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List newList = CombinationActivityConvert.INSTANCE.convertList(products, activity); - List oldList = combinationProductMapper.selectListByActivityIds(CollUtil.newArrayList(activity.getId())); - List> diffList = CollectionUtils.diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); - if (same) { - newVal.setId(oldVal.getId()); - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - combinationProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - combinationProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - combinationProductMapper.deleteBatchIds(CollectionUtils.convertList(diffList.get(2), CombinationProductDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteCombinationActivity(Long id) { - // 校验存在 - CombinationActivityDO activity = validateCombinationActivityExists(id); - // 校验状态 - if (CommonStatusEnum.isEnable(activity.getStatus())) { - throw exception(COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除 - combinationActivityMapper.deleteById(id); - } - - @Override - public CombinationActivityDO validateCombinationActivityExists(Long id) { - CombinationActivityDO activityDO = combinationActivityMapper.selectById(id); - if (activityDO == null) { - throw exception(COMBINATION_ACTIVITY_NOT_EXISTS); - } - return activityDO; - } - - @Override - public CombinationActivityDO getCombinationActivity(Long id) { - return validateCombinationActivityExists(id); - } - - @Override - public PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO) { - return combinationActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getCombinationProductListByActivityIds(Collection activityIds) { - return combinationProductMapper.selectListByActivityIds(activityIds); - } - - @Override - public List getCombinationActivityListByIds(Collection ids) { - return combinationActivityMapper.selectList(CombinationActivityDO::getId, ids); - } - - @Override - public List getCombinationActivityListByCount(Integer count) { - return combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus(), count); - } - - @Override - public PageResult getCombinationActivityPage(PageParam pageParam) { - return combinationActivityMapper.selectPage(pageParam, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) { - return combinationProductMapper.selectOne( - CombinationProductDO::getActivityId, activityId, - CombinationProductDO::getSkuId, skuId); - } - - @Override - public List getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = combinationActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2.查询活动详情 - return combinationActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java deleted file mode 100644 index 55f5b2ebc..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java +++ /dev/null @@ -1,176 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 拼团记录 Service 接口 - * - * @author HUIHUI - */ -public interface CombinationRecordService { - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - KeyValue validateCombinationRecord(Long userId, Long activityId, Long headId, - Long skuId, Integer count); - - /** - * 创建拼团记录 - * - * @param reqDTO 创建信息 - * @return 团信息 - */ - CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO); - - /** - * 获得拼团记录 - * - * @param userId 用户编号 - * @param orderId 订单编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecord(Long userId, Long orderId); - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, Long skuId, Integer count); - - /** - * 获取拼团记录数 - * - * @param status 状态-允许为空 - * @param virtualGroup 是否虚拟成团-允许为空 - * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 - * @return 记录数 - */ - Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, Long headId); - - /** - * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 - * - * @return 参加过拼团的用户数 - */ - Long getCombinationUserCount(); - - /** - * 获取最近的 count 条拼团记录 - * - * @param count 限制数量 - * @return 拼团记录列表 - */ - List getLatestCombinationRecordList(int count); - - /** - * 获得最近 n 条拼团记录(团长发起的) - * - * @param activityId 拼团活动编号 - * @param status 状态 - * @param count 数量 - * @return 拼团记录列表 - */ - List getHeadCombinationRecordList(Long activityId, Integer status, Integer count); - - /** - * 获取指定编号的拼团记录 - * - * @param id 拼团记录编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecordById(Long id); - - /** - * 获取指定团长编号的拼团记录 - * - * @param headId 团长编号 - * @return 拼团记录列表 - */ - List getCombinationRecordListByHeadId(Long headId); - - /** - * 获取拼团记录分页数据 - * - * @param pageVO 分页请求 - * @return 拼团记录分页数据 - */ - PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO); - - /** - * 【拼团活动】获得拼团记录数量 Map - * - * @param activityIds 活动记录编号数组 - * @param status 拼团状态,允许空 - * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 - * @return 拼团记录数量 Map - */ - Map getCombinationRecordCountMapByActivity(Collection activityIds, - @Nullable Integer status, - @Nullable Long headId); - - /** - * 获取拼团记录 - * - * @param userId 用户编号 - * @param id 拼团记录编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id); - - /** - * 取消拼团 - * - * @param userId 用户编号 - * @param id 拼团记录编号 - * @param headId 团长编号 - */ - void cancelCombinationRecord(Long userId, Long id, Long headId); - - /** - * 处理过期拼团 - * - * @return key 过期拼团数量, value 虚拟成团数量 - */ - KeyValue expireCombinationRecord(); - - /** - * 获得拼团记录分页数据 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 拼团记录分页数据 - */ - PageResult getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java deleted file mode 100644 index dca15c233..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ /dev/null @@ -1,426 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Nullable; -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -// TODO 芋艿:等拼团记录做完,完整 review 下 - -/** - * 拼团记录 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Slf4j -@Validated -public class CombinationRecordServiceImpl implements CombinationRecordService { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private CombinationRecordMapper combinationRecordMapper; - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Resource - @Lazy - private TradeOrderApi tradeOrderApi; - - // TODO @芋艿:在详细预览下; - @Override - public KeyValue validateCombinationRecord( - Long userId, Long activityId, Long headId, Long skuId, Integer count) { - // 1. 校验拼团活动是否存在 - CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(activityId); - // 1.1 校验活动是否开启 - if (ObjUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE); - } - // 1.2. 校验活动开始时间 - if (afterNow(activity.getStartTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_NOT_START); - } - // 1.3 校验是否超出单次限购数量 - if (count > activity.getSingleLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); - } - - // 2. 父拼团是否存在,是否已经满了 - if (headId != null) { - // 2.1. 查询进行中的父拼团 - CombinationRecordDO record = combinationRecordMapper.selectByHeadId(headId, CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); - if (record == null) { - throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); - } - // 2.2. 校验拼团是否已满 - if (ObjUtil.equal(record.getUserCount(), record.getUserSize())) { - throw exception(COMBINATION_RECORD_USER_FULL); - } - // 2.3 校验拼团是否过期(有父拼团的时候只校验父拼团的过期时间) - if (beforeNow(record.getExpireTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_END); - } - } else { - // 3. 校验当前活动是否结束(自己是父拼团的时候才校验活动是否结束) - if (beforeNow(activity.getEndTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_END); - } - } - - // 4.1 校验活动商品是否存在 - CombinationProductDO product = combinationActivityService.selectByActivityIdAndSkuId(activityId, skuId); - if (product == null) { - throw exception(COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 4.2 校验 sku 是否存在 - ProductSkuRespDTO sku = productSkuApi.getSku(skuId).getCheckedData(); - if (sku == null) { - throw exception(COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 4.3 校验库存是否充足 - if (count > sku.getStock()) { - throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 6.1 校验是否有拼团记录 - List recordList = combinationRecordMapper.selectListByUserIdAndActivityId(userId, activityId); - recordList.removeIf(record -> CombinationRecordStatusEnum.isFailed(record.getStatus())); // 取消的订单,不算数 - if (CollUtil.isEmpty(recordList)) { // 如果为空,说明可以参与,直接返回 - return new KeyValue<>(activity, product); - } - // 6.2 校验用户是否有该活动正在进行的拼团 - CombinationRecordDO inProgressRecord = findFirst(recordList, - record -> CombinationRecordStatusEnum.isInProgress(record.getStatus())); - if (inProgressRecord != null) { - throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED); - } - // 6.3 校验是否超出总限购数量 - Integer sumValue = getSumValue(recordList, CombinationRecordDO::getCount, Integer::sum); - if (sumValue != null && sumValue + count > activity.getTotalLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); - } - return new KeyValue<>(activity, product); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { - // 1. 校验拼团活动 - KeyValue keyValue = validateCombinationRecord(reqDTO.getUserId(), - reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); - - // 2. 组合数据创建拼团记录 - MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()).getCheckedData(); - ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()).getCheckedData(); - ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()).getCheckedData(); - CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku); - // 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP - if (record.getHeadId() == null) { - record.setStartTime(LocalDateTime.now()) - .setExpireTime(LocalDateTime.now().plusHours(keyValue.getKey().getLimitDuration())) - .setHeadId(CombinationRecordDO.HEAD_ID_GROUP); - } else { - // 2.2.有团长的情况下需要设置开始时间和过期时间为团长的 - CombinationRecordDO headRecord = combinationRecordMapper.selectByHeadId(record.getHeadId(), - CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); // 查询进行中的父拼团 - record.setStartTime(headRecord.getStartTime()).setExpireTime(headRecord.getExpireTime()); - } - combinationRecordMapper.insert(record); - - // 3. 更新拼团记录 - if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { - updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); - } - return record; - } - - /** - * 当新增拼团时,更新拼团记录的进展 - * - * @param headId 团长编号 - * @param activity 活动 - */ - private void updateCombinationRecordWhenCreate(Long headId, CombinationActivityDO activity) { - // 1. 团长 + 团员 - List records = getCombinationRecordListByHeadId(headId); - if (CollUtil.isEmpty(records)) { - return; - } - CombinationRecordDO headRecord = combinationRecordMapper.selectById(headId); - - // 2. 批量更新记录 - List updateRecords = new ArrayList<>(); - records.add(headRecord); // 加入团长,团长也需要更新 - boolean isFull = records.size() >= activity.getUserSize(); - LocalDateTime now = LocalDateTime.now(); - records.forEach(item -> { - CombinationRecordDO updateRecord = new CombinationRecordDO(); - updateRecord.setId(item.getId()).setUserCount(records.size()); - if (isFull) { - updateRecord.setStatus(CombinationRecordStatusEnum.SUCCESS.getStatus()); - updateRecord.setEndTime(now); - } - updateRecords.add(updateRecord); - }); - combinationRecordMapper.updateBatch(updateRecords); - } - - @Override - public CombinationRecordDO getCombinationRecord(Long userId, Long orderId) { - return combinationRecordMapper.selectByUserIdAndOrderId(userId, orderId); - } - - @Override - public CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, - Long skuId, Integer count) { - KeyValue keyValue = validateCombinationRecord(userId, activityId, - headId, skuId, count); - return new CombinationValidateJoinRespDTO().setActivityId(keyValue.getKey().getId()) - .setName(keyValue.getKey().getName()).setCombinationPrice(keyValue.getValue().getCombinationPrice()); - } - - @Override - public Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, @Nullable Long headId) { - return combinationRecordMapper.selectCountByHeadAndStatusAndVirtualGroup(status, virtualGroup, headId); - } - - @Override - public Long getCombinationUserCount() { - return combinationRecordMapper.selectUserCount(); - } - - @Override - public List getLatestCombinationRecordList(int count) { - return combinationRecordMapper.selectLatestList(count); - } - - @Override - public List getHeadCombinationRecordList(Long activityId, Integer status, Integer count) { - return combinationRecordMapper.selectListByActivityIdAndStatusAndHeadId(activityId, status, - CombinationRecordDO.HEAD_ID_GROUP, count); - } - - @Override - public CombinationRecordDO getCombinationRecordById(Long id) { - return combinationRecordMapper.selectById(id); - } - - @Override - public List getCombinationRecordListByHeadId(Long headId) { - return combinationRecordMapper.selectList(CombinationRecordDO::getHeadId, headId); - } - - @Override - public PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO) { - return combinationRecordMapper.selectPage(pageVO); - } - - @Override - public Map getCombinationRecordCountMapByActivity(Collection activityIds, - @Nullable Integer status, @Nullable Long headId) { - return combinationRecordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId); - } - - @Override - public CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id) { - return combinationRecordMapper.selectOne(CombinationRecordDO::getUserId, userId, CombinationRecordDO::getId, id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelCombinationRecord(Long userId, Long id, Long headId) { - // 删除记录 - combinationRecordMapper.deleteById(id); - - // 需要更新的记录 - List updateRecords = new ArrayList<>(); - // 如果它是团长,则顺序(下单时间)继承 - if (Objects.equals(headId, CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 - // 团员 - List list = getCombinationRecordListByHeadId(id); - if (CollUtil.isEmpty(list)) { - return; - } - // 按照创建时间升序排序 - list.sort(Comparator.comparing(CombinationRecordDO::getCreateTime)); // 影响原 list - CombinationRecordDO newHead = list.get(0); // 新团长继位 - list.forEach(item -> { - CombinationRecordDO recordDO = new CombinationRecordDO(); - recordDO.setId(item.getId()); - if (ObjUtil.equal(item.getId(), newHead.getId())) { // 新团长 - recordDO.setHeadId(CombinationRecordDO.HEAD_ID_GROUP); - } else { - recordDO.setHeadId(newHead.getId()); - } - recordDO.setUserCount(list.size()); - updateRecords.add(recordDO); - }); - } else { // 情况二:团员 - // 团长 - CombinationRecordDO recordHead = combinationRecordMapper.selectById(headId); - // 团员 - List records = getCombinationRecordListByHeadId(headId); - if (CollUtil.isEmpty(records)) { - return; - } - records.add(recordHead); // 加入团长,团长数据也需要更新 - records.forEach(item -> { - CombinationRecordDO recordDO = new CombinationRecordDO(); - recordDO.setId(item.getId()); - recordDO.setUserCount(records.size()); - updateRecords.add(recordDO); - }); - } - - // 更新拼团记录 - combinationRecordMapper.updateBatch(updateRecords); - } - - @Override - public KeyValue expireCombinationRecord() { - // 1. 获取所有正在进行中的过期的父拼团 - List headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( - CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(headExpireRecords)) { - return new KeyValue<>(0, 0); - } - - // 2. 获取拼团活动 - List activities = combinationActivityService.getCombinationActivityListByIds( - convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); - Map activityMap = convertMap(activities, CombinationActivityDO::getId); - - // 3. 逐个处理拼团,过期 or 虚拟成团 - KeyValue keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 - for (CombinationRecordDO record : headExpireRecords) { - try { - CombinationActivityDO activity = activityMap.get(record.getActivityId()); - if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 - // 3.1. 处理过期的拼团 - getSelf().handleExpireRecord(record); - keyValue.setKey(keyValue.getKey() + 1); - } else { - // 3.2. 处理虚拟成团 - getSelf().handleVirtualGroupRecord(record); - keyValue.setValue(keyValue.getValue() + 1); - } - } catch (Exception ignored) { // 处理异常继续循环 - log.error("[expireCombinationRecord][record({}) 处理异常,请进行处理!record 数据是:{}]", - record.getId(), JsonUtils.toJsonString(record)); - } - } - return keyValue; - } - - /** - * 处理过期拼团 - * - * @param headRecord 过期拼团团长记录 - */ - @Transactional(rollbackFor = Exception.class) - public void handleExpireRecord(CombinationRecordDO headRecord) { - // 1. 更新拼团记录 - List headAndRecords = updateBatchCombinationRecords(headRecord, - CombinationRecordStatusEnum.FAILED); - // 2. 订单取消 - headAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId())); - } - - /** - * 处理虚拟拼团 - * - * @param headRecord 虚拟成团团长记录 - */ - @Transactional(rollbackFor = Exception.class) - public void handleVirtualGroupRecord(CombinationRecordDO headRecord) { - // 1. 团员补齐 - combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualRecordList(headRecord)); - // 2. 更新拼团记录 - updateBatchCombinationRecords(headRecord, CombinationRecordStatusEnum.SUCCESS); - } - - /** - * 更新拼团记录 - * - * @param headRecord 团长记录 - * @param status 状态-拼团失败 FAILED 成功 SUCCESS - * @return 整团记录(包含团长和团成员) - */ - private List updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { - // 1. 查询团成员(包含团长) - List records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); - records.add(headRecord);// 把团长加进去 - - // 2. 批量更新拼团记录 status 和 endTime - List updateRecords = new ArrayList<>(records.size()); - LocalDateTime now = LocalDateTime.now(); - records.forEach(item -> { - CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) - .setStatus(status.getStatus()).setEndTime(now); - if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 - updateRecord.setUserCount(updateRecord.getUserSize()); - } - updateRecords.add(updateRecord); - }); - combinationRecordMapper.updateBatch(updateRecords); - return records; - } - - @Override - public PageResult getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) { - return combinationRecordMapper.selectPage(userId, pageReqVO); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CombinationRecordServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java deleted file mode 100644 index edd654275..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; - -import java.util.*; - -/** - * 优惠劵 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponService { - - /** - * 校验优惠劵,包括状态、有限期 - *

- * 1. 如果校验通过,则返回优惠劵信息 - * 2. 如果校验不通过,则直接抛出业务异常 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @return 优惠劵信息 - */ - CouponDO validCoupon(Long id, Long userId); - - /** - * 校验优惠劵,包括状态、有限期 - * - * @param coupon 优惠劵 - * @see #validCoupon(Long, Long) 逻辑相同,只是入参不同 - */ - void validCoupon(CouponDO coupon); - - /** - * 获得优惠劵分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵分页 - */ - PageResult getCouponPage(CouponPageReqVO pageReqVO); - - /** - * 使用优惠劵 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void useCoupon(Long id, Long userId, Long orderId); - - /** - * 退还已使用的优惠券 - * - * @param id 优惠券编号 - */ - void returnUsedCoupon(Long id); - - /** - * 回收优惠劵 - * - * @param id 优惠劵编号 - */ - void deleteCoupon(Long id); - - /** - * 获得用户的优惠劵列表 - * - * @param userId 用户编号 - * @param status 优惠劵状态 - * @return 优惠劵列表 - */ - List getCouponList(Long userId, Integer status); - - /** - * 获得未使用的优惠劵数量 - * - * @param userId 用户编号 - * @return 未使用的优惠劵数量 - */ - Long getUnusedCouponCount(Long userId); - - /** - * 领取优惠券 - * - * @param templateId 优惠券模板编号 - * @param userIds 用户编号列表 - * @param takeType 领取方式 - */ - void takeCoupon(Long templateId, Set userIds, CouponTakeTypeEnum takeType); - - /** - * 【管理员】给用户发送优惠券 - * - * @param templateId 优惠券模板编号 - * @param userIds 用户编号列表 - */ - default void takeCouponByAdmin(Long templateId, Set userIds) { - takeCoupon(templateId, userIds, CouponTakeTypeEnum.ADMIN); - } - - /** - * 【会员】领取优惠券 - * - * @param templateId 优惠券模板编号 - * @param userId 用户编号 - */ - default void takeCouponByUser(Long templateId, Long userId) { - takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER); - } - - /** - * 【系统】给用户发送新人券 - * - * @param userId 用户编号 - */ - void takeCouponByRegister(Long userId); - - /** - * 获取会员领取指定优惠券的数量 - * - * @param templateId 优惠券模板编号 - * @param userId 用户编号 - * @return 领取优惠券的数量 - */ - default Integer getTakeCount(Long templateId, Long userId) { - Map map = getTakeCountMapByTemplateIds(Collections.singleton(templateId), userId); - return MapUtil.getInt(map, templateId, 0); - } - - /** - * 统计会员领取优惠券的数量 - * - * @param templateIds 优惠券模板编号列表 - * @param userId 用户编号 - * @return 领取优惠券的数量 - */ - Map getTakeCountMapByTemplateIds(Collection templateIds, Long userId); - - /** - * 获取用户匹配的优惠券列表 - * - * @param userId 用户编号 - * @param matchReqVO 匹配参数 - * @return 优惠券列表 - */ - List getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO); - - /** - * 过期优惠券 - * - * @return 过期数量 - */ - int expireCoupon(); - - /** - * 获取用户是否可以领取优惠券 - * - * @param userId 用户编号 - * @param templates 优惠券列表 - * @return 是否可以领取 - */ - Map getUserCanCanTakeMap(Long userId, List templates); - - /** - * 获得优惠劵 - * - * @param userId 用户编号 - * @param id 编号 - * @return 优惠劵 - */ - CouponDO getCoupon(Long userId, Long id); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java deleted file mode 100644 index aa1f34fe3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java +++ /dev/null @@ -1,334 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollStreamUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 优惠劵 Service 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@Service -@Validated -public class CouponServiceImpl implements CouponService { - - @Resource - private CouponTemplateService couponTemplateService; - - @Resource - private CouponMapper couponMapper; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public CouponDO validCoupon(Long id, Long userId) { - CouponDO coupon = couponMapper.selectByIdAndUserId(id, userId); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - validCoupon(coupon); - return coupon; - } - - @Override - public void validCoupon(CouponDO coupon) { - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.UNUSED.getStatus())) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - // 校验有效期;为避免定时器没跑,实际优惠劵已经过期 - if (!LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) { - throw exception(COUPON_VALID_TIME_NOT_NOW); - } - } - - @Override - public PageResult getCouponPage(CouponPageReqVO pageReqVO) { - // 获得用户编号 - if (StrUtil.isNotEmpty(pageReqVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()).getCheckedData(); - if (CollUtil.isEmpty(users)) { - return PageResult.empty(); - } - pageReqVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // 分页查询 - return couponMapper.selectPage(pageReqVO); - } - - @Override - public void useCoupon(Long id, Long userId, Long orderId) { - // 校验优惠劵 - validCoupon(id, userId); - - // 更新状态 - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.USED.getStatus()) - .setUseOrderId(orderId).setUseTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - } - - @Override - public void returnUsedCoupon(Long id) { - // 校验存在 - CouponDO coupon = couponMapper.selectById(id); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.USED.getStatus())) { - throw exception(COUPON_STATUS_NOT_USED); - } - - // 退还 - Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime()) - ? CouponStatusEnum.EXPIRE.getStatus() // 退还时可能已经过期了 - : CouponStatusEnum.UNUSED.getStatus(); - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.USED.getStatus(), - new CouponDO().setStatus(status)); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_USED); - } - - // TODO 增加优惠券变动记录? - } - - @Override - @Transactional - public void deleteCoupon(Long id) { - // 校验存在 - validateCouponExists(id); - - // 更新优惠劵 - int deleteCount = couponMapper.delete(id, - asList(CouponStatusEnum.UNUSED.getStatus(), CouponStatusEnum.EXPIRE.getStatus())); - if (deleteCount == 0) { - throw exception(COUPON_DELETE_FAIL_USED); - } - // 减少优惠劵模板的领取数量 -1 - couponTemplateService.updateCouponTemplateTakeCount(id, -1); - } - - @Override - public List getCouponList(Long userId, Integer status) { - return couponMapper.selectListByUserIdAndStatus(userId, status); - } - - private void validateCouponExists(Long id) { - if (couponMapper.selectById(id) == null) { - throw exception(COUPON_NOT_EXISTS); - } - } - - @Override - public Long getUnusedCouponCount(Long userId) { - return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus()); - } - - @Override - public void takeCoupon(Long templateId, Set userIds, CouponTakeTypeEnum takeType) { - CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId); - // 1. 过滤掉达到领取限制的用户 - removeTakeLimitUser(userIds, template); - // 2. 校验优惠劵是否可以领取 - validateCouponTemplateCanTake(template, userIds, takeType); - - // 3. 批量保存优惠劵 - couponMapper.insertBatch(convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId))); - - // 3. 增加优惠劵模板的领取数量 - couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void takeCouponByRegister(Long userId) { - List templates = couponTemplateService.getCouponTemplateListByTakeType(CouponTakeTypeEnum.REGISTER); - for (CouponTemplateDO template : templates) { - takeCoupon(template.getId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.REGISTER); - } - } - - @Override - public Map getTakeCountMapByTemplateIds(Collection templateIds, Long userId) { - if (CollUtil.isEmpty(templateIds)) { - return Collections.emptyMap(); - } - return couponMapper.selectCountByUserIdAndTemplateIdIn(userId, templateIds); - } - - @Override - public List getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO) { - List list = couponMapper.selectListByUserIdAndStatusAndUsePriceLeAndProductScope(userId, - CouponStatusEnum.UNUSED.getStatus(), - matchReqVO.getPrice(), matchReqVO.getSpuIds(), matchReqVO.getCategoryIds()); - // 兜底逻辑:如果 CouponExpireJob 未执行,status 未变成 EXPIRE ,但是 validEndTime 已经过期了,需要进行过滤 - list.removeIf(coupon -> !LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())); - return list; - } - - @Override - public int expireCoupon() { - // 1. 查询待过期的优惠券 - List list = couponMapper.selectListByStatusAndValidEndTimeLe( - CouponStatusEnum.UNUSED.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(list)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (CouponDO coupon : list) { - try { - boolean success = getSelf().expireCoupon(coupon); - if (success) { - count++; - } - } catch (Exception e) { - log.error("[expireCoupon][coupon({}) 更新为已过期失败]", coupon.getId(), e); - } - } - return count; - } - - @Override - public Map getUserCanCanTakeMap(Long userId, List templates) { - // 1. 未登录时,都显示可以领取 - Map userCanTakeMap = convertMap(templates, CouponTemplateDO::getId, templateId -> true); - if (userId == null) { - return userCanTakeMap; - } - - // 2.1 过滤领取数量无限制的 - Set templateIds = convertSet(templates, CouponTemplateDO::getId, template -> template.getTakeLimitCount() != -1); - // 2.2 检查用户领取的数量是否超过限制 - if (CollUtil.isNotEmpty(templateIds)) { - Map couponTakeCountMap = this.getTakeCountMapByTemplateIds(templateIds, userId); - for (CouponTemplateDO template : templates) { - Integer takeCount = couponTakeCountMap.get(template.getId()); - userCanTakeMap.put(template.getId(), takeCount == null || takeCount < template.getTakeLimitCount()); - } - } - return userCanTakeMap; - } - - /** - * 过期单个优惠劵 - * - * @param coupon 优惠劵 - * @return 是否过期成功 - */ - private boolean expireCoupon(CouponDO coupon) { - // 更新记录状态 - int updateRows = couponMapper.updateByIdAndStatus(coupon.getId(), CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.EXPIRE.getStatus())); - if (updateRows == 0) { - log.error("[expireCoupon][coupon({}) 更新为已过期失败]", coupon.getId()); - return false; - } - log.info("[expireCoupon][coupon({}) 更新为已过期成功]", coupon.getId()); - return true; - } - - /** - * 校验优惠券是否可以领取 - * - * @param couponTemplate 优惠券模板 - * @param userIds 领取人列表 - * @param takeType 领取方式 - */ - private void validateCouponTemplateCanTake(CouponTemplateDO couponTemplate, Set userIds, CouponTakeTypeEnum takeType) { - // 如果所有用户都领取过,则抛出异常 - if (CollUtil.isEmpty(userIds)) { - throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); - } - - // 校验模板 - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - // 校验剩余数量 - if (couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) { - throw exception(COUPON_TEMPLATE_NOT_ENOUGH); - } - // 校验"固定日期"的有效期类型是否过期 - if (CouponTemplateValidityTypeEnum.DATE.getType().equals(couponTemplate.getValidityType())) { - if (LocalDateTimeUtils.beforeNow(couponTemplate.getValidEndTime())) { - throw exception(COUPON_TEMPLATE_EXPIRED); - } - } - // 校验领取方式 - if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getValue())) { - throw exception(COUPON_TEMPLATE_CANNOT_TAKE); - } - } - - /** - * 过滤掉达到领取上线的用户 - * - * @param userIds 用户编号数组 - * @param couponTemplate 优惠劵模版 - */ - private void removeTakeLimitUser(Set userIds, CouponTemplateDO couponTemplate) { - if (couponTemplate.getTakeLimitCount() <= 0) { - return; - } - // 查询已领过券的用户 - List alreadyTakeCoupons = couponMapper.selectListByTemplateIdAndUserId(couponTemplate.getId(), userIds); - if (CollUtil.isEmpty(alreadyTakeCoupons)) { - return; - } - // 移除达到领取限制的用户 - Map userTakeCountMap = CollStreamUtil.groupBy(alreadyTakeCoupons, CouponDO::getUserId, Collectors.summingInt(c -> 1)); - userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount()); - } - - @Override - public CouponDO getCoupon(Long userId, Long id) { - return couponMapper.selectByIdAndUserId(id, userId); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CouponServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java deleted file mode 100755 index 02ed7585b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 优惠劵模板 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponTemplateService { - - /** - * 创建优惠劵模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCouponTemplate(@Valid CouponTemplateCreateReqVO createReqVO); - - /** - * 更新优惠劵模板 - * - * @param updateReqVO 更新信息 - */ - void updateCouponTemplate(@Valid CouponTemplateUpdateReqVO updateReqVO); - - /** - * 更新优惠劵模板的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateCouponTemplateStatus(Long id, Integer status); - - /** - * 删除优惠劵模板 - * - * @param id 编号 - */ - void deleteCouponTemplate(Long id); - - /** - * 获得优惠劵模板 - * - * @param id 编号 - * @return 优惠劵模板 - */ - CouponTemplateDO getCouponTemplate(Long id); - - /** - * 获得优惠劵模板分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵模板分页 - */ - PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO); - - /** - * 更新优惠劵模板的领取数量 - * - * @param id 优惠劵模板编号 - * @param incrCount 增加数量 - */ - void updateCouponTemplateTakeCount(Long id, int incrCount); - - /** - * 获得指定领取方式的优惠券模板 - * - * @param takeType 领取方式 - * @return 优惠券模板列表 - */ - List getCouponTemplateListByTakeType(CouponTakeTypeEnum takeType); - - /** - * 获得优惠券模板列表 - * - * @param canTakeTypes 可领取的类型列表 - * @param productScope 商品使用范围类型 - * @param productScopeValue 商品使用范围编号 - * @param count 查询数量 - * @return 优惠券模板列表 - */ - List getCouponTemplateList(List canTakeTypes, Integer productScope, - Long productScopeValue, Integer count); - - /** - * 获得优惠券模版列表 - * - * @param ids 优惠券模版编号 - * @return 优惠券模版列表 - */ - List getCouponTemplateList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java deleted file mode 100755 index deaa42638..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL; - -/** - * 优惠劵模板 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CouponTemplateServiceImpl implements CouponTemplateService { - - @Resource - private CouponTemplateMapper couponTemplateMapper; - - @Resource - private ProductCategoryApi productCategoryApi; - @Resource - private ProductSpuApi productSpuApi; - - @Override - public Long createCouponTemplate(CouponTemplateCreateReqVO createReqVO) { - // 校验商品范围 - validateProductScope(createReqVO.getProductScope(), createReqVO.getProductScopeValues()); - // 插入 - CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - couponTemplateMapper.insert(couponTemplate); - // 返回 - return couponTemplate.getId(); - } - - @Override - public void updateCouponTemplate(CouponTemplateUpdateReqVO updateReqVO) { - // 校验存在 - CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId()); - // 校验发放数量不能过小 - if (updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) { - throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount()); - } - // 校验商品范围 - validateProductScope(updateReqVO.getProductScope(), updateReqVO.getProductScopeValues()); - - // 更新 - CouponTemplateDO updateObj = CouponTemplateConvert.INSTANCE.convert(updateReqVO); - couponTemplateMapper.updateById(updateObj); - } - - @Override - public void updateCouponTemplateStatus(Long id, Integer status) { - // 校验存在 - validateCouponTemplateExists(id); - // 更新 - couponTemplateMapper.updateById(new CouponTemplateDO().setId(id).setStatus(status)); - } - - @Override - public void deleteCouponTemplate(Long id) { - // 校验存在 - validateCouponTemplateExists(id); - // 删除 - couponTemplateMapper.deleteById(id); - } - - private CouponTemplateDO validateCouponTemplateExists(Long id) { - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(id); - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - return couponTemplate; - } - - private void validateProductScope(Integer productScope, List productScopeValues) { - if (Objects.equals(PromotionProductScopeEnum.SPU.getScope(), productScope)) { - productSpuApi.validateSpuList(productScopeValues); - } else if (Objects.equals(PromotionProductScopeEnum.CATEGORY.getScope(), productScope)) { - productCategoryApi.validateCategoryList(productScopeValues); - } - } - - @Override - public CouponTemplateDO getCouponTemplate(Long id) { - return couponTemplateMapper.selectById(id); - } - - @Override - public PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO) { - return couponTemplateMapper.selectPage(pageReqVO); - } - - @Override - public void updateCouponTemplateTakeCount(Long id, int incrCount) { - couponTemplateMapper.updateTakeCount(id, incrCount); - } - - @Override - public List getCouponTemplateListByTakeType(CouponTakeTypeEnum takeType) { - return couponTemplateMapper.selectListByTakeType(takeType.getValue()); - } - - @Override - public List getCouponTemplateList(List canTakeTypes, Integer productScope, - Long productScopeValue, Integer count) { - return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count); - } - - @Override - public List getCouponTemplateList(Collection ids) { - return couponTemplateMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java deleted file mode 100644 index af8b757bd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣 Service 接口 - * - * @author 芋道源码 - */ -public interface DiscountActivityService { - - /** - * 基于指定 SKU 编号数组,获得匹配的限时折扣商品 - * - * 注意,匹配的条件,仅仅是日期符合,并且处于开启状态 - * - * @param skuIds SKU 编号数组 - * @return 匹配的限时折扣商品 - */ - List getMatchDiscountProductList(Collection skuIds); - - /** - * 创建限时折扣活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiscountActivity(@Valid DiscountActivityCreateReqVO createReqVO); - - /** - * 更新限时折扣活动 - * - * @param updateReqVO 更新信息 - */ - void updateDiscountActivity(@Valid DiscountActivityUpdateReqVO updateReqVO); - - /** - * 关闭限时折扣活动 - * - * @param id 编号 - */ - void closeDiscountActivity(Long id); - - /** - * 删除限时折扣活动 - * - * @param id 编号 - */ - void deleteDiscountActivity(Long id); - - /** - * 获得限时折扣活动 - * - * @param id 编号 - * @return 限时折扣活动 - */ - DiscountActivityDO getDiscountActivity(Long id); - - /** - * 获得限时折扣活动分页 - * - * @param pageReqVO 分页查询 - * @return 限时折扣活动分页 - */ - PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityId 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Long activityId); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityIds 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Collection activityIds); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 当前日期时间 - * @return 折扣活动列表 - */ - List getDiscountActivityBySpuIdsAndStatusAndDateTimeLt( - Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java deleted file mode 100644 index 507d0e1f9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 限时折扣 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class DiscountActivityServiceImpl implements DiscountActivityService { - - @Resource - private DiscountActivityMapper discountActivityMapper; - @Resource - private DiscountProductMapper discountProductMapper; - - @Override - public List getMatchDiscountProductList(Collection skuIds) { - return discountProductMapper.getMatchDiscountProductList(skuIds); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDiscountActivity(DiscountActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(null, createReqVO.getProducts()); - - // 插入活动 - DiscountActivityDO discountActivity = DiscountActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - discountActivityMapper.insert(discountActivity); - // 插入商品 - List discountProducts = BeanUtils.toBean(createReqVO.getProducts(), DiscountProductDO.class, - product -> product.setActivityId(discountActivity.getId()).setActivityStatus(discountActivity.getStatus()) - .setActivityStartTime(createReqVO.getStartTime()).setActivityEndTime(createReqVO.getEndTime())); - discountProductMapper.insertBatch(discountProducts); - // 返回 - return discountActivity.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDiscountActivity(DiscountActivityUpdateReqVO updateReqVO) { - // 校验存在 - DiscountActivityDO discountActivity = validateDiscountActivityExists(updateReqVO.getId()); - if (discountActivity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - - // 更新活动 - DiscountActivityDO updateObj = DiscountActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime())); - discountActivityMapper.updateById(updateObj); - // 更新商品 - updateDiscountProduct(updateReqVO); - } - - private void updateDiscountProduct(DiscountActivityUpdateReqVO updateReqVO) { - // TODO @zhangshuai:这里的逻辑,可以优化下哈;参考 CombinationActivityServiceImpl 的 updateCombinationProduct,主要是 CollectionUtils.diffList 的使用哈; - // 然后原先是使用 DiscountActivityConvert.INSTANCE.isEquals 对比,现在看看是不是简化就基于 skuId 对比就完事了;之前写的太精细,意义不大; - List dbDiscountProducts = discountProductMapper.selectListByActivityId(updateReqVO.getId()); - // 计算要删除的记录 - List deleteIds = convertList(dbDiscountProducts, DiscountProductDO::getId, - discountProductDO -> updateReqVO.getProducts().stream() - .noneMatch(product -> DiscountActivityConvert.INSTANCE.isEquals(discountProductDO, product))); - if (CollUtil.isNotEmpty(deleteIds)) { - discountProductMapper.deleteBatchIds(deleteIds); - } - // 计算新增的记录 - List newDiscountProducts = convertList(updateReqVO.getProducts(), - product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); - newDiscountProducts.removeIf(product -> dbDiscountProducts.stream().anyMatch( - dbProduct -> DiscountActivityConvert.INSTANCE.isEquals(dbProduct, product))); // 如果匹配到,说明是更新的 - if (CollectionUtil.isNotEmpty(newDiscountProducts)) { - discountProductMapper.insertBatch(newDiscountProducts); - } - } - - /** - * 校验商品是否冲突 - * - * @param id 编号 - * @param products 商品列表 - */ - private void validateDiscountActivityProductConflicts(Long id, List products) { - if (CollUtil.isEmpty(products)) { - return; - } - // 查询商品参加的活动 - // TODO @zhangshuai:下面 121 这个查询,是不是不用做呀;直接 convert 出 skuId 集合就 ok 啦; - List list = discountProductMapper.selectListByActivityId(id); - // TODO @zhangshuai:一般简单的 stream 方法,建议是使用 CollectionUtils,例如说这里是 convertList 对把。 - List skuIds = list.stream().map(item -> item.getSkuId()).collect(Collectors.toList()); - List matchDiscountProductList = getMatchDiscountProductList(skuIds); - if (id != null) { // 排除自己这个活动 - matchDiscountProductList.removeIf(product -> id.equals(product.getActivityId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(matchDiscountProductList)) { - throw exception(DISCOUNT_ACTIVITY_SPU_CONFLICTS); - } - } - - @Override - public void closeDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO activity = validateDiscountActivityExists(id); - if (activity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - - // 更新 - DiscountActivityDO updateObj = new DiscountActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - discountActivityMapper.updateById(updateObj); - } - - @Override - public void deleteDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO activity = validateDiscountActivityExists(id); - if (CommonStatusEnum.isEnable(activity.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - discountActivityMapper.deleteById(id); - } - - private DiscountActivityDO validateDiscountActivityExists(Long id) { - DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); - if (discountActivity == null) { - throw exception(DISCOUNT_ACTIVITY_NOT_EXISTS); - } - return discountActivity; - } - - @Override - public DiscountActivityDO getDiscountActivity(Long id) { - return discountActivityMapper.selectById(id); - } - - @Override - public PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO) { - return discountActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getDiscountProductsByActivityId(Long activityId) { - return discountProductMapper.selectListByActivityId(activityId); - } - - @Override - public List getDiscountProductsByActivityId(Collection activityIds) { - return discountProductMapper.selectList("activity_id", activityIds); - } - - @Override - public List getDiscountActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = discountProductMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - - // 2. 查询活动详情 - return discountActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java deleted file mode 100644 index 31900e7a4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 装修页面 Service 接口 - * - * @author owen - */ -public interface DiyPageService { - - /** - * 创建装修页面 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiyPage(@Valid DiyPageCreateReqVO createReqVO); - - /** - * 更新装修页面 - * - * @param updateReqVO 更新信息 - */ - void updateDiyPage(@Valid DiyPageUpdateReqVO updateReqVO); - - /** - * 删除装修页面 - * - * @param id 编号 - */ - void deleteDiyPage(Long id); - - /** - * 获得装修页面 - * - * @param id 编号 - * @return 装修页面 - */ - DiyPageDO getDiyPage(Long id); - - /** - * 获得装修页面列表 - * - * @param ids 编号 - * @return 装修页面列表 - */ - List getDiyPageList(Collection ids); - - /** - * 获得装修页面分页 - * - * @param pageReqVO 分页查询 - * @return 装修页面分页 - */ - PageResult getDiyPagePage(DiyPagePageReqVO pageReqVO); - - /** - * 更新装修页面属性 - * - * @param updateReqVO 更新信息 - */ - void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO); - - /** - * 获得模板所属的页面列表 - * - * @param templateId 模板编号 - * @return 装修页面列表 - */ - List getDiyPageByTemplateId(Long templateId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java deleted file mode 100644 index 69f96ad8f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NAME_USED; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; - -/** - * 装修页面 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class DiyPageServiceImpl implements DiyPageService { - - @Resource - private DiyPageMapper diyPageMapper; - - @Override - public Long createDiyPage(DiyPageCreateReqVO createReqVO) { - // 校验名称唯一 - validateNameUnique(null, createReqVO.getTemplateId(), createReqVO.getName()); - // 插入 - DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); - diyPage.setProperty("{}"); - diyPageMapper.insert(diyPage); - return diyPage.getId(); - } - - @Override - public void updateDiyPage(DiyPageUpdateReqVO updateReqVO) { - // 校验存在 - validateDiyPageExists(updateReqVO.getId()); - // 校验名称唯一 - validateNameUnique(updateReqVO.getId(), updateReqVO.getTemplateId(), updateReqVO.getName()); - // 更新 - DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); - diyPageMapper.updateById(updateObj); - } - - /** - * 校验 Page 页面,在一个 template 模版下的名字是唯一的 - * - * @param id Page 编号 - * @param templateId 模版编号 - * @param name Page 名字 - */ - void validateNameUnique(Long id, Long templateId, String name) { - if (templateId != null || StrUtil.isBlank(name)) { - return; - } - DiyPageDO page = diyPageMapper.selectByNameAndTemplateIdIsNull(name); - if (page == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的页面 - if (id == null) { - throw exception(DIY_PAGE_NAME_USED, name); - } - if (!page.getId().equals(id)) { - throw exception(DIY_PAGE_NAME_USED, name); - } - } - - @Override - public void deleteDiyPage(Long id) { - // 校验存在 - validateDiyPageExists(id); - // 删除 - diyPageMapper.deleteById(id); - } - - private void validateDiyPageExists(Long id) { - if (diyPageMapper.selectById(id) == null) { - throw exception(DIY_PAGE_NOT_EXISTS); - } - } - - @Override - public DiyPageDO getDiyPage(Long id) { - return diyPageMapper.selectById(id); - } - - @Override - public List getDiyPageList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return diyPageMapper.selectBatchIds(ids); - } - - @Override - public PageResult getDiyPagePage(DiyPagePageReqVO pageReqVO) { - return diyPageMapper.selectPage(pageReqVO); - } - - @Override - public List getDiyPageByTemplateId(Long templateId) { - return diyPageMapper.selectListByTemplateId(templateId); - } - - @Override - public void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO) { - // 校验存在 - validateDiyPageExists(updateReqVO.getId()); - // 更新 - DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); - diyPageMapper.updateById(updateObj); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java deleted file mode 100644 index 4f0c0c7aa..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; - -import javax.validation.Valid; - -/** - * 装修模板 Service 接口 - * - * @author owen - */ -public interface DiyTemplateService { - - /** - * 创建装修模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiyTemplate(@Valid DiyTemplateCreateReqVO createReqVO); - - /** - * 更新装修模板 - * - * @param updateReqVO 更新信息 - */ - void updateDiyTemplate(@Valid DiyTemplateUpdateReqVO updateReqVO); - - /** - * 删除装修模板 - * - * @param id 编号 - */ - void deleteDiyTemplate(Long id); - - /** - * 获得装修模板 - * - * @param id 编号 - * @return 装修模板 - */ - DiyTemplateDO getDiyTemplate(Long id); - - /** - * 获得装修模板分页 - * - * @param pageReqVO 分页查询 - * @return 装修模板分页 - */ - PageResult getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO); - - /** - * 使用装修模板 - * - * @param id 编号 - */ - void useDiyTemplate(Long id); - - /** - * 更新装修模板属性 - * - * @param updateReqVO 更新信息 - */ - void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO); - - /** - * 获取使用中的装修模板 - * - * @return 装修模板 - */ - DiyTemplateDO getUsedDiyTemplate(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java deleted file mode 100644 index f6d5e7240..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 装修模板 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class DiyTemplateServiceImpl implements DiyTemplateService { - - @Resource - private DiyTemplateMapper diyTemplateMapper; - - @Resource - private DiyPageService diyPageService; - - @Transactional(rollbackFor = Exception.class) - @Override - public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { - // 校验名称唯一 - validateNameUnique(null, createReqVO.getName()); - // 插入 - DiyTemplateDO diyTemplate = DiyTemplateConvert.INSTANCE.convert(createReqVO); - diyTemplate.setProperty("{}"); - diyTemplateMapper.insert(diyTemplate); - // 创建默认页面 - createDefaultPage(diyTemplate); - // 返回 - return diyTemplate.getId(); - } - - /** - * 创建模板下面的默认页面 - * 默认创建两个页面:首页、我的 - * - * @param diyTemplate 模板对象 - */ - private void createDefaultPage(DiyTemplateDO diyTemplate) { - String remark = String.format("模板【%s】自动创建", diyTemplate.getName()); - diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "首页", remark)); - diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "我的", remark)); - } - - @Override - public void updateDiyTemplate(DiyTemplateUpdateReqVO updateReqVO) { - // 校验存在 - validateDiyTemplateExists(updateReqVO.getId()); - // 校验名称唯一 - validateNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); - diyTemplateMapper.updateById(updateObj); - } - - void validateNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - DiyTemplateDO template = diyTemplateMapper.selectByName(name); - if (template == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的模板 - if (id == null) { - throw exception(DIY_TEMPLATE_NAME_USED, name); - } - if (!template.getId().equals(id)) { - throw exception(DIY_TEMPLATE_NAME_USED, name); - } - } - - @Override - public void deleteDiyTemplate(Long id) { - // 校验存在 - DiyTemplateDO diyTemplateDO = validateDiyTemplateExists(id); - // 校验使用中 - if (BooleanUtil.isTrue(diyTemplateDO.getUsed())) { - throw exception(DIY_TEMPLATE_USED_CANNOT_DELETE); - } - // 删除 - diyTemplateMapper.deleteById(id); - } - - private DiyTemplateDO validateDiyTemplateExists(Long id) { - DiyTemplateDO diyTemplateDO = diyTemplateMapper.selectById(id); - if (diyTemplateDO == null) { - throw exception(DIY_TEMPLATE_NOT_EXISTS); - } - return diyTemplateDO; - } - - @Override - public DiyTemplateDO getDiyTemplate(Long id) { - return diyTemplateMapper.selectById(id); - } - - @Override - public PageResult getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO) { - return diyTemplateMapper.selectPage(pageReqVO); - } - - @Transactional(rollbackFor = Exception.class) - @Override - public void useDiyTemplate(Long id) { - // 校验存在 - validateDiyTemplateExists(id); - // TODO @疯狂:要不已使用的情况,抛个业务异常? - // 已使用的更新为未使用 - DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); - if (used != null) { - // 如果 id 相同,说明未发生变化 - if (used.getId().equals(id)) { - return; - } - this.updateTemplateUsed(used.getId(), false, null); - } - // 更新为已使用 - this.updateTemplateUsed(id, true, LocalDateTime.now()); - } - - /** - * 更新模板是否使用 - * - * @param id 模板编号 - * @param used 是否使用 - * @param usedTime 使用时间 - */ - private void updateTemplateUsed(Long id, Boolean used, LocalDateTime usedTime) { - DiyTemplateDO updateObj = new DiyTemplateDO().setId(id) - .setUsed(used).setUsedTime(usedTime); - diyTemplateMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO) { - // 校验存在 - validateDiyTemplateExists(updateReqVO.getId()); - // 更新模板属性 - DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); - diyTemplateMapper.updateById(updateObj); - } - - @Override - public DiyTemplateDO getUsedDiyTemplate() { - return diyTemplateMapper.selectByUsed(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java deleted file mode 100755 index f08e74014..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 Service 接口 - * - * @author 芋道源码 - */ -public interface RewardActivityService { - - /** - * 创建满减送活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createRewardActivity(@Valid RewardActivityCreateReqVO createReqVO); - - /** - * 更新满减送活动 - * - * @param updateReqVO 更新信息 - */ - void updateRewardActivity(@Valid RewardActivityUpdateReqVO updateReqVO); - - /** - * 关闭满减送活动 - * - * @param id 活动编号 - */ - void closeRewardActivity(Long id); - - /** - * 删除满减送活动 - * - * @param id 编号 - */ - void deleteRewardActivity(Long id); - - /** - * 获得满减送活动 - * - * @param id 编号 - * @return 满减送活动 - */ - RewardActivityDO getRewardActivity(Long id); - - /** - * 获得满减送活动分页 - * - * @param pageReqVO 分页查询 - * @return 满减送活动分页 - */ - PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO); - - /** - * 基于指定的 SPU 编号数组,获得它们匹配的满减送活动 - * - * @param spuIds SPU 编号数组 - * @return 满减送活动列表 - */ - List getMatchRewardActivityList(Collection spuIds); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 当前日期时间 - * @return 满减送活动列表 - */ - List getRewardActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java deleted file mode 100755 index b7884c746..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 满减送活动 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class RewardActivityServiceImpl implements RewardActivityService { - - @Resource - private RewardActivityMapper rewardActivityMapper; - - @Override - public Long createRewardActivity(RewardActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(null, createReqVO.getProductSpuIds()); - - // 插入 - RewardActivityDO rewardActivity = RewardActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime())); - rewardActivityMapper.insert(rewardActivity); - // 返回 - return rewardActivity.getId(); - } - - @Override - public void updateRewardActivity(RewardActivityUpdateReqVO updateReqVO) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(updateReqVO.getId()); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds()); - - // 更新 - RewardActivityDO updateObj = RewardActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime())); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void closeRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END); - } - - // 更新 - RewardActivityDO updateObj = new RewardActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void deleteRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (!dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - rewardActivityMapper.deleteById(id); - } - - private RewardActivityDO validateRewardActivityExists(Long id) { - RewardActivityDO activity = rewardActivityMapper.selectById(id); - if (activity == null) { - throw exception(REWARD_ACTIVITY_NOT_EXISTS); - } - return activity; - } - - // TODO @芋艿:逻辑有问题,需要优化;要分成全场、和指定来校验; - - /** - * 校验商品参加的活动是否冲突 - * - * @param id 活动编号 - * @param spuIds 商品 SPU 编号数组 - */ - private void validateRewardActivitySpuConflicts(Long id, Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return; - } - // 查询商品参加的活动 - List rewardActivityList = getRewardActivityListBySpuIds(spuIds, - asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); - if (id != null) { // 排除自己这个活动 - rewardActivityList.removeIf(activity -> id.equals(activity.getId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(rewardActivityList)) { - throw exception(REWARD_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 获得商品参加的满减送活动的数组 - * - * @param spuIds 商品 SPU 编号数组 - * @param statuses 活动状态数组 - * @return 商品参加的满减送活动的数组 - */ - private List getRewardActivityListBySpuIds(Collection spuIds, - Collection statuses) { - List list = rewardActivityMapper.selectListByStatus(statuses); - return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds)); - } - - @Override - public RewardActivityDO getRewardActivity(Long id) { - return rewardActivityMapper.selectById(id); - } - - @Override - public PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO) { - return rewardActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getMatchRewardActivityList(Collection spuIds) { - // TODO 芋艿:待实现;先指定,然后再全局的; -// // 如果有全局活动,则直接选择它 -// List allActivities = rewardActivityMapper.selectListByProductScopeAndStatus( -// PromotionProductScopeEnum.ALL.getScope(), PromotionActivityStatusEnum.RUN.getStatus()); -// if (CollUtil.isNotEmpty(allActivities)) { -// return MapUtil.builder(allActivities.get(0), spuIds).build(); -// } -// -// // 查询某个活动参加的活动 -// List productActivityList = getRewardActivityListBySpuIds(spuIds, -// singleton(PromotionActivityStatusEnum.RUN.getStatus())); -// return convertMap(productActivityList, activity -> activity, -// rewardActivityDO -> intersectionDistinct(rewardActivityDO.getProductSpuIds(), spuIds)); // 求交集返回 - return null; - } - - @Override - public List getRewardActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动 - List rewardActivityList = rewardActivityMapper.selectListBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(rewardActivityList)) { - return Collections.emptyList(); - } - - // 2. 查询活动详情 - return rewardActivityMapper.selectListByIdsAndDateTimeLt(convertSet(rewardActivityList, RewardActivityDO::getId), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java deleted file mode 100644 index 0ed6a4f5c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动 Service 接口 - * - * @author halfninety - */ -public interface SeckillActivityService { - - /** - * 创建秒杀活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillActivity(@Valid SeckillActivityCreateReqVO createReqVO); - - /** - * 更新秒杀活动 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillActivity(@Valid SeckillActivityUpdateReqVO updateReqVO); - - /** - * 更新秒杀库存(减少) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockDecr(Long id, Long skuId, Integer count); - - /** - * 更新秒杀库存(增加) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockIncr(Long id, Long skuId, Integer count); - - /** - * 关闭秒杀活动 - * - * @param id 编号 - */ - void closeSeckillActivity(Long id); - - /** - * 删除秒杀活动 - * - * @param id 编号 - */ - void deleteSeckillActivity(Long id); - - /** - * 获得秒杀活动 - * - * @param id 编号 - * @return 秒杀活动 - */ - SeckillActivityDO getSeckillActivity(Long id); - - /** - * 获得秒杀活动分页 - * - * @param pageReqVO 分页查询 - * @return 秒杀活动分页 - */ - PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO); - - /** - * 通过活动编号获取活动商品 - * - * @param activityId 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Long activityId); - - /** - * 通过活动编号获取活动商品 - * - * @param activityIds 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Collection activityIds); - - /** - * 通过活动时段编号获取指定 status 的秒杀活动 - * - * @param configId 时段配置编号 - * @param status 状态 - * @return 秒杀活动列表 - */ - List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status); - - /** - * 通过活动时段获取秒杀活动 - * - * @param pageReqVO 请求 - * @return 秒杀活动列表 - */ - PageResult getSeckillActivityAppPageByConfigId(AppSeckillActivityPageReqVO pageReqVO); - - /** - * 校验是否参与秒杀商品 - * - * 如果校验失败,则抛出业务异常 - * - * @param activityId 活动编号 - * @param skuId SKU 编号 - * @param count 数量 - * @return 秒杀信息 - */ - SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 秒杀活动列表 - */ - List getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java deleted file mode 100644 index 8d2bc359b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java +++ /dev/null @@ -1,339 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.collection.CollUtil.isNotEmpty; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 秒杀活动 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillActivityServiceImpl implements SeckillActivityService { - - @Resource - private SeckillActivityMapper seckillActivityMapper; - @Resource - private SeckillProductMapper seckillProductMapper; - @Resource - private SeckillConfigService seckillConfigService; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) { - // 1.1 校验商品秒杀时段是否冲突 - validateProductConflict(createReqVO.getConfigIds(), createReqVO.getSpuId(), null); - // 1.2 校验商品是否存在 - validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); - - // 2.1 插入秒杀活动 - SeckillActivityDO activity = SeckillActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setStock(getSumValue(createReqVO.getProducts(), SeckillProductBaseVO::getStock, Integer::sum)); - activity.setTotalStock(activity.getStock()); - seckillActivityMapper.insert(activity); - // 2.2 插入商品 - List products = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); - seckillProductMapper.insertBatch(products); - return activity.getId(); - } - - /** - * 校验秒杀商品参与的活动是否存在冲突 - * - * 1. 校验秒杀时段是否存在 - * 2. 秒杀商品是否参加其它活动 - * - * @param configIds 秒杀时段数组 - * @param spuId 商品 SPU 编号 - * @param activityId 秒杀活动编号 - */ - private void validateProductConflict(List configIds, Long spuId, Long activityId) { - // 1. 校验秒杀时段是否存在 - seckillConfigService.validateSeckillConfigExists(configIds); - - // 2.1 查询所有开启的秒杀活动 - List activityList = seckillActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 2.2 过滤出所有 configIds 有交集的活动,判断是否存在重叠 - List conflictActivityList = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds)); - if (isNotEmpty(conflictActivityList)) { - throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 校验秒杀商品是否都存在 - * - * @param spuId 商品 SPU 编号 - * @param products 秒杀商品 - */ - private void validateProductExists(Long spuId, List products) { - // 1. 校验商品 spu 是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 2. 校验商品 sku 都存在 - List skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)).getCheckedData(); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - products.forEach(product -> { - if (!skuMap.containsKey(product.getSkuId())) { - throw exception(SKU_NOT_EXISTS); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillActivity(SeckillActivityUpdateReqVO updateReqVO) { - // 1.1 校验存在 - SeckillActivityDO activity = validateSeckillActivityExists(updateReqVO.getId()); - if (CommonStatusEnum.DISABLE.getStatus().equals(activity.getStatus())) { - throw exception(SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 1.2 校验商品是否冲突 - validateProductConflict(updateReqVO.getConfigIds(), updateReqVO.getSpuId(), updateReqVO.getId()); - // 1.3 校验商品是否存在 - validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); - - // 2.1 更新活动 - SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO) - .setStock(getSumValue(updateReqVO.getProducts(), SeckillProductBaseVO::getStock, Integer::sum)); - if (updateObj.getStock() > activity.getTotalStock()) { // 如果更新的库存大于原来的库存,则更新总库存 - updateObj.setTotalStock(updateObj.getStock()); - } - seckillActivityMapper.updateById(updateObj); - // 2.2 更新商品 - updateSeckillProduct(updateObj, updateReqVO.getProducts()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillStockDecr(Long id, Long skuId, Integer count) { - // 1.1 校验活动库存是否充足 - SeckillActivityDO seckillActivity = validateSeckillActivityExists(id); - if (count > seckillActivity.getTotalStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - // 1.2 校验商品库存是否充足 - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId); - if (product == null || count > product.getStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 2.1 更新活动商品库存 - int updateCount = seckillProductMapper.updateStockDecr(product.getId(), count); - if (updateCount == 0) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 2.2 更新活动库存 - updateCount = seckillActivityMapper.updateStockDecr(seckillActivity.getId(), count); - if (updateCount == 0) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillStockIncr(Long id, Long skuId, Integer count) { - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId); - // 更新活动商品库存 - seckillProductMapper.updateStockIncr(product.getId(), count); - // 更新活动库存 - seckillActivityMapper.updateStockIncr(id, count); - } - - /** - * 更新秒杀商品 - * - * @param activity 秒杀活动 - * @param products 该活动的最新商品配置 - */ - private void updateSeckillProduct(SeckillActivityDO activity, List products) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List newList = SeckillActivityConvert.INSTANCE.convertList(products, activity); - List oldList = seckillProductMapper.selectListByActivityId(activity.getId()); - List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); - if (same) { - newVal.setId(oldVal.getId()); - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (isNotEmpty(diffList.get(0))) { - seckillProductMapper.insertBatch(diffList.get(0)); - } - if (isNotEmpty(diffList.get(1))) { - seckillProductMapper.updateBatch(diffList.get(1)); - } - if (isNotEmpty(diffList.get(2))) { - seckillProductMapper.deleteBatchIds(convertList(diffList.get(2), SeckillProductDO::getId)); - } - } - - @Override - public void closeSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO activity = validateSeckillActivityExists(id); - if (CommonStatusEnum.DISABLE.getStatus().equals(activity.getStatus())) { - throw exception(SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - - // 更新 - SeckillActivityDO updateObj = new SeckillActivityDO().setId(id).setStatus(CommonStatusEnum.DISABLE.getStatus()); - seckillActivityMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO seckillActivity = this.validateSeckillActivityExists(id); - if (CommonStatusEnum.ENABLE.getStatus().equals(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除活动 - seckillActivityMapper.deleteById(id); - // 删除活动商品 - List products = seckillProductMapper.selectListByActivityId(id); - seckillProductMapper.deleteBatchIds(convertSet(products, SeckillProductDO::getId)); - } - - private SeckillActivityDO validateSeckillActivityExists(Long id) { - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(id); - if (seckillActivity == null) { - throw exception(SECKILL_ACTIVITY_NOT_EXISTS); - } - return seckillActivity; - } - - @Override - public SeckillActivityDO getSeckillActivity(Long id) { - return seckillActivityMapper.selectById(id); - } - - @Override - public PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getSeckillProductListByActivityId(Long activityId) { - return seckillProductMapper.selectListByActivityId(activityId); - } - - @Override - public List getSeckillProductListByActivityId(Collection activityIds) { - return seckillProductMapper.selectListByActivityId(activityIds); - } - - @Override - public List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status) { - return filterList(seckillActivityMapper.selectList(SeckillActivityDO::getStatus, status), - item -> anyMatch(item.getConfigIds(), id -> ObjectUtil.equal(id, configId)) // 校验时段 - && isBetween(item.getStartTime(), item.getEndTime())); // 追加当前日期是否处在活动日期之间的校验条件 - } - - @Override - public PageResult getSeckillActivityAppPageByConfigId(AppSeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count) { - // 1.1 校验秒杀活动是否存在 - SeckillActivityDO activity = validateSeckillActivityExists(activityId); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(SECKILL_JOIN_ACTIVITY_STATUS_CLOSED); - } - // 1.2 是否在活动时间范围内 - if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - throw exception(SECKILL_JOIN_ACTIVITY_TIME_ERROR); - } - SeckillConfigDO config = seckillConfigService.getCurrentSeckillConfig(); - if (config == null || !CollectionUtil.contains(activity.getConfigIds(), config.getId())) { - throw exception(SECKILL_JOIN_ACTIVITY_TIME_ERROR); - } - // 1.3 超过单次购买限制 - if (count > activity.getSingleLimitCount()) { - throw exception(SECKILL_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED); - } - - // 2.1 校验秒杀商品是否存在 - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(activityId, skuId); - if (product == null) { - throw exception(SECKILL_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 2.2 校验库存是否充足 - if (count > product.getStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - return SeckillActivityConvert.INSTANCE.convert02(activity, product); - } - - @Override - public List getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = seckillActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2.查询活动详情 - return seckillActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java deleted file mode 100644 index 13214e7f8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀时段 Service 接口 - * - * @author halfninety - */ -public interface SeckillConfigService { - - /** - * 创建秒杀时段 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillConfig(@Valid SeckillConfigCreateReqVO createReqVO); - - /** - * 更新秒杀时段 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillConfig(@Valid SeckillConfigUpdateReqVO updateReqVO); - - /** - * 删除秒杀时段 - * - * @param id 编号 - */ - void deleteSeckillConfig(Long id); - - /** - * 获得秒杀时段 - * - * @param id 编号 - * @return 秒杀时段 - */ - SeckillConfigDO getSeckillConfig(Long id); - - /** - * 获得所有秒杀时段列表 - * - * @return 所有秒杀时段列表 - */ - List getSeckillConfigList(); - - /** - * 校验秒杀时段是否存在 - * - * @param ids 秒杀时段 id 集合 - */ - void validateSeckillConfigExists(Collection ids); - - /** - * 获得秒杀时间段配置分页数据 - * - * @param pageVO 分页请求参数 - * @return 秒杀时段分页列表 - */ - PageResult getSeckillConfigPage(SeckillConfigPageReqVO pageVO); - - /** - * 获得所有正常状态的时段配置列表 - * - * @param status 状态 - * @return 秒杀时段列表 - */ - List getSeckillConfigListByStatus(Integer status); - - /** - * 更新秒杀时段配置状态 - * - * @param id id - * @param status 状态 - */ - void updateSeckillConfigStatus(Long id, Integer status); - - /** - * 获得当前的秒杀时段 - * - * 要求必须处于开启状态、且在当前时间段内 - * - * @return 时段 - */ - SeckillConfigDO getCurrentSeckillConfig(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java deleted file mode 100644 index c24493bd9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalTime; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 秒杀时段 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillConfigServiceImpl implements SeckillConfigService { - - @Resource - private SeckillConfigMapper seckillConfigMapper; - - @Override - public Long createSeckillConfig(SeckillConfigCreateReqVO createReqVO) { - // 校验时间段是否冲突 - validateSeckillConfigConflict(createReqVO.getStartTime(), createReqVO.getEndTime(), null); - - // 插入 - SeckillConfigDO seckillConfig = SeckillConfigConvert.INSTANCE.convert(createReqVO); - seckillConfigMapper.insert(seckillConfig); - // 返回 - return seckillConfig.getId(); - } - - @Override - public void updateSeckillConfig(SeckillConfigUpdateReqVO updateReqVO) { - // 校验存在 - validateSeckillConfigExists(updateReqVO.getId()); - // 校验时间段是否冲突 - validateSeckillConfigConflict(updateReqVO.getStartTime(), updateReqVO.getEndTime(), updateReqVO.getId()); - - // 更新 - SeckillConfigDO updateObj = SeckillConfigConvert.INSTANCE.convert(updateReqVO); - seckillConfigMapper.updateById(updateObj); - } - - @Override - public void updateSeckillConfigStatus(Long id, Integer status) { - // 校验秒杀时段是否存在 - validateSeckillConfigExists(id); - - // 更新状态 - seckillConfigMapper.updateById(new SeckillConfigDO().setId(id).setStatus(status)); - } - - @Override - public SeckillConfigDO getCurrentSeckillConfig() { - List list = seckillConfigMapper.selectList(SeckillConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); - return findFirst(list, config -> isBetween(config.getStartTime(), config.getEndTime())); - } - - @Override - public void deleteSeckillConfig(Long id) { - // 校验存在 - validateSeckillConfigExists(id); - - // 删除 - seckillConfigMapper.deleteById(id); - } - - private void validateSeckillConfigExists(Long id) { - if (seckillConfigMapper.selectById(id) == null) { - throw exception(SECKILL_CONFIG_NOT_EXISTS); - } - } - - /** - * 校验时间是否存在冲突 - * - * @param startTimeStr 开始时间 - * @param endTimeStr 结束时间 - */ - private void validateSeckillConfigConflict(String startTimeStr, String endTimeStr, Long id) { - // 1. 查询出所有的时段配置 - LocalTime startTime = LocalTime.parse(startTimeStr); - LocalTime endTime = LocalTime.parse(endTimeStr); - List configs = seckillConfigMapper.selectList(); - // 更新时排除自己 - if (id != null) { - configs.removeIf(item -> ObjectUtil.equal(item.getId(), id)); - } - - // 2. 判断是否有重叠的时间 - boolean hasConflict = configs.stream().anyMatch(config -> LocalDateTimeUtils.isOverlap(startTime, endTime, - LocalTime.parse(config.getStartTime()), LocalTime.parse(config.getEndTime()))); - if (hasConflict) { - throw exception(SECKILL_CONFIG_TIME_CONFLICTS); - } - } - - - @Override - public SeckillConfigDO getSeckillConfig(Long id) { - return seckillConfigMapper.selectById(id); - } - - @Override - public List getSeckillConfigList() { - return seckillConfigMapper.selectList(); - } - - @Override - public void validateSeckillConfigExists(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 1. 如果有数量不匹配,说明有不存在的,则抛出 SECKILL_CONFIG_NOT_EXISTS 业务异常 - List configs = seckillConfigMapper.selectBatchIds(ids); - if (configs.size() != ids.size()) { - throw exception(SECKILL_CONFIG_NOT_EXISTS); - } - - // 2. 如果存在关闭,则抛出 SECKILL_CONFIG_DISABLE 业务异常 - configs.forEach(config -> { - if (ObjectUtil.equal(config.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(SECKILL_CONFIG_DISABLE); - } - }); - } - - @Override - public PageResult getSeckillConfigPage(SeckillConfigPageReqVO pageVO) { - return seckillConfigMapper.selectPage(pageVO); - } - - @Override - public List getSeckillConfigListByStatus(Integer status) { - List list = seckillConfigMapper.selectListByStatus(status); - list.sort(Comparator.comparing(SeckillConfigDO::getStartTime)); - return list; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java deleted file mode 100644 index 2ad362fe2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.util; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; - -import java.time.LocalDateTime; - -/** - * 活动工具类 - * - * @author 芋道源码 - */ -public class PromotionUtils { - - /** - * 根据时间,计算活动状态 - * - * @param endTime 结束时间 - * @return 活动状态 - */ - public static Integer calculateActivityStatus(LocalDateTime endTime) { - return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus(); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application.yaml deleted file mode 100644 index b21ee163d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.promotion - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 05266e5f4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: promotion-server - - profiles: - active: local - -server: - port: 48101 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml deleted file mode 100644 index 76af37db2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index c656a9fe4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,47 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 6a1a24252..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELETE FROM "market_activity"; -DELETE FROM "promotion_coupon_template"; -DELETE FROM "promotion_coupon"; -DELETE FROM "promotion_reward_activity"; -DELETE FROM "promotion_discount_activity"; -DELETE FROM "promotion_discount_product"; -DELETE FROM "promotion_seckill_config"; -DELETE FROM "promotion_combination_activity"; -DELETE FROM "promotion_article_category"; -DELETE FROM "promotion_article"; -DELETE FROM "promotion_diy_template"; -DELETE FROM "promotion_diy_page"; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 00ac3f93d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,256 +0,0 @@ -CREATE TABLE IF NOT EXISTS "market_activity" -( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL, - "activity_type" tinyint(4) NOT NULL, - "status" tinyint(4) NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "invalid_time" datetime, - "delete_time" datetime, - "time_limited_discount" varchar(2000), - "full_privilege" varchar(2000), - "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 NOT NULL DEFAULT FALSE, - "tenant_id" bigint(20) NOT NULL, - PRIMARY KEY ("id") -) COMMENT '促销活动'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon_template" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "total_count" int NOT NULL, - "take_limit_count" int NOT NULL, - "take_type" int NOT NULL, - "use_price" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "validity_type" int NOT NULL, - "valid_start_time" datetime, - "valid_end_time" datetime, - "fixed_start_term" int, - "fixed_end_term" int, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "take_count" int NOT NULL DEFAULT 0, - "use_count" int NOT NULL DEFAULT 0, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵模板'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "user_id" bigint NOT NULL, - "take_type" int NOT NULL, - "useprice" int NOT NULL, - "valid_start_time" datetime NOT NULL, - "valid_end_time" datetime NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "use_order_id" bigint, - "use_time" datetime, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵'; - -CREATE TABLE IF NOT EXISTS "promotion_reward_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "condition_type" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "rules" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '满减送活动'; - -CREATE TABLE IF NOT EXISTS "promotion_discount_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '限时折扣活动'; - -CREATE TABLE IF NOT EXISTS "promotion_seckill_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "spu_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "remark" varchar, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "sort" int NOT NULL, - "config_ids" varchar NOT NULL, - "order_count" int NOT NULL, - "user_count" int NOT NULL, - "total_price" int NOT NULL, - "total_limit_count" int, - "single_limit_count" int, - "stock" int, - "total_stock" int, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '秒杀活动'; - -CREATE TABLE IF NOT EXISTS "promotion_seckill_config" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "pic_url" varchar NOT NULL, - "status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '秒杀时段配置'; - -CREATE TABLE IF NOT EXISTS "promotion_combination_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "spu_id" bigint, - "total_limit_count" int NOT NULL, - "single_limit_count" int NOT NULL, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "user_size" int NOT NULL, - "total_num" int NOT NULL, - "success_num" int NOT NULL, - "order_user_count" int NOT NULL, - "virtual_group" int NOT NULL, - "status" int NOT NULL, - "limit_duration" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '拼团活动'; - -CREATE TABLE IF NOT EXISTS "promotion_article_category" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "pic_url" varchar, - "status" int NOT NULL, - "sort" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '文章分类表'; - -CREATE TABLE IF NOT EXISTS "promotion_article" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "category_id" bigint NOT NULL, - "title" varchar NOT NULL, - "author" varchar, - "pic_url" varchar NOT NULL, - "introduction" varchar, - "browse_count" varchar, - "sort" int NOT NULL, - "status" int NOT NULL, - "spu_id" bigint NOT NULL, - "recommend_hot" bit NOT NULL, - "recommend_banner" bit NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '文章管理表'; - -CREATE TABLE IF NOT EXISTS "promotion_diy_template" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "used" bit NOT NULL, - "used_time" varchar, - "remark" varchar, - "preview_pic_urls" varchar, - "property" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL DEFAULT 0, - PRIMARY KEY ("id") -) COMMENT '装修模板'; -CREATE TABLE IF NOT EXISTS "promotion_diy_page" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "remark" varchar, - "preview_pic_urls" varchar, - "property" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '装修页面'; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-api/pom.xml b/yudao-module-mall/yudao-module-statistics-api/pom.xml deleted file mode 100644 index 79e592c96..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-statistics-api - jar - - ${project.artifactId} - - statistics 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java deleted file mode 100644 index 2963c120a..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.api; diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java deleted file mode 100644 index 5f3c8fe22..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.statistics.enums; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 时间范围类型的枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum TimeRangeTypeEnum implements IntArrayValuable { - - /** - * 天 - */ - DAY(1), - /** - * 周 - */ - WEEK(7), - /** - * 月 - */ - MONTH(30), - /** - * 年 - */ - YEAR(365), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TimeRangeTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java deleted file mode 100644 index f885ae076..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.enums; diff --git a/yudao-module-mall/yudao-module-statistics-biz/pom.xml b/yudao-module-mall/yudao-module-statistics-biz/pom.xml deleted file mode 100644 index 0e66532b9..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/pom.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-statistics-biz - jar - - ${project.artifactId} - - statistics 模块,主要实现统计相关功能 - 例如:统计商品、会员、交易等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-statistics-api - ${revision} - - - cn.iocoder.cloud - yudao-module-promotion-api - ${revision} - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-trade-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - cn.iocoder.cloud - yudao-module-pay-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/StatisticsServerApplication.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/StatisticsServerApplication.java deleted file mode 100644 index 8811256d2..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/StatisticsServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.statistics; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class StatisticsServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(StatisticsServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java deleted file mode 100644 index efd889a87..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.common.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 数据对照 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DataComparisonRespVO { - - @Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private T value; - - @Schema(description = "参照数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private T reference; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java deleted file mode 100644 index 9b0f7158b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.NumberUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; -import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; -import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员统计") -@RestController -@RequestMapping("/statistics/member") -@Validated -@Slf4j -public class MemberStatisticsController { - - @Resource - private MemberStatisticsService memberStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private ApiAccessLogStatisticsService apiAccessLogStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得会员统计(实时统计)") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult getMemberSummary() { - return success(memberStatisticsService.getMemberSummary()); - } - - @GetMapping("/analyse") - @Operation(summary = "获得会员分析数据") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult getMemberAnalyse(MemberAnalyseReqVO reqVO) { - // 1. 查询数据 - LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); - LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); - // 1.1 查询分析对照数据 - DataComparisonRespVO comparisonData = memberStatisticsService.getMemberAnalyseComparisonData(beginTime, endTime); - // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; - // 1.2 查询成交用户数量 - Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); - // 1.3 计算客单价 - int atv = 0; - if (payUserCount != null && payUserCount > 0) { - // TODO @疯狂:类似上面的 payUserCount - Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); - atv = NumberUtil.div(payPrice, payUserCount).intValue(); - } - // 1.4 查询访客数量 - Integer visitUserCount = apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime); - // 1.5 下单用户数量 - Integer orderUserCount = tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime); - - // 2. 拼接返回 - return success(MemberStatisticsConvert.INSTANCE.convert(visitUserCount, orderUserCount, payUserCount, atv, comparisonData)); - } - - @GetMapping("/area-statistics-list") - @Operation(summary = "按照省份,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberAreaStatisticsList() { - return success(memberStatisticsService.getMemberAreaStatisticsList()); - } - - @GetMapping("/sex-statistics-list") - @Operation(summary = "按照性别,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberSexStatisticsList() { - return success(memberStatisticsService.getMemberSexStatisticsList()); - } - - @GetMapping("/terminal-statistics-list") - @Operation(summary = "按照终端,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberTerminalStatisticsList() { - return success(memberStatisticsService.getMemberTerminalStatisticsList()); - } - - // TODO @疯狂:要注意 date 的排序; - @GetMapping("/user-count-comparison") - @Operation(summary = "获得用户数量对照") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getUserCountComparison() { - return success(memberStatisticsService.getUserCountComparison()); - } - - @GetMapping("/register-count-list") - @Operation(summary = "获得会员注册数量列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { - return success(memberStatisticsService.getMemberRegisterCountList( - ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java deleted file mode 100644 index d2dd3e483..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员分析数据 Response VO") -@Data -public class MemberAnalyseDataRespVO { - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer registerUserCount; - - @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") - private Integer rechargeUserCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java deleted file mode 100644 index e0106b4e8..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员分析 Request VO") -@Data -public class MemberAnalyseReqVO { - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java deleted file mode 100644 index e1c46547b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员分析 Response VO") -@Data -public class MemberAnalyseRespVO { - - @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderUserCount; - - @Schema(description = "成交用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer payUserCount; - - @Schema(description = "客单价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer atv; - - @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) - private DataComparisonRespVO comparison; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java deleted file mode 100644 index 1024d04ef..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员地区统计 Response VO") -@Data -public class MemberAreaStatisticsRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer areaId; - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - - @Schema(description = "下单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderCreateUserCount; - @Schema(description = "支付订单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer orderPayUserCount; - - @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java deleted file mode 100644 index ce81658cf..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员数量统计 Response VO") -@Data -public class MemberCountRespVO { - - @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer registerUserCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java deleted file mode 100644 index fb7fc2ac4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@Schema(description = "管理后台 - 会员注册数量 Response VO") -@Data -public class MemberRegisterCountRespVO { - - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT) - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDate date; - - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java deleted file mode 100644 index eaf7ce5f5..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员性别统计 Response VO") -@Data -public class MemberSexStatisticsRespVO { - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sex; - - // TODO @疯狂:要不还是其它字段,我们也补全,这样方便使用的用户,做定制化;就保持和 MemberAreaStatisticsRespVO 一致; - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java deleted file mode 100644 index 2a55e3897..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员统计 Response VO") -@Data -public class MemberSummaryRespVO { - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") - private Integer rechargeUserCount; - - @Schema(description = "充值金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - - // TODO @疯狂:要不干脆这个字段改成:orderPayPrice?? - @Schema(description = "支出金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer expensePrice; // 只计算 mall 交易订单的支付金额,不考虑退款 - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java deleted file mode 100644 index 3ecf0f8fe..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员终端统计 Response VO") -@Data -public class MemberTerminalStatisticsRespVO { - - @Schema(description = "终端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; - - // TODO @疯狂:要不 orderCreateUserCount 和 orderPayUserCount 貌似更统一一些; - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java deleted file mode 100644 index 362ec7d57..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.pay; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; -import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 支付统计") -@RestController -@RequestMapping("/statistics/pay") -@Validated -@Slf4j -public class PayStatisticsController { - - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获取充值金额") - public CommonResult getWalletRechargePrice() { - Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary(); - return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java deleted file mode 100644 index 01edc24cf..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 支付统计 Response VO") -@Data -public class PaySummaryRespVO { - - @Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java deleted file mode 100644 index b215d7067..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.product.ProductStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品统计") -@RestController -@RequestMapping("/statistics/product") -@Validated -public class ProductStatisticsController { - - @Resource - private ProductStatisticsService productStatisticsService; - - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/analyse") - @Operation(summary = "获得商品统计分析") - @PreAuthorize("@ss.hasPermission('statistics:product:query')") - public CommonResult> getProductStatisticsAnalyse(ProductStatisticsReqVO reqVO) { - return success(productStatisticsService.getProductStatisticsAnalyse(reqVO)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品统计明细(日期维度)") - @PreAuthorize("@ss.hasPermission('statistics:product:query')") - public CommonResult> getProductStatisticsList(ProductStatisticsReqVO reqVO) { - List list = productStatisticsService.getProductStatisticsList(reqVO); - return success(BeanUtils.toBean(list, ProductStatisticsRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出获得商品统计明细 Excel(日期维度)") - @PreAuthorize("@ss.hasPermission('statistics:product:export')") - public void exportProductStatisticsExcel(ProductStatisticsReqVO reqVO, HttpServletResponse response) throws IOException { - List list = productStatisticsService.getProductStatisticsList(reqVO); - // 导出 Excel - List voList = BeanUtils.toBean(list, ProductStatisticsRespVO.class); - ExcelUtils.write(response, "商品状况.xls", "数据", ProductStatisticsRespVO.class, voList); - } - - @GetMapping("/rank-page") - @Operation(summary = "获得商品统计排行榜分页(商品维度)") - @PreAuthorize("@ss.hasPermission('statistics:product:query')") - public CommonResult> getProductStatisticsRankPage(@Valid ProductStatisticsReqVO reqVO, - @Valid SortablePageParam pageParam) { - PageResult pageResult = productStatisticsService.getProductStatisticsRankPage(reqVO, pageParam); - // 处理商品信息 - Set spuIds = convertSet(pageResult.getList(), ProductStatisticsDO::getSpuId); - Map spuMap = convertMap(productSpuApi.getSpuList(spuIds).getCheckedData(), ProductSpuRespDTO::getId); - return success(BeanUtils.toBean(pageResult, ProductStatisticsRespVO.class, - item -> Optional.ofNullable(spuMap.get(item.getSpuId())) - .ifPresent(spu -> item.setName(spu.getName()).setPicUrl(spu.getPicUrl())))); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsReqVO.java deleted file mode 100644 index 02387c32f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品统计分析 Request VO") -@Data -@ToString(callSuper = true) -@AllArgsConstructor -@NoArgsConstructor -public class ProductStatisticsReqVO { - - @Schema(description = "统计时间范围", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] times; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsRespVO.java deleted file mode 100644 index 9d93142e3..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsRespVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - 商品统计 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ProductStatisticsRespVO { - - @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "12393") - private Long id; - - @Schema(description = "统计日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-12-16") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) - @ExcelProperty("统计日期") - private LocalDate time; - - @Schema(description = "商品SPU编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15114") - @ExcelProperty("商品SPU编号") - private Long spuId; - - // region 商品信息 - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品名称") - @ExcelProperty("商品名称") - private String name; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "15114") - @ExcelProperty("商品封面图") - private String picUrl; - - // endregion - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "17505") - @ExcelProperty("浏览量") - private Integer browseCount; - - @Schema(description = "访客量", requiredMode = Schema.RequiredMode.REQUIRED, example = "11814") - @ExcelProperty("访客量") - private Integer browseUserCount; - - @Schema(description = "收藏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20950") - @ExcelProperty("收藏数量") - private Integer favoriteCount; - - @Schema(description = "加购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "28493") - @ExcelProperty("加购数量") - private Integer cartCount; - - @Schema(description = "下单件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "18966") - @ExcelProperty("下单件数") - private Integer orderCount; - - @Schema(description = "支付件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "15142") - @ExcelProperty("支付件数") - private Integer orderPayCount; - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "11595") - @ExcelProperty("支付金额,单位:分") - private Integer orderPayPrice; - - @Schema(description = "退款件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2591") - @ExcelProperty("退款件数") - private Integer afterSaleCount; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "21709") - @ExcelProperty("退款金额,单位:分") - private Integer afterSaleRefundPrice; - - @Schema(description = "访客支付转化率(百分比)", requiredMode = Schema.RequiredMode.REQUIRED, example = "15") - private Integer browseConvertPercent; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java deleted file mode 100644 index 5aa88e51a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; -import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.AfterSaleStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.BrokerageStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 交易统计") -@RestController -@RequestMapping("/statistics/trade") -@Validated -@Slf4j -public class TradeStatisticsController { - - @Resource - private TradeStatisticsService tradeStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private AfterSaleStatisticsService afterSaleStatisticsService; - @Resource - private BrokerageStatisticsService brokerageStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得交易统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeSummaryComparison() { - // 1.1 昨天的数据 - TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1); - // 1.2 前天的数据(用于对照昨天的数据) - TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2); - - // 2.1 本月数据 - TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0); - // 2.2 上月数据(用于对照本月的数据) - TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1); - // 拼接数据 - return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData)); - } - - @GetMapping("/analyse") - @Operation(summary = "获得交易状况统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeStatisticsAnalyse(TradeTrendReqVO reqVO) { - return success(tradeStatisticsService.getTradeStatisticsAnalyse(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1))); - } - - @GetMapping("/list") - @Operation(summary = "获得交易状况明细") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeStatisticsList(TradeTrendReqVO reqVO) { - List list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1)); - return success(TradeStatisticsConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出获得交易状况明细 Excel") - @PreAuthorize("@ss.hasPermission('statistics:trade:export')") - public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { - List list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1)); - // 导出 Excel - List voList = TradeStatisticsConvert.INSTANCE.convertList(list); - List data = TradeStatisticsConvert.INSTANCE.convertList02(voList); - ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); - } - - @GetMapping("/order-count") - @Operation(summary = "获得交易订单数量") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult getOrderCount() { - // 订单统计 - Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( - TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType()); - // TODO @疯狂:订单支付后,如果是门店自提的,需要 update 成 DELIVERED;;目前还没搞~~突然反应过来 - Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( - TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType()); - // 售后统计 - Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY); - Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING); - // 拼接返回 - return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount)); - } - - @GetMapping("/order-comparison") - @Operation(summary = "获得交易订单数量") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getOrderComparison() { - return success(tradeOrderStatisticsService.getOrderComparison()); - } - - @GetMapping("/order-count-trend") - @Operation(summary = "获得订单量趋势统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { - // TODO @疯狂:要注意 date 的排序; - return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java deleted file mode 100644 index 1320a889e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单数量 Response VO") -@Data -public class TradeOrderCountRespVO { - - @Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long undelivered; - - @Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long pickUp; - - @Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSaleApply; - - @Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long auditingWithdraw; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java deleted file mode 100644 index 22d8f4a14..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单统计 Response VO") -@Data -public class TradeOrderSummaryRespVO { - - @Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayCount; - - @Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java deleted file mode 100644 index 57f054629..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易订单量趋势统计 Request VO") -@Data -public class TradeOrderTrendReqVO { - - @Schema(description = "日期范围类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "日期范围类型不能为空") - @InEnum(value = TimeRangeTypeEnum.class, message = "日期范围类型,必须是 {value}") - private Integer type; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "起始时间") - private LocalDateTime beginTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "截止时间") - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java deleted file mode 100644 index d69c343cb..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 订单量趋势统计 Response VO") -@Data -public class TradeOrderTrendRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String date; - - @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayCount; - - @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java deleted file mode 100644 index 5e0e7c62d..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易统计 Response VO") -@Data -public class TradeSummaryRespVO { - - @Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer yesterdayOrderCount; - @Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer yesterdayPayPrice; - - @Schema(description = "本月订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer monthOrderCount; - @Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer monthPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java deleted file mode 100644 index 234b7a785..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易状况 Request VO") -@Data -public class TradeTrendReqVO { - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "时间范围") - private LocalDateTime[] times; -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java deleted file mode 100644 index 5b14fa1d4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.format.DateTimeFormat; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -/** - * 交易状况统计 Excel VO - * - * @author owen - */ -@Data -public class TradeTrendSummaryExcelVO { - - @ExcelProperty(value = "日期") - @DateTimeFormat(FORMAT_YEAR_MONTH_DAY) - private LocalDate date; - - @ExcelProperty(value = "营业额", converter = MoneyConvert.class) - private Integer turnoverPrice; - - @ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class) - private Integer orderPayPrice; - - @ExcelProperty(value = "充值金额", converter = MoneyConvert.class) - private Integer rechargePrice; - - @ExcelProperty(value = "支出金额", converter = MoneyConvert.class) - private Integer expensePrice; - - @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) - private Integer walletPayPrice; - - @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) - private Integer brokerageSettlementPrice; - - @ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class) - private Integer afterSaleRefundPrice; -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java deleted file mode 100644 index be5a93a51..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - 交易状况统计 Response VO") -@Data -public class TradeTrendSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-12-16") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDate date; - - @Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer turnoverPrice; // 营业额 = 商品支付金额 + 充值金额 - - @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - - @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer walletPayPrice; - - @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer afterSaleRefundPrice; - - @Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer brokerageSettlementPrice; - - @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - - @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额 - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java deleted file mode 100644 index 1384194b4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位 - */ -package cn.iocoder.yudao.module.statistics.controller.app; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java deleted file mode 100644 index 2d527b0a3..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.member; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseDataRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 会员统计 Convert - * - * @author owen - */ -@Mapper -public interface MemberStatisticsConvert { - - MemberStatisticsConvert INSTANCE = Mappers.getMapper(MemberStatisticsConvert.class); - - default List convertList(List areaList, - Map userCountMap, - Map orderMap) { - return CollectionUtils.convertList(areaList, area -> { - MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId())) - .orElseGet(MemberAreaStatisticsRespBO::new); - return new MemberAreaStatisticsRespVO() - .setAreaId(area.getId()).setAreaName(area.getName()) - .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) - .setOrderCreateUserCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateUserCount(), 0)) - .setOrderPayUserCount(ObjUtil.defaultIfNull(orderVo.getOrderPayUserCount(), 0)) - .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); - }); - } - - MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount); - - MemberAnalyseRespVO convert(Integer visitUserCount, Integer orderUserCount, Integer payUserCount, int atv, - DataComparisonRespVO comparison); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java deleted file mode 100644 index 08f38005f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.pay; - -import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 支付统计 Convert - * - * @author owen - */ -@Mapper -public interface PayStatisticsConvert { - - PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class); - - PaySummaryRespVO convert(Integer rechargePrice); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java deleted file mode 100644 index 7c140628f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.mapstruct.IterableMapping; -import org.mapstruct.Mapper; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Convert - * - * @author owen - */ -@Mapper -public interface TradeStatisticsConvert { - - TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); - - default DataComparisonRespVO convert(TradeSummaryRespBO yesterdayData, - TradeSummaryRespBO beforeYesterdayData, - TradeSummaryRespBO monthData, - TradeSummaryRespBO lastMonthData) { - return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); - } - - - default TradeSummaryRespVO convert(TradeSummaryRespBO yesterdayData, TradeSummaryRespBO monthData) { - return new TradeSummaryRespVO() - .setYesterdayOrderCount(yesterdayData.getCount()).setYesterdayPayPrice(yesterdayData.getSummary()) - .setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary()); - } - - DataComparisonRespVO convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); - - DataComparisonRespVO convert(TradeTrendSummaryRespVO value, - TradeTrendSummaryRespVO reference); - - List convertList02(List list); - - TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespBO orderSummary, - AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, - WalletSummaryRespBO walletSummary); - - @IterableMapping(qualifiedByName = "convert") - List convertList(List list); - - TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics); - - @Named("convert") - default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { - TradeTrendSummaryRespVO vo = convertA(tradeStatistics); - return vo - .setDate(tradeStatistics.getTime().toLocalDate()) - // 营业额 = 商品支付金额 + 充值金额 - .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) - // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - .setExpensePrice(tradeStatistics.getWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); - } - - TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java deleted file mode 100644 index 80eca3b41..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 todo - */ -package cn.iocoder.yudao.module.statistics.dal.dataobject; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/product/ProductStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/product/ProductStatisticsDO.java deleted file mode 100644 index 426906d47..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/product/ProductStatisticsDO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDate; - -/** - * 商品统计 DO - * - * @author owen - */ -@TableName("product_statistics") -@KeySequence("product_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 统计日期 - */ - private LocalDate time; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 浏览量 - */ - private Integer browseCount; - /** - * 访客量 - */ - private Integer browseUserCount; - /** - * 收藏数量 - */ - private Integer favoriteCount; - /** - * 加购数量 - */ - private Integer cartCount; - /** - * 下单件数 - */ - private Integer orderCount; - /** - * 支付件数 - */ - private Integer orderPayCount; - /** - * 支付金额,单位:分 - */ - private Integer orderPayPrice; - /** - * 退款件数 - */ - private Integer afterSaleCount; - /** - * 退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - /** - * 访客支付转化率(百分比) - */ - private Integer browseConvertPercent; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java deleted file mode 100644 index 46e148aa4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.dataobject.trade; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易统计 DO - *

- * 以天为维度,统计全部的数据 - * - * @author 芋道源码 - */ -@TableName("trade_statistics") -@KeySequence("trade_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 统计日期 - */ - private LocalDateTime time; - - /** - * 创建订单数 - */ - private Integer orderCreateCount; - /** - * 支付订单商品数 - */ - private Integer orderPayCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - - /** - * 退款订单数 - */ - private Integer afterSaleCount; - /** - * 总退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - - /** - * 佣金金额(已结算),单位:分 - */ - private Integer brokerageSettlementPrice; - - /** - * 总支付金额(余额),单位:分 - */ - private Integer walletPayPrice; - /** - * 充值订单数 - *

- * 从 PayWalletRechargeDO 计算 - */ - private Integer rechargePayCount; - /** - * 充值金额,单位:分 - */ - private Integer rechargePayPrice; - /** - * 充值退款订单数 - */ - private Integer rechargeRefundCount; - /** - * 充值退款金额,单位:分 - */ - private Integer rechargeRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java deleted file mode 100644 index 5f76b58fd..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.infra; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -// TODO @芋艿:api 访问日志,现在会清理,可能要单独有个偏业务的访问表; -/** - * API 访问日志的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface ApiAccessLogStatisticsMapper extends BaseMapperX { - - Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java deleted file mode 100644 index 595e93d9e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.member; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员信息的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface MemberStatisticsMapper extends BaseMapperX { - - List selectSummaryListByAreaId(); - - List selectSummaryListBySex(); - - List selectSummaryListByRegisterTerminal(); - - Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 获得用户的每天注册数量列表 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 每天注册数量列表 - */ - List selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java deleted file mode 100644 index b9b38fbbe..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.pay; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 支付钱包的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface PayWalletStatisticsMapper extends BaseMapperX { - - WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("payStatus") Boolean payStatus); - - WalletSummaryRespBO selectRechargeSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("refundStatus") Integer refundStatus); - - Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("bizType") Integer bizType); - - RechargeSummaryRespBO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("payStatus") Boolean payStatus); - - Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsMapper.java deleted file mode 100644 index 600296f66..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsMapper.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 商品统计 Mapper - * - * @author owen - */ -@Mapper -public interface ProductStatisticsMapper extends BaseMapperX { - - default PageResult selectPageGroupBySpuId(ProductStatisticsReqVO reqVO, SortablePageParam pageParam) { - return selectPage(pageParam, buildWrapper(reqVO) - .groupBy(ProductStatisticsDO::getSpuId) - .select(ProductStatisticsDO::getSpuId) - ); - } - - default List selectListByTimeBetween(ProductStatisticsReqVO reqVO) { - return selectList(buildWrapper(reqVO) - .groupBy(ProductStatisticsDO::getTime) - .select(ProductStatisticsDO::getTime)); - } - - default ProductStatisticsRespVO selectVoByTimeBetween(ProductStatisticsReqVO reqVO) { - return selectJoinOne(ProductStatisticsRespVO.class, buildWrapper(reqVO)); - } - - /** - * 构建 LambdaWrapper - * - * @param reqVO 查询参数 - * @return LambdaWrapper - */ - static MPJLambdaWrapperX buildWrapper(ProductStatisticsReqVO reqVO) { - return new MPJLambdaWrapperX() - .betweenIfPresent(ProductStatisticsDO::getTime, reqVO.getTimes()) - .selectSum(ProductStatisticsDO::getBrowseCount) - .selectSum(ProductStatisticsDO::getBrowseUserCount) - .selectSum(ProductStatisticsDO::getFavoriteCount) - .selectSum(ProductStatisticsDO::getCartCount) - .selectSum(ProductStatisticsDO::getOrderCount) - .selectSum(ProductStatisticsDO::getOrderPayCount) - .selectSum(ProductStatisticsDO::getOrderPayPrice) - .selectSum(ProductStatisticsDO::getAfterSaleCount) - .selectSum(ProductStatisticsDO::getAfterSaleRefundPrice) - .selectAvg(ProductStatisticsDO::getBrowseConvertPercent); - } - - /** - * 根据时间范围统计商品信息 - * - * @param page 分页参数 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 统计 - */ - IPage selectStatisticsResultPageByTimeBetween(IPage page, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - default Long selectCountByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectCount(new LambdaQueryWrapperX().between(ProductStatisticsDO::getTime, beginTime, endTime)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java deleted file mode 100644 index 7de0cb07b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 售后订单的统计 Mapper - * - * @author owen - */ -@Mapper -public interface AfterSaleStatisticsMapper extends BaseMapperX { - - AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Long selectCountByStatus(@Param("status") Integer status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java deleted file mode 100644 index 94ad06812..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 订单分销的统计 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageStatisticsMapper extends BaseMapperX { - - Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(@Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Long selectWithdrawCountByStatus(@Param("status") Integer status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java deleted file mode 100644 index 35e52e031..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易订单的统计 Mapper - * - * @author owen - */ -@Mapper -public interface TradeOrderStatisticsMapper extends BaseMapperX { - - List selectSummaryListByAreaId(); - - Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectSummaryPriceByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectUserCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 按照支付时间统计订单(按天分组) - * - * @param beginTime 支付起始时间 - * @param endTime 支付截止时间 - * @return 订单统计列表 - */ - List selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 按照支付时间统计订单(按月分组) - * - * @param beginTime 支付起始时间 - * @param endTime 支付截止时间 - * @return 订单统计列表 - */ - List selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType); - - TradeOrderSummaryRespVO selectPaySummaryByPayStatusAndPayTimeBetween(@Param("payStatus") Integer payStatus, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java deleted file mode 100644 index 67d2d5007..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Mapper - * - * @author owen - */ -@Mapper -public interface TradeStatisticsMapper extends BaseMapperX { - - TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - TradeTrendSummaryRespVO selectVoByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - default List selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectList(new LambdaQueryWrapperX() - .between(TradeStatisticsDO::getTime, beginTime, endTime)); - } - - Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectOne(new LambdaQueryWrapperX() - .between(TradeStatisticsDO::getTime, beginTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/package-info.java deleted file mode 100644 index 032d7a91b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 statistics 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.statistics.framework; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 6c613ecfe..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.statistics.framework.rpc.config; - -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {ProductSpuApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/package-info.java deleted file mode 100644 index ead659f46..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.statistics.framework.rpc; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 5fa5376b5..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Statistics 模块的 Security 配置 - */ -@Configuration("statisticsSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("statisticsAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/core/package-info.java deleted file mode 100644 index 01062c49e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.statistics.framework.security.core; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java deleted file mode 100644 index e8cf302e1..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿,占坑,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.job; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/product/ProductStatisticsJob.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/product/ProductStatisticsJob.java deleted file mode 100644 index 4d4182cec..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/product/ProductStatisticsJob.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.statistics.job.product; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.statistics.service.product.ProductStatisticsService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:缺个 Job 的配置;等和 Product 一起配置 - -/** - * 商品统计 Job - * - * @author owen - */ -@Component -public class ProductStatisticsJob { - - @Resource - private ProductStatisticsService productStatisticsService; - - /** - * 执行商品统计任务 - * - * @param param 要统计的天数,只能是正整数,1 代表昨日数据 - * @return 统计结果 - */ - @XxlJob("productStatisticsJob") - @TenantJob - public String execute(String param) { - // 默认昨日 - param = ObjUtil.defaultIfBlank(param, "1"); - // 校验参数的合理性 - if (!NumberUtil.isInteger(param)) { - throw new RuntimeException("商品统计任务的参数只能为是正整数"); - } - Integer days = Convert.toInt(param, 0); - if (days < 1) { - throw new RuntimeException("商品统计任务的参数只能为是正整数"); - } - String result = productStatisticsService.statisticsProduct(days); - return StrUtil.format("商品统计:\n{}", result); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java deleted file mode 100644 index 88e9f0c79..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.statistics.job.trade; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:缺个 Job 的配置;等和 Product 一起配置 -/** - * 交易统计 Job - * - * @author owen - */ -@Component -public class TradeStatisticsJob { - - @Resource - private TradeStatisticsService tradeStatisticsService; - - /** - * 执行交易统计任务 - * - * @param param 要统计的天数,只能是正整数,1 代表昨日数据 - * @return 统计结果 - */ - @XxlJob("tradeStatisticsJob") - @TenantJob - public String execute(String param) { - // 默认昨日 - param = ObjUtil.defaultIfBlank(param, "1"); - // 校验参数的合理性 - if (!NumberUtil.isInteger(param)) { - throw new RuntimeException("交易统计任务的参数只能为是正整数"); - } - Integer days = Convert.toInt(param, 0); - if (days < 1) { - throw new RuntimeException("交易统计任务的参数只能为是正整数"); - } - String result = tradeStatisticsService.statisticsTrade(days); - return StrUtil.format("交易统计:\n{}", result); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java deleted file mode 100644 index 598e16c02..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * statistics 模块,主要实现统计相关功能。 - * 例如:统计商品、会员、交易等功能。 - * - * 1. Controller URL:以 /statistics/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 statistics_ 为后缀,方便在数据库中区分【特殊】 - */ -package cn.iocoder.yudao.module.statistics; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java deleted file mode 100644 index 6c200fdef..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.infra; - -import java.time.LocalDateTime; - -/** - * API 访问日志的统计 Service 接口 - * - * @author owen - */ -public interface ApiAccessLogStatisticsService { - - /** - * 获取活跃用户数量 - * - * @param userType 用户类型 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 活跃用户数量 - */ - Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取访问用户数量 - * - * @param userType 用户类型 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 访问用户数量 - */ - Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java deleted file mode 100644 index 7ad62d00a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.infra; - -import cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * API 访问日志的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatisticsService { - - @Resource - private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; - - @Override - public Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { - return apiAccessLogStatisticsMapper.selectUserCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); - } - - @Override - public Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { - return apiAccessLogStatisticsMapper.selectIpCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java deleted file mode 100644 index 253cba68a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员信息的统计 Service 接口 - * - * @author owen - */ -public interface MemberStatisticsService { - - /** - * 获取会员统计(实时统计) - * - * @return 会员统计 - */ - MemberSummaryRespVO getMemberSummary(); - - /** - * 获取会员分析对照数据 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 会员分析对照数据 - */ - DataComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, - LocalDateTime endTime); - - /** - * 按照省份,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberAreaStatisticsList(); - - /** - * 按照性别,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberSexStatisticsList(); - - /** - * 按照终端,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberTerminalStatisticsList(); - - /** - * 获取用户注册数量列表 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 注册数量列表 - */ - List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得用户数量量统计对照 - * - * @return 用户数量量统计对照 - */ - DataComparisonRespVO getUserCountComparison(); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java deleted file mode 100644 index 7b159059f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 会员信息的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberStatisticsServiceImpl implements MemberStatisticsService { - - @Resource - private MemberStatisticsMapper memberStatisticsMapper; - - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - @Resource - private TradeStatisticsService tradeStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private ApiAccessLogStatisticsService apiAccessLogStatisticsService; - - @Override - public MemberSummaryRespVO getMemberSummary() { - RechargeSummaryRespBO rechargeSummary = payWalletStatisticsService.getUserRechargeSummary(null, null); - // TODO @疯狂:1)这里是实时统计,不好走走 TradeStatistics 表;2)因为这个放在商城下,所以只考虑订单数据,即按照 trade_order 的 pay_price 并且已支付来计算; - Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null); - Integer userCount = memberStatisticsMapper.selectUserCount(null, null); - return MemberStatisticsConvert.INSTANCE.convert(rechargeSummary, expensePrice, userCount); - } - - @Override - public List getMemberAreaStatisticsList() { - // 统计用户 - // TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = = - Map userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), - vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), - MemberAreaStatisticsRespBO::getUserCount, Integer::sum); - // 统计订单 - Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), - bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE), - bo -> bo, - (a, b) -> new MemberAreaStatisticsRespBO() - .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) - .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) - .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); - // 拼接数据 - List areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); - areaList.add(new Area().setId(null).setName("未知")); - return MemberStatisticsConvert.INSTANCE.convertList(areaList, userCountMap, orderMap); - } - - @Override - public DataComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { - // 当前数据 - MemberAnalyseDataRespVO vo = getMemberAnalyseData(beginTime, endTime); - // 对照数据 - LocalDateTime referenceEndDate = beginTime.minusDays(1); // 减少1天,防止出现时间重叠 - LocalDateTime referenceBeginDate = referenceEndDate.minus(Duration.between(beginTime, endTime)); - MemberAnalyseDataRespVO reference = getMemberAnalyseData( - LocalDateTimeUtil.beginOfDay(referenceBeginDate), LocalDateTimeUtil.endOfDay(referenceEndDate)); - return new DataComparisonRespVO<>(vo, reference); - } - - private MemberAnalyseDataRespVO getMemberAnalyseData(LocalDateTime beginTime, LocalDateTime endTime) { - Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) - .map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0); - return new MemberAnalyseDataRespVO() - .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) - .setVisitUserCount(apiAccessLogStatisticsService.getUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)) - .setRechargeUserCount(rechargeUserCount); - } - - @Override - public List getMemberSexStatisticsList() { - return memberStatisticsMapper.selectSummaryListBySex(); - } - - @Override - public List getMemberTerminalStatisticsList() { - return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); - } - - @Override - public List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { - return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); - } - - @Override - public DataComparisonRespVO getUserCountComparison() { - // 今日时间范围 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(beginOfToday); - // 昨日时间范围 - LocalDateTime beginOfYesterday = LocalDateTimeUtil.beginOfDay(beginOfToday.minusDays(1)); - LocalDateTime endOfYesterday = LocalDateTimeUtil.endOfDay(beginOfYesterday); - return new DataComparisonRespVO() - .setValue(getUserCount(beginOfToday, endOfToday)) - .setReference(getUserCount(beginOfYesterday, endOfYesterday)); - } - - private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return new MemberCountRespVO() - .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) - .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java deleted file mode 100644 index 6b2d9ceab..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member.bo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员地区统计 Response BO") -@Data -public class MemberAreaStatisticsRespBO { - - /** - * 省份编号 - */ - private Integer areaId; - /** - * 省份名称 - */ - private String areaName; - - /** - * 会员数量 - */ - private Integer userCount; - - /** - * 下单的会员数量 - */ - private Integer orderCreateUserCount; - /** - * 支付订单的会员数量 - */ - private Integer orderPayUserCount; - - /** - * 订单支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java deleted file mode 100644 index d43a57682..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay; - -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; - -import java.time.LocalDateTime; - -/** - * 钱包的统计 Service 接口 - * - * @author owen - */ -public interface PayWalletStatisticsService { - - /** - * 获取钱包统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 钱包统计 - */ - WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取钱包充值统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 钱包充值统计 - */ - RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取充值金额合计 - * - * @return 充值金额合计 - */ - Integer getRechargePriceSummary(); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java deleted file mode 100644 index 45532477e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay; - -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 钱包的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsService { - - @Resource - private PayWalletStatisticsMapper payWalletStatisticsMapper; - - @Override - public WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { - WalletSummaryRespBO paySummary = payWalletStatisticsMapper.selectRechargeSummaryByPayTimeBetween( - beginTime, endTime, true); - WalletSummaryRespBO refundSummary = payWalletStatisticsMapper.selectRechargeSummaryByRefundTimeBetween( - beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus()); - Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( - beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); - // 拼接 - paySummary.setWalletPayPrice(walletPayPrice) - .setRechargeRefundCount(refundSummary.getRechargeRefundCount()) - .setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); - return paySummary; - } - - @Override - public RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); - } - - @Override - public Integer getRechargePriceSummary() { - return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java deleted file mode 100644 index 05cfa1155..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay.bo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 充值统计 Response BO - */ -@Data -public class RechargeSummaryRespBO { - - /** - * 充值会员数量 - */ - private Integer rechargeUserCount; - - /** - * 充值金额 - */ - private Integer rechargePrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsService.java deleted file mode 100644 index 09d84bdea..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsService.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; - -import java.util.List; - -/** - * 商品统计 Service 接口 - * - * @author owen - */ -public interface ProductStatisticsService { - - /** - * 获得商品统计排行榜分页 - * - * @param reqVO 查询条件 - * @param pageParam 分页排序查询 - * @return 商品统计分页 - */ - PageResult getProductStatisticsRankPage(ProductStatisticsReqVO reqVO, SortablePageParam pageParam); - - /** - * 获得商品状况统计分析 - * - * @param reqVO 查询条件 - * @return 统计数据对照 - */ - DataComparisonRespVO getProductStatisticsAnalyse(ProductStatisticsReqVO reqVO); - - /** - * 获得商品状况明细 - * - * @param reqVO 查询条件 - * @return 统计数据对照 - */ - List getProductStatisticsList(ProductStatisticsReqVO reqVO); - - /** - * 统计指定天数的商品数据 - * - * @return 统计结果 - */ - String statisticsProduct(Integer days); - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsServiceImpl.java deleted file mode 100644 index f56fc47a9..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsServiceImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; -import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductStatisticsMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import org.springframework.util.StopWatch; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - - -/** - * 商品统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ProductStatisticsServiceImpl implements ProductStatisticsService { - - @Resource - private ProductStatisticsMapper productStatisticsMapper; - - - @Override - public PageResult getProductStatisticsRankPage(ProductStatisticsReqVO reqVO, SortablePageParam pageParam) { - PageUtils.buildDefaultSortingField(pageParam, ProductStatisticsDO::getBrowseCount); // 默认浏览量倒序 - return productStatisticsMapper.selectPageGroupBySpuId(reqVO, pageParam); - } - - @Override - public DataComparisonRespVO getProductStatisticsAnalyse(ProductStatisticsReqVO reqVO) { - LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); - LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); - - // 统计数据 - ProductStatisticsRespVO value = productStatisticsMapper.selectVoByTimeBetween(reqVO); - // 对照数据 - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); - ProductStatisticsReqVO referenceReqVO = new ProductStatisticsReqVO(new LocalDateTime[]{referenceBeginTime, beginTime}); - ProductStatisticsRespVO reference = productStatisticsMapper.selectVoByTimeBetween(referenceReqVO); - return new DataComparisonRespVO<>(value, reference); - } - - @Override - public List getProductStatisticsList(ProductStatisticsReqVO reqVO) { - return productStatisticsMapper.selectListByTimeBetween(reqVO); - } - - @Override - public String statisticsProduct(Integer days) { - LocalDateTime today = LocalDateTime.now(); - return IntStream.rangeClosed(1, days) - .mapToObj(day -> statisticsProduct(today.minusDays(day))) - .sorted() - .collect(Collectors.joining("\n")); - } - - /** - * 统计商品数据 - * - * @param date 需要统计的日期 - * @return 统计结果 - */ - private String statisticsProduct(LocalDateTime date) { - // 1. 处理统计时间范围 - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); - String dateStr = DatePattern.NORM_DATE_FORMATTER.format(date); - // 2. 检查该日是否已经统计过 - Long count = productStatisticsMapper.selectCountByTimeBetween(beginTime, endTime); - if (count != null && count > 0) { - return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; - } - - StopWatch stopWatch = new StopWatch(dateStr); - stopWatch.start(); - // 4. 分页统计,避免商品表数据较多时,出现超时问题 - final int pageSize = 100; - for (int pageNo = 1; ; pageNo++) { - IPage page = productStatisticsMapper.selectStatisticsResultPageByTimeBetween( - Page.of(pageNo, pageSize, false), beginTime, endTime); - if (CollUtil.isEmpty(page.getRecords())) { - break; - } - // 4.1 计算访客支付转化率(百分比) - for (ProductStatisticsDO record : page.getRecords()) { - record.setTime(date.toLocalDate()); - if (record.getBrowseUserCount() != null && ObjUtil.notEqual(record.getBrowseUserCount(), 0)) { - record.setBrowseConvertPercent(100 * record.getOrderPayCount() / record.getBrowseUserCount()); - } - } - // 4.2 插入数据 - productStatisticsMapper.insertBatch(page.getRecords()); - } - return stopWatch.prettyPrint(); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java deleted file mode 100644 index f584c3dc7..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; - -import java.time.LocalDateTime; - -/** - * 售后统计 Service 接口 - * - * @author owen - */ -public interface AfterSaleStatisticsService { - - /** - * 获取售后单统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 售后统计结果 - */ - AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取指定状态的售后订单数量 - * - * @param status 售后状态 - * @return 售后订单数量 - */ - Long getCountByStatus(AfterSaleStatusEnum status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java deleted file mode 100644 index 46ab5f3ad..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 售后统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsService { - - @Resource - private AfterSaleStatisticsMapper afterSaleStatisticsMapper; - - @Override - public AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); - } - - @Override - public Long getCountByStatus(AfterSaleStatusEnum status) { - return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java deleted file mode 100644 index 6845b608a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; - -import java.time.LocalDateTime; - -/** - * 分销统计 Service 接口 - * - * @author owen - */ -public interface BrokerageStatisticsService { - - /** - * 获取已结算的佣金金额 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 已结算的佣金金额 - */ - Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取指定状态的提现记录数量 - * - * @param status 提现记录状态 - * @return 提现记录数量 - */ - Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java deleted file mode 100644 index d7af3d523..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 分销统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsService { - - @Resource - private BrokerageStatisticsMapper brokerageStatisticsMapper; - - @Override - public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return brokerageStatisticsMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween( - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - beginTime, endTime); - } - - @Override - public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) { - return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java deleted file mode 100644 index 2197515c4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易订单的统计 Service 接口 - * - * @author owen - */ -public interface TradeOrderStatisticsService { - - /** - * 获取订单统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 订单统计结果 - */ - TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取地区订单统计 - * - * @return 订单统计结果 - */ - List getSummaryListByAreaId(); - - /** - * 获取下单用户数量 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 下单用户数量 - */ - Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取支付用户数量 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 支付用户数量 - */ - Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取支付金额 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 支付用户金额 - */ - Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 根据订单状态、物流类型,获得交易订单数量 - * - * @return 订单数量 - */ - Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType); - - /** - * 交易订单销售额对照 - * - * @return 销售额对照 - */ - DataComparisonRespVO getOrderComparison(); - - /** - * 获得订单量趋势统计 - * - * @param reqVO 统计参数 - * @return 订单量趋势统计 - */ - List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java deleted file mode 100644 index b37dfba45..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; -import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -/** - * 交易订单统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsService { - - @Resource - private TradeOrderStatisticsMapper tradeOrderStatisticsMapper; - - @Override - public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return new TradeOrderSummaryRespBO() - .setOrderCreateCount(tradeOrderStatisticsMapper.selectCountByCreateTimeBetween(beginTime, endTime)) - .setOrderPayCount(tradeOrderStatisticsMapper.selectCountByPayTimeBetween(beginTime, endTime)) - .setOrderPayPrice(tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime)); - } - - @Override - public List getSummaryListByAreaId() { - return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); - } - - @Override - public Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectUserCountByCreateTimeBetween(beginTime, endTime); - } - - @Override - public Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectUserCountByPayTimeBetween(beginTime, endTime); - } - - @Override - public Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); - } - - @Override - public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) { - return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType); - } - - @Override - public DataComparisonRespVO getOrderComparison() { - return new DataComparisonRespVO() - .setValue(getPayPriceSummary(LocalDateTime.now())) - .setReference(getPayPriceSummary(LocalDateTime.now().minusDays(1))); - } - - private TradeOrderSummaryRespVO getPayPriceSummary(LocalDateTime date) { - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.beginOfDay(date); - return tradeOrderStatisticsMapper.selectPaySummaryByPayStatusAndPayTimeBetween( - PayOrderStatusEnum.SUCCESS.getStatus(), beginTime, endTime); - } - - @Override - public List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) { - // 查询当前数据 - List value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime()); - // 查询对照数据 - LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1); - LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime())); - List reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime); - // 顺序对比返回 - return IntStream.range(0, value.size()) - .mapToObj(index -> new DataComparisonRespVO() - .setValue(CollUtil.get(value, index)) - .setReference(CollUtil.get(reference, index))) - .collect(Collectors.toList()); - } - - private List getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) { - // 情况一:按年统计时,以月份分组 - if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) { - return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime); - } - // 情况二:其它以天分组(天、周、月) - return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java deleted file mode 100644 index e175985fb..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Service 接口 - * - * @author owen - */ -public interface TradeStatisticsService { - - /** - * 获得交易状况统计对照 - * - * @return 统计数据对照 - */ - DataComparisonRespVO getTradeStatisticsAnalyse( - LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得交易状况统计 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 统计数据对照 - */ - Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得交易状况明细 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 统计数据列表 - */ - List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 统计指定天数的交易数据 - * - * @return 统计结果 - */ - String statisticsTrade(Integer days); - - /** - * 统计指定日期的交易数据 - * - * @param days 增加的天数 - * @return 交易数据 - */ - TradeSummaryRespBO getTradeSummaryByDays(int days); - - /** - * 统计指定月份的交易数据 - * - * @param months 增加的月数 - * @return 交易数据 - */ - TradeSummaryRespBO getTradeSummaryByMonths(int months); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java deleted file mode 100644 index 5c608bda9..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.util.StopWatch; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -/** - * 交易统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeStatisticsServiceImpl implements TradeStatisticsService { - - @Resource - private TradeStatisticsMapper tradeStatisticsMapper; - - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private AfterSaleStatisticsService afterSaleStatisticsService; - @Resource - private BrokerageStatisticsService brokerageStatisticsService; - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - - @Override - public TradeSummaryRespBO getTradeSummaryByDays(int days) { - LocalDateTime date = LocalDateTime.now().plusDays(days); - return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( - LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date)); - } - - @Override - public TradeSummaryRespBO getTradeSummaryByMonths(int months) { - LocalDateTime monthDate = LocalDateTime.now().plusMonths(months); - return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( - LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate)); - } - - @Override - public DataComparisonRespVO getTradeStatisticsAnalyse(LocalDateTime beginTime, - LocalDateTime endTime) { - // 统计数据 - TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectVoByTimeBetween(beginTime, endTime); - // 对照数据 - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); - TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectVoByTimeBetween(referenceBeginTime, beginTime); - return TradeStatisticsConvert.INSTANCE.convert(value, reference); - } - - @Override - public Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); - } - - @Override - public List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); - } - - @Override - public String statisticsTrade(Integer days) { - LocalDateTime today = LocalDateTime.now(); - return IntStream.rangeClosed(1, days) - .mapToObj(day -> statisticsTrade(today.minusDays(day))) - .sorted() - .collect(Collectors.joining("\n")); - } - - /** - * 统计交易数据 - * - * @param date 需要统计的日期 - * @return 统计结果 - */ - private String statisticsTrade(LocalDateTime date) { - // 1. 处理统计时间范围 - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); - String dateStr = DatePattern.NORM_DATE_FORMATTER.format(date); - // 2. 检查该日是否已经统计过 - TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); - if (entity != null) { - return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; - } - - // 3. 从各个数据表,统计对应数据 - StopWatch stopWatch = new StopWatch(dateStr); - // 3.1 统计订单 - stopWatch.start("统计订单"); - TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); - stopWatch.stop(); - // 3.2 统计售后 - stopWatch.start("统计售后"); - AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); - stopWatch.stop(); - // 3.3 统计佣金 - stopWatch.start("统计佣金"); - Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); - stopWatch.stop(); - // 3.4 统计充值 - stopWatch.start("统计充值"); - WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); - stopWatch.stop(); - - // 4. 插入数据 - entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, - walletSummary); - tradeStatisticsMapper.insert(entity); - return stopWatch.prettyPrint(); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java deleted file mode 100644 index 985643636..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 售后统计 Response DTO - * - * @author owen - */ -@Data -public class AfterSaleSummaryRespBO { - - /** - * 退款订单数 - */ - private Integer afterSaleCount; - /** - * 总退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java deleted file mode 100644 index 3d3572f90..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 会员地区统计 Response BO - * - * @author owen - */ -@Data -public class MemberAreaStatisticsRespBO { - - /** - * 省份编号 - */ - private Integer areaId; - /** - * 省份名称 - */ - private String areaName; - - /** - * 会员数量 - */ - private Integer userCount; - - /** - * 下单的会员数量 - */ - private Integer orderCreateUserCount; - /** - * 支付订单的会员数量 - */ - private Integer orderPayUserCount; - - /** - * 订单支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java deleted file mode 100644 index bc4f3903b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 订单统计 Response BO - * - * @author owen - */ -@Data -public class TradeOrderSummaryRespBO { - - /** - * 创建订单数 - */ - private Integer orderCreateCount; - /** - * 支付订单商品数 - */ - private Integer orderPayCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java deleted file mode 100644 index 8937c809c..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 交易统计 Resp BO - * - * @author owen - */ -@Data -public class TradeSummaryRespBO { - - /** - * 数量 - */ - private Integer count; - - /** - * 合计 - */ - private Integer summary; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java deleted file mode 100644 index 89371f6c1..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 钱包统计 Response DTO - * - * @author owen - */ -@Data -public class WalletSummaryRespBO { - - /** - * 总支付金额(余额),单位:分 - */ - private Integer walletPayPrice; - - /** - * 充值订单数 - */ - private Integer rechargePayCount; - /** - * 充值金额,单位:分 - */ - private Integer rechargePayPrice; - /** - * 充值退款订单数 - */ - private Integer rechargeRefundCount; - /** - * 充值退款金额,单位:分 - */ - private Integer rechargeRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application.yaml deleted file mode 100644 index 5c8477d46..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.statistics - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 4808939ca..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: statistics-server - - profiles: - active: local - -server: - port: 48103 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml deleted file mode 100644 index e64161597..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml deleted file mode 100644 index 33500fb43..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml deleted file mode 100644 index 097780841..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/product/ProductStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/product/ProductStatisticsMapper.xml deleted file mode 100644 index e640d1d83..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/product/ProductStatisticsMapper.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml deleted file mode 100644 index 933c45610..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml deleted file mode 100644 index dff7e444f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml deleted file mode 100644 index 07d2f0d58..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml deleted file mode 100644 index 2415f6d55..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/pom.xml b/yudao-module-mall/yudao-module-trade-api/pom.xml deleted file mode 100644 index 84c99130d..000000000 --- a/yudao-module-mall/yudao-module-trade-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-api - jar - - ${project.artifactId} - - trade 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java deleted file mode 100644 index b422cee2a..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 订单") -public interface TradeOrderApi { - - String PREFIX = ApiConstants.PREFIX + "/order"; - - @GetMapping(PREFIX + "/list") - @Operation(summary = "获得订单列表") - @Parameter(name = "ids", description = "订单编号数组", required = true) - CommonResult> getOrderList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得订单") - @Parameter(name = "id", description = "订单编号", required = true) - CommonResult getOrder(@RequestParam("id") Long id); - - // TODO 芋艿:需要优化下; - @PutMapping(PREFIX + "/cancel-paid") - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), - }) - CommonResult cancelPaidOrder(@RequestParam("userId") Long userId, - @RequestParam("orderId") Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java deleted file mode 100644 index 24ec028ed..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 订单信息 Response DTO - * - * @author HUIHUI - */ -@Schema(description = "RPC 服务 - 订单信息 Response DTO") -@Data -public class TradeOrderRespDTO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; // 参见 TradeOrderTypeEnum 枚举 - - @Schema(description = "订单来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; // 参见 TerminalEnum 枚举 - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - @Schema(description = "用户备注", example = "这个商品不错哦") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; // 参见 TradeOrderStatusEnum 枚举 - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "取消类型", example = "1") - private Integer cancelType; // 参见 TradeOrderCancelTypeEnum 枚举 - - @Schema(description = "商家备注", example = "这个用户很喜欢退货") - private String remark; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java deleted file mode 100644 index 5b0e37dcc..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.trade.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ApiConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ApiConstants.java deleted file mode 100644 index 9f557fd4b..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "trade-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/trade"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java deleted file mode 100644 index ff09e59d8..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -/** - * Trade 字典类型的枚举类 - * - * @author owen - */ -public interface DictTypeConstants { - - String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态 - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java deleted file mode 100644 index 33081d461..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Trade 错误码枚举类 - * trade 系统,使用 1-011-000-000 段 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ErrorCodeConstants { - - // ========== Order 模块 1-011-000-000 ========== - ErrorCode ORDER_ITEM_NOT_FOUND = new ErrorCode(1_011_000_010, "交易订单项不存在"); - ErrorCode ORDER_NOT_FOUND = new ErrorCode(1_011_000_011, "交易订单不存在"); - ErrorCode ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL = new ErrorCode(1_011_000_012, "交易订单项更新售后状态失败,请重试"); - ErrorCode ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_011_000_013, "交易订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1_011_000_014, "交易订单更新支付状态失败,支付单编号不匹配"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_015, "交易订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1_011_000_016, "交易订单更新支付状态失败,支付单金额不匹配"); - ErrorCode ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED = new ErrorCode(1_011_000_017, "交易订单发货失败,订单不是【待发货】状态"); - ErrorCode ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_018, "交易订单收货失败,订单不是【待收货】状态"); - ErrorCode ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED = new ErrorCode(1_011_000_019, "创建交易订单项的评价失败,订单不是【已完成】状态"); - ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1_011_000_020, "创建交易订单项的评价失败,订单已评价"); - ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1_011_000_021, "交易订单发货失败,订单已退款或部分退款"); - ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_022, "交易订单发货失败,拼团未成功"); - ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_023, "交易订单发货失败,砍价未成功"); - ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1_011_000_024, "交易订单发货失败,发货类型不是快递"); - ErrorCode ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID = new ErrorCode(1_011_000_025, "交易订单取消失败,订单不是【待支付】状态"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_PAID = new ErrorCode(1_011_000_026, "支付订单调价失败,原因:支付订单已付款,不能调价"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1_011_000_027, "支付订单调价失败,原因:已经修改过价格"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元"); - ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态"); - ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】"); - ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态"); - ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单"); - - // ========== After Sale 模块 1-011-000-100 ========== - ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在"); - ErrorCode AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR = new ErrorCode(1_011_000_101, "申请退款金额错误"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED = new ErrorCode(1_011_000_102, "订单已关闭,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID = new ErrorCode(1_011_000_103, "订单未支付,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED = new ErrorCode(1_011_000_104, "订单未发货,无法申请【退货退款】售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED = new ErrorCode(1_011_000_105, "订单项已申请售后,无法重复申请"); - ErrorCode AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY = new ErrorCode(1_011_000_106, "审批失败,售后状态不处于审批中"); - ErrorCode AFTER_SALE_UPDATE_STATUS_FAIL = new ErrorCode(1_011_000_107, "操作售后单失败,请刷新后重试"); - ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE = new ErrorCode(1_011_000_108, "退货失败,售后单状态不处于【待买家退货】"); - ErrorCode AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY = new ErrorCode(1_011_000_109, "确认收货失败,售后单状态不处于【待确认收货】"); - ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1_011_000_110, "退款失败,售后单状态不是【待退款】"); - ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY = - new ErrorCode(1_011_000_111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】或【商家待收货】"); - - // ========== Cart 模块 1-011-002-000 ========== - ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1_011_002_000, "购物车项不存在"); - - // ========== Price 相关 1-011-003-000 ============ - ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1_011_003_000, "支付价格计算异常,原因:价格小于等于 0"); - ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1_011_003_002, "计算快递运费异常,找不到对应的运费模板"); - ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1_011_003_004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵"); - ErrorCode PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT = new ErrorCode(1_011_003_005, "参与秒杀的商品,超过了秒杀总限购数量"); - - // ========== 物流 Express 模块 1-011-004-000 ========== - ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1_011_004_000, "快递公司不存在"); - ErrorCode EXPRESS_CODE_DUPLICATE = new ErrorCode(1_011_004_001, "已经存在该编码的快递公司"); - ErrorCode EXPRESS_CLIENT_NOT_PROVIDE = new ErrorCode(1_011_004_002, "需要接入快递服务商,比如【快递100】"); - ErrorCode EXPRESS_STATUS_NOT_ENABLE = new ErrorCode(1_011_004_003, "快递公司未启用"); - - ErrorCode EXPRESS_API_QUERY_ERROR = new ErrorCode(1_011_004_101, "快递查询接口异常"); - ErrorCode EXPRESS_API_QUERY_FAILED = new ErrorCode(1_011_004_102, "快递查询返回失败,原因:{}"); - - // ========== 物流 Template 模块 1-011-005-000 ========== - ErrorCode EXPRESS_TEMPLATE_NAME_DUPLICATE = new ErrorCode(1_011_005_000, "已经存在该运费模板名"); - ErrorCode EXPRESS_TEMPLATE_NOT_EXISTS = new ErrorCode(1_011_005_001, "运费模板不存在"); - - // ========== 物流 PICK_UP 模块 1-011-006-000 ========== - ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店不存在"); - - // ========== 分销用户 模块 1-011-007-000 ========== - ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1_011_007_000, "分销用户不存在"); - ErrorCode BROKERAGE_USER_FROZEN_PRICE_NOT_ENOUGH = new ErrorCode(1_011_007_001, "用户冻结佣金({})数量不足"); - ErrorCode BROKERAGE_BIND_SELF = new ErrorCode(1_011_007_002, "不能绑定自己"); - ErrorCode BROKERAGE_BIND_USER_NOT_ENABLED = new ErrorCode(1_011_007_003, "绑定用户没有推广资格"); - ErrorCode BROKERAGE_BIND_CONDITION_ADMIN = new ErrorCode(1_011_007_004, "仅可在后台绑定推广员"); - ErrorCode BROKERAGE_BIND_MODE_REGISTER = new ErrorCode(1_011_007_005, "只有在注册时可以绑定"); - ErrorCode BROKERAGE_BIND_OVERRIDE = new ErrorCode(1_011_007_006, "已绑定了推广人"); - ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1_011_007_007, "下级不能绑定自己的上级"); - ErrorCode BROKERAGE_USER_LEVEL_NOT_SUPPORT = new ErrorCode(1_011_007_008, "目前只支持 level 小于等于 2"); - - // ========== 分销提现 模块 1-011-008-000 ========== - ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1_011_008_000, "佣金提现记录不存在"); - ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1_011_008_001, "佣金提现记录状态不是审核中"); - ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1_011_008_002, "提现金额不能低于 {} 元"); - ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1_011_008_003, "您当前最多可提现 {} 元"); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java deleted file mode 100644 index 5041139b4..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -// TODO @芋艿:枚举 -/** - * 通知模板枚举类 - * - * @author HUIHUI - */ -public interface MessageTemplateConstants { - - String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 - - String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) - String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java deleted file mode 100644 index db870c637..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 售后操作类型的枚举 - * - * @author 陈賝 - * @since 2023/6/13 13:53 - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleOperateTypeEnum { - - MEMBER_CREATE(10, "会员申请退款"), - ADMIN_AGREE_APPLY(11, "商家同意退款"), - ADMIN_DISAGREE_APPLY(12, "商家拒绝退款"), - MEMBER_DELIVERY(20, "会员填写退货物流信息,快递公司:{deliveryName},快递单号:{logisticsNo}"), - ADMIN_AGREE_RECEIVE(21, "商家收货"), - ADMIN_DISAGREE_RECEIVE(22, "商家拒绝收货,原因:{reason}"), - ADMIN_REFUND(30, "商家退款"), - MEMBER_CANCEL(40, "会员取消退款"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作描述 - */ - private final String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java deleted file mode 100644 index 23c1b2efe..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Collection; - -import static cn.hutool.core.util.ArrayUtil.firstMatch; - -/** - * 售后状态的枚举 - * - * 状态流转 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum AfterSaleStatusEnum implements IntArrayValuable { - - /** - * 【申请售后】 - */ - APPLY(10,"申请中", "会员申请退款"), // 有赞的状态提示:退款申请待商家处理 - /** - * 卖家通过售后;【商品待退货】 - */ - SELLER_AGREE(20, "卖家通过", "商家同意退款"), // 有赞的状态提示:请退货并填写物流信息 - /** - * 买家已退货,等待卖家收货;【商家待收货】 - */ - BUYER_DELIVERY(30,"待卖家收货", "会员填写退货物流信息"), // 有赞的状态提示:退货退款申请待商家处理 - /** - * 卖家已收货,等待平台退款;等待退款【等待退款】 - */ - WAIT_REFUND(40, "等待平台退款", "商家收货"), // 有赞的状态提示:无(有赞无该状态) - /** - * 完成退款【退款成功】 - */ - COMPLETE(50, "完成", "商家确认退款"), // 有赞的状态提示:退款成功 - /** - * 【买家取消】 - */ - BUYER_CANCEL(61, "买家取消售后", "会员取消退款"), // 有赞的状态提示:退款关闭 - /** - * 卖家拒绝售后;商家拒绝【商家拒绝】 - */ - SELLER_DISAGREE(62,"卖家拒绝", "商家拒绝退款"), // 有赞的状态提示:商家不同意退款申请 - /** - * 卖家拒绝收货,终止售后;【商家拒收货】 - */ - SELLER_REFUSE(63,"卖家拒绝收货", "商家拒绝收货"), // 有赞的状态提示:商家拒绝收货,不同意退款 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleStatusEnum::getStatus).toArray(); - - /** - * 进行中的售后状态 - * - * 不包括已经结束的状态 - */ - public static final Collection APPLYING_STATUSES = Arrays.asList( - APPLY.getStatus(), - SELLER_AGREE.getStatus(), - BUYER_DELIVERY.getStatus(), - WAIT_REFUND.getStatus() - ); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - /** - * 操作内容 - * - * 目的:记录售后日志的内容 - */ - private final String content; - - @Override - public int[] array() { - return ARRAYS; - } - - public static AfterSaleStatusEnum valueOf(Integer status) { - return firstMatch(value -> value.getStatus().equals(status), values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java deleted file mode 100644 index dfb32f7be..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 类型 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleTypeEnum implements IntArrayValuable { - - IN_SALE(10, "售中退款"), // 交易完成前买家申请退款 - AFTER_SALE(20, "售后退款"); // 交易完成后买家申请退款 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java deleted file mode 100644 index 1d608a102..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 方式 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleWayEnum implements IntArrayValuable { - - REFUND(10, "仅退款"), - RETURN_AND_REFUND(20, "退货退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleWayEnum::getWay).toArray(); - - /** - * 方式 - */ - private final Integer way; - /** - * 方式名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java deleted file mode 100644 index 72ce10032..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 分销关系绑定模式枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageBindModeEnum implements IntArrayValuable { - - /** - * 只要用户没有推广人,随时都可以绑定分销关系 - */ - ANYTIME(1, "首次绑定"), - /** - * 仅新用户注册时才能绑定推广关系 - */ - REGISTER(2, "注册绑定"), - /** - * 每次扫码都覆盖 - */ - OVERRIDE(3, "覆盖绑定"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageBindModeEnum::getMode).toArray(); - - /** - * 模式 - */ - private final Integer mode; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java deleted file mode 100644 index 990d10e16..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 分佣模式枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageEnabledConditionEnum implements IntArrayValuable { - - /** - * 所有用户都可以分销 - */ - ALL(1, "人人分销"), - /** - * 仅可后台手动设置推广员 - */ - ADMIN(2, "指定分销"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageEnabledConditionEnum::getCondition).toArray(); - - /** - * 模式 - */ - private final Integer condition; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java deleted file mode 100644 index 546069465..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金记录业务类型枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageRecordBizTypeEnum implements IntArrayValuable { - - ORDER(1, "获得推广佣金", "获得推广佣金 {}", true), - WITHDRAW(2, "提现申请", "提现申请扣除佣金 {}", false), - WITHDRAW_REJECT(3, "提现申请驳回", "提现申请驳回,返还佣金 {}", true), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 标题 - */ - private final String title; - /** - * 描述 - */ - private final String description; - /** - * 是否为增加佣金 - */ - private final boolean add; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java deleted file mode 100644 index 827390998..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金记录状态枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageRecordStatusEnum implements IntArrayValuable { - - WAIT_SETTLEMENT(0, "待结算"), - SETTLEMENT(1, "已结算"), - CANCEL(2, "已取消"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java deleted file mode 100644 index b68db4a71..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO 芋艿:提现的打通,在纠结下; -/** - * 佣金提现状态枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageWithdrawStatusEnum implements IntArrayValuable { - - AUDITING(0, "审核中"), - AUDIT_SUCCESS(10, "审核通过"), - WITHDRAW_SUCCESS(11, "提现成功"), - AUDIT_FAIL(20, "审核不通过"), - WITHDRAW_FAIL(21, "提现失败"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java deleted file mode 100644 index 46edf010e..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金提现类型枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageWithdrawTypeEnum implements IntArrayValuable { - - WALLET(1, "钱包"), - BANK(2, "银行卡"), - WECHAT(3, "微信"), - ALIPAY(4, "支付宝"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java deleted file mode 100644 index 7503dd322..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.delivery; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 快递配送计费方式枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DeliveryExpressChargeModeEnum implements IntArrayValuable { - - COUNT(1, "按件"), - WEIGHT(2,"按重量"), - VOLUME(3, "按体积"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryExpressChargeModeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 描述 - */ - private final String desc; - - @Override - public int[] array() { - return ARRAYS; - } - - public static DeliveryExpressChargeModeEnum valueOf(Integer value) { - return ArrayUtil.firstMatch(chargeMode -> chargeMode.getType().equals(value), DeliveryExpressChargeModeEnum.values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java deleted file mode 100644 index 27e11370c..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.delivery; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 配送方式枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum DeliveryTypeEnum implements IntArrayValuable { - - EXPRESS(1, "快递发货"), - PICK_UP(2, "用户自提"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getType).toArray(); - - /** - * 配送方式 - */ - private final Integer type; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java deleted file mode 100644 index 74c6b23fe..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.notify; - -// TODO @芋艿:这个枚举的作用? -public interface TradeNotifyEnums { -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java deleted file mode 100644 index 8ec1e9b16..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 关闭类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderCancelTypeEnum implements IntArrayValuable { - - PAY_TIMEOUT(10, "超时未支付"), - AFTER_SALE_CLOSE(20, "退款关闭"), - MEMBER_CANCEL(30, "买家取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray(); - - /** - * 关闭类型 - */ - private final Integer type; - /** - * 关闭类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java deleted file mode 100644 index 50640717e..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单项 - 售后状态 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable { - - NONE(0, "未售后"), - APPLY(10, "售后中"), - SUCCESS(20, "售后成功"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断指定状态,是否正处于【未申请】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isNone(Integer status) { - return ObjectUtil.equals(status, NONE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java deleted file mode 100644 index 695cb41ce..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 订单操作类型的枚举 - * - * @author 陈賝 - * @since 2023/7/6 15:31 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderOperateTypeEnum { - - MEMBER_CREATE(1, "用户下单"), - ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,调整价格 {adjustPrice},实际支付金额为 {newPayPrice} 元"), - MEMBER_PAY(10, "用户付款成功"), - ADMIN_UPDATE_ADDRESS(11, "收货地址修改"), - ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), - MEMBER_RECEIVE(30, "用户已收货"), - SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), - ADMIN_PICK_UP_RECEIVE(32, "管理员自提收货"), - MEMBER_COMMENT(33, "用户评价"), - SYSTEM_COMMENT(34, "到期未评价,系统自动评价"), - MEMBER_CANCEL(40, "取消订单"), - SYSTEM_CANCEL(41, "到期未支付,系统自动取消订单"), - // 42 预留:管理员取消订单 - ADMIN_CANCEL_AFTER_SALE(43, "订单全部售后,管理员自动取消订单"), - MEMBER_DELETE(49, "删除订单"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作描述 - */ - private final String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java deleted file mode 100644 index d0e4190bb..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 退款状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderRefundStatusEnum implements IntArrayValuable { - - NONE(0, "未退款"), - PART(10, "部分退款"), - ALL(20, "全部退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderRefundStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java deleted file mode 100644 index 86d3d996f..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderStatusEnum implements IntArrayValuable { - - UNPAID(0, "待支付"), - UNDELIVERED(10, "待发货"), - DELIVERED(20, "已发货"), - COMPLETED(30, "已完成"), - CANCELED(40, "已取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - // ========== 问:为什么写了很多 isXXX 和 haveXXX 的判断逻辑呢? ========== - // ========== 答:方便找到某一类判断,哪些业务正在使用 ========== - - /** - * 判断指定状态,是否正处于【未付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUnpaid(Integer status) { - return ObjectUtil.equal(UNPAID.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【待发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUndelivered(Integer status) { - return ObjectUtil.equal(UNDELIVERED.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isDelivered(Integer status) { - return ObjectUtil.equals(status, DELIVERED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已取消】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCanceled(Integer status) { - return ObjectUtil.equals(status, CANCELED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已完成】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCompleted(Integer status) { - return ObjectUtil.equals(status, COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean havePaid(Integer status) { - return ObjectUtils.equalsAny(status, UNDELIVERED.getStatus(), - DELIVERED.getStatus(), COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean haveDelivered(Integer status) { - return ObjectUtils.equalsAny(status, DELIVERED.getStatus(), COMPLETED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java deleted file mode 100644 index f82071206..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderTypeEnum implements IntArrayValuable { - - NORMAL(0, "普通订单"), - SECKILL(1, "秒杀订单"), - BARGAIN(2, "砍价订单"), - COMBINATION(3, "拼团订单"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isNormal(Integer type) { - return ObjectUtil.equal(type, NORMAL.getType()); - } - - public static boolean isSeckill(Integer type) { - return ObjectUtil.equal(type, SECKILL.getType()); - } - - public static boolean isBargain(Integer type) { - return ObjectUtil.equal(type, BARGAIN.getType()); - } - - public static boolean isCombination(Integer type) { - return ObjectUtil.equal(type, COMBINATION.getType()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/Dockerfile b/yudao-module-mall/yudao-module-trade-biz/Dockerfile deleted file mode 100644 index 872f55c16..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-trade-biz -WORKDIR /yudao-module-trade-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-trade-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48102 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mall/yudao-module-trade-biz/pom.xml b/yudao-module-mall/yudao-module-trade-biz/pom.xml deleted file mode 100644 index f00538d8b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-biz - jar - - ${project.artifactId} - - trade 模块,主要实现交易相关功能 - 例如:订单、退款、购物车等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-trade-api - ${revision} - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-pay-api - ${revision} - - - cn.iocoder.cloud - yudao-module-promotion-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/TradeServerApplication.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/TradeServerApplication.java deleted file mode 100644 index be59b7804..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/TradeServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class TradeServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(TradeServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java deleted file mode 100644 index a342c6baf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 订单 API 接口实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class TradeOrderApiImpl implements TradeOrderApi { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @Override - public CommonResult> getOrderList(Collection ids) { - return success(TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids))); - } - - @Override - public CommonResult getOrder(Long id) { - return success(TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id))); - } - - @Override - public CommonResult cancelPaidOrder(Long userId, Long orderId) { - tradeOrderUpdateService.cancelPaidOrder(userId, orderId); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java deleted file mode 100644 index 5b0e37dcc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.trade.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java deleted file mode 100644 index a15637428..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.*; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 售后订单") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AfterSaleController { - - @Resource - private AfterSaleService afterSaleService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private AfterSaleLogService afterSaleLogService; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得售后订单分页") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult> getAfterSalePage(@Valid AfterSalePageReqVO pageVO) { - // 查询售后 - PageResult pageResult = afterSaleService.getAfterSalePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询会员 - Map memberUsers = memberUserApi.getUserMap( - convertSet(pageResult.getList(), AfterSaleDO::getUserId)); - return success(AfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得售后订单详情") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - AfterSaleDO afterSale = afterSaleService.getAfterSale(id); - if (afterSale == null) { - return success(null); - } - - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId()); - // 查询订单项 - TradeOrderItemDO orderItem = tradeOrderQueryService.getOrderItem(afterSale.getOrderItemId()); - // 拼接数据 - MemberUserRespDTO user = memberUserApi.getUser(afterSale.getUserId()).getCheckedData(); - List logs = afterSaleLogService.getAfterSaleLogList(afterSale.getId()); - return success(AfterSaleConvert.INSTANCE.convert(afterSale, order, orderItem, user, logs)); - } - - @PutMapping("/agree") - @Operation(summary = "同意售后") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:agree')") - public CommonResult agreeAfterSale(@RequestParam("id") Long id) { - afterSaleService.agreeAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/disagree") - @Operation(summary = "拒绝售后") - @PreAuthorize("@ss.hasPermission('trade:after-sale:disagree')") - public CommonResult disagreeAfterSale(@RequestBody AfterSaleDisagreeReqVO confirmReqVO) { - afterSaleService.disagreeAfterSale(getLoginUserId(), confirmReqVO); - return success(true); - } - - @PutMapping("/receive") - @Operation(summary = "确认收货") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult receiveAfterSale(@RequestParam("id") Long id) { - afterSaleService.receiveAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/refuse") - @Operation(summary = "拒绝收货") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult refuseAfterSale(AfterSaleRefuseReqVO refuseReqVO) { - afterSaleService.refuseAfterSale(getLoginUserId(), refuseReqVO); - return success(true); - } - - @PutMapping("/refund") - @Operation(summary = "确认退款") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:refund')") - public CommonResult refundAfterSale(@RequestParam("id") Long id) { - afterSaleService.refundAfterSale(getLoginUserId(), getClientIP(), id); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新售后订单为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - public CommonResult updateAfterRefund(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - // 目前业务逻辑,不需要做任何事情 - // 当然,退款会有小概率会失败的情况,可以监控失败状态,进行告警 - log.info("[updateAfterRefund][notifyReqDTO({})]", notifyReqDTO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http deleted file mode 100644 index 81cb35cbf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http +++ /dev/null @@ -1,33 +0,0 @@ -### 获得交易售后分页 => 成功 -GET {{baseUrl}}/trade/after-sale/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 同意售后 => 成功 -PUT {{baseUrl}}/trade/after-sale/agree?id=7 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -### 拒绝售后 => 成功 -PUT {{baseUrl}}/trade/after-sale/disagree -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -{ - "id": 6, - "auditReason": "阿巴巴" -} - -### 确认退款 => 成功 -PUT {{baseUrl}}/trade/after-sale/refund?id=6 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -### 确认收货 => 成功 -PUT {{baseUrl}}/trade/after-sale/receive?id=7 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java deleted file mode 100644 index ae7bd395c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 交易售后 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class AfterSaleBaseVO { - - @Schema(description = "售后流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "202211190847450020500077") - @NotNull(message = "售后流水号不能为空") - private String no; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "售后状态不能为空") - private Integer status; - - @Schema(description = "售后类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - @NotNull(message = "售后类型不能为空") - private Integer type; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "售后方式不能为空") - private Integer way; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30337") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不喜欢") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @Schema(description = "补充描述", example = "你说的对") - private String applyDescription; - - @Schema(description = "补充凭证图片", example = "https://www.iocoder.cn/1.png") - private List applyPicUrls; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18078") - @NotNull(message = "订单编号不能为空") - private Long orderId; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022111917190001") - @NotNull(message = "订单流水号不能为空") - private String orderNo; - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "572") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2888") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15657") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品图片", example = "https://www.iocoder.cn/2.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20012") - @NotNull(message = "购买数量不能为空") - private Integer count; - - @Schema(description = "审批时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @Schema(description = "审批人", example = "30835") - private Long auditUserId; - - @Schema(description = "审批备注", example = "不香") - private String auditReason; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "18077") - @NotNull(message = "退款金额,单位:分不能为空") - private Integer refundPrice; - - @Schema(description = "支付退款编号", example = "10271") - private Long payRefundId; - - @Schema(description = "退款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime refundTime; - - @Schema(description = "退货物流公司编号", example = "10") - private Long logisticsId; - - @Schema(description = "退货物流单号", example = "610003952009") - private String logisticsNo; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime receiveTime; - - @Schema(description = "收货备注", example = "不喜欢") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java deleted file mode 100644 index 3f220770b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 售后订单的详情 Response VO") -@Data -public class AfterSaleDetailRespVO extends AfterSaleBaseVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - - - /** - * 订单基本信息 - */ - private TradeOrderBaseVO order; - /** - * 订单项列表 - */ - private OrderItem orderItem; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - - /** - * 售后日志 - */ - private List logs; - - @Schema(description = "管理后台 - 交易订单的详情的订单项目") - @Data - public static class OrderItem extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java deleted file mode 100644 index 6fa511acd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 交易售后拒绝 Request VO") -@Data -public class AfterSaleDisagreeReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "审批备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotEmpty(message = "审批备注不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java deleted file mode 100644 index f74c84b8f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易售后分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AfterSalePageReqVO extends PageParam { - - @Schema(description = "售后流水号", example = "202211190847450020500077") - private String no; - - @Schema(description = "售后状态", example = "10") - @InEnum(value = AfterSaleStatusEnum.class, message = "售后状态必须是 {value}") - private Integer status; - - @Schema(description = "售后类型", example = "20") - @InEnum(value = AfterSaleTypeEnum.class, message = "售后类型必须是 {value}") - private Integer type; - - @Schema(description = "售后方式", example = "10") - @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @Schema(description = "订单编号", example = "18078") - private String orderNo; - - @Schema(description = "商品 SPU 名称", example = "李四") - private String spuName; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java deleted file mode 100644 index 6dfced4d8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 交易售后拒绝收货 Request VO") -@Data -public class AfterSaleRefuseReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "收货备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotNull(message = "收货备注不能为空") - private String refuseMemo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java deleted file mode 100644 index 3e76405e9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 交易售后分页的每一条记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AfterSaleRespPageItemVO extends AfterSaleBaseVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27630") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java deleted file mode 100644 index 0a5e019a0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 交易售后日志 Response VO") -@Data -public class AfterSaleLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20669") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22634") - private Long userId; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer userType; - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3023") - private Long afterSaleId; - - @Schema(description = "售后状态(之前)", example = "2") - private Integer beforeStatus; - - @Schema(description = "售后状态(之后)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterStatus; - - @Schema(description = "操作明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "维权完成,退款金额:¥37776.00") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java deleted file mode 100644 index f874e482d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,可忽略 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base.member; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java deleted file mode 100644 index 2d7c3512d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.member.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员用户 Response VO") -@Data -public class MemberUserRespVO { - - @Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String nickname; - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java deleted file mode 100644 index 0baa83e49..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 放置该模块通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java deleted file mode 100644 index 3d6d3b061..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.product.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品属性值的明细 Response VO") -@Data -public class ProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java deleted file mode 100644 index ff9bd5285..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 佣金记录") -@RestController -@RequestMapping("/trade/brokerage-record") -@Validated -public class BrokerageRecordController { - - @Resource - private BrokerageRecordService brokerageRecordService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @Operation(summary = "获得佣金记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult getBrokerageRecord(@RequestParam("id") Integer id) { - BrokerageRecordDO brokerageRecord = brokerageRecordService.getBrokerageRecord(id); - return success(BrokerageRecordConvert.INSTANCE.convert(brokerageRecord)); - } - - @GetMapping("/page") - @Operation(summary = "获得佣金记录分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult> getBrokerageRecordPage(@Valid BrokerageRecordPageReqVO pageVO) { - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage(pageVO); - - // 查询用户信息 - Set userIds = convertSet(pageResult.getList(), BrokerageRecordDO::getUserId); - userIds.addAll(convertList(pageResult.getList(), BrokerageRecordDO::getSourceUserId)); - Map userMap = memberUserApi.getUserMap(userIds); - // 拼接数据 - return success(BrokerageRecordConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java deleted file mode 100644 index 7844b93e5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.*; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-user") -@Validated -public class BrokerageUserController { - - @Resource - private BrokerageUserService brokerageUserService; - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @PutMapping("/update-bind-user") - @Operation(summary = "修改推广员") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-bind-user')") - public CommonResult updateBindUser(@Valid @RequestBody BrokerageUserUpdateBrokerageUserReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), updateReqVO.getBindUserId()); - return success(true); - } - - @PutMapping("/clear-bind-user") - @Operation(summary = "清除推广员") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:clear-bind-user')") - public CommonResult clearBindUser(@Valid @RequestBody BrokerageUserClearBrokerageUserReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), null); - return success(true); - } - - @PutMapping("/update-brokerage-enable") - @Operation(summary = "修改推广资格") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-enable')") - public CommonResult updateBrokerageEnabled(@Valid @RequestBody BrokerageUserUpdateBrokerageEnabledReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserEnabled(updateReqVO.getId(), updateReqVO.getEnabled()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分销用户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") - public CommonResult getBrokerageUser(@RequestParam("id") Long id) { - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(id); - // TODO @疯狂:是不是搞成一个统一的 convert? - BrokerageUserRespVO respVO = BrokerageUserConvert.INSTANCE.convert(brokerageUser); - return success(BrokerageUserConvert.INSTANCE.copyTo(memberUserApi.getUser(id).getCheckedData(), respVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得分销用户分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") - public CommonResult> getBrokerageUserPage(@Valid BrokerageUserPageReqVO pageVO) { - // 分页查询 - PageResult pageResult = brokerageUserService.getBrokerageUserPage(pageVO); - - // 查询用户信息 - Set userIds = convertSet(pageResult.getList(), BrokerageUserDO::getId); - Map userMap = memberUserApi.getUserMap(userIds); - // 合计分佣的推广订单 - Map brokerageOrderSummaryMap = brokerageRecordService.getUserBrokerageSummaryMapByUserId( - userIds, BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus()); - // 合计分佣的推广用户 - // TODO @疯狂:转成 map 批量读取 - Map brokerageUserCountMap = convertMap(userIds, - userId -> userId, - userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null)); - // 合计分佣的提现 - // TODO @疯狂:如果未来支持了打款这个动作,可能 status 会不对; - Map withdrawMap = brokerageWithdrawService.getWithdrawSummaryMapByUserId( - userIds, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS); - // 拼接返回 - return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, - brokerageOrderSummaryMap, withdrawMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java deleted file mode 100644 index 609cfa433..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRejectReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 佣金提现") -@RestController -@RequestMapping("/trade/brokerage-withdraw") -@Validated -public class BrokerageWithdrawController { - - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @PutMapping("/approve") - @Operation(summary = "通过申请") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult approveBrokerageWithdraw(@RequestParam("id") Integer id) { - brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, ""); - return success(true); - } - - @PutMapping("/reject") - @Operation(summary = "驳回申请") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult rejectBrokerageWithdraw(@Valid @RequestBody BrokerageWithdrawRejectReqVO reqVO) { - brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得佣金提现") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult getBrokerageWithdraw(@RequestParam("id") Integer id) { - BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id); - return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw)); - } - - @GetMapping("/page") - @Operation(summary = "获得佣金提现分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult> getBrokerageWithdrawPage(@Valid BrokerageWithdrawPageReqVO pageVO) { - // 分页查询 - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(pageVO); - - // 拼接信息 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BrokerageWithdrawDO::getUserId)); - return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java deleted file mode 100644 index 0c53f99fb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 佣金记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25973") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23353") - @NotEmpty(message = "业务编号不能为空") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "标题不能为空") - private String title; - - @Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "28731") - @NotNull(message = "金额不能为空") - private Integer price; - - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "13226") - @NotNull(message = "当前总佣金不能为空") - private Integer totalPrice; - - @Schema(description = "说明", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") - @NotNull(message = "说明不能为空") - private String description; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "冻结时间(天)不能为空") - private Integer frozenDays; - - @Schema(description = "解冻时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime unfreezeTime; - - @Schema(description = "来源用户等级") - private Integer sourceUserLevel; - - @Schema(description = "来源用户编号") - private Long sourceUserId; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java deleted file mode 100644 index 36c4744e8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 佣金记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "25973") - private Long userId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户类型", example = "1") - private Integer sourceUserLevel; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java deleted file mode 100644 index 224ecf1e5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 佣金记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageRecordRespVO extends BrokerageRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28896") - private Integer id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - - // ========== 用户信息 ========== - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String userAvatar; - @Schema(description = "用户昵称", example = "李四") - private String userNickname; - - - // ========== 来源用户信息 ========== - - @Schema(description = "来源用户头像", example = "https://www.iocoder.cn/xxx.png") - private String sourceUserAvatar; - @Schema(description = "来源用户昵称", example = "李四") - private String sourceUserNickname; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java deleted file mode 100644 index 05e5935b0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 分销用户 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageUserBaseVO { - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - - @Schema(description = "推广员绑定时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime bindUserTime; - - @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "推广资格不能为空") - private Boolean brokerageEnabled; - - @Schema(description = "成为分销员时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime brokerageTime; - - @Schema(description = "可用佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "11089") - @NotNull(message = "可用佣金不能为空") - private Integer price; - - @Schema(description = "冻结佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "30916") - @NotNull(message = "冻结佣金不能为空") - private Integer frozenPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java deleted file mode 100644 index 5a05c56ce..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 清除推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserClearBrokerageUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java deleted file mode 100644 index cb0ce8954..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 分销用户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageUserPageReqVO extends PageParam { - - @Schema(description = "推广员编号", example = "4587") - private Long bindUserId; - - @Schema(description = "推广资格", example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户等级", example = "1") // 注意,这了不是用户的会员等级,而是过滤推广的层级 - private Integer level; - - @Schema(description = "绑定时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] bindUserTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java deleted file mode 100644 index 3f5fe258f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 分销用户 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageUserRespVO extends BrokerageUserBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 用户信息 ========== - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png") - private String avatar; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String nickname; - - // ========== 推广信息 ========== 注意:是包括 1 + 2 级的数据 - - @Schema(description = "推广用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageUserCount; - @Schema(description = "推广订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageOrderCount; - @Schema(description = "推广订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageOrderPrice; - - // ========== 提现信息 ========== - - @Schema(description = "已提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer withdrawPrice; - @Schema(description = "已提现次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer withdrawCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java deleted file mode 100644 index d097855a2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserUpdateBrokerageEnabledReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "推广资格不能为空") - private Boolean enabled; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java deleted file mode 100644 index 56391c4d5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserUpdateBrokerageUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java deleted file mode 100644 index 8aca8a2bb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 佣金提现 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageWithdrawBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") - @NotNull(message = "提现金额不能为空") - private Integer price; - - @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") - @NotNull(message = "提现手续费不能为空") - private Integer feePrice; - - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") - @NotNull(message = "当前总佣金不能为空") - private Integer totalPrice; - - @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "提现类型不能为空") - private Integer type; - - @Schema(description = "真实姓名", example = "赵六") - private String name; - - @Schema(description = "账号", example = "88677912132") - private String accountNo; - - @Schema(description = "银行名称", example = "1") - private String bankName; - - @Schema(description = "开户地址", example = "海淀支行") - private String bankAddress; - - @Schema(description = "收款码", example = "https://www.iocoder.cn") - private String accountQrCodeUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "审核驳回原因", example = "不对") - private String auditReason; - - @Schema(description = "审核时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @Schema(description = "备注", example = "随便") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java deleted file mode 100644 index b18ff74af..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 佣金提现分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageWithdrawPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "11436") - private Long userId; - - @Schema(description = "提现类型", example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现类型必须是 {value}") - private Integer type; - - @Schema(description = "真实姓名", example = "赵六") - private String name; - - @Schema(description = "账号", example = "886779132") - private String accountNo; - - @Schema(description = "银行名称", example = "1") - private String bankName; - - @Schema(description = "状态", example = "1") - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java deleted file mode 100644 index 23e6c28e5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 驳回申请 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageWithdrawRejectReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - @NotNull(message = "编号不能为空") - private Integer id; - - @Schema(description = "审核驳回原因", example = "不对") - @NotEmpty(message = "审核驳回原因不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java deleted file mode 100644 index de74bb4f6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 佣金提现 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - private Integer id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String userNickname; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java deleted file mode 100644 index 5e0558fbf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 交易中心配置") -@RestController -@RequestMapping("/trade/config") -@Validated -public class TradeConfigController { - - @Resource - private TradeConfigService tradeConfigService; - - @Value("${yudao.tencent-lbs-key}") - private String tencentLbsKey; - - @PutMapping("/save") - @Operation(summary = "更新交易中心配置") - @PreAuthorize("@ss.hasPermission('trade:config:save')") - public CommonResult updateConfig(@Valid @RequestBody TradeConfigSaveReqVO updateReqVO) { - tradeConfigService.saveTradeConfig(updateReqVO); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得交易中心配置") - @PreAuthorize("@ss.hasPermission('trade:config:query')") - public CommonResult getConfig() { - TradeConfigDO config = tradeConfigService.getTradeConfig(); - TradeConfigRespVO configVO = TradeConfigConvert.INSTANCE.convert(config); - if (configVO != null) { - configVO.setTencentLbsKey(tencentLbsKey); - } - return success(configVO); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java deleted file mode 100644 index 3c58275fa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; -import java.util.List; - -/** - * 交易中心配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeConfigBaseVO { - - // ========== 售后相关 ========== - - @Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "售后的退款理由不能为空") - private List afterSaleRefundReasons; - - @Schema(description = "售后的退货理由", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "售后的退货理由不能为空") - private List afterSaleReturnReasons; - - // ========== 配送相关 ========== - - /** - * 是否启用全场包邮 - */ - @Schema(description = "是否启用全场包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用全场包邮不能为空") - private Boolean deliveryExpressFreeEnabled; - - @Schema(description = "全场包邮的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "全场包邮的最小金额不能为空") - @PositiveOrZero(message = "全场包邮的最小金额不能是负数") - private Integer deliveryExpressFreePrice; - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否开启自提不能为空") - private Boolean deliveryPickUpEnabled; - - // ========== 分销相关 ========== - - @Schema(description = "是否启用分佣", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用分佣不能为空") - private Boolean brokerageEnabled; - - @Schema(description = "分佣模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "分佣模式不能为空") - @InEnum(value = BrokerageEnabledConditionEnum.class, message = "分佣模式必须是 {value}") - private Integer brokerageEnabledCondition; - - @Schema(description = "分销关系绑定模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "分销关系绑定模式不能为空") - @InEnum(value = BrokerageBindModeEnum.class, message = "分销关系绑定模式必须是 {value}") - private Integer brokerageBindMode; - - @Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]") - private List brokeragePosterUrls; - - @Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "一级返佣比例不能为空") - @Range(min = 0, max = 100, message = "一级返佣比例必须在 0 - 100 之间") - private Integer brokerageFirstPercent; - - @Schema(description = "二级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "二级返佣比例不能为空") - @Range(min = 0, max = 100, message = "二级返佣比例必须在 0 - 100 之间") - private Integer brokerageSecondPercent; - - @Schema(description = "用户提现最低金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "用户提现最低金额不能为空") - @PositiveOrZero(message = "用户提现最低金额不能是负数") - private Integer brokerageWithdrawMinPrice; - - @Schema(description = "用户提现手续费百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "用户提现手续费百分比不能为空") - @PositiveOrZero(message = "用户提现手续费百分比不能是负数") - private Integer brokerageWithdrawFeePercent; - - @Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - @NotNull(message = "佣金冻结时间(天)不能为空") - @PositiveOrZero(message = "佣金冻结时间不能是负数") - private Integer brokerageFrozenDays; - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]") - @NotEmpty(message = "提现方式不能为空") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}") - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java deleted file mode 100644 index 5ded00ace..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 交易中心配置 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeConfigRespVO extends TradeConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java deleted file mode 100644 index 03a0c41df..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 交易中心配置更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeConfigSaveReqVO extends TradeConfigBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java deleted file mode 100644 index 63f77c1d8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 快递公司") -@RestController -@RequestMapping("/trade/delivery/express") -@Validated -public class DeliveryExpressController { - - @Resource - private DeliveryExpressService deliveryExpressService; - - @PostMapping("/create") - @Operation(summary = "创建快递公司") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:create')") - public CommonResult createDeliveryExpress(@Valid @RequestBody DeliveryExpressCreateReqVO createReqVO) { - return success(deliveryExpressService.createDeliveryExpress(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新快递公司") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:update')") - public CommonResult updateDeliveryExpress(@Valid @RequestBody DeliveryExpressUpdateReqVO updateReqVO) { - deliveryExpressService.updateDeliveryExpress(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除快递公司") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:express:delete')") - public CommonResult deleteDeliveryExpress(@RequestParam("id") Long id) { - deliveryExpressService.deleteDeliveryExpress(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得快递公司") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") - public CommonResult getDeliveryExpress(@RequestParam("id") Long id) { - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(id); - return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryExpressConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得快递公司分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") - public CommonResult> getDeliveryExpressPage(@Valid DeliveryExpressPageReqVO pageVO) { - PageResult pageResult = deliveryExpressService.getDeliveryExpressPage(pageVO); - return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出快递公司 Excel") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportDeliveryExpressExcel(@Valid DeliveryExpressExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = deliveryExpressService.getDeliveryExpressList(exportReqVO); - // 导出 Excel - List dataList = DeliveryExpressConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "快递公司.xls", "数据", DeliveryExpressExcelVO.class, dataList); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java deleted file mode 100644 index 5dc83682a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 快递运费模板") -@RestController -@RequestMapping("/trade/delivery/express-template") -@Validated -public class DeliveryExpressTemplateController { - - @Resource - private DeliveryExpressTemplateService deliveryExpressTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建快递运费模板") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:create')") - public CommonResult createDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateCreateReqVO createReqVO) { - return success(deliveryExpressTemplateService.createDeliveryExpressTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新快递运费模板") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:update')") - public CommonResult updateDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateUpdateReqVO updateReqVO) { - deliveryExpressTemplateService.updateDeliveryExpressTemplate(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除快递运费模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:delete')") - public CommonResult deleteDeliveryExpressTemplate(@RequestParam("id") Long id) { - deliveryExpressTemplateService.deleteDeliveryExpressTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得快递运费模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult getDeliveryExpressTemplate(@RequestParam("id") Long id) { - return success(deliveryExpressTemplateService.getDeliveryExpressTemplate(id)); - } - - @GetMapping("/list") - @Operation(summary = "获得快递运费模板列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult> getDeliveryExpressTemplateList(@RequestParam("ids") Collection ids) { - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(ids); - return success(DeliveryExpressTemplateConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取快递模版精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleTemplateList() { - // 获取运费模版列表,只要开启状态的 - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(); - // 排序后,返回给前端 - return success(DeliveryExpressTemplateConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得快递运费模板分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult> getDeliveryExpressTemplatePage(@Valid DeliveryExpressTemplatePageReqVO pageVO) { - PageResult pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO); - return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java deleted file mode 100644 index 4235d6ef5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 自提门店") -@RestController -@RequestMapping("/trade/delivery/pick-up-store") -@Validated -public class DeliveryPickUpStoreController { - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - - @PostMapping("/create") - @Operation(summary = "创建自提门店") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") - public CommonResult createDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpStoreCreateReqVO createReqVO) { - return success(deliveryPickUpStoreService.createDeliveryPickUpStore(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新自提门店") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:update')") - public CommonResult updateDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpStoreUpdateReqVO updateReqVO) { - deliveryPickUpStoreService.updateDeliveryPickUpStore(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除自提门店") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:delete')") - public CommonResult deleteDeliveryPickUpStore(@RequestParam("id") Long id) { - deliveryPickUpStoreService.deleteDeliveryPickUpStore(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得自提门店") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult getDeliveryPickUpStore(@RequestParam("id") Long id) { - DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得自提门店精简信息列表") - public CommonResult> getSimpleDeliveryPickUpStoreList() { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得自提门店列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult> getDeliveryPickUpStoreList(@RequestParam("ids") Collection ids) { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreList(ids); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得自提门店分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult> getDeliveryPickUpStorePage(@Valid DeliveryPickUpStorePageReqVO pageVO) { - PageResult pageResult = deliveryPickUpStoreService.getDeliveryPickUpStorePage(pageVO); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java deleted file mode 100644 index cc7b8bedd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 快递公司 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryExpressBaseVO { - - @Schema(description = "快递公司编码", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "快递公司编码不能为空") - private String code; - - @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "快递公司名称不能为空") - private String name; - - @Schema(description = "快递公司logo") - private String logo; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java deleted file mode 100644 index a9ba8a7cb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 快递公司创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressCreateReqVO extends DeliveryExpressBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java deleted file mode 100644 index c84a3a189..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递公司 Excel VO - */ -@Data -public class DeliveryExpressExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("快递公司编码") - private String code; - - @ExcelProperty("快递公司名称") - private String name; - - @ExcelProperty("快递公司 logo") - private String logo; - - @ExcelProperty("排序") - private Integer sort; - - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java deleted file mode 100644 index c601721e8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递公司 Excel 导出 Request VO") -@Data -public class DeliveryExpressExportReqVO { - - @Schema(description = "快递公司编码") - private String code; - - @Schema(description = "快递公司名称", example = "李四") - private String name; - - @Schema(description = "状态(0正常 1停用)", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java deleted file mode 100644 index 4a000f319..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递公司分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressPageReqVO extends PageParam { - - @Schema(description = "快递公司编码") - private String code; - - @Schema(description = "快递公司名称", example = "李四") - private String name; - - @Schema(description = "状态(0正常 1停用)", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java deleted file mode 100644 index cc314d105..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 快递公司 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressRespVO extends DeliveryExpressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java deleted file mode 100644 index b97cc2317..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 快递公司精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryExpressSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰速运") - @NotNull(message = "快递公司名称不能为空") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java deleted file mode 100644 index e51366ded..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 快递公司更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressUpdateReqVO extends DeliveryExpressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java deleted file mode 100644 index 3be8ffc3b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 快递运费模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryExpressTemplateBaseVO { - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "模板名称不能为空") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "配送计费方式 1:按件 2:按重量 3:按体积不能为空") - private Integer chargeMode; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java deleted file mode 100644 index efb15c894..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 快递运费模板运费设置 Base VO,提供给添加运费模板使用 - */ -@Data -public class DeliveryExpressTemplateChargeBaseVO { - - @Schema(description = "编号", example = "6592", hidden = true) // 由于想简单一点,复用这个 VO 在更新操作,所以 hidden 为 false - private Long id; - - @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") - @NotEmpty(message = "区域编号列表不能为空") - private List areaIds; - - @Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "首件数量不能为空") - private Double startCount; - - @Schema(description = "起步价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "起步价不能为空") - private Integer startPrice; - - @Schema(description = "续件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "续件数量不能为空") - private Double extraCount; - - @Schema(description = "额外价", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - @NotNull(message = "额外价不能为空") - private Integer extraPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java deleted file mode 100644 index c5eeaebc9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateCreateReqVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "区域运费列表") - @Valid - private List charges; - - @Schema(description = "包邮区域列表") - @Valid - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java deleted file mode 100644 index 272ab59a0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateDetailRespVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - private Long id; - - @Schema(description = "运费模板运费设置", requiredMode = Schema.RequiredMode.REQUIRED) - private List charges; - - @Schema(description = "运费模板包邮区域", requiredMode = Schema.RequiredMode.REQUIRED) - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java deleted file mode 100644 index b3e0f12b5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 快递运费模板包邮 Base VO,提供给添加运费模板使用 - */ -@Data -public class DeliveryExpressTemplateFreeBaseVO { - - @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") - @NotEmpty(message = "区域编号列表不能为空") - private List areaIds; - - @Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000") - @NotNull(message = "包邮金额不能为空") - private Integer freePrice; - - @Schema(description = "包邮件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "包邮件数不能为空") - private Integer freeCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java deleted file mode 100644 index ea1e4ab3e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递运费模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplatePageReqVO extends PageParam { - - @Schema(description = "模板名称", example = "王五") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积") - private Integer chargeMode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java deleted file mode 100644 index 19a8c1621..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 快递运费模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateRespVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号,自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java deleted file mode 100644 index 074cc5337..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - - -@Schema(description = "管理后台 - 模版精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryExpressTemplateSimpleRespVO { - - @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java deleted file mode 100644 index 4c1774524..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateUpdateReqVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "区域运费列表") - @Valid - private List charges; - - @Schema(description = "包邮区域列表") - @Valid - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java deleted file mode 100644 index 6a4ab1141..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.time.LocalTime; - -/** -* 自提门店 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryPickUpStoreBaseVO { - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotBlank(message = "门店名称不能为空") - private String name; - - @Schema(description = "门店简介", example = "我是门店简介") - private String introduction; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - @NotBlank(message = "门店手机不能为空") - @Mobile - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - @NotNull(message = "区域编号不能为空") - private Integer areaId; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - @NotBlank(message = "门店详细地址不能为空") - private String detailAddress; - - @Schema(description = "门店 logo", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotBlank(message = "门店 logo 不能为空") - private String logo; - - @Schema(description = "营业开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "营业开始时间不能为空") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") - private LocalTime openingTime; - - @Schema(description = "营业结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "营业结束时间不能为空") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") - private LocalTime closingTime; - - @Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88") - @NotNull(message = "纬度不能为空") - private Double latitude; - - @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99") - @NotNull(message = "经度不能为空") - private Double longitude; - - @Schema(description = "门店状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "门店状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java deleted file mode 100644 index d3d23f977..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 自提门店创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreCreateReqVO extends DeliveryPickUpStoreBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java deleted file mode 100644 index ee3ce2e49..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import lombok.*; - -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 自提门店分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStorePageReqVO extends PageParam { - - @Schema(description = "门店名称", example = "李四") - private String name; - - @Schema(description = "门店手机") - private String phone; - - @Schema(description = "区域编号", example = "18733") - private Integer areaId; - - @Schema(description = "门店状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java deleted file mode 100644 index 5b5bd0d0c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 自提门店 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java deleted file mode 100644 index c12fc9fc3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 自提门店精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryPickUpStoreSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - private Integer areaId; - - @Schema(description = "区域名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx市") - private String areaName; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - private String detailAddress; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java deleted file mode 100644 index 2b0548d9d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 自提门店更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreUpdateReqVO extends DeliveryPickUpStoreBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http deleted file mode 100644 index 0bf8812b2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http +++ /dev/null @@ -1,9 +0,0 @@ -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/get-detail?id=21 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java deleted file mode 100644 index 3109ff35c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ /dev/null @@ -1,169 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class TradeOrderController { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private TradeOrderLogService tradeOrderLogService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得交易订单分页") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderPage(TradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderQueryService.getOrderPage(reqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询用户信息 - Set userIds = CollUtil.unionDistinct(convertList(pageResult.getList(), TradeOrderDO::getUserId), - convertList(pageResult.getList(), TradeOrderDO::getBrokerageUserId, Objects::nonNull)); - Map userMap = memberUserApi.getUserMap(userIds); - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, userMap)); - } - - @GetMapping("/summary") - @Operation(summary = "获得交易订单统计") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderSummary(TradeOrderPageReqVO reqVO) { - return success(tradeOrderQueryService.getOrderSummary(reqVO)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单详情") - @Parameter(name = "id", description = "订单编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(id); - if (order == null) { - return success(null); - } - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id); - - // 拼接数据 - MemberUserRespDTO user = memberUserApi.getUser(order.getUserId()).getCheckedData(); - MemberUserRespDTO brokerageUser = order.getBrokerageUserId() != null ? - memberUserApi.getUser(order.getBrokerageUserId()).getCheckedData() : null; - List orderLogs = tradeOrderLogService.getOrderLogListByOrderId(id); - return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs, user, brokerageUser)); - } - - @GetMapping("/get-express-track-list") - @Operation(summary = "获得交易订单的物流轨迹") - @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { - return success(TradeOrderConvert.INSTANCE.convertList02( - tradeOrderQueryService.getExpressTrackList(id))); - } - - @PutMapping("/delivery") - @Operation(summary = "订单发货") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { - tradeOrderUpdateService.deliveryOrder(deliveryReqVO); - return success(true); - } - - @PutMapping("/update-remark") - @Operation(summary = "订单备注") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) { - tradeOrderUpdateService.updateOrderRemark(reqVO); - return success(true); - } - - @PutMapping("/update-price") - @Operation(summary = "订单调价") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) { - tradeOrderUpdateService.updateOrderPrice(reqVO); - return success(true); - } - - @PutMapping("/update-address") - @Operation(summary = "修改订单收货地址") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) { - tradeOrderUpdateService.updateOrderAddress(reqVO); - return success(true); - } - - @PutMapping("/pick-up-by-id") - @Operation(summary = "订单核销") - @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") - public CommonResult pickUpOrderById(@RequestParam("id") Long id) { - tradeOrderUpdateService.pickUpOrderByAdmin(id); - return success(true); - } - - @PutMapping("/pick-up-by-verify-code") - @Operation(summary = "订单核销") - @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") - public CommonResult pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode); - return success(true); - } - - @GetMapping("/get-by-pick-up-verify-code") - @Operation(summary = "查询核销码对应的订单") - @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getByPickUpVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - TradeOrderDO tradeOrder = tradeOrderUpdateService.getByPickUpVerifyCode(pickUpVerifyCode); - return success(TradeOrderConvert.INSTANCE.convert2(tradeOrder, null)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java deleted file mode 100755 index 88f5b0cd4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderBaseVO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "订单来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - @Schema(description = "用户备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "取消类型", example = "10") - private Integer cancelType; - - @Schema(description = "商家备注", example = "你猜一下") - private String remark; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - - @Schema(description = "付款时间") - private LocalDateTime payTime; - - @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_lite") - private String payChannelCode; - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalPrice; - - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer deliveryPrice; - - @Schema(description = "订单调价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer adjustPrice; - - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", example = "10") - private Integer deliveryType; - - @Schema(description = "自提门店", example = "10") - private Long pickUpStoreId; - - @Schema(description = "自提核销码", example = "10") - private Long pickUpVerifyCode; - - @Schema(description = "配送模板编号", example = "1024") - private Long deliveryTemplateId; - - @Schema(description = "发货物流公司编号", example = "1024") - private Long logisticsId; - - @Schema(description = "发货物流单号", example = "1024") - private String logisticsNo; - - @Schema(description = "发货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer receiverAreaId; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") - private String receiverDetailAddress; - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", example = "1") - private Integer afterSaleStatus; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer refundPrice; - - // ========== 营销基本信息 ========== - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "优惠劵减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer vipPrice; - - @Schema(description = "推广人编号", example = "1") - private Long brokerageUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java deleted file mode 100644 index 791c4088e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单发货 Request VO") -@Data -public class TradeOrderDeliveryReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "发货物流公司编号", example = "1") - @NotNull(message = "发货物流公司不能为空") - private Long logisticsId; - - @Schema(description = "发货物流单号", example = "SF123456789") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java deleted file mode 100644 index 055639e47..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 交易订单的详情 Response VO") -@Data -public class TradeOrderDetailRespVO extends TradeOrderBaseVO { - - /** - * 订单项列表 - */ - private List items; - - /** - * 下单用户信息 - */ - private MemberUserRespVO user; - /** - * 推广用户信息 - */ - private MemberUserRespVO brokerageUser; - - /** - * 操作日志列表 - */ - private List logs; - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "管理后台 - 交易订单的操作日志") - @Data - public static class OrderLog { - - @Schema(description = "操作详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单发货") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-06-01 10:50:20") - private LocalDateTime createTime; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer userType; - - } - - @Schema(description = "管理后台 - 交易订单的详情的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java deleted file mode 100644 index ded1fe7a1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 交易订单项 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderItemBaseVO { - - // ========== 订单项基本信息 ========== - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long userId; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderId; - - // ========== 商品基本信息 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "商品优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "商品实付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer payPrice; - - @Schema(description = "子订单分摊金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer orderPartPrice; - - @Schema(description = "分摊后子订单实付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer orderDividePrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java deleted file mode 100644 index 704067ed0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 交易订单的分页项 Response VO") -@Data -public class TradeOrderPageItemRespVO extends TradeOrderBaseVO { - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED) - private MemberUserRespVO user; - - @Schema(description = "推广人信息") - private MemberUserRespVO brokerageUser; - - @Schema(description = "管理后台 - 交易订单的分页项的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - @Schema(description = "属性列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java deleted file mode 100644 index 074a1e544..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易订单的分页 Request VO") -@Data -public class TradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单号", example = "88888888") - private String no; - - @Schema(description = "用户编号", example = "1024") - private Long userId; - - @Schema(description = "用户昵称", example = "小王") - private String userNickname; - - @Schema(description = "用户手机号", example = "小王") - @Mobile - private String userMobile; - - @Schema(description = "配送方式", example = "1") - private Integer deliveryType; - - @Schema(description = "发货物流公司编号", example = "1") - private Long logisticsId; - - @Schema(description = "自提门店编号", example = "[1,2]") - private List pickUpStoreIds; - - @Schema(description = "自提核销码", example = "12345678") - private String pickUpVerifyCode; - - @Schema(description = "订单类型", example = "1") - private Integer type; - - @Schema(description = "订单状态", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @Schema(description = "支付渠道", example = "wx_lite") - private String payChannelCode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "订单来源", example = "10") - @InEnum(value = TerminalEnum.class, message = "订单来源 {value}") - private Integer terminal; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java deleted file mode 100644 index 4ef8da40e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单备注 Request VO") -@Data -public class TradeOrderRemarkReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "商家备注", example = "你猜一下") - @NotEmpty(message = "订单备注不能为空") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java deleted file mode 100644 index 184c8db83..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单统计 Response VO") -@Data -public class TradeOrderSummaryRespVO { - - @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderCount; - - @Schema(description = "订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderPayPrice; - - @Schema(description = "退款单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSaleCount; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSalePrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java deleted file mode 100644 index b66216b46..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单修改地址 Request VO") -@Data -public class TradeOrderUpdateAddressReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "z张三") - @NotEmpty(message = "收件人名称不能为空") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "19988188888") - @NotEmpty(message = "收件人手机不能为空") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7310") - @NotNull(message = "收件人地区编号不能为空") - private Integer receiverAreaId; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "昆明市五华区xxx小区xxx") - @NotEmpty(message = "收件人详细地址不能为空") - private String receiverDetailAddress; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java deleted file mode 100644 index d3e0afb7c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单改价 Request VO") -@Data -public class TradeOrderUpdatePriceReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "订单调价,单位:分。正数,加价;负数,减价", requiredMode = Schema.RequiredMode.REQUIRED, example = "-100") - @NotNull(message = "订单调价价格不能为空") - private Integer adjustPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java deleted file mode 100644 index 4874610aa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易售后") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AppAfterSaleController { - - @Resource - private AfterSaleService afterSaleService; - - @GetMapping(value = "/page") - @Operation(summary = "获得售后分页") - public CommonResult> getAfterSalePage(PageParam pageParam) { - return success(AfterSaleConvert.INSTANCE.convertPage02( - afterSaleService.getAfterSalePage(getLoginUserId(), pageParam))); - } - - @GetMapping(value = "/get") - @Operation(summary = "获得售后订单") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - public CommonResult getAfterSale(@RequestParam("id") Long id) { - return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id))); - } - - @PostMapping(value = "/create") - @Operation(summary = "申请售后") - public CommonResult createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) { - return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); - } - - @PutMapping(value = "/delivery") - @Operation(summary = "退回货物") - public CommonResult deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) { - afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO); - return success(true); - } - - @DeleteMapping(value = "/cancel") - @Operation(summary = "取消售后") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - public CommonResult cancelAfterSale(@RequestParam("id") Long id) { - afterSaleService.cancelAfterSale(getLoginUserId(), id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleLogController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleLogController.java deleted file mode 100644 index c54ed0c4e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleLogController.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log.AppAfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 售后日志") -@RestController -@RequestMapping("/trade/after-sale-log") -@Validated -@Slf4j -public class AppAfterSaleLogController { - - @Resource - private AfterSaleLogService afterSaleLogService; - - @GetMapping("/list") - @Operation(summary = "获得售后日志列表") - @Parameter(name = "afterSaleId", description = "售后编号", required = true, example = "1") - public CommonResult> getAfterSaleLogList( - @RequestParam("afterSaleId") Long afterSaleId) { - List logs = afterSaleLogService.getAfterSaleLogList(afterSaleId); - return success(BeanUtils.toBean(logs, AppAfterSaleLogRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java deleted file mode 100644 index 253db62a2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易售后创建 Request VO") -@Data -public class AppAfterSaleCreateReqVO { - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "售后方式不能为空") - @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于 0") - private Integer refundPrice; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @Schema(description = "补充描述", example = "商品质量不好") - private String applyDescription; - - @Schema(description = "补充凭证图片", example = "https://www.iocoder.cn/1.png, https://www.iocoder.cn/2.png") - private List applyPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java deleted file mode 100644 index 83b88d133..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 交易售后退回货物 Request VO") -@Data -public class AppAfterSaleDeliveryReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "退货物流公司编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "退货物流公司编号不能为空") - private Long logisticsId; - - @Schema(description = "退货物流单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SF123456789") - @NotNull(message = "退货物流单号不能为空") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java deleted file mode 100644 index 1da0595c7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 交易售后 Response VO") -@Data -public class AppAfterSaleRespVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "售后流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer way; - - @Schema(description = "售后类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String applyReason; - - @Schema(description = "补充描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String applyDescription; - - @Schema(description = "补充凭证图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List applyPicUrls; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - // ========== 交易订单相关 ========== - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderId; - - @Schema(description = "交易订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String orderNo; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - /** - * 属性数组 - */ - private List properties; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/01.jpg") - private String picUrl; - - @Schema(description = "退货商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - - @Schema(description = "退款金额,单位:分", example = "100") - private Integer refundPrice; - - @Schema(description = "退款时间") - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - - @Schema(description = "退货物流公司编号", example = "1") - private Long logisticsId; - - @Schema(description = "退货物流单号", example = "SF123456789") - private String logisticsNo; - - @Schema(description = "退货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收货备注") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java deleted file mode 100644 index 4d7fb66a4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - App 交易售后日志 Response VO") -@Data -public class AppAfterSaleLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20669") - private Long id; - - @Schema(description = "操作明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "维权完成,退款金额:¥37776.00") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java deleted file mode 100644 index 08acfdbca..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 基础包,放一些通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.app.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 750f16bf3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java deleted file mode 100644 index ac0c0ee6b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.sku; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SKU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSkuBaseRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "图片地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer stock; - - /** - * 属性数组 - */ - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java deleted file mode 100644 index a0e1bc670..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.spu; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SPU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSpuBaseRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品主图地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java deleted file mode 100644 index 212db07bb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-record") -@Validated -@Slf4j -public class AppBrokerageRecordController { - @Resource - private BrokerageRecordService brokerageRecordService; - - @GetMapping("/page") - @Operation(summary = "获得分销记录分页") - @PreAuthenticated - public CommonResult> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) { - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage( - BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); - return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class)); - } - - @GetMapping("/get-product-brokerage-price") - @Operation(summary = "获得商品的分销金额") - public CommonResult getProductBrokeragePrice(@RequestParam("spuId") Long spuId) { - return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java deleted file mode 100644 index 141ee68dd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-user") -@Validated -@Slf4j -public class AppBrokerageUserController { - - @Resource - private BrokerageUserService brokerageUserService; - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @Operation(summary = "获得个人分销信息") - @PreAuthenticated - public CommonResult getBrokerageUser() { - Optional user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId())); - // 返回数据 - AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() - .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false)) - .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0)) - .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0)); - return success(respVO); - } - - @PutMapping("/bind") - @Operation(summary = "绑定推广员") - @PreAuthenticated - public CommonResult bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) { - return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId())); - } - - @GetMapping("/get-summary") - @Operation(summary = "获得个人分销统计") - @PreAuthenticated - public CommonResult getBrokerageUserSummary() { - // 查询当前登录用户信息 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(getLoginUserId()); - // 统计用户昨日的佣金 - LocalDateTime yesterday = LocalDateTime.now().minusDays(1); - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); - Integer yesterdayPrice = brokerageRecordService.getSummaryPriceByUserId(brokerageUser.getId(), - BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime); - // 统计用户提现的佣金 - Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(brokerageUser.getId()), - BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream() - .findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0); - // 统计分销用户数量(一级) - Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1); - // 统计分销用户数量(二级) - Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2); - - // 拼接返回 - return success(BrokerageUserConvert.INSTANCE.convert(yesterdayPrice, withdrawPrice, firstBrokerageUserCount, secondBrokerageUserCount, brokerageUser)); - } - - @GetMapping("/rank-page-by-user-count") - @Operation(summary = "获得分销用户排行分页(基于用户量)") - @PreAuthenticated - public CommonResult> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) { - // 分页查询 - PageResult pageResult = brokerageUserService.getBrokerageUserRankPageByUserCount(pageReqVO); - // 拼接数据 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByUserCountRespVO::getId)); - return success(BrokerageUserConvert.INSTANCE.convertPage03(pageResult, userMap)); - } - - @GetMapping("/rank-page-by-price") - @Operation(summary = "获得分销用户排行分页(基于佣金)") - @PreAuthenticated - public CommonResult> getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) { - // 分页查询 - PageResult pageResult = brokerageRecordService.getBrokerageUserChildSummaryPageByPrice(pageReqVO); - // 拼接数据 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByPriceRespVO::getId)); - return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap)); - } - - @GetMapping("/child-summary-page") - @Operation(summary = "获得下级分销统计分页") - @PreAuthenticated - public CommonResult> getBrokerageUserChildSummaryPage( - AppBrokerageUserChildSummaryPageReqVO pageReqVO) { - PageResult pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId()); - return success(pageResult); - } - - @GetMapping("/get-rank-by-price") - @Operation(summary = "获得分销用户排行(基于佣金)") - @Parameter(name = "times", description = "时间段", required = true) - public CommonResult getRankByPrice( - @RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) { - return success(brokerageRecordService.getUserRankByPrice(getLoginUserId(), times)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java deleted file mode 100644 index b1ef5f890..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销提现") -@RestController -@RequestMapping("/trade/brokerage-withdraw") -@Validated -@Slf4j -public class AppBrokerageWithdrawController { - - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @GetMapping("/page") - @Operation(summary = "获得分销提现分页") - @PreAuthenticated - public CommonResult> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) { - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage( - BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); - return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult)); - } - - @PostMapping("/create") - @Operation(summary = "创建分销提现") - @PreAuthenticated - public CommonResult createBrokerageWithdraw(@RequestBody @Valid AppBrokerageWithdrawCreateReqVO createReqVO) { - return success(brokerageWithdrawService.createBrokerageWithdraw(getLoginUserId(), createReqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java deleted file mode 100644 index 6b2191d5f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品的分销金额 Response VO") -@Data -public class AppBrokerageProductPriceRespVO { - - @Schema(description = "是否开启", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Boolean enabled; - - @Schema(description = "分销最小金额,单位:分", example = "100") - private Integer brokerageMinPrice; - - @Schema(description = "分销最大金额,单位:分", example = "100") - private Integer brokerageMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java deleted file mode 100644 index 2100c2324..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "应用 App - 分销记录分页 Request VO") -@Data -public class AppBrokerageRecordPageReqVO extends PageParam { - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageRecordBizTypeEnum.class, message = "业务类型必须是 {value}") - private Integer bizType; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageRecordStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java deleted file mode 100644 index 993006e34..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 分销记录 Response VO") -@Data -public class AppBrokerageRecordRespVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private String bizId; - - @Schema(description = "分销标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "用户下单") - private String title; - - @Schema(description = "分销金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "完成时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime finishTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java deleted file mode 100644 index f2a14996a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "应用 App - 绑定推广员 Request VO") -@Data -public class AppBrokerageUserBindReqVO extends PageParam { - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java deleted file mode 100644 index 890500c62..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.SortingField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 下级分销统计分页 Request VO") -@Data -public class AppBrokerageUserChildSummaryPageReqVO extends PageParam { - - public static final String SORT_FIELD_USER_COUNT = "userCount"; - public static final String SORT_FIELD_ORDER_COUNT = "orderCount"; - public static final String SORT_FIELD_PRICE = "price"; - - @Schema(description = "用户昵称", example = "李") // 模糊匹配 - private String nickname; - - @Schema(description = "排序字段", example = "userCount") - private SortingField sortingField; - - @Schema(description = "下级的级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 1 - 直接下级;2 - 间接下级 - @NotNull(message = "下级的级别不能为空") - @Range(min = 1, max = 2, message = "下级的级别只能是 {min} 或者 {max}") - private Integer level; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java deleted file mode 100644 index 6bc4184e8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 下级分销统计 Response VO") -@Data -public class AppBrokerageUserChildSummaryRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "佣金金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokeragePrice; - - @Schema(description = "分销订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer brokerageOrderCount; - - @Schema(description = "分销用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer brokerageUserCount; - - @Schema(description = "绑定推广员的时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime brokerageTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java deleted file mode 100644 index 8a0c387c6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 个人分销统计 Response VO") -@Data -public class AppBrokerageUserMySummaryRespVO { - - @Schema(description = "昨天的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer yesterdayPrice; - - @Schema(description = "提现的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer withdrawPrice; - - @Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408") - private Integer brokeragePrice; - - @Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234") - private Integer frozenPrice; - - @Schema(description = "分销用户数量(一级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long firstBrokerageUserCount; - - @Schema(description = "分销用户数量(二级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long secondBrokerageUserCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java deleted file mode 100644 index 91345ea78..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销排行用户(基于用户量) Response VO") -@Data -public class AppBrokerageUserRankByPriceRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokeragePrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java deleted file mode 100644 index 1a6de8138..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销排行用户(基于用户量) Response VO") -@Data -public class AppBrokerageUserRankByUserCountRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "邀请用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokerageUserCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java deleted file mode 100644 index de1d61a7b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "应用 App - 分销用户排行 Request VO") -@Data -public class AppBrokerageUserRankPageReqVO extends PageParam { - - @Schema(description = "开始 + 结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java deleted file mode 100644 index f98da7eb6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销用户信息 Response VO") -@Data -public class AppBrokerageUserRespVO { - - @Schema(description = "是否有分销资格", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408") - private Integer brokeragePrice; - - @Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234") - private Integer frozenPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java deleted file mode 100644 index d49957d25..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Validator; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; - -@Schema(description = "用户 App - 分销提现创建 Request VO") -@Data -public class AppBrokerageWithdrawCreateReqVO { - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}") - private Integer type; - - @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @PositiveOrZero(message = "提现金额不能小于 0") - @NotNull(message = "提现金额不能为空") - private Integer price; - - // ========== 银行卡、微信、支付宝 提现相关字段 ========== - - @Schema(description = "提现账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456789") - @NotBlank(message = "提现账号不能为空", groups = {Bank.class, Wechat.class, Alipay.class}) - private String accountNo; - - // ========== 微信、支付宝 提现相关字段 ========== - - @Schema(description = "收款码的图片", example = "https://www.iocoder.cn/1.png") - @URL(message = "收款码的图片,必须是一个 URL") - private String accountQrCodeUrl; - - // ========== 银行卡 提现相关字段 ========== - - @Schema(description = "持卡人姓名", example = "张三") - @NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class}) - private String name; - @Schema(description = "提现银行", example = "1") - @NotNull(message = "提现银行不能为空", groups = {Bank.class}) - private Integer bankName; - @Schema(description = "开户地址", example = "海淀支行") - private String bankAddress; - - public interface Wallet { - } - - public interface Bank { - } - - public interface Wechat { - } - - public interface Alipay { - } - - public void validate(Validator validator) { - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(type)) { - ValidationUtils.validate(validator, this, Wallet.class); - } else if (BrokerageWithdrawTypeEnum.BANK.getType().equals(type)) { - ValidationUtils.validate(validator, this, Bank.class); - } else if (BrokerageWithdrawTypeEnum.WECHAT.getType().equals(type)) { - ValidationUtils.validate(validator, this, Wechat.class); - } else if (BrokerageWithdrawTypeEnum.ALIPAY.getType().equals(type)) { - ValidationUtils.validate(validator, this, Alipay.class); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java deleted file mode 100644 index b1757d43e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 分销提现分页 Request VO") -@Data -public class AppBrokerageWithdrawPageReqVO extends PageParam { - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "类型必须是 {value}") - private Integer type; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java deleted file mode 100644 index 4cfe930c8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 分销提现 Response VO") -@Data -public class AppBrokerageWithdrawRespVO { - - @Schema(description = "提现编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer status; - - @Schema(description = "提现状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "审核中") - private String statusName; - - @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer price; - - @Schema(description = "提现时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http deleted file mode 100644 index b341a4886..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http +++ /dev/null @@ -1,42 +0,0 @@ -### 请求 /trade/cart/add 接口 => 成功 -POST {{appApi}}/trade/cart/add -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "skuId": 1, - "count": 10, - "addStatus": true -} - -### 请求 /trade/cart/update 接口 => 成功 -PUT {{appApi}}/trade/cart/update -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "id": 35, - "count": 5 -} - -### 请求 /trade/cart/delete 接口 => 成功 -DELETE {{appApi}}/trade/cart/delete?ids=1 -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count 接口 => 成功 -GET {{appApi}}/trade/cart/get-count -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count-map 接口 => 成功 -GET {{appApi}}/trade/cart/get-count-map -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/list 接口 => 成功 -GET {{appApi}}/trade/cart/list -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java deleted file mode 100644 index 2c9d77b52..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.service.cart.CartService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 购物车") -@RestController -@RequestMapping("/trade/cart") -@RequiredArgsConstructor -@Validated -@Slf4j -public class AppCartController { - - @Resource - private CartService cartService; - - @PostMapping("/add") - @Operation(summary = "添加购物车商品") - @PreAuthenticated - public CommonResult addCart(@Valid @RequestBody AppCartAddReqVO addCountReqVO) { - return success(cartService.addCart(getLoginUserId(), addCountReqVO)); - } - - @PutMapping("/update-count") - @Operation(summary = "更新购物车商品数量") - @PreAuthenticated - public CommonResult updateCartCount(@Valid @RequestBody AppCartUpdateCountReqVO updateReqVO) { - cartService.updateCartCount(getLoginUserId(), updateReqVO); - return success(true); - } - - @PutMapping("/update-selected") - @Operation(summary = "更新购物车商品选中") - @PreAuthenticated - public CommonResult updateCartSelected(@Valid @RequestBody AppCartUpdateSelectedReqVO updateReqVO) { - cartService.updateCartSelected(getLoginUserId(), updateReqVO); - return success(true); - } - - @PutMapping("/reset") - @Operation(summary = "重置购物车商品") - @PreAuthenticated - public CommonResult resetCart(@Valid @RequestBody AppCartResetReqVO updateReqVO) { - cartService.resetCart(getLoginUserId(), updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除购物车商品") - @Parameter(name = "ids", description = "购物车商品编号", required = true, example = "1024,2048") - @PreAuthenticated - public CommonResult deleteCart(@RequestParam("ids") List ids) { - cartService.deleteCart(getLoginUserId(), ids); - return success(true); - } - - @GetMapping("get-count") - @Operation(summary = "查询用户在购物车中的商品数量") - @PreAuthenticated - public CommonResult getCartCount() { - return success(cartService.getCartCount(getLoginUserId())); - } - - @GetMapping("/list") - @Operation(summary = "查询用户的购物车列表") - @PreAuthenticated - public CommonResult getCartList() { - return success(cartService.getCartList(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java deleted file mode 100644 index 57eb0582e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车添加购物项 Request VO") -@Data -public class AppCartAddReqVO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "新增商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(value = 1, message = "商品数量必须大于等于 1") - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java deleted file mode 100644 index 1a28d96a6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物车明细 Response VO") -@Data -public class AppCartDetailRespVO { - - /** - * 商品分组数组 - */ - private List itemGroups; - - /** - * 费用 - */ - private Order order; - - @Schema(description = "商品分组") // 多个商品,参加同一个活动,从而形成分组 - @Data - public static class ItemGroup { - - /** - * 商品数组 - */ - private List items; - /** - * 营销活动,订单级别 - */ - private Promotion promotion; - - } - - @Schema(description = "商品 SKU") - @Data - public static class Sku extends AppProductSkuBaseRespVO { - - /** - * SPU 信息 - */ - private AppProductSkuBaseRespVO spu; - - // ========== 购物车相关的字段 ========== - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean selected; - - // ========== 价格相关的字段,对应 PriceCalculateRespDTO.OrderItem 的属性 ========== - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer originalPrice; - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalOriginalPrice; - @Schema(description = "商品级优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer totalPromotionPrice; - @Schema(description = "最终购买金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "400") - private Integer totalPresentPrice; - @Schema(description = "最终购买金额(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer presentPrice; - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "600") - private Integer totalPayPrice; - - // ========== 营销相关的字段 ========== - /** - * 营销活动,商品级别 - */ - private Promotion promotion; - - } - - @Schema(description = "订单") // 对应 PriceCalculateRespDTO.Order 类,用于费用(合计) - @Data - public static class Order { - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer skuOriginalPrice; - @Schema(description = "商品优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer skuPromotionPrice; - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer orderPromotionPrice; - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "400") - private Integer deliveryPrice; - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer payPrice; - - } - - @Schema(description = "营销活动") // 对应 PriceCalculateRespDTO.Promotion 类的属性 - @Data - public static class Promotion { - - @Schema(description = "营销编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // 营销活动的编号、优惠劵的编号 - private Long id; - @Schema(description = "营销名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx 活动") - private String name; - @Schema(description = "营销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - // ========== 匹配情况 ========== - @Schema(description = "是否满足优惠条件", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean meet; - @Schema(description = "满足条件的提示", requiredMode = Schema.RequiredMode.REQUIRED, example = "圣诞价:省 150.00 元") - private String meetTip; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java deleted file mode 100644 index cef09f78f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物列表 Response VO") -@Data -public class AppCartListRespVO { - - /** - * 有效的购物项数组 - */ - private List validList; - - /** - * 无效的购物项数组 - */ - private List invalidList; - - @Schema(description = "购物项") - @Data - public static class Cart { - - @Schema(description = "购物项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean selected; - - /** - * 商品 SPU - */ - private AppProductSpuBaseRespVO spu; - /** - * 商品 SKU - */ - private AppProductSkuBaseRespVO sku; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java deleted file mode 100644 index 1ef82c69b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车重置 Request VO") -@Data -public class AppCartResetReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java deleted file mode 100644 index 4341d501d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车更新数量 Request VO") -@Data -public class AppCartUpdateCountReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java deleted file mode 100644 index 3348d2d19..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.Collection; - -@Schema(description = "用户 App - 购物车更新是否选中 Request VO") -@Data -public class AppCartUpdateSelectedReqVO { - - @Schema(description = "编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024,2048") - @NotNull(message = "编号列表不能为空") - private Collection ids; - - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否选中不能为空") - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java deleted file mode 100644 index 5046c6512..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.config; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 交易配置") -@RestController -@RequestMapping("/trade/config") -@RequiredArgsConstructor -@Validated -@Slf4j -public class AppTradeConfigController { - - @Resource - private TradeConfigService tradeConfigService; - - @Value("${yudao.tencent-lbs-key}") - private String tencentLbsKey; - - @GetMapping("/get") - @Operation(summary = "获得交易配置") - public CommonResult getTradeConfig() { - TradeConfigDO config = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO()); - return success(TradeConfigConvert.INSTANCE.convert02(config).setTencentLbsKey(tencentLbsKey)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java deleted file mode 100644 index c80472c8b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易配置 Response VO") -@Data -public class AppTradeConfigRespVO { - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - - // ========== 配送相关 ========== - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否开启自提不能为空") - private Boolean deliveryPickUpEnabled; - - // ========== 售后相关 ========== - - @Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED) - private List afterSaleRefundReasons; - - @Schema(description = "售后的退货理由", requiredMode = Schema.RequiredMode.REQUIRED) - private List afterSaleReturnReasons; - - // ========== 分销相关 ========== - - @Schema(description = "分销海报地址数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List brokeragePosterUrls; - - @Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokerageFrozenDays; - - @Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer brokerageWithdrawMinPrice; - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java deleted file mode 100644 index 1d4e36f90..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config.AppDeliveryConfigRespVO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 配送配置") -@RestController -@RequestMapping("/trade/delivery/config") -@Validated -public class AppDeliverConfigController { - - // TODO @芋艿:这里后面干掉,合并到 AppTradeConfigController 中 - @GetMapping("/get") - @Operation(summary = "获得配送配置") - public CommonResult getDeliveryConfig() { - return success(new AppDeliveryConfigRespVO().setPickUpEnable(true).setTencentLbsKey("123456")); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java deleted file mode 100644 index 20cdef588..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 快递公司") -@RestController -@RequestMapping("/trade/delivery/express") -@Validated -public class AppDeliverExpressController { - - @Resource - private DeliveryExpressService deliveryExpressService; - - @GetMapping("/list") - @Operation(summary = "获得快递公司列表") - public CommonResult> getDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); - list.sort(Comparator.comparing(DeliveryExpressDO::getSort)); - return success(DeliveryExpressConvert.INSTANCE.convertList03(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java deleted file mode 100644 index fcc4993f1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 自提门店") -@RestController -@RequestMapping("/trade/delivery/pick-up-store") -@Validated -public class AppDeliverPickUpStoreController { - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - - @GetMapping("/list") - @Operation(summary = "获得自提门店列表") - @Parameters({ - @Parameter(name = "latitude", description = "精度", example = "110"), - @Parameter(name = "longitude", description = "纬度", example = "120") - }) - public CommonResult> getDeliveryPickUpStoreList( - @RequestParam(value = "latitude", required = false) Double latitude, - @RequestParam(value = "longitude", required = false) Double longitude) { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude)); - } - - @GetMapping("/get") - @Operation(summary = "获得自提门店") - @Parameter(name = "id", description = "门店编号") - public CommonResult getOrder(@RequestParam("id") Long id) { - DeliveryPickUpStoreDO store = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert03(store)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java deleted file mode 100644 index f3b50bf84..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -// TODO 芋艿:后续要实现下,配送配置;后续融合到 AppTradeConfigRespVO 中 -@Schema(description = "用户 App - 配送配置 Response VO") -@Data -public class AppDeliveryConfigRespVO { - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean pickUpEnable; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java deleted file mode 100644 index d01d90502..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 快递公司 Response VO") -@Data -public class AppDeliveryExpressRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java deleted file mode 100644 index 1ca25ade5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 自提门店 Response VO") -@Data -public class AppDeliveryPickUpStoreRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "门店 logo", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String logo; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - private Integer areaId; - - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - private String detailAddress; - - @Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88") - private Double latitude; - - @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99") - private Double longitude; - - @Schema(description = "距离,单位:千米", example = "100") // 只有在用户传递了经纬度时,才进行计算 - private Double distance; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http deleted file mode 100644 index 4a9441694..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http +++ /dev/null @@ -1,64 +0,0 @@ -### /trade-order/settlement 获得订单结算信息(基于商品) -GET {{appApi}}/trade/order/settlement?type=0&items[0].skuId=1&items[0].count=2&items[1].skuId=2&items[1].count=3&couponId=1 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### /trade-order/settlement 获得订单结算信息(基于购物车) -GET {{appApi}}/trade/order/settlement?type=0&items[0].cartId=50&couponId=1 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### /trade-order/create 创建订单(基于商品)【快递】 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "pointStatus": true, - "deliveryType": 1, - "addressId": 21, - "items": [ - { - "skuId": 1, - "count": 2 - } - ], - "remark": "我是备注" -} - -### /trade-order/create 创建订单(基于商品)【自提】 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "pointStatus": true, - "deliveryType": 2, - "pickUpStoreId": 1, - "items": [ - { - "skuId": 1, - "count": 2 - } - ], - "remark": "我是备注", - "receiverName": "土豆", - "receiverMobile": "15601691300" -} - -### 获得订单交易的分页 -GET {{appApi}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的详细 -GET {{appApi}}/trade/order/get-detail?id=21 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得交易订单的物流轨迹 -GET {{appApi}}/trade/order/get-express-track-list?id=70 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java deleted file mode 100644 index 762b238c7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ /dev/null @@ -1,182 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class AppTradeOrderController { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private AfterSaleService afterSaleService; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @GetMapping("/settlement") - @Operation(summary = "获得订单结算信息") - @PreAuthenticated - public CommonResult settlementOrder(@Valid AppTradeOrderSettlementReqVO settlementReqVO) { - return success(tradeOrderUpdateService.settlementOrder(getLoginUserId(), settlementReqVO)); - } - - @PostMapping("/create") - @Operation(summary = "创建订单") - @PreAuthenticated - public CommonResult createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) { - TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), createReqVO); - return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId())); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - public CommonResult updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult getOrder(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(getLoginUserId(), id); - if (order == null) { - return success(null); - } - - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(order.getId()); - // 查询物流公司 - DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ? - deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null; - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express)); - } - - @GetMapping("/get-express-track-list") - @Operation(summary = "获得交易订单的物流轨迹") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { - return success(TradeOrderConvert.INSTANCE.convertList02( - tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得交易订单分页") - public CommonResult> getOrderPage(AppTradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderQueryService.getOrderPage(getLoginUserId(), reqVO); - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得交易订单数量") - public CommonResult> getOrderCount() { - Map orderCount = Maps.newLinkedHashMapWithExpectedSize(5); - // 全部 - orderCount.put("allCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), null, null)); - // 待付款(未支付) - orderCount.put("unpaidCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.UNPAID.getStatus(), null)); - // 待发货 - orderCount.put("undeliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.UNDELIVERED.getStatus(), null)); - // 待收货 - orderCount.put("deliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.DELIVERED.getStatus(), null)); - // 待评价 - orderCount.put("uncommentedCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.COMPLETED.getStatus(), false)); - // 售后数量 - orderCount.put("afterSaleCount", afterSaleService.getApplyingAfterSaleCount(getLoginUserId())); - return success(orderCount); - } - - @PutMapping("/receive") - @Operation(summary = "确认交易订单收货") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult receiveOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.receiveOrderByMember(getLoginUserId(), id); - return success(true); - } - - @DeleteMapping("/cancel") - @Operation(summary = "取消交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult cancelOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.cancelOrderByMember(getLoginUserId(), id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult deleteOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.deleteOrder(getLoginUserId(), id); - return success(true); - } - - // ========== 订单项 ========== - - @GetMapping("/item/get") - @Operation(summary = "获得交易订单项") - @Parameter(name = "id", description = "交易订单项编号") - public CommonResult getOrderItem(@RequestParam("id") Long id) { - TradeOrderItemDO item = tradeOrderQueryService.getOrderItem(getLoginUserId(), id); - return success(TradeOrderConvert.INSTANCE.convert03(item)); - } - - @PostMapping("/item/create-comment") - @Operation(summary = "创建交易订单项的评价") - public CommonResult createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) { - return success(tradeOrderUpdateService.createOrderItemCommentByMember(getLoginUserId(), createReqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java deleted file mode 100644 index 2324c40bb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递查询的轨迹 Resp DTO - * - * @author jason - */ -@Schema(description = "用户 App - 快递查询的轨迹 Response VO") -@Data -public class AppOrderExpressTrackRespDTO { - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime time; - - @Schema(description = "快递状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "已签收") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java deleted file mode 100644 index 2f4503d02..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; - -@Schema(description = "用户 App - 交易订单创建 Request VO") -@Data -public class AppTradeOrderCreateReqVO extends AppTradeOrderSettlementReqVO { - - @Schema(description = "备注", example = "这个是我的订单哟") - private String remark; - - @AssertTrue(message = "配送方式不能为空") - @JsonIgnore - public boolean isDeliveryTypeNotNull() { - return getDeliveryType() != null; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java deleted file mode 100644 index ae3f83194..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 交易订单创建 Response VO") -@Data -public class AppTradeOrderCreateRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java deleted file mode 100644 index b91bbf1a6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 订单交易的明细 Response VO") -@Data -public class AppTradeOrderDetailRespVO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer type; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "付款时间") - private LocalDateTime payTime; - - @Schema(description = "付款超时时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime payExpireTime; - - @Schema(description = "支付渠道", example = "wx_lite_pay") - private String payChannelCode; - @Schema(description = "支付渠道名", example = "微信小程序支付") - private String payChannelName; - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalPrice; - - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer deliveryPrice; - - @Schema(description = "订单调价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer adjustPrice; - - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer deliveryType; - - @Schema(description = "发货物流公司编号", example = "10") - private Long logisticsId; - - @Schema(description = "发货物流名称", example = "顺丰快递") - private String logisticsName; - - @Schema(description = "发货物流单号", example = "1024") - private String logisticsNo; - - @Schema(description = "发货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer receiverAreaId; - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") - private String receiverDetailAddress; - - @Schema(description = "自提门店编号", example = "1088") - private Long pickUpStoreId; - - @Schema(description = "自提核销码", example = "40964096") - private String pickUpVerifyCode; - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", example = "0") - private Integer refundStatus; - - @Schema(description = "退款金额,单位:分", example = "100") - private Integer refundPrice; - - // ========== 营销基本信息 ========== - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "优惠劵减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer vipPrice; - - @Schema(description = "拼团记录编号", example = "100") - private Long combinationRecordId; - - /** - * 订单项数组 - */ - private List items; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java deleted file mode 100644 index ba7b8138c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 订单交易的分页项 Response VO") -@Data -public class AppTradeOrderPageItemRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer type; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "应付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer deliveryType; - - /** - * 订单项数组 - */ - private List items; - - // ========== 营销基本信息 ========== - - @Schema(description = "拼团记录编号", example = "100") - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java deleted file mode 100644 index c1e07c176..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "交易订单分页 Request VO") -@Data -public class AppTradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单状态", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @Schema(description = "是否评价", example = "true") - private Boolean commentStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java deleted file mode 100644 index e8ed038ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单结算 Request VO") -@Data -@Valid -public class AppTradeOrderSettlementReqVO { - - @Schema(description = "商品项数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "商品不能为空") - private List items; - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "是否使用积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否使用积分不能为空") - private Boolean pointStatus; - - // ========== 配送相关相关字段 ========== - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DeliveryTypeEnum.class, message = "配送方式不正确") - private Integer deliveryType; - - @Schema(description = "收件地址编号", example = "1") - private Long addressId; - - @Schema(description = "自提门店编号", example = "1088") - private Long pickUpStoreId; - @Schema(description = "收件人名称", example = "芋艿") // 选择门店自提时,该字段为联系人名 - private String receiverName; - @Schema(description = "收件人手机", example = "15601691300") // 选择门店自提时,该字段为联系人手机 - @Mobile(message = "收件人手机格式不正确") - private String receiverMobile; - - // ========== 秒杀活动相关字段 ========== - @Schema(description = "秒杀活动编号", example = "1024") - private Long seckillActivityId; - - // ========== 拼团活动相关字段 ========== - @Schema(description = "拼团活动编号", example = "1024") - private Long combinationActivityId; - - @Schema(description = "拼团团长编号", example = "2048") - private Long combinationHeadId; - - // ========== 砍价活动相关字段 ========== - @Schema(description = "砍价记录编号", example = "123") - private Long bargainRecordId; - - @AssertTrue(message = "活动商品每次只能购买一种规格") - @JsonIgnore - public boolean isValidActivityItems() { - // 校验是否是活动订单 - if (ObjUtil.isAllEmpty(seckillActivityId, combinationActivityId, combinationHeadId, bargainRecordId)) { - return true; - } - // 校验订单项是否超出 - return items.size() == 1; - } - - @Data - @Schema(description = "用户 App - 商品项") - @Valid - public static class Item { - - @Schema(description = "商品 SKU 编号", example = "2048") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "购买数量", example = "1") - @Min(value = 1, message = "购买数量最小值为 {value}") - private Integer count; - - @Schema(description = "购物车项的编号", example = "1024") - private Long cartId; - - @AssertTrue(message = "商品不正确") - @JsonIgnore - public boolean isValid() { - // 组合一:skuId + count 使用商品 SKU - if (skuId != null && count != null) { - return true; - } - // 组合二:cartId 使用购物车项 - return cartId != null; - } - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java deleted file mode 100644 index 0c851bf34..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单结算信息 Response VO") -@Data -public class AppTradeOrderSettlementRespVO { - - @Schema(description = "交易类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 对应 TradeOrderTypeEnum 枚举 - private Integer type; - - @Schema(description = "购物项数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "费用", requiredMode = Schema.RequiredMode.REQUIRED) - private Price price; - - @Schema(description = "收件地址", requiredMode = Schema.RequiredMode.REQUIRED) - private Address address; - - @Schema(description = "已使用的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer usedPoint; - - @Schema(description = "总积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer totalPoint; - - @Schema(description = "购物项") - @Data - public static class Item { - - // ========== SPU 信息 ========== - - @Schema(description = "品类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long categoryId; - @Schema(description = "SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "Apple iPhone 12") - private String spuName; - - // ========== SKU 信息 ========== - - @Schema(description = "SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer skuId; - @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "属性数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private List properties; - - // ========== 购物车信息 ========== - - @Schema(description = "购物车编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long cartId; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - } - - @Schema(description = "费用(合计)") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Price { - - @Schema(description = "商品原价(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer totalPrice; - - @Schema(description = "订单优惠(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") - private Integer discountPrice; - - @Schema(description = "运费金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer deliveryPrice; - - @Schema(description = "优惠劵减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer vipPrice; - - @Schema(description = "实际支付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "450") - private Integer payPrice; - - } - - @Schema(description = "地址信息") - @Data - public static class Address { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - private String mobile; - - @Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "地区编号不能为空") - private Long areaId; - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "望京悠乐汇 A 座") - private String detailAddress; - - @Schema(description = "是否默认收件地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean defaultStatus; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java deleted file mode 100644 index a6a8b9582..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo.item; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -@Schema(description = "用户 App - 商品评价创建 Request VO") -@Data -public class AppTradeOrderItemCommentCreateReqVO { - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否匿名不能为空") - private Boolean anonymous; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2312312") - @NotNull(message = "交易订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级 1-5 分不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级 1-5 分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿身上很漂亮诶(*^▽^*)") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java deleted file mode 100644 index 98d1820bc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo.item; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 订单交易项 Response VO") -@Data -public class AppTradeOrderItemRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - /** - * 属性数组 - */ - private List properties; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "应付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer payPrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @Schema(description = "售后编号", example = "1024") - private Long afterSaleId; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java deleted file mode 100644 index aa2f99f35..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.trade.controller; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java deleted file mode 100644 index fd759c625..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRespPageItemVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface AfterSaleConvert { - - AfterSaleConvert INSTANCE = Mappers.getMapper(AfterSaleConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "createTime", ignore = true), - @Mapping(target = "updateTime", ignore = true), - @Mapping(target = "creator", ignore = true), - @Mapping(target = "updater", ignore = true), - }) - AfterSaleDO convert(AppAfterSaleCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItem); - - @Mappings({ - @Mapping(source = "afterSale.orderId", target = "merchantOrderId"), - @Mapping(source = "afterSale.id", target = "merchantRefundId"), - @Mapping(source = "afterSale.applyReason", target = "reason"), - @Mapping(source = "afterSale.refundPrice", target = "price") - }) - PayRefundCreateReqDTO convert(String userIp, AfterSaleDO afterSale, - TradeOrderProperties orderProperties); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, - Map memberUsers) { - PageResult voPageResult = convertPage(pageResult); - // 处理会员 - voPageResult.getList().forEach(afterSale -> afterSale.setUser( - convert(memberUsers.get(afterSale.getUserId())))); - return voPageResult; - } - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - AppAfterSaleRespVO convert(AfterSaleDO bean); - - PageResult convertPage02(PageResult page); - - default AfterSaleDetailRespVO convert(AfterSaleDO afterSale, TradeOrderDO order, TradeOrderItemDO orderItem, - MemberUserRespDTO user, List logs) { - AfterSaleDetailRespVO respVO = convert02(afterSale); - // 处理用户信息 - respVO.setUser(convert(user)); - // 处理订单信息 - respVO.setOrder(convert(order)); - respVO.setOrderItem(convert02(orderItem)); - // 处理售后日志 - respVO.setLogs(convertList1(logs)); - return respVO; - } - - List convertList1(List list); - AfterSaleDetailRespVO convert02(AfterSaleDO bean); - AfterSaleDetailRespVO.OrderItem convert02(TradeOrderItemDO bean); - TradeOrderBaseVO convert(TradeOrderDO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java deleted file mode 100644 index e8960c4ac..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AfterSaleLogConvert { - - AfterSaleLogConvert INSTANCE = Mappers.getMapper(AfterSaleLogConvert.class); - - AfterSaleLogDO convert(AfterSaleLogCreateReqBO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java deleted file mode 100644 index 0f1fe6178..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.hutool.core.math.Money; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 佣金记录 Convert - * - * @author owen - */ -@Mapper -public interface BrokerageRecordConvert { - - BrokerageRecordConvert INSTANCE = Mappers.getMapper(BrokerageRecordConvert.class); - - BrokerageRecordRespVO convert(BrokerageRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default BrokerageRecordDO convert(BrokerageUserDO user, BrokerageRecordBizTypeEnum bizType, String bizId, - Integer brokerageFrozenDays, int brokeragePrice, LocalDateTime unfreezeTime, - String title, Long sourceUserId, Integer sourceUserLevel) { - brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); - // 不冻结时,佣金直接就是结算状态 - Integer status = brokerageFrozenDays > 0 - ? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus() - : BrokerageRecordStatusEnum.SETTLEMENT.getStatus(); - return new BrokerageRecordDO().setUserId(user.getId()) - .setBizType(bizType.getType()).setBizId(bizId) - .setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice()) - .setTitle(title) - .setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice)))) - .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) - .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); - } - - default PageResult convertPage(PageResult pageResult, Map userMap) { - PageResult result = convertPage(pageResult); - for (BrokerageRecordRespVO respVO : result.getList()) { - Optional.ofNullable(userMap.get(respVO.getUserId())).ifPresent(user -> - respVO.setUserNickname(user.getNickname()).setUserAvatar(user.getAvatar())); - Optional.ofNullable(userMap.get(respVO.getSourceUserId())).ifPresent(user -> - respVO.setSourceUserNickname(user.getNickname()).setSourceUserAvatar(user.getAvatar())); - } - return result; - } - - BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId); - - default PageResult convertPage03(PageResult pageResult, Map userMap) { - for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) { - copyTo(userMap.get(vo.getId()), vo); - } - return pageResult; - } - - void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByPriceRespVO to); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java deleted file mode 100644 index aa4ba348d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserMySummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 分销用户 Convert - * - * @author owen - */ -@Mapper -public interface BrokerageUserConvert { - - BrokerageUserConvert INSTANCE = Mappers.getMapper(BrokerageUserConvert.class); - - BrokerageUserRespVO convert(BrokerageUserDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page, Map userMap, Map brokerageUserCountMap, Map userOrderSummaryMap); - - default PageResult convertPage(PageResult pageResult, - Map userMap, - Map brokerageUserCountMap, - Map userOrderSummaryMap, - Map withdrawMap) { - PageResult result = convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap); - for (BrokerageUserRespVO userVO : result.getList()) { - // 用户信息 - copyTo(userMap.get(userVO.getId()), userVO); - // 推广用户数量 - userVO.setBrokerageUserCount(MapUtil.getInt(brokerageUserCountMap, userVO.getId(), 0)); - // 推广订单数量、推广订单金额 - Optional orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId())); - userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryRespBO::getCount).orElse(0)) - .setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryRespBO::getPrice).orElse(0)); - // 已提现次数、已提现金额 - Optional withdrawSummaryOptional = Optional.ofNullable(withdrawMap.get(userVO.getId())); - userVO.setWithdrawCount(withdrawSummaryOptional.map(BrokerageWithdrawSummaryRespBO::getCount).orElse(0)) - .setWithdrawPrice(withdrawSummaryOptional.map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0)); - } - return result; - } - - default BrokerageUserRespVO copyTo(MemberUserRespDTO source, BrokerageUserRespVO target) { - Optional.ofNullable(source).ifPresent( - user -> target.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - return target; - } - - default PageResult convertPage03(PageResult pageResult, - Map userMap) { - pageResult.getList().forEach(vo -> copyTo(userMap.get(vo.getId()), vo)); - return pageResult; - } - - void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to); - - default AppBrokerageUserMySummaryRespVO convert(Integer yesterdayPrice, Integer withdrawPrice, - Long firstBrokerageUserCount, Long secondBrokerageUserCount, - BrokerageUserDO brokerageUser) { - AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO() - .setYesterdayPrice(ObjUtil.defaultIfNull(yesterdayPrice, 0)) - .setWithdrawPrice(ObjUtil.defaultIfNull(withdrawPrice, 0)) - .setBrokeragePrice(0).setFrozenPrice(0) - .setFirstBrokerageUserCount(ObjUtil.defaultIfNull(firstBrokerageUserCount, 0L)) - .setSecondBrokerageUserCount(ObjUtil.defaultIfNull(secondBrokerageUserCount, 0L)); - // 设置 brokeragePrice、frozenPrice 字段 - Optional.ofNullable(brokerageUser) - .ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice())); - return respVO; - } - - default void copyTo(List list, Map userMap) { - for (AppBrokerageUserChildSummaryRespVO vo : list) { - Optional.ofNullable(userMap.get(vo.getId())).ifPresent(user -> - vo.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - } - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java deleted file mode 100644 index 4b818af25..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 佣金提现 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BrokerageWithdrawConvert { - - BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); - - BrokerageWithdrawDO convert(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId, Integer feePrice); - - BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, Map userMap) { - PageResult result = convertPage(pageResult); - for (BrokerageWithdrawRespVO vo : result.getList()) { - vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse(null)); - } - return result; - } - - PageResult convertPage02(PageResult pageResult); - - default PageResult convertPage03(PageResult pageResult) { - PageResult result = convertPage02(pageResult); - for (AppBrokerageWithdrawRespVO vo : result.getList()) { - vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus())); - } - return result; - } - - BrokerageWithdrawPageReqVO convert(AppBrokerageWithdrawPageReqVO pageReqVO, Long userId); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java deleted file mode 100644 index 83cd45954..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.cart; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppCartListRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface TradeCartConvert { - - TradeCartConvert INSTANCE = Mappers.getMapper(TradeCartConvert.class); - - default AppCartListRespVO convertList(List carts, - List spus, List skus) { - Map spuMap = convertMap(spus, ProductSpuRespDTO::getId); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - // 遍历,开始转换 - List validList = new ArrayList<>(carts.size()); - List invalidList = new ArrayList<>(); - carts.forEach(cart -> { - AppCartListRespVO.Cart cartVO = new AppCartListRespVO.Cart(); - cartVO.setId(cart.getId()).setCount(cart.getCount()).setSelected(cart.getSelected()); - ProductSpuRespDTO spu = spuMap.get(cart.getSpuId()); - ProductSkuRespDTO sku = skuMap.get(cart.getSkuId()); - cartVO.setSpu(convert(spu)).setSku(convert(sku)); - // 如果 SPU 不存在,或者下架,或者库存不足,说明是无效的 - if (spu == null - || !ProductSpuStatusEnum.isEnable(spu.getStatus()) - || spu.getStock() <= 0) { - cartVO.setSelected(false); // 强制设置成不可选中 - invalidList.add(cartVO); - } else { - // 虽然 SKU 可能也会不存在,但是可以通过购物车重新选择 - validList.add(cartVO); - } - }); - return new AppCartListRespVO().setValidList(validList).setInvalidList(invalidList); - } - AppProductSpuBaseRespVO convert(ProductSpuRespDTO spu); - AppProductSkuBaseRespVO convert(ProductSkuRespDTO sku); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java deleted file mode 100644 index 57da020c2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.config; - -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 交易中心配置 Convert - * - * @author owen - */ -@Mapper -public interface TradeConfigConvert { - - TradeConfigConvert INSTANCE = Mappers.getMapper(TradeConfigConvert.class); - - TradeConfigDO convert(TradeConfigSaveReqVO bean); - - TradeConfigRespVO convert(TradeConfigDO bean); - - AppTradeConfigRespVO convert02(TradeConfigDO tradeConfig); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java deleted file mode 100644 index 3910dcaa3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExcelVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DeliveryExpressConvert { - - DeliveryExpressConvert INSTANCE = Mappers.getMapper(DeliveryExpressConvert.class); - - DeliveryExpressDO convert(DeliveryExpressCreateReqVO bean); - - DeliveryExpressDO convert(DeliveryExpressUpdateReqVO bean); - - DeliveryExpressRespVO convert(DeliveryExpressDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - - List convertList1(List list); - - List convertList03(List list); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java deleted file mode 100644 index b917d874b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import com.google.common.collect.Maps; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; - -@Mapper -public interface DeliveryExpressTemplateConvert { - - DeliveryExpressTemplateConvert INSTANCE = Mappers.getMapper(DeliveryExpressTemplateConvert.class); - - // ========== Template ========== - - DeliveryExpressTemplateDO convert(DeliveryExpressTemplateCreateReqVO bean); - - DeliveryExpressTemplateDO convert(DeliveryExpressTemplateUpdateReqVO bean); - - DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean); - - DeliveryExpressTemplateDetailRespVO convert2(DeliveryExpressTemplateDO bean); - - List convertList(List list); - - List convertList1(List list); - - PageResult convertPage(PageResult page); - - default DeliveryExpressTemplateDetailRespVO convert(DeliveryExpressTemplateDO bean, - List chargeList, - List freeList) { - DeliveryExpressTemplateDetailRespVO respVO = convert2(bean); - respVO.setCharges(convertTemplateChargeList(chargeList)); - respVO.setFrees(convertTemplateFreeList(freeList)); - return respVO; - } - - // ========== Template Charge ========== - - DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, DeliveryExpressTemplateChargeBaseVO vo); - - DeliveryExpressTemplateRespBO.Charge convertTemplateCharge(DeliveryExpressTemplateChargeDO bean); - - default List convertTemplateChargeList(Long templateId, Integer chargeMode, List list) { - return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo)); - } - - // ========== Template Free ========== - - DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, DeliveryExpressTemplateFreeBaseVO vo); - - DeliveryExpressTemplateRespBO.Free convertTemplateFree(DeliveryExpressTemplateFreeDO bean); - - List convertTemplateChargeList(List list); - - List convertTemplateFreeList(List list); - - default List convertTemplateFreeList(Long templateId, List list) { - return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo)); - } - - default Map convertMap(Integer areaId, List templateList, - List chargeList, - List freeList) { - Map> templateIdChargeMap = convertMultiMap(chargeList, - DeliveryExpressTemplateChargeDO::getTemplateId); - Map> templateIdFreeMap = convertMultiMap(freeList, - DeliveryExpressTemplateFreeDO::getTemplateId); - // 组合运费模板配置 RespBO - Map result = Maps.newHashMapWithExpectedSize(templateList.size()); - templateList.forEach(template -> { - DeliveryExpressTemplateRespBO bo = new DeliveryExpressTemplateRespBO() - .setChargeMode(template.getChargeMode()) - .setCharge(convertTemplateCharge(findFirst(templateIdChargeMap.get(template.getId()), charge -> charge.getAreaIds().contains(areaId)))) - .setFree(convertTemplateFree(findFirst(templateIdFreeMap.get(template.getId()), free -> free.getAreaIds().contains(areaId)))); - result.put(template.getId(), bo); - }); - return result; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java deleted file mode 100644 index 1d5b360a5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreSimpleRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DeliveryPickUpStoreConvert { - - DeliveryPickUpStoreConvert INSTANCE = Mappers.getMapper(DeliveryPickUpStoreConvert.class); - - DeliveryPickUpStoreDO convert(DeliveryPickUpStoreCreateReqVO bean); - - DeliveryPickUpStoreDO convert(DeliveryPickUpStoreUpdateReqVO bean); - - DeliveryPickUpStoreRespVO convert(DeliveryPickUpStoreDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList1(List list); - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - DeliveryPickUpStoreSimpleRespVO convert02(DeliveryPickUpStoreDO bean); - - @Named("convertAreaIdToAreaName") - default String convertAreaIdToAreaName(Integer areaId) { - return AreaUtils.format(areaId); - } - - default List convertList(List list, - Double latitude, Double longitude) { - List voList = CollectionUtils.convertList(list, store -> { - AppDeliveryPickUpStoreRespVO storeVO = convert03(store); - if (latitude != null && longitude != null) { - storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude())); - } - return storeVO; - }); - return voList; - } - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java deleted file mode 100644 index 64f74c99f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ /dev/null @@ -1,288 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; - -@Mapper -public interface TradeOrderConvert { - - TradeOrderConvert INSTANCE = Mappers.getMapper(TradeOrderConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "userId", target = "userId"), - @Mapping(source = "createReqVO.couponId", target = "couponId"), - @Mapping(target = "remark", ignore = true), - @Mapping(source = "createReqVO.remark", target = "userRemark"), - @Mapping(source = "calculateRespBO.price.totalPrice", target = "totalPrice"), - @Mapping(source = "calculateRespBO.price.discountPrice", target = "discountPrice"), - @Mapping(source = "calculateRespBO.price.deliveryPrice", target = "deliveryPrice"), - @Mapping(source = "calculateRespBO.price.couponPrice", target = "couponPrice"), - @Mapping(source = "calculateRespBO.price.pointPrice", target = "pointPrice"), - @Mapping(source = "calculateRespBO.price.vipPrice", target = "vipPrice"), - @Mapping(source = "calculateRespBO.price.payPrice", target = "payPrice") - }) - TradeOrderDO convert(Long userId, AppTradeOrderCreateReqVO createReqVO, TradePriceCalculateRespBO calculateRespBO); - - TradeOrderRespDTO convert(TradeOrderDO orderDO); - - default List convertList(TradeOrderDO tradeOrderDO, TradePriceCalculateRespBO calculateRespBO) { - return CollectionUtils.convertList(calculateRespBO.getItems(), item -> { - TradeOrderItemDO orderItem = convert(item); - orderItem.setOrderId(tradeOrderDO.getId()); - orderItem.setUserId(tradeOrderDO.getUserId()); - orderItem.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - orderItem.setCommentStatus(false); - return orderItem; - }); - } - - TradeOrderItemDO convert(TradePriceCalculateRespBO.OrderItem item); - - default ProductSkuUpdateStockReqDTO convert(List list) { - List items = CollectionUtils.convertList(list, item -> - new ProductSkuUpdateStockReqDTO.Item().setId(item.getSkuId()).setIncrCount(item.getCount())); - return new ProductSkuUpdateStockReqDTO(items); - } - - default ProductSkuUpdateStockReqDTO convertNegative(List list) { - List items = CollectionUtils.convertList(list, item -> - new ProductSkuUpdateStockReqDTO.Item().setId(item.getSkuId()).setIncrCount(-item.getCount())); - return new ProductSkuUpdateStockReqDTO(items); - } - - default PayOrderCreateReqDTO convert(TradeOrderDO order, List orderItems, - TradeOrderProperties orderProperties) { - PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO() - .setAppId(orderProperties.getAppId()).setUserIp(order.getUserIp()); - // 商户相关字段 - createReqDTO.setMerchantOrderId(String.valueOf(order.getId())); - String subject = orderItems.get(0).getSpuName(); - subject = StrUtils.maxLength(subject, PayOrderCreateReqDTO.SUBJECT_MAX_LENGTH); // 避免超过 32 位 - createReqDTO.setSubject(subject); - createReqDTO.setBody(subject); // TODO 芋艿:临时写死 - // 订单相关字段 - createReqDTO.setPrice(order.getPayPrice()).setExpireTime(addTime(orderProperties.getPayExpireTime())); - return createReqDTO; - } - - default PageResult convertPage(PageResult pageResult, - List orderItems, - Map memberUserMap) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - TradeOrderPageItemRespVO orderVO = convert(order, xOrderItems); - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 增加用户信息 - orderVO.setUser(convertUser(memberUserMap.get(orderVO.getUserId()))); - // 增加推广人信息 - orderVO.setBrokerageUser(convertUser(memberUserMap.get(orderVO.getBrokerageUserId()))); - return orderVO; - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - - MemberUserRespVO convertUser(MemberUserRespDTO memberUserRespDTO); - - TradeOrderPageItemRespVO convert(TradeOrderDO order, List items); - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - default TradeOrderDetailRespVO convert(TradeOrderDO order, List orderItems, - List orderLogs, - MemberUserRespDTO user, MemberUserRespDTO brokerageUser) { - TradeOrderDetailRespVO orderVO = convert2(order, orderItems); - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 处理用户信息 - orderVO.setUser(convert(user)); - orderVO.setBrokerageUser(convert(brokerageUser)); - // 处理日志 - orderVO.setLogs(convertList03(orderLogs)); - return orderVO; - } - List convertList03(List orderLogs); - - TradeOrderDetailRespVO convert2(TradeOrderDO order, List items); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - default PageResult convertPage02(PageResult pageResult, - List orderItems) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - return convert02(order, xOrderItems); - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - - AppTradeOrderPageItemRespVO convert02(TradeOrderDO order, List items); - - AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean); - - default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List orderItems, - TradeOrderProperties tradeOrderProperties, - DeliveryExpressDO express) { - AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); - orderVO.setPayExpireTime(addTime(tradeOrderProperties.getPayExpireTime())); - if (StrUtil.isNotEmpty(order.getPayChannelCode())) { - orderVO.setPayChannelName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CHANNEL_CODE, order.getPayChannelCode())); - } - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - if (express != null) { - orderVO.setLogisticsId(express.getId()).setLogisticsName(express.getName()); - } - return orderVO; - } - - AppTradeOrderDetailRespVO convert3(TradeOrderDO order, List items); - - AppTradeOrderItemRespVO convert03(TradeOrderItemDO bean); - - @Mappings({ - @Mapping(target = "skuId", source = "tradeOrderItemDO.skuId"), - @Mapping(target = "orderId", source = "tradeOrderItemDO.orderId"), - @Mapping(target = "orderItemId", source = "tradeOrderItemDO.id"), - @Mapping(target = "descriptionScores", source = "createReqVO.descriptionScores"), - @Mapping(target = "benefitScores", source = "createReqVO.benefitScores"), - @Mapping(target = "content", source = "createReqVO.content"), - @Mapping(target = "picUrls", source = "createReqVO.picUrls"), - @Mapping(target = "anonymous", source = "createReqVO.anonymous"), - @Mapping(target = "userId", source = "tradeOrderItemDO.userId") - }) - ProductCommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItemDO); - - TradePriceCalculateReqBO convert(AppTradeOrderSettlementReqVO settlementReqVO); - - default TradePriceCalculateReqBO convert(Long userId, AppTradeOrderSettlementReqVO settlementReqVO, - List cartList) { - TradePriceCalculateReqBO reqBO = new TradePriceCalculateReqBO().setUserId(userId) - .setItems(new ArrayList<>(settlementReqVO.getItems().size())) - .setCouponId(settlementReqVO.getCouponId()).setPointStatus(settlementReqVO.getPointStatus()) - // 物流信息 - .setDeliveryType(settlementReqVO.getDeliveryType()).setAddressId(settlementReqVO.getAddressId()) - .setPickUpStoreId(settlementReqVO.getPickUpStoreId()) - // 各种活动 - .setSeckillActivityId(settlementReqVO.getSeckillActivityId()) - .setBargainRecordId(settlementReqVO.getBargainRecordId()) - .setCombinationActivityId(settlementReqVO.getCombinationActivityId()) - .setCombinationHeadId(settlementReqVO.getCombinationHeadId()); - // 商品项的构建 - Map cartMap = convertMap(cartList, CartDO::getId); - for (AppTradeOrderSettlementReqVO.Item item : settlementReqVO.getItems()) { - // 情况一:skuId + count - if (item.getSkuId() != null) { - reqBO.getItems().add(new TradePriceCalculateReqBO.Item().setSkuId(item.getSkuId()).setCount(item.getCount()) - .setSelected(true)); // true 的原因,下单一定选中 - continue; - } - // 情况二:cartId - CartDO cart = cartMap.get(item.getCartId()); - if (cart == null) { - continue; - } - reqBO.getItems().add(new TradePriceCalculateReqBO.Item().setSkuId(cart.getSkuId()).setCount(cart.getCount()) - .setCartId(item.getCartId()).setSelected(true)); // true 的原因,下单一定选中 - } - return reqBO; - } - - default AppTradeOrderSettlementRespVO convert(TradePriceCalculateRespBO calculate, MemberAddressRespDTO address) { - AppTradeOrderSettlementRespVO respVO = convert0(calculate, address); - if (address != null) { - respVO.getAddress().setAreaName(AreaUtils.format(address.getAreaId())); - } - return respVO; - } - - AppTradeOrderSettlementRespVO convert0(TradePriceCalculateRespBO calculate, MemberAddressRespDTO address); - - List convertList02(List list); - - TradeOrderDO convert(TradeOrderUpdateAddressReqVO reqVO); - - TradeOrderDO convert(TradeOrderUpdatePriceReqVO reqVO); - - TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); - - default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { - BrokerageAddReqBO bo = new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId()) - .setBasePrice(item.getPayPrice() * item.getCount()) - .setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName())) - .setFirstFixedPrice(0).setSecondFixedPrice(0); - if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - bo.setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice()); - } - return bo; - } - - @Named("convertList04") - List convertList04(List list); - - @Mappings({ - @Mapping(target = "activityId", source = "order.combinationActivityId"), - @Mapping(target = "spuId", source = "item.spuId"), - @Mapping(target = "skuId", source = "item.skuId"), - @Mapping(target = "count", source = "item.count"), - @Mapping(target = "orderId", source = "order.id"), - @Mapping(target = "userId", source = "order.userId"), - @Mapping(target = "headId", source = "order.combinationHeadId"), - @Mapping(target = "combinationPrice", source = "item.payPrice"), - }) - CombinationRecordCreateReqDTO convert(TradeOrderDO order, TradeOrderItemDO item); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java deleted file mode 100644 index 763f05822..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface TradeOrderLogConvert { - - TradeOrderLogConvert INSTANCE = Mappers.getMapper(TradeOrderLogConvert.class); - - TradeOrderLogDO convert(TradeOrderLogCreateReqBO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java deleted file mode 100644 index 214592b62..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java +++ /dev/null @@ -1,201 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 售后订单,用于处理 {@link TradeOrderDO} 交易订单的退款退货流程 - * - * @author 芋道源码 - */ -@TableName(value = "trade_after_sale", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class AfterSaleDO extends BaseDO { - - /** - * 售后编号,主键自增 - */ - private Long id; - /** - * 售后单号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 退款状态 - * - * 枚举 {@link AfterSaleStatusEnum} - */ - private Integer status; - /** - * 售后方式 - * - * 枚举 {@link AfterSaleWayEnum} - */ - private Integer way; - /** - * 售后类型 - * - * 枚举 {@link AfterSaleTypeEnum} - */ - private Integer type; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 申请原因 - * - * type = 退款,对应 trade_after_sale_refund_reason 类型 - * type = 退货退款,对应 trade_after_sale_refund_and_return_reason 类型 - */ - private String applyReason; - /** - * 补充描述 - */ - private String applyDescription; - /** - * 补充凭证图片 - * - * 数组,以逗号分隔 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List applyPicUrls; - - // ========== 交易订单相关 ========== - /** - * 交易订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 订单流水号 - * - * 冗余 {@link TradeOrderDO#getNo()} - */ - private String orderNo; - /** - * 交易订单项编号 - * - * 关联 {@link TradeOrderItemDO#getId()} - */ - private Long orderItemId; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 字段 - * 冗余 {@link TradeOrderItemDO#getSpuId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 ProductSkuDO 的 name 字段 - * 冗余 {@link TradeOrderItemDO#getSpuName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 {@link TradeOrderItemDO#getProperties()} - */ - @TableField(typeHandler = TradeOrderItemDO.PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - * - * 冗余 {@link TradeOrderItemDO#getPicUrl()} - */ - private String picUrl; - /** - * 退货商品数量 - */ - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批时间 - */ - private LocalDateTime auditTime; - /** - * 审批人 - * - * 关联 AdminUserDO 的 id 编号 - */ - private Long auditUserId; - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - /** - * 退款金额,单位:分。 - */ - private Integer refundPrice; - /** - * 支付退款编号 - * - * 对接 pay-module-biz 支付服务的退款订单编号,即 PayRefundDO 的 id 编号 - */ - private Long payRefundId; - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - /** - * 退货物流公司编号 - * - * 关联 LogisticsDO 的 id 编号 - */ - private Long logisticsId; - /** - * 退货物流单号 - */ - private String logisticsNo; - /** - * 退货时间 - */ - private LocalDateTime deliveryTime; - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收货备注 - * - * 注意,只有拒绝收货才会填写 - */ - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java deleted file mode 100644 index 2820f23e1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 交易售后日志 DO - * - * @author 芋道源码 - */ -@TableName("trade_after_sale_log") -@KeySequence("trade_after_sale_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class AfterSaleLogDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 1:AdminUserDO 的 id 字段 - * 关联 2:MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 售后编号 - * - * 关联 {@link AfterSaleDO#getId()} - */ - private Long afterSaleId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - private Integer afterStatus; - - /** - * 操作类型 - * - * 枚举 {@link AfterSaleOperateTypeEnum} - */ - private Integer operateType; - /** - * 操作明细 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java deleted file mode 100644 index c819d723b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 佣金记录 DO - * - * @author owen - */ -@TableName("trade_brokerage_record") -@KeySequence("trade_brokerage_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Integer id; - /** - * 用户编号 - *

- * 关联 MemberUserDO.id - */ - private Long userId; - /** - * 业务编号 - */ - private String bizId; - /** - * 业务类型 - *

- * 枚举 {@link BrokerageRecordBizTypeEnum} - */ - private Integer bizType; - - /** - * 标题 - */ - private String title; - /** - * 说明 - */ - private String description; - - /** - * 金额 - */ - private Integer price; - /** - * 当前总佣金 - */ - private Integer totalPrice; - - /** - * 状态 - *

- * 枚举 {@link BrokerageRecordStatusEnum} - */ - private Integer status; - - /** - * 冻结时间(天) - */ - private Integer frozenDays; - /** - * 解冻时间 - */ - private LocalDateTime unfreezeTime; - - /** - * 来源用户等级 - *

- * 被推广用户和 {@link #userId} 的推广层级关系 - */ - private Integer sourceUserLevel; - /** - * 来源用户编号 - *

- * 关联 MemberUserDO.id 字段,被推广用户的编号 - */ - private Long sourceUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java deleted file mode 100644 index 8d73858ec..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 分销用户 DO - * - * @author owen - */ -@TableName("trade_brokerage_user") -@KeySequence("trade_brokerage_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageUserDO extends BaseDO { - - /** - * 用户编号 - *

- * 对应 MemberUserDO 的 id 字段 - */ - @TableId - private Long id; - - /** - * 推广员编号 - *

- * 关联 MemberUserDO 的 id 字段 - */ - private Long bindUserId; - /** - * 推广员绑定时间 - */ - private LocalDateTime bindUserTime; - - /** - * 是否有分销资格 - */ - private Boolean brokerageEnabled; - /** - * 成为分销员时间 - */ - private LocalDateTime brokerageTime; - - /** - * 可用佣金 - */ - private Integer brokeragePrice; - /** - * 冻结佣金 - */ - private Integer frozenPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java deleted file mode 100644 index f31c23800..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 佣金提现 DO - * - * @author 芋道源码 - */ -@TableName("trade_brokerage_withdraw") -@KeySequence("trade_brokerage_withdraw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageWithdrawDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - - /** - * 提现金额,单位:分 - */ - private Integer price; - /** - * 提现手续费,单位:分 - */ - private Integer feePrice; - /** - * 当前总佣金,单位:分 - */ - private Integer totalPrice; - /** - * 提现类型 - *

- * 枚举 {@link BrokerageWithdrawTypeEnum} - */ - private Integer type; - - /** - * 真实姓名 - */ - private String name; - /** - * 账号 - */ - private String accountNo; - /** - * 银行名称 - */ - private String bankName; - /** - * 开户地址 - */ - private String bankAddress; - /** - * 收款码 - */ - private String accountQrCodeUrl; - /** - * 状态 - *

- * 枚举 {@link BrokerageWithdrawStatusEnum} - */ - private Integer status; - /** - * 审核驳回原因 - */ - private String auditReason; - /** - * 审核时间 - */ - private LocalDateTime auditTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java deleted file mode 100644 index d8bf14088..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.cart; - -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; - -/** - * 购物车的商品信息 DO - * - * 每个商品,对应一条记录,通过 {@link #spuId} 和 {@link #skuId} 关联 - * - * @author 芋道源码 - */ -@TableName("trade_cart") -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class CartDO extends BaseDO { - - // ========= 基础字段 BEGIN ========= - - /** - * 编号,唯一自增 - */ - private Long id; - - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - - // ========= 商品信息 ========= - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 商品购买数量 - */ - private Integer count; - /** - * 是否选中 - */ - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java deleted file mode 100644 index 5d7116b9d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.config; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 交易中心配置 DO - * - * @author owen - */ -@TableName(value = "trade_config", autoResultMap = true) -@KeySequence("trade_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeConfigDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - - // ========== 售后相关 ========== - - /** - * 售后的退款理由 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List afterSaleRefundReasons; - /** - * 售后的退货理由 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List afterSaleReturnReasons; - - // ========== 配送相关 ========== - - /** - * 是否启用全场包邮 - */ - private Boolean deliveryExpressFreeEnabled; - /** - * 全场包邮的最小金额,单位:分 - */ - private Integer deliveryExpressFreePrice; - - /** - * 是否开启自提 - */ - private Boolean deliveryPickUpEnabled; - - // ========== 分销相关 ========== - - /** - * 是否启用分佣 - */ - private Boolean brokerageEnabled; - /** - * 分佣模式 - *

- * 枚举 {@link BrokerageEnabledConditionEnum 对应的类} - */ - private Integer brokerageEnabledCondition; - /** - * 分销关系绑定模式 - *

- * 枚举 {@link BrokerageBindModeEnum 对应的类} - */ - private Integer brokerageBindMode; - /** - * 分销海报图地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List brokeragePosterUrls; - /** - * 一级返佣比例 - */ - private Integer brokerageFirstPercent; - /** - * 二级返佣比例 - */ - private Integer brokerageSecondPercent; - /** - * 用户提现最低金额 - */ - private Integer brokerageWithdrawMinPrice; - /** - * 用户提现手续费百分比 - */ - private Integer brokerageWithdrawFeePercent; - /** - * 佣金冻结时间(天) - */ - private Integer brokerageFrozenDays; - /** - * 提现方式 - *

- * 枚举 {@link BrokerageWithdrawTypeEnum 对应的类} - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java deleted file mode 100644 index 265066d83..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 快递公司 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express") -@KeySequence("trade_delivery_express_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 快递公司 code - */ - private String code; - - /** - * 快递公司名称 - */ - private String name; - - /** - * 快递公司 logo - */ - private String logo; - - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:c 和结算相关的字段,后续在看 - // partnerId 是否需要月结账号 - // partnerKey 是否需要月结密码 - // net 是否需要取件网店 - // account 账号 - // password 网点名称 - // isShow 是否显示 -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java deleted file mode 100644 index c3bb30e9a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -/** - * 快递运费模板计费配置 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express_template_charge", autoResultMap = true) -@KeySequence("trade_delivery_express_template_charge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateChargeDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 配送模板编号 - * - * 关联 {@link DeliveryExpressTemplateDO#getId()} - */ - private Long templateId; - - /** - * 配送区域编号列表 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List areaIds; - - /** - * 配送计费方式 - * - * 冗余 {@link DeliveryExpressTemplateDO#getChargeMode()} - */ - private Integer chargeMode; - - /** - * 首件数量(件数,重量,或体积) - */ - private Double startCount; - /** - * 起步价,单位:分 - */ - private Integer startPrice; - - /** - * 续件数量(件, 重量,或体积) - */ - private Double extraCount; - /** - * 额外价,单位:分 - */ - private Integer extraPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java deleted file mode 100644 index b6d6db3b7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 快递运费模板 DO - * - * @author jason - */ -@TableName("trade_delivery_express_template") -@KeySequence("trade_delivery_express_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 模板名称 - */ - private String name; - - /** - * 配送计费方式 - * - * 枚举 {@link DeliveryExpressChargeModeEnum} - */ - private Integer chargeMode; - - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java deleted file mode 100644 index 07eef1be2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -/** - * 快递运费模板包邮配置 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express_template_free", autoResultMap = true) -@KeySequence("trade_delivery_express_template_free_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateFreeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 配送模板编号 - * - * 关联 {@link DeliveryExpressTemplateDO#getId()} - */ - private Long templateId; - - - /** - * 配送区域编号列表 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List areaIds; - - /** - * 包邮金额,单位:分 - * - * 订单总金额 > 包邮金额时,才免运费 - */ - private Integer freePrice; - - /** - * 包邮件数 - * - * 订单总件数 > 包邮件数时,才免运费 - */ - private Integer freeCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java deleted file mode 100644 index 21ff99374..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalTime; - -/** - * 自提门店 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store") -@KeySequence("trade_delivery_pick_up_store_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 门店名称 - */ - private String name; - - /** - * 门店简介 - */ - private String introduction; - - /** - * 门店手机 - */ - private String phone; - - /** - * 区域编号 - */ - private Integer areaId; - - /** - * 门店详细地址 - */ - private String detailAddress; - - /** - * 门店 logo - */ - private String logo; - - /** - * 营业开始时间 - */ - private LocalTime openingTime; - - /** - * 营业结束时间 - */ - private LocalTime closingTime; - - /** - * 纬度 - */ - private Double latitude; - /** - * 经度 - */ - private Double longitude; - - /** - * 门店状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java deleted file mode 100644 index 4c03a8e5d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -// TODO @芋艿:后续再详细 review 一轮 -// TODO @芋艿:可能改成 DeliveryPickUpStoreUserDO -/** - * 自提门店店员 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store_staff") -@KeySequence("trade_delivery_pick_up_store_staff_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreStaffDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long storeId; - - /** - * 管理员用户id - * - * 关联 {AdminUserDO#getId()} - */ - private Long adminUserId; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java deleted file mode 100644 index b127004aa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java +++ /dev/null @@ -1,333 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易订单 DO - * - * @author 芋道源码 - */ -@TableName("trade_order") -@KeySequence("trade_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderDO extends BaseDO { - - /** - * 发货物流公司编号 - 空(无需发货) - */ - public static final Long LOGISTICS_ID_NULL = 0L; - - // ========== 订单基本信息 ========== - /** - * 订单编号,主键自增 - */ - private Long id; - /** - * 订单流水号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - /** - * 订单来源 - * - * 枚举 {@link TerminalEnum} - */ - private Integer terminal; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户 IP - */ - private String userIp; - /** - * 用户备注 - */ - private String userRemark; - /** - * 订单状态 - * - * 枚举 {@link TradeOrderStatusEnum} - */ - private Integer status; - /** - * 购买的商品数量 - */ - private Integer productCount; - /** - * 订单完成时间 - */ - private LocalDateTime finishTime; - /** - * 订单取消时间 - */ - private LocalDateTime cancelTime; - /** - * 取消类型 - * - * 枚举 {@link TradeOrderCancelTypeEnum} - */ - private Integer cancelType; - /** - * 商家备注 - */ - private String remark; - /** - * 是否评价 - * - * true - 已评价 - * false - 未评价 - */ - private Boolean commentStatus; - - /** - * 推广人编号 - * - * 关联 {@link BrokerageUserDO#getId()} 字段,即 {@link MemberUserRespDTO#getId()} 字段 - */ - private Long brokerageUserId; - - // ========== 价格 + 支付基本信息 ========== - - // 价格文档 - 淘宝:https://open.taobao.com/docV3.htm?docId=108471&docType=1 - // 价格文档 - 京东到家:https://openo2o.jddj.com/api/getApiDetail/182/4d1494c5e7ac4679bfdaaed950c5bc7f.htm - // 价格文档 - 有赞:https://doc.youzanyun.com/detail/API/0/906 - - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 是否已支付 - * - * true - 已经支付过 - * false - 没有支付过 - */ - private Boolean payStatus; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - /** - * 商品原价,单位:分 - * - * totalPrice = {@link TradeOrderItemDO#getPrice()} * {@link TradeOrderItemDO#getCount()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer totalPrice; - /** - * 优惠金额,单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价,单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #totalPrice} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * + {@link #adjustPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - /** - * 配送方式 - * - * 枚举 {@link DeliveryTypeEnum} - */ - private Integer deliveryType; - /** - * 发货物流公司编号 - * - * 如果无需发货,则 logisticsId 设置为 0。原因是,不想再添加额外字段 - * - * 关联 {@link DeliveryExpressDO#getId()} - */ - private Long logisticsId; - /** - * 发货物流单号 - * - * 如果无需发货,则 logisticsNo 设置 ""。原因是,不想再添加额外字段 - */ - private String logisticsNo; - /** - * 发货时间 - */ - private LocalDateTime deliveryTime; - - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收件人名称 - */ - private String receiverName; - /** - * 收件人手机 - */ - private String receiverMobile; - /** - * 收件人地区编号 - */ - private Integer receiverAreaId; - /** - * 收件人详细地址 - */ - private String receiverDetailAddress; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long pickUpStoreId; - /** - * 自提核销码 - */ - private String pickUpVerifyCode; - - // ========== 售后基本信息 ========== - /** - * 售后状态 - * - * 枚举 {@link TradeOrderRefundStatusEnum} - */ - private Integer refundStatus; - /** - * 退款金额,单位:分 - * - * 注意,退款并不会影响 {@link #payPrice} 实际支付金额 - * 也就说,一个订单最终产生多少金额的收入 = payPrice - refundPrice - */ - private Integer refundPrice; - - // ========== 营销基本信息 ========== - /** - * 优惠劵编号 - */ - private Long couponId; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 使用的积分 - */ - private Integer usePoint; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 赠送的积分 - */ - private Integer givePoint; - /** - * 退还的使用的积分 - */ - private Integer refundPoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - - /** - * 秒杀活动编号 - * - * 关联 SeckillActivityDO 的 id 字段 - */ - private Long seckillActivityId; - - /** - * 砍价活动编号 - * - * 关联 BargainActivityDO 的 id 字段 - */ - private Long bargainActivityId; - /** - * 砍价记录编号 - * - * 关联 BargainRecordDO 的 id 字段 - */ - private Long bargainRecordId; - - /** - * 拼团活动编号 - * - * 关联 CombinationActivityDO 的 id 字段 - */ - private Long combinationActivityId; - /** - * 拼团团长编号 - * - * 关联 CombinationRecordDO 的 headId 字段 - */ - private Long combinationHeadId; - /** - * 拼团记录编号 - * - * 关联 CombinationRecordDO 的 id 字段 - */ - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java deleted file mode 100644 index 675067713..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * 交易订单项 DO - * - * @author 芋道源码 - */ -@TableName(value = "trade_order_item", autoResultMap = true) -@Data -@Accessors(chain = true) -@EqualsAndHashCode(callSuper = true) -public class TradeOrderItemDO extends BaseDO { - - // ========== 订单项基本信息 ========== - /** - * 编号 - */ - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 购物车项编号 - * - * 关联 {@link CartDO#getId()} - */ - private Long cartId; - - // ========== 商品基本信息; 冗余较多字段,减少关联查询 ========== - /** - * 商品 SPU 编号 - * - * 关联 ProductSkuDO 的 spuId 编号 - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 冗余 ProductSkuDO 的 spuName 名称 - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 ProductSkuDO 的 properties 字段 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - */ - private String picUrl; - /** - * 购买数量 - */ - private Integer count; - /** - * 是否评价 - * - * true - 已评价 - * false - 未评价 - */ - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer price; - /** - * 优惠金额(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额(总),单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价(总),单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #price} * {@link #count} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * + {@link #adjustPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 营销基本信息 ========== - - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 使用的积分 - * - * 目的:用于后续取消或者售后订单时,需要归还赠送 - */ - private Integer usePoint; - /** - * 赠送的积分 - * - * 目的:用于后续取消或者售后订单时,需要扣减赠送 - */ - private Integer givePoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - - // ========== 售后基本信息 ========== - - /** - * 售后单编号 - * - * 关联 {@link AfterSaleDO#getId()} 字段 - */ - private Long afterSaleId; - /** - * 售后状态 - * - * 枚举 {@link TradeOrderItemAfterSaleStatusEnum} - */ - private Integer afterSaleStatus; - - /** - * 商品属性 - */ - @Data - public static class Property implements Serializable { - - /** - * 属性编号 - * - * 关联 ProductPropertyDO 的 id 编号 - */ - private Long propertyId; - /** - * 属性名字 - * - * 关联 ProductPropertyDO 的 name 字段 - */ - private String propertyName; - - /** - * 属性值编号 - * - * 关联 ProductPropertyValueDO 的 id 编号 - */ - private Long valueId; - /** - * 属性值名字 - * - * 关联 ProductPropertyValueDO 的 name 字段 - */ - private String valueName; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java deleted file mode 100644 index 36022c16e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 订单日志 DO - * - * @author 陈賝 - */ -@TableName("trade_order_log") -@KeySequence("trade_order_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderLogDO extends BaseDO { - - /** - * 用户类型 - 系统 - * - * 例如说:Job 自动过期订单时,通过系统自动操作 - */ - public static final Integer USER_TYPE_SYSTEM = 0; - /** - * 用户编号 - 系统 - */ - public static final Long USER_ID_SYSTEM = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 AdminUserDO 的 id 字段、或者 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 订单号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - private Integer afterStatus; - - /** - * 操作类型 - * - * {@link TradeOrderOperateTypeEnum} - */ - private Integer operateType; - /** - * 订单日志信息 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java deleted file mode 100644 index c0ec91c6d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface AfterSaleLogMapper extends BaseMapperX { - - default List selectListByAfterSaleId(Long afterSaleId) { - return selectList(AfterSaleLogDO::getAfterSaleId, afterSaleId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java deleted file mode 100644 index 68a09a82a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; - -@Mapper -public interface AfterSaleMapper extends BaseMapperX { - - default PageResult selectPage(AfterSalePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(AfterSaleDO::getNo, reqVO.getNo()) - .eqIfPresent(AfterSaleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(AfterSaleDO::getType, reqVO.getType()) - .eqIfPresent(AfterSaleDO::getWay, reqVO.getWay()) - .likeIfPresent(AfterSaleDO::getOrderNo, reqVO.getOrderNo()) - .likeIfPresent(AfterSaleDO::getSpuName, reqVO.getSpuName()) - .betweenIfPresent(AfterSaleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(AfterSaleDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eqIfPresent(AfterSaleDO::getUserId, userId) - .orderByDesc(AfterSaleDO::getId)); - } - - default int updateByIdAndStatus(Long id, Integer status, AfterSaleDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(AfterSaleDO::getId, id).eq(AfterSaleDO::getStatus, status)); - } - - default AfterSaleDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(AfterSaleDO::getId, id, - AfterSaleDO::getUserId, userId); - } - - default Long selectCountByUserIdAndStatus(Long userId, Collection statuses) { - return selectCount(new LambdaQueryWrapperX() - .eq(AfterSaleDO::getUserId, userId) - .in(AfterSaleDO::getStatus, statuses)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java deleted file mode 100644 index 388f927ad..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.yulichang.toolkit.MPJWrappers; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 佣金记录 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageRecordMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(BrokerageRecordDO::getStatus, reqVO.getStatus()) - .eqIfPresent(BrokerageRecordDO::getSourceUserLevel, reqVO.getSourceUserLevel()) - .betweenIfPresent(BrokerageRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BrokerageRecordDO::getId)); - } - - default List selectListByStatusAndUnfreezeTimeLt(Integer status, LocalDateTime unfreezeTime) { - return selectList(new LambdaQueryWrapper() - .eq(BrokerageRecordDO::getStatus, status) - .lt(BrokerageRecordDO::getUnfreezeTime, unfreezeTime)); - } - - default int updateByIdAndStatus(Integer id, Integer status, BrokerageRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(BrokerageRecordDO::getId, id) - .eq(BrokerageRecordDO::getStatus, status)); - } - - default BrokerageRecordDO selectByBizTypeAndBizIdAndUserId(Integer bizType, String bizId, Long userId) { - return selectOne(BrokerageRecordDO::getBizType, bizType, - BrokerageRecordDO::getBizId, bizId, - BrokerageRecordDO::getUserId, userId); - } - - default List selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(Collection userIds, - Integer bizType, - Integer status) { - List> list = selectMaps(MPJWrappers.lambdaJoin(BrokerageRecordDO.class) - .select(BrokerageRecordDO::getUserId) - .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryRespBO::getCount) - .selectSum(BrokerageRecordDO::getPrice) - .in(BrokerageRecordDO::getUserId, userIds) - .eq(BrokerageRecordDO::getBizId, bizType) - .eq(BrokerageRecordDO::getStatus, status) - .groupBy(BrokerageRecordDO::getUserId)); // 按照 userId 聚合 - return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class); - // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW -// return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class) -// .select(BrokerageRecordDO::getUserId) -// .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryBO::getCount) -// .selectSum(BrokerageRecordDO::getPrice) -// .in(BrokerageRecordDO::getUserId, userIds) -// .eq(BrokerageRecordDO::getBizId, bizType) -// .eq(BrokerageRecordDO::getStatus, status) -// .groupBy(BrokerageRecordDO::getUserId)); - } - - @Select("SELECT SUM(price) FROM trade_brokerage_record " + - "WHERE user_id = #{userId} AND biz_type = #{bizType} AND status = #{status} " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE") - Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO @芋艿:收敛掉 @Select 注解操作,统一成 MyBatis-Plus 的方式,或者 xml - @Select("SELECT user_id AS id, SUM(price) AS brokeragePrice FROM trade_brokerage_record " + - "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY user_id " + - "ORDER BY brokeragePrice DESC") - IPage selectSummaryPricePageGroupByUserId(IPage page, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - @Select("SELECT COUNT(1) FROM trade_brokerage_record " + - "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY user_id HAVING SUM(price) > #{brokeragePrice}") - Integer selectCountByPriceGt(@Param("brokeragePrice") Integer brokeragePrice, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java deleted file mode 100644 index 6c24cac90..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortingField; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 分销用户 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageUserMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageUserPageReqVO reqVO, List ids) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(BrokerageUserDO::getId, ids) - .eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) - .betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime()) - .betweenIfPresent(BrokerageUserDO::getBindUserTime, reqVO.getBindUserTime()) - .orderByDesc(BrokerageUserDO::getId)); - } - - /** - * 更新用户可用佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加佣金(正数) - */ - default void updatePriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" brokerage_price = brokerage_price + " + incrCount) - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户可用佣金(减少) - * 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失 - * - * @param id 用户编号 - * @param incrCount 增加佣金(负数) - * @return 更新行数 - */ - default int updatePriceDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号 - .eq(BrokerageUserDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加冻结佣金(正数) - */ - default void updateFrozenPriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount) - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(减少) - * 注意:理论上冻结佣金可能已经解冻,这时会扣出负数,确保平台不会造成损失 - * - * @param id 用户编号 - * @param incrCount 减少冻结佣金(负数) - */ - default void updateFrozenPriceDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount) // 负数,所以使用 + 号 - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(减少), 更新用户佣金(增加) - * - * @param id 用户编号 - * @param incrCount 减少冻结佣金(负数) - * @return 更新条数 - */ - default int updateFrozenPriceDecrAndPriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount + // 负数,所以使用 + 号 - ", brokerage_price = brokerage_price + " + -incrCount) // 负数,所以使用 - 号 - .eq(BrokerageUserDO::getId, id) - .ge(BrokerageUserDO::getFrozenPrice, -incrCount); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - default void updateBindUserIdAndBindUserTimeToNull(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BrokerageUserDO::getId, id) - .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null)); - } - - default void updateEnabledFalseAndBrokerageTimeToNull(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BrokerageUserDO::getId, id) - .set(BrokerageUserDO::getBrokerageEnabled, false).set(BrokerageUserDO::getBrokerageTime, null)); - } - - @Select("SELECT bind_user_id AS id, COUNT(1) AS brokerageUserCount FROM trade_brokerage_user " + - "WHERE bind_user_id IS NOT NULL AND deleted = FALSE " + - "AND bind_user_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY bind_user_id " + - "ORDER BY brokerageUserCount DESC") - IPage selectCountPageGroupByBindUserId(Page page, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 下级分销统计(分页) - * - * @param bizType 业务类型 - * @param status 状态 - * @param ids 用户编号列表 - * @param sortingField 排序字段 - * @return 下级分销统计分页列表 - */ - IPage selectSummaryPageByUserId(Page page, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("ids") Collection ids, - @Param("sortingField") SortingField sortingField); - - /** - * 获得被 bindUserIds 推广的用户编号数组 - * - * @param bindUserIds 推广员编号数组 - * @return 用户编号数组 - */ - default List selectIdListByBindUserIdIn(Collection bindUserIds) { - return Convert.toList(Long.class, - selectObjs(new LambdaQueryWrapperX() - .select(Collections.singletonList(BrokerageUserDO::getId)) // 只查询 id 字段,加速返回速度 - .in(BrokerageUserDO::getBindUserId, bindUserIds))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java deleted file mode 100644 index 9e2cf68ad..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.github.yulichang.wrapper.MPJLambdaWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 佣金提现 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BrokerageWithdrawMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageWithdrawPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId()) - .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType()) - .likeIfPresent(BrokerageWithdrawDO::getName, reqVO.getName()) - .eqIfPresent(BrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo()) - .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName()) - .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId)); - } - - default int updateByIdAndStatus(Integer id, Integer status, BrokerageWithdrawDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(BrokerageWithdrawDO::getId, id) - .eq(BrokerageWithdrawDO::getStatus, status)); - } - - default List selectCountAndSumPriceByUserIdAndStatus(Collection userIds, Integer status) { - List> list = selectMaps(new MPJLambdaWrapper() - .select(BrokerageWithdrawDO::getUserId) - .selectCount(BrokerageWithdrawDO::getId, BrokerageWithdrawSummaryRespBO::getCount) - .selectSum(BrokerageWithdrawDO::getPrice) - .in(BrokerageWithdrawDO::getUserId, userIds) - .eq(BrokerageWithdrawDO::getStatus, status) - .groupBy(BrokerageWithdrawDO::getUserId)); - return BeanUtil.copyToList(list, BrokerageWithdrawSummaryRespBO.class); - // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW -// return selectJoinList(UserWithdrawSummaryBO.class, new MPJLambdaWrapper() -// .select(BrokerageWithdrawDO::getUserId) -// .selectCount(BrokerageWithdrawDO::getId, UserWithdrawSummaryBO::getCount) -// .selectSum(BrokerageWithdrawDO::getPrice) -// .in(BrokerageWithdrawDO::getUserId, userIds) -// .eq(BrokerageWithdrawDO::getStatus, status) -// .groupBy(BrokerageWithdrawDO::getUserId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java deleted file mode 100644 index b67265156..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface CartMapper extends BaseMapperX { - - default CartDO selectByUserIdAndSkuId(Long userId, Long skuId) { - return selectOne(CartDO::getUserId, userId, - CartDO::getSkuId, skuId); - } - - default Integer selectSumByUserId(Long userId) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .eq("user_id", userId) - .eq("selected", true)); // 只计算选中的 - // 获得数量 - return CollUtil.getFirst(result) != null ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - - default CartDO selectById(Long id, Long userId) { - return selectOne(CartDO::getId, id, - CartDO::getUserId, userId); - } - - default List selectListByIds(Collection ids, Long userId) { - return selectList(new LambdaQueryWrapper() - .in(CartDO::getId, ids) - .eq(CartDO::getUserId, userId)); - } - - default List selectListByUserId(Long userId) { - return selectList(new LambdaQueryWrapper() - .eq(CartDO::getUserId, userId)); - } - - default List selectListByUserId(Long userId, Set ids) { - return selectList(new LambdaQueryWrapper() - .eq(CartDO::getUserId, userId) - .in(CartDO::getId, ids)); - } - - default void updateByIds(Collection ids, Long userId, CartDO updateObj) { - update(updateObj, new LambdaQueryWrapper() - .in(CartDO::getId, ids) - .eq(CartDO::getUserId, userId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java deleted file mode 100644 index 18a3f4df7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.config; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 交易中心配置 Mapper - * - * @author owen - */ -@Mapper -public interface TradeConfigMapper extends BaseMapperX { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java deleted file mode 100644 index 59e7cf02e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DeliveryExpressMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryExpressPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode()) - .likeIfPresent(DeliveryExpressDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressDO::getSort)); - } - - default List selectList(DeliveryExpressExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode()) - .likeIfPresent(DeliveryExpressDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressDO::getSort)); - } - - default DeliveryExpressDO selectByCode(String code) { - return selectOne(new LambdaQueryWrapper() - .eq(DeliveryExpressDO::getCode, code)); - } - - default List selectListByStatus(Integer status) { - return selectList(DeliveryExpressDO::getStatus, status); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java deleted file mode 100644 index a2403f019..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX { - - default List selectListByTemplateId(Long templateId){ - return selectList(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); - } - - default int deleteByTemplateId(Long templateId){ - return delete(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); - } - - default List selectByTemplateIds(Collection templateIds) { - return selectList(DeliveryExpressTemplateChargeDO::getTemplateId, templateIds); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java deleted file mode 100644 index b64a3c979..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX { - - default List selectListByTemplateId(Long templateId) { - return selectList(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); - } - - default int deleteByTemplateId(Long templateId) { - return delete(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); - } - - default List selectListByTemplateIds(Collection templateIds) { - return selectList(DeliveryExpressTemplateFreeDO::getTemplateId, templateIds); - } -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java deleted file mode 100644 index c93346894..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryExpressTemplateMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryExpressTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode()) - .betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressTemplateDO::getSort)); - } - - default DeliveryExpressTemplateDO selectByName(String name) { - return selectOne(DeliveryExpressTemplateDO::getName,name); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java deleted file mode 100644 index b26b1c015..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DeliveryPickUpStoreMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryPickUpStorePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryPickUpStoreDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryPickUpStoreDO::getPhone, reqVO.getPhone()) - .eqIfPresent(DeliveryPickUpStoreDO::getAreaId, reqVO.getAreaId()) - .eqIfPresent(DeliveryPickUpStoreDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryPickUpStoreDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DeliveryPickUpStoreDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(DeliveryPickUpStoreDO::getStatus, status); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java deleted file mode 100644 index 06cc14e26..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryPickUpStoreStaffMapper extends BaseMapperX { - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java deleted file mode 100644 index b701b7f87..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface TradeOrderItemMapper extends BaseMapperX { - - default int updateAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, - Long afterSaleId) { - return update(new TradeOrderItemDO().setAfterSaleStatus(newAfterSaleStatus).setAfterSaleId(afterSaleId), - new LambdaUpdateWrapper<>(new TradeOrderItemDO().setId(id).setAfterSaleStatus(oldAfterSaleStatus))); - } - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderId(Collection orderIds) { - return selectList(TradeOrderItemDO::getOrderId, orderIds); - } - - default TradeOrderItemDO selectByIdAndUserId(Long orderItemId, Long loginUserId) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderItemDO::getId, orderItemId) - .eq(TradeOrderItemDO::getUserId, loginUserId)); - } - - default List selectListByOrderIdAndCommentStatus(Long orderId, Boolean commentStatus) { - return selectList(new LambdaQueryWrapperX() - .eq(TradeOrderItemDO::getOrderId, orderId) - .eq(TradeOrderItemDO::getCommentStatus, commentStatus)); - } - - default int selectProductSumByOrderId(@Param("orderIds") Set orderIds) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .in("order_id", orderIds)); // 只计算选中的 - // 获得数量 - return CollUtil.getFirst(result) != null ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java deleted file mode 100644 index 7788030ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface TradeOrderLogMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderLogDO::getOrderId, orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java deleted file mode 100644 index 21fc038ba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface TradeOrderMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, Integer status, TradeOrderDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(TradeOrderDO::getId, id).eq(TradeOrderDO::getStatus, status)); - } - - default TradeOrderDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(TradeOrderDO::getId, id, TradeOrderDO::getUserId, userId); - } - - default PageResult selectPage(TradeOrderPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .eqIfPresent(TradeOrderDO::getDeliveryType, reqVO.getDeliveryType()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) - .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) - .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) - .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(TradeOrderDO::getId)); - } - - // TODO @疯狂:如果用 map 返回,要不这里直接用 TradeOrderSummaryRespVO 返回?也算合理,就当 sql 查询出这么个玩意~~ - default List> selectOrderSummaryGroupByRefundStatus(TradeOrderPageReqVO reqVO, Set userIds) { - return selectMaps(new MPJLambdaWrapperX() - .selectAs(TradeOrderDO::getRefundStatus, TradeOrderDO::getRefundStatus) // 售后状态 - .selectCount(TradeOrderDO::getId, "count") // 售后状态对应的数量 - .selectSum(TradeOrderDO::getPayPrice, "price") // 售后状态对应的支付金额 - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .eqIfPresent(TradeOrderDO::getDeliveryType, reqVO.getDeliveryType()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) - .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) - .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) - .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) - .groupBy(TradeOrderDO::getRefundStatus)); // 按售后状态分组 - } - - default PageResult selectPage(AppTradeOrderPageReqVO reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getCommentStatus, reqVO.getCommentStatus()) - .orderByDesc(TradeOrderDO::getId)); // TODO 芋艿:未来不同的 status,不同的排序 - } - - default Long selectCountByUserIdAndStatus(Long userId, Integer status, Boolean commentStatus) { - return selectCount(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, status) - .eqIfPresent(TradeOrderDO::getCommentStatus, commentStatus)); - } - - default TradeOrderDO selectOrderByIdAndUserId(Long orderId, Long loginUserId) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getId, orderId) - .eq(TradeOrderDO::getUserId, loginUserId)); - } - - default List selectListByStatusAndCreateTimeLt(Integer status, LocalDateTime createTime) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getCreateTime, createTime)); - } - - default List selectListByStatusAndDeliveryTimeLt(Integer status, LocalDateTime deliveryTime) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getDeliveryTime, deliveryTime)); - } - - default List selectListByStatusAndReceiveTimeLt(Integer status, LocalDateTime receive, - Boolean commentStatus) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getReceiveTime, receive) - .eq(TradeOrderDO::getCommentStatus, commentStatus)); - } - - default List selectListByUserIdAndSeckillActivityId(Long userId, Long seckillActivityId) { - return selectList(new LambdaUpdateWrapper<>(TradeOrderDO.class) - .eq(TradeOrderDO::getUserId, userId) - .eq(TradeOrderDO::getSeckillActivityId, seckillActivityId)); - } - - default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { - return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); - } - - default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long combinationActivityId, Integer status) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eq(TradeOrderDO::getStatus, status) - .eq(TradeOrderDO::getCombinationActivityId, combinationActivityId) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java deleted file mode 100644 index 37e0ba7d6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位 - */ -package cn.iocoder.yudao.module.trade.dal.mysql; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java deleted file mode 100644 index eff48e51c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.redis; - -/** - * 交易 Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 交易序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String TRADE_NO = "trade_no:"; - - /** - * 交易序号的缓存 - * - * KEY 格式:express_track:{code-logisticsNo-receiverMobile} - * VALUE 数据格式 String, 物流信息集合 - */ - String EXPRESS_TRACK = "express_track"; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java deleted file mode 100644 index 8b76f195e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class TradeNoRedisDAO { - - public static final String TRADE_ORDER_NO_PREFIX = "o"; - - public static final String AFTER_SALE_NO_PREFIX = "r"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号 - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN); - String key = RedisKeyConstants.TRADE_NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofMinutes(1L)); - return noPrefix + no; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java deleted file mode 100644 index 1c2613789..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.config; - -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -// TODO @chenchen:改成 aftersale 好点哈; -/** - * trade 模块的 afterSaleLog 组件的 Configuration - * - * @author 陈賝 - * @since 2023/6/18 11:09 - */ -@Configuration(proxyBeanMethods = false) -public class AfterSaleLogConfiguration { - - @Bean - public AfterSaleLogAspect afterSaleLogAspect() { - return new AfterSaleLogAspect(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java deleted file mode 100644 index bc41bf986..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations; - -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; - -import java.lang.annotation.*; - -/** - * 售后日志的注解 - * - * 写在方法上时,会自动记录售后日志 - * - * @author 陈賝 - * @since 2023/6/8 17:04 - * @see AfterSaleLogAspect - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface AfterSaleLog { - - /** - * 操作类型 - */ - AfterSaleOperateTypeEnum operateType(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java deleted file mode 100644 index f7b3f7e90..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.aop; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations.AfterSaleLog; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; - -import javax.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static java.util.Collections.emptyMap; - -/** - * 售后订单的操作记录的 AOP 切面 - * - * @author 陈賝 - * @since 2023/6/13 13:54 - */ -@Slf4j -@Aspect -public class AfterSaleLogAspect { - - /** - * 用户编号 - * - * 目前的使用场景:支付回调时,需要强制设置下用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 订单编号 - */ - private static final ThreadLocal AFTER_SALE_ID = new ThreadLocal<>(); - /** - * 操作前的状态 - */ - private static final ThreadLocal BEFORE_STATUS = new ThreadLocal<>(); - /** - * 操作后的状态 - */ - private static final ThreadLocal AFTER_STATUS = new ThreadLocal<>(); - /** - * 拓展参数 Map,用于格式化操作内容 - */ - private static final ThreadLocal> EXTS = new ThreadLocal<>(); - - @Resource - private AfterSaleLogService afterSaleLogService; - - @AfterReturning(pointcut = "@annotation(afterSaleLog)") - public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog) { - try { - // 1.1 操作用户 - Integer userType = getUserType(); - Long userId = getUserId(); - // 1.2 售后信息 - Long afterSaleId = AFTER_SALE_ID.get(); - if (afterSaleId == null) { // 如果未设置,只有注解,说明不需要记录日志 - return; - } - Integer beforeStatus = BEFORE_STATUS.get(); - Integer afterStatus = AFTER_STATUS.get(); - Map exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); - String content = StrUtil.format(afterSaleLog.operateType().getContent(), exts); - - // 2. 记录日志 - AfterSaleLogCreateReqBO createBO = new AfterSaleLogCreateReqBO() - .setUserId(userId).setUserType(userType) - .setAfterSaleId(afterSaleId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setOperateType(afterSaleLog.operateType().getType()).setContent(content); - afterSaleLogService.createAfterSaleLog(createBO); - } catch (Exception exception) { - log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); - } finally { - clear(); - } - } - - /** - * 获得用户类型 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 - * - * @return 用户类型 - */ - private static Integer getUserType() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); - } - - /** - * 获得用户编号 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 - * - * @return 用户类型 - */ - private static Long getUserId() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); - } - - public static void setAfterSale(Long id, Integer beforeStatus, Integer afterStatus, Map exts) { - AFTER_SALE_ID.set(id); - BEFORE_STATUS.set(beforeStatus); - AFTER_STATUS.set(afterStatus); - EXTS.set(exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - AFTER_SALE_ID.remove(); - BEFORE_STATUS.remove(); - AFTER_STATUS.remove(); - EXTS.remove(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java deleted file mode 100644 index 3f9fc5d74..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.utils; - - -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; - -import java.util.Map; - -/** - * 操作日志工具类 - * 目前主要的作用,是提供给业务代码,记录操作明细和拓展字段 - * - * @author 芋道源码 - */ -public class AfterSaleLogUtils { - - public static void setAfterSaleInfo(Long id, Integer beforeStatus, Integer afterStatus) { - setAfterSaleInfo(id, beforeStatus, afterStatus, null); - } - - public static void setAfterSaleInfo(Long id, Integer beforeStatus, Integer afterStatus, - Map exts) { - AfterSaleLogAspect.setAfterSale(id, beforeStatus, afterStatus, exts); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java deleted file mode 100644 index 2799c3f1c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.config; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.ExpressClientFactoryImpl; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; - -/** - * 快递客户端端配置类: - * - * 1. 快递客户端工厂 {@link ExpressClientFactory} - * 2. 默认的快递客户端实现 {@link ExpressClient} - * - * @author jason - */ -@Configuration(proxyBeanMethods = false) -public class ExpressClientConfig { - - @Bean - public ExpressClientFactory expressClientFactory(TradeExpressProperties tradeExpressProperties, - RestTemplate restTemplate) { - return new ExpressClientFactoryImpl(tradeExpressProperties, restTemplate); - } - - @Bean - public ExpressClient defaultExpressClient(ExpressClientFactory expressClientFactory) { - return expressClientFactory.getDefaultExpressClient(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java deleted file mode 100644 index 73efef90a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.config; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; - -// TODO @芋艿:未来要不要放数据库中?考虑 saas 多租户时,不同租户使用不同的配置? -/** - * 交易运费快递的配置项 - * - * @author jason - */ -@Component -@ConfigurationProperties(prefix = "yudao.trade.express") -@Data -@Validated -public class TradeExpressProperties { - - /** - * 快递客户端 - * - * 默认不提供,需要提醒用户配置一个快递服务商。 - */ - private ExpressClientEnum client = ExpressClientEnum.NOT_PROVIDE; - - /** - * 快递鸟配置 - */ - @Valid - private KdNiaoConfig kdNiao; - /** - * 快递 100 配置 - */ - @Valid - private Kd100Config kd100; - - /** - * 快递鸟配置项目 - */ - @Data - public static class KdNiaoConfig { - - /** - * 快递鸟用户 ID - */ - @NotEmpty(message = "快递鸟用户 ID 配置项不能为空") - private String businessId; - /** - * 快递鸟 API Key - */ - @NotEmpty(message = "快递鸟 Api Key 配置项不能为空") - private String apiKey; - - } - - /** - * 快递 100 配置项 - */ - @Data - public static class Kd100Config { - - /** - * 快递 100 授权码 - */ - @NotEmpty(message = "快递 100 授权码配置项不能为空") - private String customer; - /** - * 快递 100 授权 key - */ - @NotEmpty(message = "快递 100 授权 Key 配置项不能为空") - private String key; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java deleted file mode 100644 index 76b361c3f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.List; - -/** - * 快递客户端接口 - * - * @author jason - */ -public interface ExpressClient { - - /** - * 快递实时查询 - * - * @param reqDTO 查询请求参数 - */ - // TODO @jason:返回字段可以参考 https://doc.youzanyun.com/detail/API/0/5 响应的 data - List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java deleted file mode 100644 index 5e457092f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; - -/** - * 快递客户端工厂接口:用于创建和缓存快递客户端 - * - * @author jason - */ -public interface ExpressClientFactory { - - /** - * 获取默认的快递客户端 - */ - ExpressClient getDefaultExpressClient(); - - /** - * 通过枚举获取快递客户端,如果不存在,就创建一个对应快递客户端 - * - * @param clientEnum 快递客户端枚举 - */ - ExpressClient getOrCreateExpressClient(ExpressClientEnum clientEnum); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java deleted file mode 100644 index b68e119c5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface ExpressQueryConvert { - - ExpressQueryConvert INSTANCE = Mappers.getMapper(ExpressQueryConvert.class); - - List convertList(List list); - @Mapping(source = "acceptTime", target = "time") - @Mapping(source = "acceptStation", target = "content") - ExpressTrackRespDTO convert(KdNiaoExpressQueryRespDTO.ExpressTrack track); - - List convertList2(List list); - @Mapping(source = "context", target = "content") - ExpressTrackRespDTO convert(Kd100ExpressQueryRespDTO.ExpressTrack track); - - KdNiaoExpressQueryReqDTO convert(ExpressTrackQueryReqDTO dto); - - Kd100ExpressQueryReqDTO convert2(ExpressTrackQueryReqDTO dto); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java deleted file mode 100644 index 34ad0128d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; - -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import lombok.Data; - -/** - * 快递轨迹的查询 Req DTO - * - * @author jason - */ -@Data -public class ExpressTrackQueryReqDTO { - - /** - * 快递公司编码 - * - * 对应 {@link DeliveryExpressDO#getCode()} - */ - private String expressCode; - - /** - * 发货快递单号 - */ - private String logisticsNo; - - /** - * 收、寄件人的电话号码 - */ - private String phone; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java deleted file mode 100644 index bc99e1cba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; - -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递查询的轨迹 Resp DTO - * - * @author jason - */ -@Data -public class ExpressTrackRespDTO { - - /** - * 发生时间 - */ - private LocalDateTime time; - - /** - * 快递状态 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java deleted file mode 100644 index 7befc84f7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * 快递 100 快递查询 Req DTO - * - * @author jason - */ -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -public class Kd100ExpressQueryReqDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("com") - private String expressCode; - - /** - * 快递单号 - */ - @JsonProperty("num") - private String logisticsNo; - - /** - * 收、寄件人的电话号码 - */ - private String phone; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java deleted file mode 100644 index 9d33cac21..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 快递 100 实时快递查询 Resp DTO - * - * 参见 快递 100 文档 - * - * @author jason - */ -@Data -public class Kd100ExpressQueryRespDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("com") - private String expressCompanyCode; - /** - * 快递单号 - */ - @JsonProperty("nu") - private String logisticsNo; - /** - * 快递单当前状态 - */ - private String state; - - /** - * 查询结果 - * - * 失败返回 "false" - */ - private String result; - /** - * 查询结果失败时的错误信息 - */ - private String message; - - /** - * 轨迹数组 - */ - @JsonProperty("data") - private List tracks; - - @Data - public static class ExpressTrack { - - /** - * 轨迹发生时间 - */ - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime time; - - /** - * 轨迹描述 - */ - private String context; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java deleted file mode 100644 index bcb6e3353..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * 快递鸟快递查询 Req DTO - * - * @author jason - */ -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -public class KdNiaoExpressQueryReqDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("ShipperCode") - private String expressCode; - /** - * 快递单号 - */ - @JsonProperty("LogisticCode") - private String logisticsNo; - /** - * 订单编号 - */ - @JsonProperty("OrderCode") - private String orderNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java deleted file mode 100644 index 04a7c1431..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 快递鸟快递查询 Resp DTO - * - * 参见 快递鸟接口文档 - * - * @author jason - */ -@Data -public class KdNiaoExpressQueryRespDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("ShipperCode") - private String shipperCode; - - /** - * 快递单号 - */ - @JsonProperty("LogisticCode") - private String logisticsNo; - - /** - * 订单编号 - */ - @JsonProperty("OrderCode") - private String orderNo; - - /** - * 用户 ID - */ - @JsonProperty("EBusinessID") - private String businessId; - - /** - * 普通物流状态 - * - * 0 - 暂无轨迹信息 - * 1 - 已揽收 - * 2 - 在途中 - * 3 - 签收 - * 4 - 问题件 - * 5 - 转寄 - * 6 - 清关 - */ - @JsonProperty("State") - private String state; - - /** - * 成功与否 - */ - @JsonProperty("Success") - private Boolean success; - /** - * 失败原因 - */ - @JsonProperty("Reason") - private String reason; - - /** - * 轨迹数组 - */ - @JsonProperty("Traces") - private List tracks; - - @Data - public static class ExpressTrack { - - /** - * 发生时间 - */ - @JsonProperty("AcceptTime") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime acceptTime; - - /** - * 轨迹描述 - */ - @JsonProperty("AcceptStation") - private String acceptStation; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java deleted file mode 100644 index d4432b264..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import lombok.AllArgsConstructor; -import org.springframework.web.client.RestTemplate; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 快递客户端工厂实现类 - * - * @author jason - */ -@AllArgsConstructor -public class ExpressClientFactoryImpl implements ExpressClientFactory { - - private final Map clientMap = new ConcurrentHashMap<>(8); - - private final TradeExpressProperties tradeExpressProperties; - private final RestTemplate restTemplate; - - @Override - public ExpressClient getDefaultExpressClient() { - ExpressClient defaultClient = getOrCreateExpressClient(tradeExpressProperties.getClient()); - Assert.notNull("默认的快递客户端不能为空"); - return defaultClient; - } - - @Override - public ExpressClient getOrCreateExpressClient(ExpressClientEnum clientEnum) { - return clientMap.computeIfAbsent(clientEnum, - client -> createExpressClient(client, tradeExpressProperties)); - } - - private ExpressClient createExpressClient(ExpressClientEnum queryProviderEnum, - TradeExpressProperties tradeExpressProperties) { - switch (queryProviderEnum) { - case NOT_PROVIDE: - return new NoProvideExpressClient(); - case KD_NIAO: - return new KdNiaoExpressClient(restTemplate, tradeExpressProperties.getKdNiao()); - case KD_100: - return new Kd100ExpressClient(restTemplate, tradeExpressProperties.getKd100()); - } - return null; - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java deleted file mode 100644 index 7289710f6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CLIENT_NOT_PROVIDE; - -/** - * 未实现的快递客户端,用来提醒用户需要接入快递服务商, - * - * @author jason - */ -public class NoProvideExpressClient implements ExpressClient { - - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - throw exception(EXPRESS_CLIENT_NOT_PROVIDE); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java deleted file mode 100644 index f04abde70..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.HexUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.*; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_ERROR; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_FAILED; -import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert.ExpressQueryConvert.INSTANCE; - -/** - * 快递 100 客户端 - * - * @author jason - */ -@Slf4j -@AllArgsConstructor -public class Kd100ExpressClient implements ExpressClient { - - private static final String REAL_TIME_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do"; - - private final RestTemplate restTemplate; - private final TradeExpressProperties.Kd100Config config; - - /** - * 查询快递轨迹 - * - * @see 接口文档 - * - * @param reqDTO 查询请求参数 - * @return 快递轨迹 - */ - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - // 发起请求 - Kd100ExpressQueryReqDTO requestDTO = INSTANCE.convert2(reqDTO) - .setExpressCode(reqDTO.getExpressCode().toLowerCase()); - Kd100ExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, requestDTO, - Kd100ExpressQueryRespDTO.class); - - // 处理结果 - if (Objects.equals("false", respDTO.getResult())) { - throw exception(EXPRESS_API_QUERY_FAILED, respDTO.getMessage()); - } - if (CollUtil.isEmpty(respDTO.getTracks())) { - return Collections.emptyList(); - } - return INSTANCE.convertList2(respDTO.getTracks()); - } - - /** - * 快递 100 API 请求 - * - * @param url 请求 url - * @param req 对应请求的请求参数 - * @param respClass 对应请求的响应 class - * @param 每个请求的请求结构 Req DTO - * @param 每个请求的响应结构 Resp DTO - */ - private Resp httpRequest(String url, Req req, Class respClass) { - // 请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - // 请求体 - String param = JsonUtils.toJsonString(req); - String sign = generateReqSign(param, config.getKey(), config.getCustomer()); // 签名 - MultiValueMap requestBody = new LinkedMultiValueMap<>(); - requestBody.add("customer", config.getCustomer()); - requestBody.add("sign", sign); - requestBody.add("param", param); - log.debug("[httpRequest][请求参数({})]", requestBody); - - // 发送请求 - HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - log.debug("[httpRequest][的响应结果({})]", responseEntity); - // 处理响应 - if (!responseEntity.getStatusCode().is2xxSuccessful()) { - throw exception(EXPRESS_API_QUERY_ERROR); - } - return JsonUtils.parseObject(responseEntity.getBody(), respClass); - } - - private String generateReqSign(String param, String key, String customer) { - String plainText = String.format("%s%s%s", param, key, customer); - return HexUtil.encodeHexStr(DigestUtil.md5(plainText), false); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java deleted file mode 100644 index 1f1116882..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao; - -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.net.URLEncodeUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryRespDTO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.*; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_FAILED; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_ERROR; -import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert.ExpressQueryConvert.INSTANCE; - -/** - * 快递鸟客户端 - * - * @author jason - */ -@Slf4j -@AllArgsConstructor -public class KdNiaoExpressClient implements ExpressClient { - - private static final String REAL_TIME_QUERY_URL = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; - - /** - * 快递鸟即时查询免费版 RequestType - */ - private static final String REAL_TIME_FREE_REQ_TYPE = "1002"; - - private final RestTemplate restTemplate; - private final TradeExpressProperties.KdNiaoConfig config; - - /** - * 查询快递轨迹【免费版】 - * - * 仅支持 3 家:申通快递、圆通速递、百世快递 - * - * @see 接口文档 - * - * @param reqDTO 查询请求参数 - * @return 快递轨迹 - */ - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - // 发起请求 - KdNiaoExpressQueryReqDTO requestDTO = INSTANCE.convert(reqDTO) - .setExpressCode(reqDTO.getExpressCode().toUpperCase()); - KdNiaoExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, REAL_TIME_FREE_REQ_TYPE, - requestDTO, KdNiaoExpressQueryRespDTO.class); - - // 处理结果 - if (respDTO == null || !respDTO.getSuccess()) { - throw exception(EXPRESS_API_QUERY_FAILED, respDTO == null ? "" : respDTO.getReason()); - } - if (CollUtil.isEmpty(respDTO.getTracks())) { - return Collections.emptyList(); - } - return INSTANCE.convertList(respDTO.getTracks()); - } - - /** - * 快递鸟 API 请求 - * - * @param url 请求 url - * @param requestType 对应的请求指令 (快递鸟的 RequestType) - * @param req 对应请求的请求参数 - * @param respClass 对应请求的响应 class - * @param 每个请求的请求结构 Req DTO - * @param 每个请求的响应结构 Resp DTO - */ - private Resp httpRequest(String url, String requestType, Req req, Class respClass) { - // 请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - // 请求体 - String reqData = JsonUtils.toJsonString(req); - String dataSign = generateDataSign(reqData, config.getApiKey()); - MultiValueMap requestBody = new LinkedMultiValueMap<>(); - requestBody.add("RequestData", reqData); - requestBody.add("DataType", "2"); - requestBody.add("EBusinessID", config.getBusinessId()); - requestBody.add("DataSign", dataSign); - requestBody.add("RequestType", requestType); - log.debug("[httpRequest][RequestType({}) 的请求参数({})]", requestType, requestBody); - - // 发送请求 - HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - log.debug("[httpRequest][RequestType({}) 的响应结果({})", requestType, responseEntity); - // 处理响应 - if (!responseEntity.getStatusCode().is2xxSuccessful()) { - throw exception(EXPRESS_API_QUERY_ERROR); - } - return JsonUtils.parseObject(responseEntity.getBody(), respClass); - } - - /** - * 快递鸟生成请求签名 - * - * 参见 签名说明 - * - * @param reqData 请求实体 - * @param apiKey api Key - */ - private String generateDataSign(String reqData, String apiKey) { - String plainText = String.format("%s%s", reqData, apiKey); - return URLEncodeUtil.encode(Base64.encode(DigestUtil.md5Hex(plainText))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java deleted file mode 100644 index 81b96184c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 快递客户端枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum ExpressClientEnum { - - NOT_PROVIDE("not-provide","未提供"), - KD_NIAO("kd-niao", "快递鸟"), - KD_100("kd-100", "快递100"); - - /** - * 快递服务商唯一编码 - */ - private final String code; - /** - * 快递服务商名称 - */ - private final String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java deleted file mode 100644 index 715169275..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -// TODO @LeeYan9: 可以直接给 TradeOrderProperties 一个 @Component生效哈 -/** - * @author LeeYan9 - * @since 2022-09-15 - */ -@Configuration -@EnableConfigurationProperties(TradeOrderProperties.class) -public class TradeOrderConfig { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java deleted file mode 100644 index 786c0004b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotNull; -import java.time.Duration; - -/** - * 交易订单的配置项 - * - * @author LeeYan9 - * @since 2022-09-15 - */ -@ConfigurationProperties(prefix = "yudao.trade.order") -@Data -@Validated -public class TradeOrderProperties { - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - - /** - * 支付超时时间 - */ - @NotNull(message = "支付超时时间不能为空") - private Duration payExpireTime; - - /** - * 收货超时时间 - */ - @NotNull(message = "收货超时时间不能为空") - private Duration receiveExpireTime; - - /** - * 评论超时时间 - */ - @NotNull(message = "评论超时时间不能为空") - private Duration commentExpireTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java deleted file mode 100644 index cc023c10d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.annotations; - -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; -import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; - -/** - * 交易订单的操作日志 AOP 注解 - * - * @author 陈賝 - * @since 2023/7/6 15:37 - * @see TradeOrderLogAspect - */ -@Target({METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface TradeOrderLog { - - /** - * 操作类型 - */ - TradeOrderOperateTypeEnum operateType(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java deleted file mode 100644 index ccdf91c61..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.aop; - - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static java.util.Collections.emptyMap; - -/** - * 交易订单的操作日志的记录 AOP 切面 - * - * @author 陈賝 - * @since 2023/6/13 13:54 - */ -@Component -@Aspect -@Slf4j -public class TradeOrderLogAspect { - - /** - * 用户编号 - * - * 目前的使用场景:支付回调时,需要强制设置下用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 订单编号 - */ - private static final ThreadLocal ORDER_ID = new ThreadLocal<>(); - /** - * 操作前的状态 - */ - private static final ThreadLocal BEFORE_STATUS = new ThreadLocal<>(); - /** - * 操作后的状态 - */ - private static final ThreadLocal AFTER_STATUS = new ThreadLocal<>(); - /** - * 拓展参数 Map,用于格式化操作内容 - */ - private static final ThreadLocal> EXTS = new ThreadLocal<>(); - - @Resource - private TradeOrderLogService orderLogService; - - @AfterReturning("@annotation(orderLog)") - public void doAfterReturning(JoinPoint joinPoint, TradeOrderLog orderLog) { - try { - // 1.1 操作用户 - Integer userType = getUserType(); - Long userId = getUserId(); - // 1.2 订单信息 - Long orderId = ORDER_ID.get(); - if (orderId == null) { // 如果未设置,只有注解,说明不需要记录日志 - return; - } - Integer beforeStatus = BEFORE_STATUS.get(); - Integer afterStatus = AFTER_STATUS.get(); - Map exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); - String content = StrUtil.format(orderLog.operateType().getContent(), exts); - - // 2. 记录日志 - TradeOrderLogCreateReqBO createBO = new TradeOrderLogCreateReqBO() - .setUserId(userId).setUserType(userType) - .setOrderId(orderId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setOperateType(orderLog.operateType().getType()).setContent(content); - orderLogService.createOrderLog(createBO); - } catch (Exception ex) { - log.error("[doAfterReturning][orderLog({}) 订单日志错误]", toJsonString(orderLog), ex); - } finally { - clear(); - } - } - - /** - * 获得用户类型 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 - * - * @return 用户类型 - */ - private static Integer getUserType() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); - } - - /** - * 获得用户编号 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 - * - * @return 用户类型 - */ - private static Long getUserId() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); - } - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, Map exts) { - ORDER_ID.set(id); - BEFORE_STATUS.set(beforeStatus); - AFTER_STATUS.set(afterStatus); - EXTS.set(exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - ORDER_ID.remove(); - BEFORE_STATUS.remove(); - AFTER_STATUS.remove(); - EXTS.remove(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java deleted file mode 100644 index d134b7573..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.utils; - -import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; - -import java.util.Map; - -/** - * 交易订单的操作日志 Utils - * - * @author 芋道源码 - */ -public class TradeOrderLogUtils { - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus) { - TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, null); - } - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, - Map exts) { - TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - TradeOrderLogAspect.setUserInfo(userId, userType); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java deleted file mode 100644 index 68c67112f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 trade 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.trade.framework; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 2e795cb54..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.point.MemberPointApi; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainActivityApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi; -import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = { - BargainActivityApi.class, BargainRecordApi.class, CombinationRecordApi.class, - CouponApi.class, DiscountActivityApi.class, RewardActivityApi.class, SeckillActivityApi.class, - MemberUserApi.class, MemberPointApi.class, MemberLevelApi.class, MemberAddressApi.class, MemberConfigApi.class, - ProductSpuApi.class, ProductSkuApi.class, ProductCommentApi.class, ProductCategoryApi.class, - PayOrderApi.class, PayRefundApi.class, - NotifyMessageSendApi.class -}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/package-info.java deleted file mode 100644 index 42531afa8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.trade.framework.rpc; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 64c0e3db9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Trade 模块的 Security 配置 - */ -@Configuration("tradeSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("tradeAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/core/package-info.java deleted file mode 100644 index 0ec1e46e7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.trade.framework.security.core; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java deleted file mode 100644 index fa968dedc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.brokerage; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 佣金解冻 Job - * - * @author owen - */ -@Component -public class BrokerageRecordUnfreezeJob { - - @Resource - private BrokerageRecordService brokerageRecordService; - - @XxlJob("brokerageRecordUnfreezeJob") - @TenantJob // 多租户 - public String execute(String param) { - int count = brokerageRecordService.unfreezeRecord(); - return StrUtil.format("解冻佣金 {} 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java deleted file mode 100644 index cdff918ad..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 交易订单的自动过期 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoCancelJob { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @XxlJob("tradeOrderAutoCancelJob") - @TenantJob // 多租户 - public String execute() { - int count = tradeOrderUpdateService.cancelOrderBySystem(); - return String.format("过期订单 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java deleted file mode 100644 index 8537bf76b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 交易订单的自动评论 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoCommentJob { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @XxlJob("tradeOrderAutoCommentJob") - @TenantJob // 多租户 - public String execute() { - int count = tradeOrderUpdateService.createOrderItemCommentBySystem(); - return String.format("评论订单 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java deleted file mode 100644 index 93e3054dd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 交易订单的自动收货 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoReceiveJob { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @XxlJob("tradeOrderAutoReceiveJob") - @TenantJob // 多租户 - public String execute() { - int count = tradeOrderUpdateService.receiveOrderBySystem(); - return String.format("自动收货 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java deleted file mode 100644 index eba4aa766..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * trade 模块,product 模块,主要实现商品相关功能 - * 例如:品牌、商品分类、spu、sku等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.trade; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java deleted file mode 100644 index 2620ca0c6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - - -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; - -import java.util.List; - -/** - * 交易售后日志 Service 接口 - * - * @author 陈賝 - * @since 2023/6/12 14:18 - */ -public interface AfterSaleLogService { - - /** - * 创建售后日志 - * - * @param createReqBO 日志记录 - * @author 陈賝 - * @since 2023/6/12 14:18 - */ - void createAfterSaleLog(AfterSaleLogCreateReqBO createReqBO); - - /** - * 获取售后日志 - * - * @param afterSaleId 售后编号 - * @return 售后日志 - */ - List getAfterSaleLogList(Long afterSaleId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java deleted file mode 100644 index 280af9276..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleLogConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleLogMapper; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 交易售后日志 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AfterSaleLogServiceImpl implements AfterSaleLogService { - - @Resource - private AfterSaleLogMapper afterSaleLogMapper; - - @Override - public void createAfterSaleLog(AfterSaleLogCreateReqBO createReqBO) { - AfterSaleLogDO afterSaleLog = AfterSaleLogConvert.INSTANCE.convert(createReqBO); - afterSaleLogMapper.insert(afterSaleLog); - } - - @Override - public List getAfterSaleLogList(Long afterSaleId) { - return afterSaleLogMapper.selectListByAfterSaleId(afterSaleId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java deleted file mode 100644 index 1a0c1e95d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; - -/** - * 售后订单 Service 接口 - * - * @author 芋道源码 - */ -public interface AfterSaleService { - - /** - * 【管理员】获得售后订单分页 - * - * @param pageReqVO 分页查询 - * @return 售后订单分页 - */ - PageResult getAfterSalePage(AfterSalePageReqVO pageReqVO); - - /** - * 【会员】获得售后订单分页 - * - * @param userId 用户编号 - * @param pageParam 分页参数 - * @return 售后订单分页 - */ - PageResult getAfterSalePage(Long userId, PageParam pageParam); - - /** - * 【会员】获得售后单 - * - * @param userId 用户编号 - * @param id 售后编号 - * @return 售后订单 - */ - AfterSaleDO getAfterSale(Long userId, Long id); - - /** - * 【管理员】获得售后单 - * - * @param id 售后编号 - * @return 售后订单 - */ - AfterSaleDO getAfterSale(Long id); - - /** - * 【会员】创建售后订单 - * - * @param userId 会员用户编号 - * @param createReqVO 创建 Request 信息 - * @return 售后编号 - */ - Long createAfterSale(Long userId, AppAfterSaleCreateReqVO createReqVO); - - /** - * 【管理员】同意售后订单 - * - * @param userId 管理员用户编号 - * @param id 售后编号 - */ - void agreeAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝售后订单 - * - * @param userId 管理员用户编号 - * @param auditReqVO 审批 Request 信息 - */ - void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO); - - /** - * 【会员】退回货物 - * - * @param userId 会员用户编号 - * @param deliveryReqVO 退货 Request 信息 - */ - void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO); - - /** - * 【管理员】确认收货 - * - * @param userId 管理员编号 - * @param id 售后编号 - */ - void receiveAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝收货 - * - * @param userId 管理员用户编号 - * @param refuseReqVO 拒绝收货 Request 信息 - */ - void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO); - - /** - * 【管理员】确认退款 - * - * @param userId 管理员用户编号 - * @param userIp 管理员用户 IP - * @param id 售后编号 - */ - void refundAfterSale(Long userId, String userIp, Long id); - - /** - * 【会员】取消售后 - * - * @param userId 会员用户编号 - * @param id 售后编号 - */ - void cancelAfterSale(Long userId, Long id); - - /** - * 【会员】获得正在进行中的售后订单数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getApplyingAfterSaleCount(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java deleted file mode 100644 index 3b96fb7ba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java +++ /dev/null @@ -1,415 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleMapper; -import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations.AfterSaleLog; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.utils.AfterSaleLogUtils; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 售后订单 Service 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@Service -@Validated -public class AfterSaleServiceImpl implements AfterSaleService { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private AfterSaleMapper tradeAfterSaleMapper; - @Resource - private TradeNoRedisDAO tradeNoRedisDAO; - - @Resource - private PayRefundApi payRefundApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @Override - public PageResult getAfterSalePage(AfterSalePageReqVO pageReqVO) { - return tradeAfterSaleMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getAfterSalePage(Long userId, PageParam pageParam) { - return tradeAfterSaleMapper.selectPage(userId, pageParam); - } - - @Override - public AfterSaleDO getAfterSale(Long userId, Long id) { - return tradeAfterSaleMapper.selectByIdAndUserId(id, userId); - } - - @Override - public AfterSaleDO getAfterSale(Long id) { - return tradeAfterSaleMapper.selectById(id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_CREATE) - public Long createAfterSale(Long userId, AppAfterSaleCreateReqVO createReqVO) { - // 第一步,前置校验 - TradeOrderItemDO tradeOrderItem = validateOrderItemApplicable(userId, createReqVO); - - // 第二步,存储售后订单 - AfterSaleDO afterSale = createAfterSale(createReqVO, tradeOrderItem); - return afterSale.getId(); - } - - /** - * 校验交易订单项是否可以申请售后 - * - * @param userId 用户编号 - * @param createReqVO 售后创建信息 - * @return 交易订单项 - */ - private TradeOrderItemDO validateOrderItemApplicable(Long userId, AppAfterSaleCreateReqVO createReqVO) { - // 校验订单项存在 - TradeOrderItemDO orderItem = tradeOrderQueryService.getOrderItem(userId, createReqVO.getOrderItemId()); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - // 已申请售后,不允许再发起售后申请 - if (!TradeOrderItemAfterSaleStatusEnum.isNone(orderItem.getAfterSaleStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED); - } - // 申请的退款金额,不能超过商品的价格 - if (createReqVO.getRefundPrice() > orderItem.getPayPrice()) { - throw exception(AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR); - } - - // 校验订单存在 - TradeOrderDO order = tradeOrderQueryService.getOrder(userId, orderItem.getOrderId()); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // TODO 芋艿:超过一定时间,不允许售后 - // 已取消,无法发起售后 - if (TradeOrderStatusEnum.isCanceled(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED); - } - // 未支付,无法发起售后 - if (!TradeOrderStatusEnum.havePaid(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID); - } - // 如果是【退货退款】的情况,需要额外校验是否发货 - if (createReqVO.getWay().equals(AfterSaleWayEnum.RETURN_AND_REFUND.getWay()) - && !TradeOrderStatusEnum.haveDelivered(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED); - } - return orderItem; - } - - private AfterSaleDO createAfterSale(AppAfterSaleCreateReqVO createReqVO, - TradeOrderItemDO orderItem) { - // 创建售后单 - AfterSaleDO afterSale = AfterSaleConvert.INSTANCE.convert(createReqVO, orderItem); - afterSale.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.AFTER_SALE_NO_PREFIX)); - afterSale.setStatus(AfterSaleStatusEnum.APPLY.getStatus()); - // 标记是售中还是售后 - TradeOrderDO order = tradeOrderQueryService.getOrder(orderItem.getUserId(), orderItem.getOrderId()); - afterSale.setOrderNo(order.getNo()); // 记录 orderNo 订单流水,方便后续检索 - afterSale.setType(TradeOrderStatusEnum.isCompleted(order.getStatus()) - ? AfterSaleTypeEnum.AFTER_SALE.getType() : AfterSaleTypeEnum.IN_SALE.getType()); - tradeAfterSaleMapper.insert(afterSale); - - // 更新交易订单项的售后状态 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCreate(orderItem.getId(), afterSale.getId()); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), null, - AfterSaleStatusEnum.APPLY.getStatus()); - - // TODO 发送售后消息 - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_AGREE_APPLY) - public void agreeAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态未审批 - AfterSaleDO afterSale = validateAfterSaleAuditable(id); - - // 更新售后单的状态 - // 情况一:退款:标记为 WAIT_REFUND 状态。后续等退款发起成功后,在标记为 COMPLETE 状态 - // 情况二:退货退款:需要等用户退货后,才能发起退款 - Integer newStatus = afterSale.getWay().equals(AfterSaleWayEnum.REFUND.getWay()) ? - AfterSaleStatusEnum.WAIT_REFUND.getStatus() : AfterSaleStatusEnum.SELLER_AGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.APPLY.getStatus(), new AfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_DISAGREE_APPLY) - public void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO) { - // 校验售后单存在,并状态未审批 - AfterSaleDO afterSale = validateAfterSaleAuditable(auditReqVO.getId()); - - // 更新售后单的状态 - Integer newStatus = AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.APPLY.getStatus(), new AfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now()) - .setAuditReason(auditReqVO.getAuditReason())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - /** - * 校验售后单是否可审批(同意售后、拒绝售后) - * - * @param id 售后编号 - * @return 售后单 - */ - private AfterSaleDO validateAfterSaleAuditable(Long id) { - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus())) { - throw exception(AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY); - } - return afterSale; - } - - private void updateAfterSaleStatus(Long id, Integer status, AfterSaleDO updateObj) { - int updateCount = tradeAfterSaleMapper.updateByIdAndStatus(id, status, updateObj); - if (updateCount == 0) { - throw exception(AFTER_SALE_UPDATE_STATUS_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_DELIVERY) - public void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO) { - // 校验售后单存在,并状态未退货 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectByIdAndUserId(deliveryReqVO.getId(), userId); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.SELLER_AGREE.getStatus())) { - throw exception(AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE); - } - DeliveryExpressDO express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); - - // 更新售后单的物流信息 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.SELLER_AGREE.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus()) - .setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()) - .setDeliveryTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), - MapUtil.builder().put("deliveryName", express.getName()) - .put("logisticsNo", deliveryReqVO.getLogisticsNo()).build()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_AGREE_RECEIVE) - public void receiveAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态为已退货 - AfterSaleDO afterSale = validateAfterSaleReceivable(id); - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.WAIT_REFUND.getStatus()).setReceiveTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.WAIT_REFUND.getStatus()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_DISAGREE_RECEIVE) - public void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO) { - // 校验售后单存在,并状态为已退货 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(refuseReqVO.getId()); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.SELLER_REFUSE.getStatus()).setReceiveTime(LocalDateTime.now()) - .setReceiveReason(refuseReqVO.getRefuseMemo())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.SELLER_REFUSE.getStatus(), - MapUtil.of("reason", refuseReqVO.getRefuseMemo())); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - /** - * 校验售后单是否可收货,即处于买家已发货 - * - * @param id 售后编号 - * @return 售后单 - */ - private AfterSaleDO validateAfterSaleReceivable(Long id) { - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_REFUND) - public void refundAfterSale(Long userId, String userIp, Long id) { - // 校验售后单的状态,并状态待退款 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.WAIT_REFUND.getStatus())) { - throw exception(AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND); - } - - // 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起 - createPayRefund(userIp, afterSale); - - // 更新售后单的状态为【已完成】 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.WAIT_REFUND.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.COMPLETE.getStatus()).setRefundTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.COMPLETE.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【已完成】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleSuccess(afterSale.getOrderItemId(), afterSale.getRefundPrice()); - } - - private void createPayRefund(String userIp, AfterSaleDO afterSale) { - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - // 创建退款单 - PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties) - .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName())); - Long payRefundId = payRefundApi.createRefund(createReqDTO).getCheckedData(); - // 更新售后单的退款单号 - tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId)); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_CANCEL) - public void cancelAfterSale(Long userId, Long id) { - // 校验售后单的状态,并状态待退款 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (!ObjectUtils.equalsAny(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus(), - AfterSaleStatusEnum.SELLER_AGREE.getStatus(), - AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY); - } - - // 更新售后单的状态为【已取消】 - updateAfterSaleStatus(afterSale.getId(), afterSale.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.BUYER_CANCEL.getStatus())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.BUYER_CANCEL.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - @Override - public Long getApplyingAfterSaleCount(Long userId) { - return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java deleted file mode 100644 index 5793fed2b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 售后日志的创建 Request BO - * - * @author 陈賝 - * @since 2023/6/19 09:54 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AfterSaleLogCreateReqBO { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 售后编号 - */ - @NotNull(message = "售后编号不能为空") - private Long afterSaleId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - @NotNull(message = "操作后的状态不能为空") - private Integer afterStatus; - - /** - * 操作类型 - */ - @NotNull(message = "操作类型不能为空") - private Integer operateType; - /** - * 操作明细 - */ - @NotEmpty(message = "操作明细不能为空") - private String content; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java deleted file mode 100644 index 1cf1e2443..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 佣金记录 Service 接口 - * - * @author owen - */ -public interface BrokerageRecordService { - - /** - * 获得佣金记录 - * - * @param id 编号 - * @return 佣金记录 - */ - BrokerageRecordDO getBrokerageRecord(Integer id); - - /** - * 获得佣金记录分页 - * - * @param pageReqVO 分页查询 - * @return 佣金记录分页 - */ - PageResult getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO); - - /** - * 增加佣金【多级分佣】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param list 请求参数列表 - */ - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, @Valid List list); - - /** - * 增加佣金【只针对自己】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - * @param brokeragePrice 佣金 - * @param title 标题 - */ - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title); - - /** - * 减少佣金【只针对自己】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - * @param brokeragePrice 佣金 - * @param title 标题 - */ - default void reduceBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { - addBrokerage(userId, bizType, bizId, -brokeragePrice, title); - } - - /** - * 取消佣金:将佣金记录,状态修改为已失效 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId); - - /** - * 解冻佣金:将待结算的佣金记录,状态修改为已结算 - * - * @return 解冻佣金的数量 - */ - int unfreezeRecord(); - - /** - * 按照 userId,汇总每个用户的佣金 - * - * @param userIds 用户编号 - * @param bizType 业务类型 - * @param status 佣金状态 - * @return 用户佣金汇总 List - */ - List getUserBrokerageSummaryListByUserId(Collection userIds, - Integer bizType, Integer status); - - /** - * 按照 userId,汇总每个用户的佣金 - * - * @param userIds 用户编号 - * @param bizType 业务类型 - * @param status 佣金状态 - * @return 用户佣金汇总 Map - */ - default Map getUserBrokerageSummaryMapByUserId(Collection userIds, - Integer bizType, Integer status) { - return convertMap(getUserBrokerageSummaryListByUserId(userIds, bizType, status), - UserBrokerageSummaryRespBO::getUserId); - } - - /** - * 获得用户佣金合计 - * - * @param userId 用户编号 - * @param bizType 业务类型 - * @param status 状态 - * @param beginTime 开始时间 - * @param endTime 截止时间 - * @return 用户佣金合计 - */ - Integer getSummaryPriceByUserId(Long userId, BrokerageRecordBizTypeEnum bizType, BrokerageRecordStatusEnum status, - LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得用户佣金排行分页列表(基于佣金总数) - * - * @param pageReqVO 分页查询 - * @return 排行榜分页 - */ - PageResult getBrokerageUserChildSummaryPageByPrice( - AppBrokerageUserRankPageReqVO pageReqVO); - - /** - * 获取用户的排名(基于佣金总数) - * - * @param userId 用户编号 - * @param times 时间范围 - * @return 用户的排名 - */ - Integer getUserRankByPrice(Long userId, LocalDateTime[] times); - - /** - * 计算商品被购买后,推广员可以得到的佣金 - * - * @param userId 用户编号 - * @param spuId 商品编号 - * @return 用户佣金 - */ - AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java deleted file mode 100644 index 915bf0bc8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.*; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH; - -/** - * 佣金记录 Service 实现类 - * - * @author owen - */ -@Slf4j -@Service -@Validated -public class BrokerageRecordServiceImpl implements BrokerageRecordService { - - @Resource - private BrokerageRecordMapper brokerageRecordMapper; - @Resource - private TradeConfigService tradeConfigService; - @Resource - private BrokerageUserService brokerageUserService; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - public BrokerageRecordDO getBrokerageRecord(Integer id) { - return brokerageRecordMapper.selectById(id); - } - - @Override - public PageResult getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO) { - return brokerageRecordMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, List list) { - TradeConfigDO memberConfig = tradeConfigService.getTradeConfig(); - // 0 未启用分销功能 - if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) { - log.warn("[addBrokerage][增加佣金失败:brokerageEnabled 未配置,userId({})", userId); - return; - } - - // 1.1 获得一级推广人 - BrokerageUserDO firstUser = brokerageUserService.getBindBrokerageUser(userId); - if (firstUser == null || !BooleanUtil.isTrue(firstUser.getBrokerageEnabled())) { - return; - } - // 1.2 计算一级分佣 - addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), - bizType, 1); - - // 2.1 获得二级推广员 - if (firstUser.getBindUserId() == null) { - return; - } - BrokerageUserDO secondUser = brokerageUserService.getBrokerageUser(firstUser.getBindUserId()); - if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) { - return; - } - // 2.2 计算二级分佣 - addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), - bizType, 2); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId) { - BrokerageRecordDO record = brokerageRecordMapper.selectByBizTypeAndBizIdAndUserId(bizType.getType(), bizId, userId); - if (record == null) { - log.error("[cancelBrokerage][userId({})][bizId({}) 更新为已失效失败:记录不存在]", userId, bizId); - return; - } - - // 1. 更新佣金记录为已失效 - BrokerageRecordDO updateObj = new BrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus()); - int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); - if (updateRows == 0) { - log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId()); - return; - } - - // 2. 更新用户的佣金 - if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) { - brokerageUserService.updateUserFrozenPrice(userId, -record.getPrice()); - } else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) { - brokerageUserService.updateUserPrice(userId, -record.getPrice()); - } - } - - /** - * 计算佣金 - * - * @param basePrice 佣金基数 - * @param percent 佣金比例 - * @param fixedPrice 固定佣金 - * @return 佣金 - */ - int calculatePrice(Integer basePrice, Integer percent, Integer fixedPrice) { - // 1. 优先使用固定佣金 - if (fixedPrice != null && fixedPrice > 0) { - return ObjectUtil.defaultIfNull(fixedPrice, 0); - } - // 2. 根据比例计算佣金 - if (basePrice != null && basePrice > 0 && percent != null && percent > 0) { - return MoneyUtils.calculateRatePriceFloor(basePrice, Double.valueOf(percent)); - } - return 0; - } - - /** - * 增加用户佣金 - * - * @param user 用户 - * @param list 佣金增加参数列表 - * @param brokerageFrozenDays 冻结天数 - * @param brokeragePercent 佣金比例 - * @param bizType 业务类型 - * @param sourceUserLevel 来源用户等级 - */ - private void addBrokerage(BrokerageUserDO user, List list, Integer brokerageFrozenDays, - Integer brokeragePercent, BrokerageRecordBizTypeEnum bizType, Integer sourceUserLevel) { - // 1.1 处理冻结时间 - LocalDateTime unfreezeTime = null; - if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { - unfreezeTime = LocalDateTime.now().plusDays(brokerageFrozenDays); - } - // 1.2 计算分佣 - int totalBrokerage = 0; - List records = new ArrayList<>(); - for (BrokerageAddReqBO item : list) { - // 计算金额 - Integer fixedPrice; - if (Objects.equals(sourceUserLevel, 1)) { - fixedPrice = item.getFirstFixedPrice(); - } else if (Objects.equals(sourceUserLevel, 2)) { - fixedPrice = item.getSecondFixedPrice(); - } else { - throw new IllegalArgumentException(StrUtil.format("用户等级({}) 不合法", sourceUserLevel)); - } - int brokeragePrice = calculatePrice(item.getBasePrice(), brokeragePercent, fixedPrice); - if (brokeragePrice <= 0) { - continue; - } - totalBrokerage += brokeragePrice; - // 创建记录实体 - records.add(BrokerageRecordConvert.INSTANCE.convert(user, bizType, item.getBizId(), - brokerageFrozenDays, brokeragePrice, unfreezeTime, item.getTitle(), - item.getSourceUserId(), sourceUserLevel)); - } - if (CollUtil.isEmpty(records)) { - return; - } - // 1.3 保存佣金记录 - brokerageRecordMapper.insertBatch(records); - - // 2. 更新用户佣金 - if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { // 更新用户冻结佣金 - brokerageUserService.updateUserFrozenPrice(user.getId(), totalBrokerage); - } else { // 更新用户可用佣金 - brokerageUserService.updateUserPrice(user.getId(), totalBrokerage); - } - } - - @Override - public int unfreezeRecord() { - // 1. 查询待结算的佣金记录 - List records = brokerageRecordMapper.selectListByStatusAndUnfreezeTimeLt( - BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(records)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (BrokerageRecordDO record : records) { - try { - boolean success = getSelf().unfreezeRecord(record); - if (success) { - count++; - } - } catch (Exception e) { - log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId(), e); - } - } - return count; - } - - /** - * 解冻单条佣金记录 - * - * @param record 佣金记录 - * @return 解冻是否成功 - */ - @Transactional(rollbackFor = Exception.class) - public boolean unfreezeRecord(BrokerageRecordDO record) { - // 更新记录状态 - BrokerageRecordDO updateObj = new BrokerageRecordDO() - .setStatus(BrokerageRecordStatusEnum.SETTLEMENT.getStatus()) - .setUnfreezeTime(LocalDateTime.now()); - int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); - if (updateRows == 0) { - log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId()); - return false; - } - - // 更新用户冻结佣金 - brokerageUserService.updateFrozenPriceDecrAndPriceIncr(record.getUserId(), -record.getPrice()); - log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId()); - return true; - } - - @Override - public List getUserBrokerageSummaryListByUserId(Collection userIds, - Integer bizType, Integer status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageRecordMapper.selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(userIds, bizType, status); - } - - @Override - public Integer getSummaryPriceByUserId(Long userId, BrokerageRecordBizTypeEnum bizType, BrokerageRecordStatusEnum status, - LocalDateTime beginTime, LocalDateTime endTime) { - return brokerageRecordMapper.selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(userId, - bizType.getType(), status.getStatus(), beginTime, endTime); - } - - @Override - public PageResult getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) { - IPage pageResult = brokerageRecordMapper.selectSummaryPricePageGroupByUserId( - MyBatisUtils.buildPage(pageReqVO), - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(pageReqVO.getTimes(), 0), ArrayUtil.get(pageReqVO.getTimes(), 1)); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - @Override - public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) { - // 用户的推广金额 - Integer price = brokerageRecordMapper.selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(userId, - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(times, 0), ArrayUtil.get(times, 1)); - // 排在用户前面的人数 - Integer greaterCount = brokerageRecordMapper.selectCountByPriceGt(price, - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(times, 0), ArrayUtil.get(times, 1)); - // 获得排名 - return ObjUtil.defaultIfNull(greaterCount, 0) + 1; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { - // 1. 校验佣金余额 - BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); - int balance = Optional.of(user) - .map(BrokerageUserDO::getBrokeragePrice).orElse(0); - if (balance + brokeragePrice < 0) { - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); - } - - // 2. 更新佣金余额 - boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice); - if (!success) { - // 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况 - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); - } - - // 3. 新增记录 - BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, bizType, bizId, 0, brokeragePrice, - null, title, null, null); - brokerageRecordMapper.insert(record); - } - - @Override - public AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId) { - // 1. 构建默认的返回值 - AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO().setEnabled(false) - .setBrokerageMinPrice(0).setBrokerageMaxPrice(0); - - // 2.1 校验分销功能是否开启 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || BooleanUtil.isFalse(tradeConfig.getBrokerageEnabled())) { - return respVO; - } - // 2.2 校验用户是否有分销资格 - respVO.setEnabled(brokerageUserService.getUserBrokerageEnabled(getLoginUserId())); - if (BooleanUtil.isFalse(respVO.getEnabled())) { - return respVO; - } - // 2.3 校验商品是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - if (spu == null) { - return respVO; - } - - // 3.1 商品单独分佣模式 - Integer fixedMinPrice = 0; - Integer fixedMaxPrice = 0; - Integer spuMinPrice = 0; - Integer spuMaxPrice = 0; - List skuList = productSkuApi.getSkuListBySpuId(ListUtil.of(spuId)).getCheckedData(); - if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - fixedMinPrice = getMinValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); - fixedMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); - // 3.2 全局分佣模式(根据商品价格比例计算) - } else { - spuMinPrice = getMinValue(skuList, ProductSkuRespDTO::getPrice); - spuMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getPrice); - } - respVO.setBrokerageMinPrice(calculatePrice(spuMinPrice, tradeConfig.getBrokerageFirstPercent(), fixedMinPrice)); - respVO.setBrokerageMaxPrice(calculatePrice(spuMaxPrice, tradeConfig.getBrokerageFirstPercent(), fixedMaxPrice)); - return respVO; - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private BrokerageRecordServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java deleted file mode 100644 index e5b7e7abf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; - -import javax.validation.constraints.NotNull; -import java.util.Collection; -import java.util.List; - -/** - * 分销用户 Service 接口 - * - * @author owen - */ -public interface BrokerageUserService { - - /** - * 获得分销用户 - * - * @param id 编号 - * @return 分销用户 - */ - BrokerageUserDO getBrokerageUser(Long id); - - /** - * 获得分销用户列表 - * - * @param ids 编号 - * @return 分销用户列表 - */ - List getBrokerageUserList(Collection ids); - - /** - * 获得分销用户分页 - * - * @param pageReqVO 分页查询 - * @return 分销用户分页 - */ - PageResult getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO); - - /** - * 修改推广员编号 - * - * @param id 用户编号 - * @param bindUserId 推广员编号 - */ - void updateBrokerageUserId(Long id, Long bindUserId); - - /** - * 修改推广资格 - * - * @param id 用户编号 - * @param enabled 推广资格 - */ - void updateBrokerageUserEnabled(Long id, Boolean enabled); - - /** - * 获得用户的推广人 - * - * @param id 用户编号 - * @return 用户的推广人 - */ - BrokerageUserDO getBindBrokerageUser(Long id); - - /** - * 更新用户佣金 - * - * @param id 用户编号 - * @param price 用户可用佣金 - * @return 更新结果 - */ - boolean updateUserPrice(Long id, Integer price); - - /** - * 更新用户冻结佣金 - * - * @param id 用户编号 - * @param frozenPrice 用户冻结佣金 - */ - void updateUserFrozenPrice(Long id, Integer frozenPrice); - - /** - * 更新用户冻结佣金(减少),更新用户佣金(增加) - * - * @param id 用户编号 - * @param frozenPrice 减少冻结佣金(负数) - */ - void updateFrozenPriceDecrAndPriceIncr(Long id, Integer frozenPrice); - - /** - * 获得推广用户数量 - * - * @param bindUserId 绑定的推广员编号 - * @param level 推广用户等级 - * @return 推广用户数量 - */ - Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level); - - /** - * 【会员】绑定推广员 - * - * @param userId 用户编号 - * @param bindUserId 推广员编号 - * @return 是否绑定 - */ - boolean bindBrokerageUser(@NotNull Long userId, @NotNull Long bindUserId); - - /** - * 获取用户是否有分销资格 - * - * @param userId 用户编号 - * @return 是否有分销资格 - */ - Boolean getUserBrokerageEnabled(Long userId); - - /** - * 获得推广人排行 - * - * @param pageReqVO 分页查询 - * @return 推广人排行 - */ - PageResult getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO); - - /** - * 获得下级分销统计分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 下级分销统计分页 - */ - PageResult getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java deleted file mode 100644 index 2ed9ec2de..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java +++ /dev/null @@ -1,356 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMapByFilter; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 分销用户 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class BrokerageUserServiceImpl implements BrokerageUserService { - - @Resource - private BrokerageUserMapper brokerageUserMapper; - - @Resource - private TradeConfigService tradeConfigService; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public BrokerageUserDO getBrokerageUser(Long id) { - return brokerageUserMapper.selectById(id); - } - - @Override - public List getBrokerageUserList(Collection ids) { - return brokerageUserMapper.selectBatchIds(ids); - } - - @Override - public PageResult getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO) { - List childIds = getChildUserIdsByLevel(pageReqVO.getBindUserId(), pageReqVO.getLevel()); - // 有”绑定用户编号“查询条件时,没有查到下级会员,直接返回空 - if (pageReqVO.getBindUserId() != null && CollUtil.isEmpty(childIds)) { - return PageResult.empty(); - } - return brokerageUserMapper.selectPage(pageReqVO, childIds); - } - - @Override - public void updateBrokerageUserId(Long id, Long bindUserId) { - // 校验存在 - BrokerageUserDO brokerageUser = validateBrokerageUserExists(id); - // 绑定关系未发生变化 - if (Objects.equals(brokerageUser.getBindUserId(), bindUserId)) { - return; - } - - // 情况一:清除推广员 - if (bindUserId == null) { - // 清除推广员 - brokerageUserMapper.updateBindUserIdAndBindUserTimeToNull(id); - return; - } - - // 情况二:修改推广员 - validateCanBindUser(brokerageUser, bindUserId); - brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(id))); - } - - @Override - public void updateBrokerageUserEnabled(Long id, Boolean enabled) { - // 校验存在 - validateBrokerageUserExists(id); - if (BooleanUtil.isTrue(enabled)) { - // 开通推广资格 - brokerageUserMapper.updateById(new BrokerageUserDO().setId(id) - .setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now())); - } else { - // 取消推广资格 - brokerageUserMapper.updateEnabledFalseAndBrokerageTimeToNull(id); - } - } - - private BrokerageUserDO validateBrokerageUserExists(Long id) { - BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(id); - if (brokerageUserDO == null) { - throw exception(BROKERAGE_USER_NOT_EXISTS); - } - - return brokerageUserDO; - } - - @Override - public BrokerageUserDO getBindBrokerageUser(Long id) { - return Optional.ofNullable(id) - .map(this::getBrokerageUser) - .map(BrokerageUserDO::getBindUserId) - .map(this::getBrokerageUser) - .orElse(null); - } - - @Override - public boolean updateUserPrice(Long id, Integer price) { - if (price > 0) { - brokerageUserMapper.updatePriceIncr(id, price); - } else if (price < 0) { - return brokerageUserMapper.updatePriceDecr(id, price) > 0; - } - return true; - } - - @Override - public void updateUserFrozenPrice(Long id, Integer frozenPrice) { - if (frozenPrice > 0) { - brokerageUserMapper.updateFrozenPriceIncr(id, frozenPrice); - } else if (frozenPrice < 0) { - brokerageUserMapper.updateFrozenPriceDecr(id, frozenPrice); - } - } - - @Override - public void updateFrozenPriceDecrAndPriceIncr(Long id, Integer frozenPrice) { - Assert.isTrue(frozenPrice < 0); - int updateRows = brokerageUserMapper.updateFrozenPriceDecrAndPriceIncr(id, frozenPrice); - if (updateRows == 0) { - throw exception(BROKERAGE_USER_FROZEN_PRICE_NOT_ENOUGH); - } - } - - @Override - public Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level) { - List childIds = getChildUserIdsByLevel(bindUserId, level); - return (long) CollUtil.size(childIds); - } - - @Override - public boolean bindBrokerageUser(Long userId, Long bindUserId) { - // 1. 获得分销用户 - boolean isNewBrokerageUser = false; - BrokerageUserDO brokerageUser = brokerageUserMapper.selectById(userId); - if (brokerageUser == null) { // 分销用户不存在的情况:1. 新注册;2. 旧数据;3. 分销功能关闭后又打开 - isNewBrokerageUser = true; - brokerageUser = new BrokerageUserDO().setId(userId).setBrokerageEnabled(false).setBrokeragePrice(0).setFrozenPrice(0); - } - - // 2.1 校验是否能绑定用户 - boolean validated = isUserCanBind(brokerageUser); - if (!validated) { - return false; - } - // 2.3 校验能否绑定 - validateCanBindUser(brokerageUser, bindUserId); - // 2.3 绑定用户 - if (isNewBrokerageUser) { - Integer enabledCondition = tradeConfigService.getTradeConfig().getBrokerageEnabledCondition(); - if (BrokerageEnabledConditionEnum.ALL.getCondition().equals(enabledCondition)) { // 人人分销:用户默认就有分销资格 - brokerageUser.setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now()); - } - brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); - brokerageUserMapper.insert(fillBindUserData(bindUserId, brokerageUser)); - } else { - brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(userId))); - } - return true; - } - - /** - * 补全绑定用户的字段 - * - * @param bindUserId 绑定的用户编号 - * @param brokerageUser update 对象 - * @return 补全后的 update 对象 - */ - private BrokerageUserDO fillBindUserData(Long bindUserId, BrokerageUserDO brokerageUser) { - return brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); - } - - @Override - public Boolean getUserBrokerageEnabled(Long userId) { - // 全局分销功能是否开启 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || BooleanUtil.isFalse(tradeConfig.getBrokerageEnabled())) { - return false; - } - - // 用户是否有分销资格 - return Optional.ofNullable(getBrokerageUser(userId)) - .map(BrokerageUserDO::getBrokerageEnabled) - .orElse(false); - } - - @Override - public PageResult getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) { - IPage pageResult = brokerageUserMapper.selectCountPageGroupByBindUserId(MyBatisUtils.buildPage(pageReqVO), - ArrayUtil.get(pageReqVO.getTimes(), 0), ArrayUtil.get(pageReqVO.getTimes(), 1)); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - @Override - public PageResult getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId) { - // 1.1 查询下级用户编号列表 - List childIds = getChildUserIdsByLevel(userId, pageReqVO.getLevel()); - if (CollUtil.isEmpty(childIds)) { - return PageResult.empty(); - } - // 1.2 根据昵称过滤下级用户 - List users = memberUserApi.getUserList(childIds).getCheckedData(); - Map userMap = convertMapByFilter(users, - user -> StrUtil.contains(user.getNickname(), pageReqVO.getNickname()), - MemberUserRespDTO::getId); - if (CollUtil.isEmpty(userMap)) { - return PageResult.empty(); - } - - // 2. 分页查询 - IPage pageResult = brokerageUserMapper.selectSummaryPageByUserId( - MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(), - BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), userMap.keySet(), pageReqVO.getSortingField() - ); - - // 3. 拼接数据并返回 - BrokerageUserConvert.INSTANCE.copyTo(pageResult.getRecords(), userMap); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - private boolean isUserCanBind(BrokerageUserDO user) { - // 校验分销功能是否启用 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || !BooleanUtil.isTrue(tradeConfig.getBrokerageEnabled())) { - return false; - } - - // 校验分佣模式:仅可后台手动设置推广员 - if (BrokerageEnabledConditionEnum.ADMIN.getCondition().equals(tradeConfig.getBrokerageEnabledCondition())) { - throw exception(BROKERAGE_BIND_CONDITION_ADMIN); - } - - // 校验分销关系绑定模式 - if (BrokerageBindModeEnum.REGISTER.getMode().equals(tradeConfig.getBrokerageBindMode())) { - // 判断是否为新用户:注册时间在 30 秒内的,都算新用户 - if (!isNewRegisterUser(user.getId())) { - throw exception(BROKERAGE_BIND_MODE_REGISTER); // 只有在注册时可以绑定 - } - } else if (BrokerageBindModeEnum.ANYTIME.getMode().equals(tradeConfig.getBrokerageBindMode())) { - if (user.getBindUserId() != null) { - throw exception(BROKERAGE_BIND_OVERRIDE); // 已绑定了推广人 - } - } - return true; - } - - /** - * 判断是否为新用户 - *

- * 标准:注册时间在 30 秒内的,都算新用户 - *

- * 疑问:为什么通过这样的方式实现? - * 回答:因为注册在 member 模块,希望它和 trade 模块解耦,所以只能用这种约定的逻辑。 - * - * @param userId 用户编号 - * @return 是否新用户 - */ - private boolean isNewRegisterUser(Long userId) { - MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData(); - return user != null && LocalDateTimeUtils.beforeNow(user.getCreateTime().plusSeconds(30)); - } - - private void validateCanBindUser(BrokerageUserDO user, Long bindUserId) { - // 校验要绑定的用户有无推广资格 - BrokerageUserDO bindUser = brokerageUserMapper.selectById(bindUserId); - if (bindUser == null || BooleanUtil.isFalse(bindUser.getBrokerageEnabled())) { - throw exception(BROKERAGE_BIND_USER_NOT_ENABLED); - } - - // 校验绑定自己 - if (Objects.equals(user.getId(), bindUserId)) { - throw exception(BROKERAGE_BIND_SELF); - } - - // 下级不能绑定自己的上级 - for (int i = 0; i <= Short.MAX_VALUE; i++) { - if (Objects.equals(bindUser.getBindUserId(), user.getId())) { - throw exception(BROKERAGE_BIND_LOOP); - } - bindUser = getBrokerageUser(bindUser.getBindUserId()); - // 找到根节点,结束循环 - if (bindUser == null || bindUser.getBindUserId() == null) { - break; - } - } - } - - /** - * 根据绑定用户编号,获得下级用户编号列表 - * - * @param bindUserId 绑定用户编号 - * @param level 下级用户的层级。 - * 如果 level 为空,则查询 1+2 两个层级 - * @return 下级用户编号列表 - */ - private List getChildUserIdsByLevel(Long bindUserId, Integer level) { - if (bindUserId == null) { - return Collections.emptyList(); - } - // 先查第 1 级 - List bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId)); - if (CollUtil.isEmpty(bindUserIds)) { - return Collections.emptyList(); - } - - // 情况一:level 为空,查询所有级别 - if (level == null) { - // 再查第 2 级,并合并结果 - bindUserIds.addAll(brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds)); - return bindUserIds; - } - // 情况二:level 为 1,只查询第 1 级 - if (level == 1) { - return bindUserIds; - } - // 情况三:level 为 1,只查询第 2 级 - if (level == 2) { - return brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds); - } - throw exception(BROKERAGE_USER_LEVEL_NOT_SUPPORT); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java deleted file mode 100644 index 04ea9c49b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 佣金提现 Service 接口 - * - * @author 芋道源码 - */ -public interface BrokerageWithdrawService { - - /** - * 【管理员】审核佣金提现 - * - * @param id 佣金编号 - * @param status 审核状态 - * @param auditReason 驳回原因 - */ - void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason); - - /** - * 获得佣金提现 - * - * @param id 编号 - * @return 佣金提现 - */ - BrokerageWithdrawDO getBrokerageWithdraw(Integer id); - - /** - * 获得佣金提现分页 - * - * @param pageReqVO 分页查询 - * @return 佣金提现分页 - */ - PageResult getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO); - - /** - * 【会员】创建佣金提现 - * - * @param userId 会员用户编号 - * @param createReqVO 创建信息 - * @return 佣金提现编号 - */ - Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO); - - /** - * 按照 userId,汇总每个用户的提现 - * - * @param userIds 用户编号 - * @param status 提现状态 - * @return 用户提现汇总 List - */ - List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status); - - /** - * 按照 userId,汇总每个用户的提现 - * - * @param userIds 用户编号 - * @param status 提现状态 - * @return 用户提现汇总 Map - */ - default Map getWithdrawSummaryMapByUserId(Set userIds, - BrokerageWithdrawStatusEnum status) { - return convertMap(getWithdrawSummaryListByUserId(userIds, status), BrokerageWithdrawSummaryRespBO::getUserId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java deleted file mode 100644 index b6b4034ce..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 佣金提现 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { - - @Resource - private BrokerageWithdrawMapper brokerageWithdrawMapper; - - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private TradeConfigService tradeConfigService; - - @Resource - private NotifyMessageSendApi notifyMessageSendApi; - - @Resource - private Validator validator; - - @Override - @Transactional(rollbackFor = Exception.class) - public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason) { - // 1.1 校验存在 - BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); - // 1.2 校验状态为审核中 - if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) { - throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); - } - - // 2. 更新 - int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), - new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now())); - if (rows == 0) { - throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); - } - - String templateCode; - if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_APPROVE; - // 3.1 通过时佣金转余额 - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(withdraw.getType())) { - // todo 疯狂: - } - // TODO 疯狂:调用转账接口 - } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT; - // 3.2 驳回时需要退还用户佣金 - brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, - String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); - } else { - throw new IllegalArgumentException("不支持的提现状态:" + status); - } - - // 4. 通知用户 - Map templateParams = MapUtil.builder() - .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) - .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice())) - .put("reason", withdraw.getAuditReason()) - .build(); - notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() - .setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams)); - } - - private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { - BrokerageWithdrawDO withdraw = brokerageWithdrawMapper.selectById(id); - if (withdraw == null) { - throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS); - } - return withdraw; - } - - @Override - public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) { - return brokerageWithdrawMapper.selectById(id); - } - - @Override - public PageResult getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO) { - return brokerageWithdrawMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO) { - // 1.1 校验提现金额 - TradeConfigDO tradeConfig = validateWithdrawPrice(createReqVO.getPrice()); - // 1.2 校验提现参数 - createReqVO.validate(validator); - - // 2.1 计算手续费 - Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); - // 2.2 创建佣金提现记录 - BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); - brokerageWithdrawMapper.insert(withdraw); - - // 3. 创建用户佣金记录 - // 注意,佣金是否充足,reduceBrokerage 已经进行校验 - brokerageRecordService.reduceBrokerage(userId, BrokerageRecordBizTypeEnum.WITHDRAW, String.valueOf(withdraw.getId()), - createReqVO.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW.getTitle()); - return withdraw.getId(); - } - - @Override - public List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); - } - - /** - * 计算提现手续费 - * - * @param withdrawPrice 提现金额 - * @param percent 手续费百分比 - * @return 提现手续费 - */ - Integer calculateFeePrice(Integer withdrawPrice, Integer percent) { - Integer feePrice = 0; - if (percent != null && percent > 0) { - feePrice = MoneyUtils.calculateRatePrice(withdrawPrice, Double.valueOf(percent)); - } - return feePrice; - } - - /** - * 校验提现金额要求 - * - * @param withdrawPrice 提现金额 - * @return 分销配置 - */ - TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) { - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) { - throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, MoneyUtils.fenToYuanStr(tradeConfig.getBrokerageWithdrawMinPrice())); - } - return tradeConfig; - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java deleted file mode 100644 index 1b5de5431..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 佣金 增加 Request BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageAddReqBO { - - /** - * 业务编号 - */ - @NotBlank(message = "业务编号不能为空") - private String bizId; - /** - * 佣金基数 - */ - @NotNull(message = "佣金基数不能为空") - private Integer basePrice; - /** - * 一级佣金(固定) - */ - @NotNull(message = "一级佣金(固定)不能为空") - private Integer firstFixedPrice; - /** - * 二级佣金(固定) - */ - private Integer secondFixedPrice; - - /** - * 来源用户编号 - */ - @NotNull(message = "来源用户编号不能为空") - private Long sourceUserId; - - /** - * 佣金记录标题 - */ - @NotEmpty(message = "佣金记录标题不能为空") - private String title; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java deleted file mode 100644 index 1c3a3c991..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 佣金提现合计 BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageWithdrawSummaryRespBO { - - /** - * 用户编号 - */ - private Long userId; - - /** - * 提现次数 - */ - private Integer count; - /** - * 提现金额 - */ - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java deleted file mode 100644 index 3e677b96a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 用户佣金合计 BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserBrokerageSummaryRespBO { - - /** - * 用户编号 - */ - private Long userId; - /** - * 推广数量 - */ - private Integer count; - /** - * 佣金总额 - */ - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java deleted file mode 100644 index 6130614e0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 购物车 Service 接口 - * - * @author 芋道源码 - */ -public interface CartService { - - /** - * 添加商品到购物车 - * - * @param userId 用户编号 - * @param addReqVO 添加信息 - * @return 购物项的编号 - */ - Long addCart(Long userId, @Valid AppCartAddReqVO addReqVO); - - /** - * 更新购物车商品数量 - * - * @param userId 用户编号 - * @param updateCountReqVO 更新信息 - */ - void updateCartCount(Long userId, AppCartUpdateCountReqVO updateCountReqVO); - - /** - * 更新购物车选中状态 - * - * @param userId 用户编号 - * @param updateSelectedReqVO 更新信息 - */ - void updateCartSelected(Long userId, @Valid AppCartUpdateSelectedReqVO updateSelectedReqVO); - - /** - * 重置购物车商品 - * - * 使用场景:在一个购物车项对应的商品失效(例如说 SPU 被下架),可以重新选择对应的 SKU - * - * @param userId 用户编号 - * @param updateReqVO 重置信息 - */ - void resetCart(Long userId, AppCartResetReqVO updateReqVO); - - /** - * 删除购物车商品 - * - * @param userId 用户编号 - * @param ids 购物项的编号 - */ - void deleteCart(Long userId, Collection ids); - - /** - * 查询用户在购物车中的商品数量 - * - * @param userId 用户编号 - * @return 商品数量 - */ - Integer getCartCount(Long userId); - - /** - * 查询用户的购物车列表 - * - * @param userId 用户编号 - * @return 购物车列表 - */ - AppCartListRespVO getCartList(Long userId); - - /** - * 查询用户的购物车列表 - * - * @param userId 用户编号 - * @param ids 购物项的编号 - * @return 购物车列表 - */ - List getCartList(Long userId, Set ids); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java deleted file mode 100644 index e402aee3a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java +++ /dev/null @@ -1,196 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.convert.cart.TradeCartConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.mysql.cart.CartMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.CARD_ITEM_NOT_FOUND; -import static java.util.Collections.emptyList; - -/** - * 购物车 Service 实现类 - * - * // TODO 芋艿:未来优化:购物车的价格计算,支持营销信息;目前不支持的原因,前端界面需要前端 pr 支持下;例如说:会员价格; - * - * @author 芋道源码 - */ -@Service -@Validated -public class CartServiceImpl implements CartService { - - @Resource - private CartMapper cartMapper; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - public Long addCart(Long userId, AppCartAddReqVO addReqVO) { - // 查询 TradeCartDO - CartDO cart = cartMapper.selectByUserIdAndSkuId(userId, addReqVO.getSkuId()); - // 校验 SKU - Integer count = addReqVO.getCount(); - ProductSkuRespDTO sku = checkProductSku(addReqVO.getSkuId(), count); - - // 情况一:存在,则进行数量更新 - if (cart != null) { - cartMapper.updateById(new CartDO().setId(cart.getId()).setSelected(true) - .setCount(cart.getCount() + count)); - return cart.getId(); - // 情况二:不存在,则进行插入 - } else { - cart = new CartDO().setUserId(userId).setSelected(true) - .setSpuId(sku.getSpuId()).setSkuId(sku.getId()).setCount(count); - cartMapper.insert(cart); - } - return cart.getId(); - } - - @Override - public void updateCartCount(Long userId, AppCartUpdateCountReqVO updateReqVO) { - // 校验 TradeCartDO 存在 - CartDO cart = cartMapper.selectById(updateReqVO.getId(), userId); - if (cart == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - // 校验商品 SKU - checkProductSku(cart.getSkuId(), updateReqVO.getCount()); - - // 更新数量 - cartMapper.updateById(new CartDO().setId(cart.getId()) - .setCount(updateReqVO.getCount())); - } - - @Override - public void updateCartSelected(Long userId, AppCartUpdateSelectedReqVO updateSelectedReqVO) { - cartMapper.updateByIds(updateSelectedReqVO.getIds(), userId, - new CartDO().setSelected(updateSelectedReqVO.getSelected())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void resetCart(Long userId, AppCartResetReqVO resetReqVO) { - // 第一步:删除原本的购物项 - CartDO oldCart = cartMapper.selectById(resetReqVO.getId(), userId); - if (oldCart == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - cartMapper.deleteById(oldCart.getId()); - - // 第二步:添加新的购物项 - CartDO newCart = cartMapper.selectByUserIdAndSkuId(userId, resetReqVO.getSkuId()); - if (newCart != null) { - updateCartCount(userId, new AppCartUpdateCountReqVO() - .setId(newCart.getId()).setCount(resetReqVO.getCount())); - } else { - addCart(userId, new AppCartAddReqVO().setSkuId(resetReqVO.getSkuId()) - .setCount(resetReqVO.getCount())); - } - } - - /** - * 购物车删除商品 - * - * @param userId 用户编号 - * @param ids 商品 SKU 编号的数组 - */ - @Override - public void deleteCart(Long userId, Collection ids) { - // 查询 TradeCartDO 列表 - List carts = cartMapper.selectListByIds(ids, userId); - if (CollUtil.isEmpty(carts)) { - return; - } - - // 批量标记删除 - cartMapper.deleteBatchIds(ids); - } - - @Override - public Integer getCartCount(Long userId) { - // TODO 芋艿:需要算上 selected - return cartMapper.selectSumByUserId(userId); - } - - @Override - public AppCartListRespVO getCartList(Long userId) { - // 获得购物车的商品 - List carts = cartMapper.selectListByUserId(userId); - carts.sort(Comparator.comparing(CartDO::getId).reversed()); - // 如果未空,则返回空结果 - if (CollUtil.isEmpty(carts)) { - return new AppCartListRespVO().setValidList(emptyList()) - .setInvalidList(emptyList()); - } - - // 查询 SPU、SKU 列表 - List spus = productSpuApi.getSpuList(convertSet(carts, CartDO::getSpuId)).getCheckedData(); - List skus = productSkuApi.getSkuList(convertSet(carts, CartDO::getSkuId)).getCheckedData(); - - // 如果 SPU 被删除,则删除购物车对应的商品。延迟删除 - // 为什么不是 SKU 被删除呢?因为 SKU 被删除时,还可以通过 SPU 选择其它 SKU - deleteCartIfSpuDeleted(carts, spus); - - // 拼接数据 - return TradeCartConvert.INSTANCE.convertList(carts, spus, skus); - } - - @Override - public List getCartList(Long userId, Set ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return cartMapper.selectListByUserId(userId, ids); - } - - private void deleteCartIfSpuDeleted(List carts, List spus) { - // 如果 SPU 被删除,则删除购物车对应的商品。延迟删除 - carts.removeIf(cart -> { - if (spus.stream().noneMatch(spu -> spu.getId().equals(cart.getSpuId()))) { - cartMapper.deleteById(cart.getId()); - return true; - } - return false; - }); - } - - /** - * 校验商品 SKU 是否合法 - * 1. 是否存在 - * 2. 是否下架 - * 3. 库存不足 - * - * @param skuId 商品 SKU 编号 - * @param count 商品数量 - * @return 商品 SKU - */ - private ProductSkuRespDTO checkProductSku(Long skuId, Integer count) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId).getCheckedData(); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - return sku; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java deleted file mode 100644 index 1edb4f30b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.config; - -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; - -import javax.validation.Valid; - -/** - * 交易中心配置 Service 接口 - * - * @author owen - */ -public interface TradeConfigService { - - /** - * 更新交易中心配置 - * - * @param updateReqVO 更新信息 - */ - void saveTradeConfig(@Valid TradeConfigSaveReqVO updateReqVO); - - /** - * 获得交易中心配置 - * - * @return 交易中心配置 - */ - TradeConfigDO getTradeConfig(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java deleted file mode 100644 index c859cdee6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.config; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.config.TradeConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 交易中心配置 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeConfigServiceImpl implements TradeConfigService { - - @Resource - private TradeConfigMapper tradeConfigMapper; - - @Override - public void saveTradeConfig(TradeConfigSaveReqVO saveReqVO) { - // 存在,则进行更新 - TradeConfigDO dbConfig = getTradeConfig(); - if (dbConfig != null) { - tradeConfigMapper.updateById(TradeConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); - return; - } - // 不存在,则进行插入 - tradeConfigMapper.insert(TradeConfigConvert.INSTANCE.convert(saveReqVO)); - } - - @Override - public TradeConfigDO getTradeConfig() { - List list = tradeConfigMapper.selectList(); - return CollectionUtils.getFirst(list); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java deleted file mode 100644 index c504b3053..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 快递公司 Service 接口 - * - * @author jason - */ -public interface DeliveryExpressService { - - /** - * 创建快递公司 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryExpress(@Valid DeliveryExpressCreateReqVO createReqVO); - - /** - * 更新快递公司 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryExpress(@Valid DeliveryExpressUpdateReqVO updateReqVO); - - /** - * 删除快递公司 - * - * @param id 编号 - */ - void deleteDeliveryExpress(Long id); - - /** - * 获得快递公司 - * - * @param id 编号 - * @return 快递公司 - */ - DeliveryExpressDO getDeliveryExpress(Long id); - - /** - * 校验快递公司是否合法 - * - * @param id 编号 - * @return 快递公司 - */ - DeliveryExpressDO validateDeliveryExpress(Long id); - - /** - * 获得快递公司分页 - * - * @param pageReqVO 分页查询 - * @return 快递公司分页 - */ - PageResult getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO); - - /** - * 获得快递公司列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 快递公司列表 - */ - List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO); - - /** - * 获取指定状态的快递公司列表 - * - * @param status 状态 - * @return 快递公司列表 - */ - List getDeliveryExpressListByStatus(Integer status); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java deleted file mode 100644 index ec787af6d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 快递公司 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryExpressServiceImpl implements DeliveryExpressService { - - @Resource - private DeliveryExpressMapper deliveryExpressMapper; - - @Override - public Long createDeliveryExpress(DeliveryExpressCreateReqVO createReqVO) { - //校验编码是否唯一 - validateExpressCodeUnique(createReqVO.getCode(), null); - // 插入 - DeliveryExpressDO deliveryExpress = DeliveryExpressConvert.INSTANCE.convert(createReqVO); - deliveryExpressMapper.insert(deliveryExpress); - // 返回 - return deliveryExpress.getId(); - } - - @Override - public void updateDeliveryExpress(DeliveryExpressUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryExpressExists(updateReqVO.getId()); - //校验编码是否唯一 - validateExpressCodeUnique(updateReqVO.getCode(), updateReqVO.getId()); - // 更新 - DeliveryExpressDO updateObj = DeliveryExpressConvert.INSTANCE.convert(updateReqVO); - deliveryExpressMapper.updateById(updateObj); - } - - @Override - public void deleteDeliveryExpress(Long id) { - // 校验存在 - validateDeliveryExpressExists(id); - // 删除 - deliveryExpressMapper.deleteById(id); - } - - private void validateExpressCodeUnique(String code, Long id) { - DeliveryExpressDO express = deliveryExpressMapper.selectByCode(code); - if (express == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的快递公司 - if (id == null) { - throw exception(EXPRESS_CODE_DUPLICATE); - } - if (!express.getId().equals(id)) { - throw exception(EXPRESS_CODE_DUPLICATE); - } - } - private void validateDeliveryExpressExists(Long id) { - if (deliveryExpressMapper.selectById(id) == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - } - - @Override - public DeliveryExpressDO getDeliveryExpress(Long id) { - return deliveryExpressMapper.selectById(id); - } - - @Override - public DeliveryExpressDO validateDeliveryExpress(Long id) { - DeliveryExpressDO deliveryExpress = deliveryExpressMapper.selectById(id); - if (deliveryExpress == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(EXPRESS_STATUS_NOT_ENABLE); - } - return deliveryExpress; - } - - @Override - public PageResult getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) { - return deliveryExpressMapper.selectPage(pageReqVO); - } - - @Override - public List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO) { - return deliveryExpressMapper.selectList(exportReqVO); - } - - @Override - public List getDeliveryExpressListByStatus(Integer status) { - return deliveryExpressMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java deleted file mode 100644 index c455701b2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 快递运费模板 Service 接口 - * - * @author jason - */ -public interface DeliveryExpressTemplateService { - - /** - * 创建快递运费模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryExpressTemplate(@Valid DeliveryExpressTemplateCreateReqVO createReqVO); - - /** - * 更新快递运费模板 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryExpressTemplate(@Valid DeliveryExpressTemplateUpdateReqVO updateReqVO); - - /** - * 删除快递运费模板 - * - * @param id 编号 - */ - void deleteDeliveryExpressTemplate(Long id); - - /** - * 获得快递运费模板 - * - * @param id 编号 - * @return 快递运费模板详情 - */ - DeliveryExpressTemplateDetailRespVO getDeliveryExpressTemplate(Long id); - - /** - * 获得快递运费模板列表 - * - * @param ids 编号 - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(Collection ids); - - /** - * 获得快递运费模板列表 - * - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(); - - /** - * 获得快递运费模板分页 - * - * @param pageReqVO 分页查询 - * @return 快递运费模板分页 - */ - PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO); - - /** - * 校验快递运费模板 - * - * 如果校验不通过,抛出 {@link cn.iocoder.yudao.framework.common.exception.ServiceException} 异常 - * - * @param templateId 模板编号 - * @return 快递运费模板 - */ - DeliveryExpressTemplateDO validateDeliveryExpressTemplate(Long templateId); - - /** - * 基于运费模板编号数组和收件人地址区域编号,获取匹配运费模板 - * - * @param ids 编号列表 - * @param areaId 区域编号 - * @return Map (templateId -> 运费模板设置) - */ - Map getExpressTemplateMapByIdsAndArea(Collection ids, Integer areaId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java deleted file mode 100644 index 92e6d91ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateChargeMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateFreeMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateMapper; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert.INSTANCE; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_TEMPLATE_NAME_DUPLICATE; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_TEMPLATE_NOT_EXISTS; - -/** - * 快递运费模板 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTemplateService { - - @Resource - private DeliveryExpressTemplateMapper expressTemplateMapper; - @Resource - private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper; - @Resource - private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) { - // 校验模板名是否唯一 - validateTemplateNameUnique(createReqVO.getName(), null); - - // 插入 - DeliveryExpressTemplateDO template = INSTANCE.convert(createReqVO); - expressTemplateMapper.insert(template); - // 插入运费模板计费表 - if (CollUtil.isNotEmpty(createReqVO.getCharges())) { - expressTemplateChargeMapper.insertBatch( - INSTANCE.convertTemplateChargeList(template.getId(), createReqVO.getChargeMode(), createReqVO.getCharges()) - ); - } - // 插入运费模板包邮表 - if (CollUtil.isNotEmpty(createReqVO.getFrees())) { - expressTemplateFreeMapper.insertBatch( - INSTANCE.convertTemplateFreeList(template.getId(), createReqVO.getFrees()) - ); - } - return template.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryExpressTemplateExists(updateReqVO.getId()); - // 校验模板名是否唯一 - validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); - - // 更新运费从表 - updateExpressTemplateCharge(updateReqVO.getId(), updateReqVO.getChargeMode(), updateReqVO.getCharges()); - // 更新包邮从表 - updateExpressTemplateFree(updateReqVO.getId(), updateReqVO.getFrees()); - // 更新模板主表 - DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); - expressTemplateMapper.updateById(updateObj); - } - - private void updateExpressTemplateFree(Long templateId, List frees) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = expressTemplateFreeMapper.selectListByTemplateId(templateId); - List newList = INSTANCE.convertTemplateFreeList(templateId, frees); - List> diffList = CollectionUtils.diffList(oldList, newList, - (oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - expressTemplateFreeMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - expressTemplateFreeMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - expressTemplateFreeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateFreeDO::getId)); - } - } - - private void updateExpressTemplateCharge(Long templateId, Integer chargeMode, List charges) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = expressTemplateChargeMapper.selectListByTemplateId(templateId); - List newList = INSTANCE.convertTemplateChargeList(templateId, chargeMode, charges); - List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId()); - if (same) { - newVal.setChargeMode(chargeMode); // 更新下收费模式 - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - expressTemplateChargeMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - expressTemplateChargeMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - expressTemplateChargeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateChargeDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteDeliveryExpressTemplate(Long id) { - // 校验存在 - validateDeliveryExpressTemplateExists(id); - - // 删除主表 - expressTemplateMapper.deleteById(id); - // 删除运费从表 - expressTemplateChargeMapper.deleteByTemplateId(id); - // 删除包邮从表 - expressTemplateFreeMapper.deleteByTemplateId(id); - } - - /** - * 校验运费模板名是否唯一 - * - * @param name 模板名称 - * @param id 运费模板编号,可以为 null - */ - private void validateTemplateNameUnique(String name, Long id) { - DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name); - if (template == null) { - return; - } - // 如果 id 为空 - if (id == null) { - throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE); - } - if (!template.getId().equals(id)) { - throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE); - } - } - - private void validateDeliveryExpressTemplateExists(Long id) { - if (expressTemplateMapper.selectById(id) == null) { - throw exception(EXPRESS_TEMPLATE_NOT_EXISTS); - } - } - - @Override - public DeliveryExpressTemplateDetailRespVO getDeliveryExpressTemplate(Long id) { - List chargeList = expressTemplateChargeMapper.selectListByTemplateId(id); - List freeList = expressTemplateFreeMapper.selectListByTemplateId(id); - DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id); - return INSTANCE.convert(template, chargeList, freeList); - } - - @Override - public List getDeliveryExpressTemplateList(Collection ids) { - return expressTemplateMapper.selectBatchIds(ids); - } - - @Override - public List getDeliveryExpressTemplateList() { - return expressTemplateMapper.selectList(); - } - - @Override - public PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) { - return expressTemplateMapper.selectPage(pageReqVO); - } - - @Override - public DeliveryExpressTemplateDO validateDeliveryExpressTemplate(Long templateId) { - DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(templateId); - if (template == null) { - throw exception(EXPRESS_TEMPLATE_NOT_EXISTS); - } - return template; - } - - @Override - public Map getExpressTemplateMapByIdsAndArea(Collection ids, Integer areaId) { - Assert.notNull(areaId, "区域编号 {} 不能为空", areaId); - // 查询 template 数组 - if (CollUtil.isEmpty(ids)) { - return Collections.emptyMap(); - } - List templateList = expressTemplateMapper.selectBatchIds(ids); - // 查询 templateCharge 数组 - List chargeList = expressTemplateChargeMapper.selectByTemplateIds(ids); - // 查询 templateFree 数组 - List freeList = expressTemplateFreeMapper.selectListByTemplateIds(ids); - - // 组合运费模板配置 RespBO - return INSTANCE.convertMap(areaId, templateList, chargeList, freeList); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java deleted file mode 100644 index 8cfdb2220..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 自提门店 Service 接口 - * - * @author jason - */ -public interface DeliveryPickUpStoreService { - - /** - * 创建自提门店 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryPickUpStore(@Valid DeliveryPickUpStoreCreateReqVO createReqVO); - - /** - * 更新自提门店 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryPickUpStore(@Valid DeliveryPickUpStoreUpdateReqVO updateReqVO); - - /** - * 删除自提门店 - * - * @param id 编号 - */ - void deleteDeliveryPickUpStore(Long id); - - /** - * 获得自提门店 - * - * @param id 编号 - * @return 自提门店 - */ - DeliveryPickUpStoreDO getDeliveryPickUpStore(Long id); - - /** - * 获得自提门店列表 - * - * @param ids 编号 - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreList(Collection ids); - - /** - * 获得自提门店分页 - * - * @param pageReqVO 分页查询 - * @return 自提门店分页 - */ - PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); - - /** - * 获得指定状态的自提门店列表 - * - * @param status 状态 - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreListByStatus(Integer status); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java deleted file mode 100644 index 4e31839b8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; - -/** - * 自提门店 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreService { - - @Resource - private DeliveryPickUpStoreMapper deliveryPickUpStoreMapper; - - @Override - public Long createDeliveryPickUpStore(DeliveryPickUpStoreCreateReqVO createReqVO) { - // 插入 - DeliveryPickUpStoreDO deliveryPickUpStore = DeliveryPickUpStoreConvert.INSTANCE.convert(createReqVO); - deliveryPickUpStoreMapper.insert(deliveryPickUpStore); - // 返回 - return deliveryPickUpStore.getId(); - } - - @Override - public void updateDeliveryPickUpStore(DeliveryPickUpStoreUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryPickUpStoreExists(updateReqVO.getId()); - // 更新 - DeliveryPickUpStoreDO updateObj = DeliveryPickUpStoreConvert.INSTANCE.convert(updateReqVO); - deliveryPickUpStoreMapper.updateById(updateObj); - } - - @Override - public void deleteDeliveryPickUpStore(Long id) { - // 校验存在 - validateDeliveryPickUpStoreExists(id); - // 删除 - deliveryPickUpStoreMapper.deleteById(id); - } - - private void validateDeliveryPickUpStoreExists(Long id) { - if (deliveryPickUpStoreMapper.selectById(id) == null) { - throw exception(PICK_UP_STORE_NOT_EXISTS); - } - } - - @Override - public DeliveryPickUpStoreDO getDeliveryPickUpStore(Long id) { - return deliveryPickUpStoreMapper.selectById(id); - } - - @Override - public List getDeliveryPickUpStoreList(Collection ids) { - return deliveryPickUpStoreMapper.selectBatchIds(ids); - } - - @Override - public PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO) { - return deliveryPickUpStoreMapper.selectPage(pageReqVO); - } - - @Override - public List getDeliveryPickUpStoreListByStatus(Integer status) { - return deliveryPickUpStoreMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java deleted file mode 100644 index db0af04eb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery.bo; - -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import lombok.Data; - -/** - * 运费模板配置 Resp BO - * - * @author jason - */ -@Data -public class DeliveryExpressTemplateRespBO { - - /** - * 配送计费方式 - * - * 枚举 {@link DeliveryExpressChargeModeEnum} - */ - private Integer chargeMode; - - /** - * 运费模板快递运费设置 - */ - private Charge charge; - - /** - * 运费模板包邮设置 - */ - private Free free; - - /** - * 快递运费模板费用配置 BO - * - * @author jason - */ - @Data - public static class Charge { - - /** - * 首件数量(件数,重量,或体积) - */ - private Double startCount; - /** - * 起步价,单位:分 - */ - private Integer startPrice; - /** - * 续件数量(件, 重量,或体积) - */ - private Double extraCount; - /** - * 额外价,单位:分 - */ - private Integer extraPrice; - } - - /** - * 快递运费模板包邮配置 BO - * - * @author jason - */ - @Data - public static class Free { - - /** - * 包邮金额,单位:分 - * - * 订单总金额 > 包邮金额时,才免运费 - */ - private Integer freePrice; - - /** - * 包邮件数 - * - * 订单总件数 > 包邮件数时,才免运费 - */ - private Integer freeCount; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java deleted file mode 100644 index dce5faf0e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message; - -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; - -/** - * Trade 消息 service 接口 - * - * @author HUIHUI - */ -public interface TradeMessageService { - - /** - * 订单发货时发送通知 - * - * @param reqBO 发送消息 - */ - void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java deleted file mode 100644 index b9cdf9476..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message; - -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * Trade 消息 service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class TradeMessageServiceImpl implements TradeMessageService { - - @Resource - private NotifyMessageSendApi notifyMessageSendApi; - - @Override - public void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO) { - if (true) { - return; - } - // 1、构造消息 - Map msgMap = new HashMap<>(2); - msgMap.put("orderId", reqBO.getOrderId()); - msgMap.put("deliveryMessage", reqBO.getMessage()); - // TODO 芋艿:看下模版 - // 2、发送站内信 - notifyMessageSendApi.sendSingleMessageToMember( - new NotifySendSingleToUserReqDTO() - .setUserId(reqBO.getUserId()) - .setTemplateCode(MessageTemplateConstants.ORDER_DELIVERY) - .setTemplateParams(msgMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java deleted file mode 100644 index 7fe987391..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message.bo; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 订单发货时通知创建 Req BO - * - * @author HUIHUI - */ -@Data -public class TradeOrderMessageWhenDeliveryOrderReqBO { - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 消息 - */ - @NotEmpty(message = "发送消息不能为空") - private String message; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java deleted file mode 100644 index a08f01398..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.springframework.scheduling.annotation.Async; - -import java.util.List; - -/** - * 交易下单日志 Service 接口 - * - * @author 陈賝 - * @since 2023/7/6 15:44 - */ -public interface TradeOrderLogService { - - /** - * 创建交易下单日志 - * - * @param logDTO 日志记录 - * @author 陈賝 - * @since 2023/7/6 15:45 - */ - @Async - void createOrderLog(TradeOrderLogCreateReqBO logDTO); - - /** - * 获得交易订单日志列表 - * - * @param orderId 订单编号 - * @return 交易订单日志列表 - */ - List getOrderLogListByOrderId(Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java deleted file mode 100644 index 7c79c9fd4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderLogConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderLogMapper; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 交易下单日志 Service 实现类 - * - * @author 陈賝 - * @since 2023/7/6 15:44 - */ -@Service -public class TradeOrderLogServiceImpl implements TradeOrderLogService { - - @Resource - private TradeOrderLogMapper tradeOrderLogMapper; - - @Override - public void createOrderLog(TradeOrderLogCreateReqBO createReqBO) { - tradeOrderLogMapper.insert(TradeOrderLogConvert.INSTANCE.convert(createReqBO)); - } - - @Override - public List getOrderLogListByOrderId(Long orderId) { - return tradeOrderLogMapper.selectListByOrderId(orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java deleted file mode 100644 index 445792232..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ /dev/null @@ -1,158 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.Collection; -import java.util.List; - -import static java.util.Collections.singleton; - -/** - * 交易订单【读】 Service 接口 - * - * @author 芋道源码 - */ -public interface TradeOrderQueryService { - - // =================== Order =================== - - /** - * 获得指定编号的交易订单 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long id); - - /** - * 获得指定用户,指定的交易订单 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long userId, Long id); - - /** - * 获得指定用户,指定活动,指定状态的交易订单 - * - * @param userId 用户编号 - * @param combinationActivityId 活动编号 - * @param status 订单状态 - * @return 交易订单 - */ - TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status); - - /** - * 获得订单列表 - * - * @param ids 订单编号数组 - * @return 订单列表 - */ - List getOrderList(Collection ids); - - /** - * 【管理员】获得交易订单分页 - * - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(TradeOrderPageReqVO reqVO); - - /** - * 获得订单统计 - * - * @param reqVO 请求参数 - * @return 订单统计 - */ - TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单分页 - * - * @param userId 用户编号 - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单数量 - * - * @param userId 用户编号 - * @param status 订单状态。如果为空,则不进行筛选 - * @param commonStatus 评价状态。如果为空,则不进行筛选 - * @return 订单数量 - */ - Long getOrderCount(Long userId, Integer status, Boolean commonStatus); - - /** - * 【前台】获得订单的物流轨迹 - * - * @param id 订单编号 - * @param userId 用户编号 - * @return 物流轨迹数组 - */ - List getExpressTrackList(Long id, Long userId); - - /** - * 【后台】获得订单的物流轨迹 - * - * @param id 订单编号 - * @return 物流轨迹数组 - */ - List getExpressTrackList(Long id); - - /** - * 【会员】在指定秒杀活动下,用户购买的商品数量 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @return 秒杀商品数量 - */ - int getSeckillProductCount(Long userId, Long activityId); - - // =================== Order Item =================== - - /** - * 获得指定用户,指定的交易订单项 - * - * @param userId 用户编号 - * @param itemId 交易订单项编号 - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long userId, Long itemId); - - /** - * 获得交易订单项 - * - * @param id 交易订单项编号 itemId - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long id); - - /** - * 根据交易订单编号,查询交易订单项 - * - * @param orderId 交易订单编号 - * @return 交易订单项数组 - */ - default List getOrderItemListByOrderId(Long orderId) { - return getOrderItemListByOrderId(singleton(orderId)); - } - - /** - * 根据交易订单编号数组,查询交易订单项 - * - * @param orderIds 交易订单编号数组 - * @return 交易订单项数组 - */ - List getOrderItemListByOrderId(Collection orderIds); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java deleted file mode 100644 index ed5b712fa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ /dev/null @@ -1,260 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; - -/** - * 交易订单【读】 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { - - @Resource - private ExpressClientFactory expressClientFactory; - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private MemberUserApi memberUserApi; - - // =================== Order =================== - - @Override - public TradeOrderDO getOrder(Long id) { - return tradeOrderMapper.selectById(id); - } - - @Override - public TradeOrderDO getOrder(Long userId, Long id) { - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order != null - && ObjectUtil.notEqual(order.getUserId(), userId)) { - return null; - } - return order; - } - - @Override - public TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status) { - return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, combinationActivityId, status); - } - - @Override - public List getOrderList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return tradeOrderMapper.selectBatchIds(ids); - } - - @Override - public PageResult getOrderPage(TradeOrderPageReqVO reqVO) { - // 根据用户查询条件构建用户编号列表 - Set userIds = buildQueryConditionUserIds(reqVO); - if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 - return PageResult.empty(); - } - // 分页查询 - return tradeOrderMapper.selectPage(reqVO, userIds); - } - - private Set buildQueryConditionUserIds(TradeOrderPageReqVO reqVO) { - // 获得 userId 相关的查询 - Set userIds = new HashSet<>(); - if (StrUtil.isNotEmpty(reqVO.getUserMobile())) { - MemberUserRespDTO user = memberUserApi.getUserByMobile(reqVO.getUserMobile()).getCheckedData(); - if (user == null) { // 没查询到用户,说明肯定也没他的订单 - return null; - } - userIds.add(user.getId()); - } - if (StrUtil.isNotEmpty(reqVO.getUserNickname())) { - List users = memberUserApi.getUserListByNickname(reqVO.getUserNickname()).getCheckedData(); - if (CollUtil.isEmpty(users)) { // 没查询到用户,说明肯定也没他的订单 - return null; - } - userIds.addAll(convertSet(users, MemberUserRespDTO::getId)); - } - return userIds; - } - - @Override - public TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO) { - // 根据用户查询条件构建用户编号列表 - Set userIds = buildQueryConditionUserIds(reqVO); - if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 - return new TradeOrderSummaryRespVO(); - } - // 查询每个售后状态对应的数量、金额 - List> list = tradeOrderMapper.selectOrderSummaryGroupByRefundStatus(reqVO, null); - - TradeOrderSummaryRespVO vo = new TradeOrderSummaryRespVO().setAfterSaleCount(0L).setAfterSalePrice(0L); - for (Map map : list) { - Long count = MapUtil.getLong(map, "count", 0L); - Long price = MapUtil.getLong(map, "price", 0L); - // 未退款的计入订单,部分退款、全部退款计入售后 - if (TradeOrderRefundStatusEnum.NONE.getStatus().equals(MapUtil.getInt(map, "refundStatus"))) { - vo.setOrderCount(count).setOrderPayPrice(price); - } else { - vo.setAfterSaleCount(vo.getAfterSaleCount() + count).setAfterSalePrice(vo.getAfterSalePrice() + price); - } - } - return vo; - } - - @Override - public PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO) { - return tradeOrderMapper.selectPage(reqVO, userId); - } - - @Override - public Long getOrderCount(Long userId, Integer status, Boolean commentStatus) { - return tradeOrderMapper.selectCountByUserIdAndStatus(userId, status, commentStatus); - } - - @Override - public List getExpressTrackList(Long id, Long userId) { - // 查询订单 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 查询物流 - return getExpressTrackList(order); - } - - @Override - public List getExpressTrackList(Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 查询物流 - return getExpressTrackList(order); - } - - @Override - public int getSeckillProductCount(Long userId, Long activityId) { - // 获得订单列表 - List orders = tradeOrderMapper.selectListByUserIdAndSeckillActivityId(userId, activityId); - orders.removeIf(order -> TradeOrderStatusEnum.isCanceled(order.getStatus())); // 过滤掉【已取消】的订单 - if (CollUtil.isEmpty(orders)) { - return 0; - } - // 获得订单项列表 - return tradeOrderItemMapper.selectProductSumByOrderId(convertSet(orders, TradeOrderDO::getId)); - } - - /** - * 获得订单的物流轨迹 - * - * @param order 订单 - * @return 物流轨迹 - */ - private List getExpressTrackList(TradeOrderDO order) { - if (order.getLogisticsId() == null) { - return Collections.emptyList(); - } - // 查询物流公司 - DeliveryExpressDO express = deliveryExpressService.getDeliveryExpress(order.getLogisticsId()); - if (express == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - // 查询物流轨迹 - return getSelf().getExpressTrackList(express.getCode(), order.getLogisticsNo(), order.getReceiverMobile()); - } - - /** - * 查询物流轨迹 - * - * 缓存的目的:考虑及时性要求不高,但是每次调用需要钱 - * - * @param code 快递公司编码 - * @param logisticsNo 发货快递单号 - * @param receiverMobile 收、寄件人的电话号码 - * @return 物流轨迹 - */ - @Cacheable(cacheNames = RedisKeyConstants.EXPRESS_TRACK, key = "#code + '-' + #logisticsNo + '-' + #receiverMobile", - condition = "#result != null") - public List getExpressTrackList(String code, String logisticsNo, String receiverMobile) { - return expressClientFactory.getDefaultExpressClient().getExpressTrackList( - new ExpressTrackQueryReqDTO().setExpressCode(code).setLogisticsNo(logisticsNo) - .setPhone(receiverMobile)); - } - - - // =================== Order Item =================== - - @Override - public TradeOrderItemDO getOrderItem(Long userId, Long itemId) { - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(itemId); - if (orderItem != null - && ObjectUtil.notEqual(orderItem.getUserId(), userId)) { - return null; - } - return orderItem; - } - - @Override - public TradeOrderItemDO getOrderItem(Long id) { - return tradeOrderItemMapper.selectById(id); - } - - @Override - public List getOrderItemListByOrderId(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return tradeOrderItemMapper.selectListByOrderId(orderIds); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private TradeOrderQueryServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java deleted file mode 100644 index 9f3c6cf93..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ /dev/null @@ -1,199 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; - -import javax.validation.constraints.NotNull; - -/** - * 交易订单【写】Service 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface TradeOrderUpdateService { - - // =================== Order =================== - - /** - * 获得订单结算信息 - * - * @param userId 登录用户 - * @param settlementReqVO 订单结算请求 - * @return 订单结算结果 - */ - AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO); - - /** - * 【会员】创建交易订单 - * - * @param userId 登录用户 - * @param createReqVO 创建交易订单请求模型 - * @return 交易订单的 - */ - TradeOrderDO createOrder(Long userId, AppTradeOrderCreateReqVO createReqVO); - - /** - * 更新交易订单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - */ - void updateOrderPaid(Long id, Long payOrderId); - - /** - * 【管理员】发货交易订单 - * - * @param deliveryReqVO 发货请求 - */ - void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO); - - /** - * 【会员】收货交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void receiveOrderByMember(Long userId, Long id); - - /** - * 【系统】自动收货交易订单 - * - * @return 收货数量 - */ - int receiveOrderBySystem(); - - /** - * 【会员】取消交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void cancelOrderByMember(Long userId, Long id); - - /** - * 【系统】自动取消订单 - * - * @return 取消数量 - */ - int cancelOrderBySystem(); - - /** - * 【会员】删除订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void deleteOrder(Long userId, Long id); - - /** - * 【管理员】交易订单备注 - * - * @param reqVO 请求 - */ - void updateOrderRemark(TradeOrderRemarkReqVO reqVO); - - /** - * 【管理员】调整价格 - * - * @param reqVO 请求 - */ - void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO); - - /** - * 【管理员】调整地址 - * - * @param reqVO 请求 - */ - void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO); - - /** - * 【管理员】核销订单 - * - * @param id 订单编号 - */ - void pickUpOrderByAdmin(Long id); - - /** - * 【管理员】核销订单 - * - * @param pickUpVerifyCode 自提核销码 - */ - void pickUpOrderByAdmin(String pickUpVerifyCode); - - /** - * 【管理员】根据自提核销码,查询订单 - * - * @param pickUpVerifyCode 自提核销码 - */ - TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode); - - // =================== Order Item =================== - - /** - * 当售后申请后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param afterSaleId 售后单编号 - */ - void updateOrderItemWhenAfterSaleCreate(@NotNull Long id, @NotNull Long afterSaleId); - - /** - * 当售后完成后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param refundPrice 退款金额 - */ - void updateOrderItemWhenAfterSaleSuccess(@NotNull Long id, @NotNull Integer refundPrice); - - /** - * 当售后取消(用户取消、管理员驳回、管理员拒绝收货)后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - */ - void updateOrderItemWhenAfterSaleCancel(@NotNull Long id); - - /** - * 【会员】创建订单项的评论 - * - * @param userId 用户编号 - * @param createReqVO 创建请求 - * @return 得到评价 id - */ - Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO); - - /** - * 【系统】创建订单项的评论 - * - * @return 被评论的订单数 - */ - int createOrderItemCommentBySystem(); - - /** - * 更新拼团相关信息到订单 - * - * @param orderId 订单编号 - * @param activityId 拼团活动编号 - * @param combinationRecordId 拼团记录编号 - * @param headId 团长编号 - */ - void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId); - - // TODO 芋艿:拼团取消,不调这个接口哈; - /** - * 取消支付订单 - * - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void cancelPaidOrder(Long userId, Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java deleted file mode 100644 index 2b7b4596f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ /dev/null @@ -1,903 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.*; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; -import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils; -import cn.iocoder.yudao.module.trade.service.cart.CartService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.message.TradeMessageService; -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; -import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler; -import cn.iocoder.yudao.module.trade.service.price.TradePriceService; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.minusTime; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getTerminal; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 交易订单【写】Service 实现类 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Service -@Slf4j -public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - @Resource - private TradeNoRedisDAO tradeNoRedisDAO; - - @Resource - private List tradeOrderHandlers; - - @Resource - private CartService cartService; - @Resource - private TradePriceService tradePriceService; - @Resource - private DeliveryExpressService deliveryExpressService; - @Resource - private TradeMessageService tradeMessageService; - - @Resource - private PayOrderApi payOrderApi; - @Resource - private MemberAddressApi addressApi; - @Resource - private ProductCommentApi productCommentApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - // =================== Order =================== - - @Override - public AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) { - // 1. 获得收货地址 - MemberAddressRespDTO address = getAddress(userId, settlementReqVO.getAddressId()); - if (address != null) { - settlementReqVO.setAddressId(address.getId()); - } - - // 2. 计算价格 - TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, settlementReqVO); - - // 3. 拼接返回 - return TradeOrderConvert.INSTANCE.convert(calculateRespBO, address); - } - - /** - * 获得用户地址 - * - * @param userId 用户编号 - * @param addressId 地址编号 - * @return 地址 - */ - private MemberAddressRespDTO getAddress(Long userId, Long addressId) { - if (addressId != null) { - return addressApi.getAddress(addressId, userId).getCheckedData(); - } - return addressApi.getDefaultAddress(userId).getCheckedData(); - } - - /** - * 计算订单价格 - * - * @param userId 用户编号 - * @param settlementReqVO 结算信息 - * @return 订单价格 - */ - private TradePriceCalculateRespBO calculatePrice(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) { - // 1. 如果来自购物车,则获得购物车的商品 - List cartList = cartService.getCartList(userId, - convertSet(settlementReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCartId)); - - // 2. 计算价格 - TradePriceCalculateReqBO calculateReqBO = TradeOrderConvert.INSTANCE.convert(userId, settlementReqVO, cartList); - calculateReqBO.getItems().forEach(item -> Assert.isTrue(item.getSelected(), // 防御性编程,保证都是选中的 - "商品({}) 未设置为选中", item.getSkuId())); - return tradePriceService.calculatePrice(calculateReqBO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE) - public TradeOrderDO createOrder(Long userId, AppTradeOrderCreateReqVO createReqVO) { - // 1.1 价格计算 - TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO); - // 1.2 构建订单 - TradeOrderDO order = buildTradeOrder(userId, createReqVO, calculateRespBO); - List orderItems = buildTradeOrderItems(order, calculateRespBO); - - // 2. 订单创建前的逻辑 - tradeOrderHandlers.forEach(handler -> handler.beforeOrderCreate(order, orderItems)); - - // 3. 保存订单 - tradeOrderMapper.insert(order); - orderItems.forEach(orderItem -> orderItem.setOrderId(order.getId())); - tradeOrderItemMapper.insertBatch(orderItems); - - // 4. 订单创建后的逻辑 - afterCreateTradeOrder(order, orderItems, createReqVO); - return order; - } - - private TradeOrderDO buildTradeOrder(Long userId, AppTradeOrderCreateReqVO createReqVO, - TradePriceCalculateRespBO calculateRespBO) { - TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, createReqVO, calculateRespBO); - order.setType(calculateRespBO.getType()); - order.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX)); - order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); - order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); - order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); - order.setUserIp(getClientIP()).setTerminal(getTerminal()); - // 支付 + 退款信息 - order.setAdjustPrice(0).setPayStatus(false); - order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); - // 物流信息 - order.setDeliveryType(createReqVO.getDeliveryType()); - if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) { - MemberAddressRespDTO address = addressApi.getAddress(createReqVO.getAddressId(), userId).getCheckedData(); - Assert.notNull(address, "地址({}) 不能为空", createReqVO.getAddressId()); // 价格计算时,已经计算 - order.setReceiverName(address.getName()).setReceiverMobile(address.getMobile()) - .setReceiverAreaId(address.getAreaId()).setReceiverDetailAddress(address.getDetailAddress()); - } else if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.PICK_UP.getType())) { - order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile()); - order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码,长度为 8 位 - } - return order; - } - - private List buildTradeOrderItems(TradeOrderDO tradeOrderDO, - TradePriceCalculateRespBO calculateRespBO) { - return TradeOrderConvert.INSTANCE.convertList(tradeOrderDO, calculateRespBO); - } - - /** - * 订单创建后,执行后置逻辑 - *

- * 例如说:优惠劵的扣减、积分的扣减、支付单的创建等等 - * - * @param order 订单 - * @param orderItems 订单项 - * @param createReqVO 创建订单请求 - */ - private void afterCreateTradeOrder(TradeOrderDO order, List orderItems, - AppTradeOrderCreateReqVO createReqVO) { - // 1. 执行订单创建后置处理器 - tradeOrderHandlers.forEach(handler -> handler.afterOrderCreate(order, orderItems)); - - // 2. 删除购物车商品 - Set cartIds = convertSet(createReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCartId); - if (CollUtil.isNotEmpty(cartIds)) { - cartService.deleteCart(order.getUserId(), cartIds); - } - - // 3. 生成预支付 - createPayOrder(order, orderItems); - - // 4. 插入订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus()); - - // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! - } - - private void createPayOrder(TradeOrderDO order, List orderItems) { - // 创建支付单,用于后续的支付 - PayOrderCreateReqDTO payOrderCreateReqDTO = TradeOrderConvert.INSTANCE.convert( - order, orderItems, tradeOrderProperties); - Long payOrderId = payOrderApi.createOrder(payOrderCreateReqDTO).getCheckedData(); - - // 更新到交易单上 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setPayOrderId(payOrderId)); - order.setPayOrderId(payOrderId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_PAY) - public void updateOrderPaid(Long id, Long payOrderId) { - // 1. 校验并获得交易订单(可支付) - KeyValue orderResult = validateOrderPayable(id, payOrderId); - TradeOrderDO order = orderResult.getKey(); - PayOrderRespDTO payOrder = orderResult.getValue(); - - // 2. 更新 TradeOrderDO 状态为已支付,等待发货 - int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true) - .setPayTime(LocalDateTime.now()).setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // 3. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - tradeOrderHandlers.forEach(handler -> handler.afterPayOrder(order, orderItems)); - - // 4. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus()); - TradeOrderLogUtils.setUserInfo(order.getUserId(), UserTypeEnum.MEMBER.getValue()); - } - - /** - * 校验交易订单满足被支付的条件 - *

- * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private KeyValue validateOrderPayable(Long id, Long payOrderId) { - // 校验订单是否存在 - TradeOrderDO order = validateOrderExists(id); - // 校验订单未支付 - if (!TradeOrderStatusEnum.isUnpaid(order.getStatus()) || order.getPayStatus()) { - log.error("[validateOrderPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 校验支付订单匹配 - if (ObjectUtil.notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId).getCheckedData(); - if (payOrder == null) { - log.error("[validateOrderPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(ORDER_NOT_FOUND); - } - // 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 校验支付金额一致 - if (ObjectUtil.notEqual(payOrder.getPrice(), order.getPayPrice())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order), JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 校验支付订单匹配(二次) - if (ObjectUtil.notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return new KeyValue<>(order, payOrder); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_DELIVERY) - public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { - // 1.1 校验并获得交易订单(可发货) - TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); - // 1.2 校验 deliveryType 是否为快递,是快递才可以发货 - if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) { - throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); - } - - // 2. 更新订单为已发货 - TradeOrderDO updateOrderObj = new TradeOrderDO(); - // 2.1 快递发货 - DeliveryExpressDO express = null; - if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) { - express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); - } else { - // 2.2 无需发货 - updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); - } - // 执行更新 - updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); - if (updateCount == 0) { - throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); - } - - // 3. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(), - MapUtil.builder().put("expressName", express != null ? express.getName() : "") - .put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build()); - - // 4. 发送站内信 - tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO() - .setOrderId(order.getId()).setUserId(order.getUserId()).setMessage(null)); - } - - /** - * 校验交易订单满足被发货的条件 - *

- * 1. 交易订单未发货 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderDeliverable(Long id) { - TradeOrderDO order = validateOrderExists(id); - // 1. 校验订单是否未发货 - if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) { - throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE); - } - - // 2. 执行 TradeOrderHandler 前置处理 - tradeOrderHandlers.forEach(handler -> handler.beforeDeliveryOrder(order)); - return order; - } - - @NotNull - private TradeOrderDO validateOrderExists(Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_RECEIVE) - public void receiveOrderByMember(Long userId, Long id) { - // 校验并获得交易订单(可收货) - TradeOrderDO order = validateOrderReceivable(userId, id); - - // 收货订单 - receiveOrder0(order); - } - - @Override - public int receiveOrderBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getReceiveExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndDeliveryTimeLt( - TradeOrderStatusEnum.DELIVERED.getStatus(), expireTime); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().receiveOrderBySystem(order); - count++; - } catch (Throwable e) { - log.error("[receiveOrderBySystem][order({}) 自动收货订单异常]", order.getId(), e); - } - } - return count; - } - - /** - * 自动收货单个订单 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_RECEIVE) - public void receiveOrderBySystem(TradeOrderDO order) { - receiveOrder0(order); - } - - /** - * 收货订单的核心实现 - * - * @param order 订单 - */ - private void receiveOrder0(TradeOrderDO order) { - // 更新 TradeOrderDO 状态为已完成 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - - // 插入订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus()); - } - - /** - * 校验交易订单满足可售货的条件 - *

- * 1. 交易订单待收货 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderReceivable(Long userId, Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 校验订单是否是待收货状态 - if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL) - public void cancelOrderByMember(Long userId, Long id) { - // 1.1 校验存在 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 1.2 校验状态 - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) { - throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID); - } - - // 2. 取消订单 - cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); - } - - @Override - public int cancelOrderBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getPayExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndCreateTimeLt( - TradeOrderStatusEnum.UNPAID.getStatus(), expireTime); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().cancelOrderBySystem(order); - count++; - } catch (Throwable e) { - log.error("[cancelOrderBySystem][order({}) 过期订单异常]", order.getId(), e); - } - } - return count; - } - - /** - * 自动取消单个订单 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL) - public void cancelOrderBySystem(TradeOrderDO order) { - cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT); - } - - /** - * 取消订单的核心实现 - * - * @param order 订单 - * @param cancelType 取消类型 - */ - private void cancelOrder0(TradeOrderDO order, TradeOrderCancelTypeEnum cancelType) { - // 1. 更新 TradeOrderDO 状态为已取消 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.CANCELED.getStatus()) - .setCancelType(cancelType.getType()).setCancelTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID); - } - - // 2. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems)); - - // 3. 增加订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus()); - } - - /** - * 如果金额全部被退款,则取消订单 - * 如果还有未被退款的金额,则无需取消订单 - * - * @param order 订单 - * @param refundPrice 退款金额 - */ - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_CANCEL_AFTER_SALE) - public void cancelOrderByAfterSale(TradeOrderDO order, Integer refundPrice) { - // 1. 更新订单 - if (refundPrice < order.getPayPrice()) { - return; - } - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setStatus(TradeOrderStatusEnum.CANCELED.getStatus()) - .setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now())); - - // 2. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_DELETE) - public void deleteOrder(Long userId, Long id) { - // 1.1 校验存在 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 1.2 校验状态 - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus())) { - throw exception(ORDER_DELETE_FAIL_STATUS_NOT_CANCEL); - } - // 2. 删除订单 - tradeOrderMapper.deleteById(id); - - // 3. 记录日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - @Override - public void updateOrderRemark(TradeOrderRemarkReqVO reqVO) { - // 校验并获得交易订单 - validateOrderExists(reqVO.getId()); - - // 更新 - TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO); - tradeOrderMapper.updateById(order); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_PRICE) - public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) { - // 1.1 校验交易订单 - TradeOrderDO order = validateOrderExists(reqVO.getId()); - if (order.getPayStatus()) { - throw exception(ORDER_UPDATE_PRICE_FAIL_PAID); - } - // 1.2 校验调价金额是否变化 - if (order.getAdjustPrice() > 0) { - throw exception(ORDER_UPDATE_PRICE_FAIL_ALREADY); - } - // 1.3 支付价格不能为 0 - int newPayPrice = order.getPayPrice() + reqVO.getAdjustPrice(); - if (newPayPrice <= 0) { - throw exception(ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR); - } - - // 2. 更新订单 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setAdjustPrice(reqVO.getAdjustPrice() + order.getAdjustPrice()).setPayPrice(newPayPrice)); - - // 3. 更新 TradeOrderItem,需要做 adjustPrice 的分摊 - List orderOrderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - List dividePrices = TradePriceCalculatorHelper.dividePrice2(orderOrderItems, reqVO.getAdjustPrice()); - List updateItems = new ArrayList<>(); - for (int i = 0; i < orderOrderItems.size(); i++) { - TradeOrderItemDO item = orderOrderItems.get(i); - updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(item.getAdjustPrice() + dividePrices.get(i)) - .setPayPrice((item.getPayPrice() - item.getAdjustPrice()) + dividePrices.get(i))); - } - tradeOrderItemMapper.updateBatch(updateItems); - - // 4. 更新支付订单 - payOrderApi.updatePayOrderPrice(order.getPayOrderId(), newPayPrice); - - // 5. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(), - MapUtil.builder().put("oldPayPrice", MoneyUtils.fenToYuanStr(order.getPayPrice())) - .put("adjustPrice", MoneyUtils.fenToYuanStr(reqVO.getAdjustPrice())) - .put("newPayPrice", MoneyUtils.fenToYuanStr(newPayPrice)).build()); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS) - public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { - // 校验交易订单 - TradeOrderDO order = validateOrderExists(reqVO.getId()); - // 只有待发货状态,才可以修改订单收货地址; - if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { - throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED); - } - - // 更新 - tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO)); - - // 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(Long id) { - getSelf().pickUpOrder(tradeOrderMapper.selectById(id)); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(String pickUpVerifyCode) { - getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); - } - - @Override - public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) { - return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode); - } - - @Transactional(rollbackFor = Exception.class) - public void pickUpOrder(TradeOrderDO order) { - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) { - throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP); - } - receiveOrder0(order); - } - - // =================== Order Item =================== - - @Override - public void updateOrderItemWhenAfterSaleCreate(Long id, Long afterSaleId) { - // 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), afterSaleId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateOrderItemWhenAfterSaleSuccess(Long id, Integer refundPrice) { - // 1.1 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), null); - // 1.2 执行 TradeOrderHandler 的后置处理 - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(id); - TradeOrderDO order = tradeOrderMapper.selectById(orderItem.getOrderId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrderItem(order, orderItem)); - - // 2.1 更新订单的退款金额、积分 - Integer orderRefundPrice = order.getRefundPrice() + refundPrice; - Integer orderRefundPoint = order.getRefundPoint() + orderItem.getUsePoint(); - Integer refundStatus = isAllOrderItemAfterSaleSuccess(order.getId()) ? - TradeOrderRefundStatusEnum.ALL.getStatus() // 如果都售后成功,则需要取消订单 - : TradeOrderRefundStatusEnum.PART.getStatus(); - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setRefundStatus(refundStatus) - .setRefundPrice(orderRefundPrice).setRefundPoint(orderRefundPoint)); - // 2.2 如果全部退款,则进行取消订单 - getSelf().cancelOrderByAfterSale(order, orderRefundPrice); - } - - @Override - public void updateOrderItemWhenAfterSaleCancel(Long id) { - // 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null); - } - - private void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, - Long afterSaleId) { - // 更新订单项 - int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, afterSaleId); - if (updateCount <= 0) { - throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL); - } - - } - - /** - * 判断指定订单的所有订单项,是不是都售后成功 - * - * @param id 订单编号 - * @return 是否都售后成功 - */ - private boolean isAllOrderItemAfterSaleSuccess(Long id) { - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - return orderItems.stream().allMatch(orderItem -> Objects.equals(orderItem.getAfterSaleStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_COMMENT) - public Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO) { - // 1.1 先通过订单项 ID,查询订单项是否存在 - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectByIdAndUserId(createReqVO.getOrderItemId(), userId); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - // 1.2 校验订单相关状态 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderItem.getOrderId(), userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) { - throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED); - } - if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) { - throw exception(ORDER_COMMENT_STATUS_NOT_FALSE); - } - - // 2. 创建评价 - Long commentId = createOrderItemComment0(orderItem, createReqVO); - - // 3. 如果订单项都评论了,则更新订单评价状态 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) { - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE) - .setFinishTime(LocalDateTime.now())); - // 增加订单日志。注意:只有在所有订单项都评价后,才会增加 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - return commentId; - } - - @Override - public int createOrderItemCommentBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getCommentExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndReceiveTimeLt( - TradeOrderStatusEnum.COMPLETED.getStatus(), expireTime, false); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().createOrderItemCommentBySystemBySystem(order); - count++; - } catch (Throwable e) { - log.error("[createOrderItemCommentBySystem][order({}) 过期订单异常]", order.getId(), e); - } - } - return count; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) { - tradeOrderMapper.updateById( - new TradeOrderDO().setId(orderId).setCombinationActivityId(activityId) - .setCombinationRecordId(combinationRecordId).setCombinationHeadId(headId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelPaidOrder(Long userId, Long orderId) { - // TODO 芋艿:这里实现要优化下; - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); - } - - /** - * 创建单个订单的评论 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_COMMENT) - public void createOrderItemCommentBySystemBySystem(TradeOrderDO order) { - // 1. 查询未评论的订单项 - List orderItems = tradeOrderItemMapper.selectListByOrderIdAndCommentStatus( - order.getId(), Boolean.FALSE); - if (CollUtil.isEmpty(orderItems)) { - return; - } - - // 2. 逐个评论 - for (TradeOrderItemDO orderItem : orderItems) { - // 2.1 创建评价 - AppTradeOrderItemCommentCreateReqVO commentCreateReqVO = new AppTradeOrderItemCommentCreateReqVO() - .setOrderItemId(orderItem.getId()).setAnonymous(false).setContent("") - .setBenefitScores(5).setDescriptionScores(5); - createOrderItemComment0(orderItem, commentCreateReqVO); - - // 2.2 更新订单项评价状态 - tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); - } - - // 3. 所有订单项都评论了,则更新订单评价状态 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE) - .setFinishTime(LocalDateTime.now())); - // 增加订单日志。注意:只有在所有订单项都评价后,才会增加 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - /** - * 创建订单项的评论的核心实现 - * - * @param orderItem 订单项 - * @param createReqVO 评论内容 - * @return 评论编号 - */ - private Long createOrderItemComment0(TradeOrderItemDO orderItem, AppTradeOrderItemCommentCreateReqVO createReqVO) { - // 1. 创建评价 - ProductCommentCreateReqDTO productCommentCreateReqDTO = TradeOrderConvert.INSTANCE.convert04(createReqVO, orderItem); - Long commentId = productCommentApi.createComment(productCommentCreateReqDTO).getCheckedData(); - - // 2. 更新订单项评价状态 - tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); - return commentId; - } - - // =================== 营销相关的操作 =================== - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private TradeOrderUpdateServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java deleted file mode 100644 index e0a9e1e02..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.bo; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 订单日志的创建 Request BO - * - * @author 陈賝 - * @since 2023/7/6 15:27 - */ -@Data -public class TradeOrderLogCreateReqBO { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - @NotNull(message = "操作后的状态不能为空") - private Integer afterStatus; - - /** - * 操作类型 - */ - @NotNull(message = "操作类型不能为空") - private Integer operateType; - /** - * 操作明细 - */ - @NotEmpty(message = "操作明细不能为空") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java deleted file mode 100644 index 9af7be670..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainActivityApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 砍价订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeBargainOrderHandler implements TradeOrderHandler { - - @Resource - private BargainActivityApi bargainActivityApi; - @Resource - private BargainRecordApi bargainRecordApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 扣减砍价活动的库存 - bargainActivityApi.updateBargainActivityStock(order.getBargainActivityId(), - -orderItems.get(0).getCount()); - } - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 记录砍价记录对应的订单编号 - bargainRecordApi.updateBargainRecordOrderId(order.getBargainRecordId(), order.getId()); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - afterCancelOrderItem(order, orderItems.get(0)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 恢复(增加)砍价活动的库存 - bargainActivityApi.updateBargainActivityStock(order.getBargainActivityId(), orderItem.getCount()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java deleted file mode 100644 index 930ed2160..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * 订单分销的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeBrokerageOrderHandler implements TradeOrderHandler { - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageUserService brokerageUserService; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - // 设置订单推广人 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); - if (brokerageUser != null && brokerageUser.getBindUserId() != null) { - order.setBrokerageUserId(brokerageUser.getBindUserId()); - } - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - if (order.getBrokerageUserId() == null) { - return; - } - addBrokerage(order.getUserId(), orderItems); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 如果是未支付的订单,不会产生分销结果,所以直接 return - if (!order.getPayStatus()) { - return; - } - if (order.getBrokerageUserId() == null) { - return; - } - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - orderItems.forEach(orderItem -> afterCancelOrderItem(order, orderItem)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (order.getBrokerageUserId() == null) { - return; - } - cancelBrokerage(order.getBrokerageUserId(), orderItem.getId()); - } - - /** - * 创建分销记录 - *

- * 目前是支付成功后,就会创建分销记录。 - *

- * 业内还有两种做法,可以根据自己的业务调整: - * 1. 确认收货后,才创建分销记录 - * 2. 支付 or 下单成功时,创建分销记录(冻结),确认收货解冻或者 n 天后解冻 - * - * @param userId 用户编号 - * @param orderItems 订单项 - */ - protected void addBrokerage(Long userId, List orderItems) { - MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData(); - Assert.notNull(user); - ProductSpuRespDTO spu = productSpuApi.getSpu(orderItems.get(0).getSpuId()).getCheckedData(); - Assert.notNull(spu); - ProductSkuRespDTO sku = productSkuApi.getSku(orderItems.get(0).getSkuId()).getCheckedData(); - - // 每一个订单项,都会去生成分销记录 - List addList = convertList(orderItems, - item -> TradeOrderConvert.INSTANCE.convert(user, item, spu, sku)); - brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList); - } - - protected void cancelBrokerage(Long userId, Long orderItemId) { - brokerageRecordService.cancelBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, String.valueOf(orderItemId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java deleted file mode 100644 index 435b6e7ae..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_CREATE_FAIL_EXIST_UNPAID; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS; - -/** - * 拼团订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeCombinationOrderHandler implements TradeOrderHandler { - - @Resource - private TradeOrderUpdateService orderUpdateService; - @Resource - private TradeOrderQueryService orderQueryService; - - @Resource - private CombinationRecordApi combinationRecordApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - // 如果不是拼团订单则结束 - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - Assert.isTrue(orderItems.size() == 1, "拼团时,只允许选择一个商品"); - - // 1. 校验是否满足拼团活动相关限制 - TradeOrderItemDO item = orderItems.get(0); - combinationRecordApi.validateCombinationRecord(order.getUserId(), order.getCombinationActivityId(), - order.getCombinationHeadId(), item.getSkuId(), item.getCount()); - - // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 - TradeOrderDO activityOrder = orderQueryService.getOrderByUserIdAndStatusAndCombination( - order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); - if (activityOrder != null) { - throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); - } - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - // 1.如果不是拼团订单则结束 - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - Assert.isTrue(orderItems.size() == 1, "拼团时,只允许选择一个商品"); - - // 2. 创建拼团记录 - TradeOrderItemDO item = orderItems.get(0); - CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( - TradeOrderConvert.INSTANCE.convert(order, item)).getCheckedData(); - - // 3. 更新拼团相关信息到订单。为什么几个字段都要更新? - // 原因是:如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 - orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), - combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); - } - - @Override - public void beforeDeliveryOrder(TradeOrderDO order) { - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - // 校验订单拼团是否成功 - if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId()).getCheckedData()) { - throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); - } - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java deleted file mode 100644 index 0f953fec7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 优惠劵的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeCouponOrderHandler implements TradeOrderHandler { - - @Resource - private CouponApi couponApi; - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - if (order.getCouponId() == null || order.getCouponId() <= 0) { - return; - } - // 不在前置扣减的原因,是因为优惠劵要记录使用的订单号 - couponApi.useCoupon(new CouponUseReqDTO().setId(order.getCouponId()).setUserId(order.getUserId()) - .setOrderId(order.getId())); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (order.getCouponId() == null || order.getCouponId() <= 0) { - return; - } - // 退回优惠劵 - couponApi.returnUsedCoupon(order.getCouponId()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java deleted file mode 100644 index 0c1f9d497..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.point.MemberPointApi; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; - -/** - * 会员积分、等级的 {@link TradeOrderHandler} 实现类 - * - * @author owen - */ -@Component -public class TradeMemberPointOrderHandler implements TradeOrderHandler { - - @Resource - private MemberPointApi memberPointApi; - @Resource - private MemberLevelApi memberLevelApi; - - @Resource - private AfterSaleService afterSaleService; - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - // 扣减用户积分(订单抵扣)。不在前置扣减的原因,是因为积分扣减时,需要记录关联业务 - reducePoint(order.getUserId(), order.getUsePoint(), MemberPointBizTypeEnum.ORDER_USE, order.getId()); - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - // 增加用户积分(订单赠送) - addPoint(order.getUserId(), order.getGivePoint(), MemberPointBizTypeEnum.ORDER_GIVE, - order.getId()); - - // 增加用户经验 - memberLevelApi.addExperience(order.getUserId(), order.getPayPrice(), - MemberExperienceBizTypeEnum.ORDER_GIVE.getType(), String.valueOf(order.getId())); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - - // 增加(回滚)用户积分(订单抵扣) - Integer usePoint = getSumValue(orderItems, TradeOrderItemDO::getUsePoint, Integer::sum); - addPoint(order.getUserId(), usePoint, MemberPointBizTypeEnum.ORDER_USE_CANCEL, - order.getId()); - - // 如下的返还,需要经过支持,也就是经历 afterPayOrder 流程 - if (!order.getPayStatus()) { - return; - } - // 扣减(回滚)积分(订单赠送) - Integer givePoint = getSumValue(orderItems, TradeOrderItemDO::getGivePoint, Integer::sum); - reducePoint(order.getUserId(), givePoint, MemberPointBizTypeEnum.ORDER_GIVE_CANCEL, - order.getId()); - // 扣减(回滚)用户经验 - int payPrice = order.getPayPrice() - order.getRefundPrice(); - memberLevelApi.addExperience(order.getUserId(), payPrice, - MemberExperienceBizTypeEnum.ORDER_GIVE_CANCEL.getType(), String.valueOf(order.getId())); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - // 扣减(回滚)积分(订单赠送) - reducePoint(order.getUserId(), orderItem.getGivePoint(), MemberPointBizTypeEnum.ORDER_GIVE_CANCEL_ITEM, - orderItem.getId()); - // 增加(回滚)积分(订单抵扣) - addPoint(order.getUserId(), orderItem.getUsePoint(), MemberPointBizTypeEnum.ORDER_USE_CANCEL_ITEM, - orderItem.getId()); - - // 扣减(回滚)用户经验 - AfterSaleDO afterSale = afterSaleService.getAfterSale(orderItem.getAfterSaleId()); - memberLevelApi.reduceExperience(order.getUserId(), afterSale.getRefundPrice(), - MemberExperienceBizTypeEnum.ORDER_GIVE_CANCEL_ITEM.getType(), String.valueOf(orderItem.getId())); - } - - /** - * 添加用户积分 - *

- * 目前是支付成功后,就会创建积分记录。 - *

- * 业内还有两种做法,可以根据自己的业务调整: - * 1. 确认收货后,才创建积分记录 - * 2. 支付 or 下单成功时,创建积分记录(冻结),确认收货解冻或者 n 天后解冻 - * - * @param userId 用户编号 - * @param point 增加积分数量 - * @param bizType 业务编号 - * @param bizId 业务编号 - */ - protected void addPoint(Long userId, Integer point, MemberPointBizTypeEnum bizType, Long bizId) { - if (point != null && point > 0) { - memberPointApi.addPoint(userId, point, bizType.getType(), String.valueOf(bizId)); - } - } - - protected void reducePoint(Long userId, Integer point, MemberPointBizTypeEnum bizType, Long bizId) { - if (point != null && point > 0) { - memberPointApi.reducePoint(userId, point, bizType.getType(), String.valueOf(bizId)); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java deleted file mode 100644 index 4cc5c69a3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; - -import java.util.List; - -/** - * 订单活动特殊逻辑处理器 handler 接口 - * 提供订单生命周期钩子接口;订单创建前、订单创建后、订单支付后、订单取消 - * - * @author HUIHUI - */ -public interface TradeOrderHandler { - - /** - * 订单创建前 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void beforeOrderCreate(TradeOrderDO order, List orderItems) {} - - /** - * 订单创建后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterOrderCreate(TradeOrderDO order, List orderItems) {} - - /** - * 支付订单后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterPayOrder(TradeOrderDO order, List orderItems) {} - - /** - * 订单取消后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterCancelOrder(TradeOrderDO order, List orderItems) {} - - /** - * 订单项取消后 - * - * @param order 订单 - * @param orderItem 订单项 - */ - default void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) {} - - /** - * 订单发货前 - * - * @param order 订单 - */ - default void beforeDeliveryOrder(TradeOrderDO order) {} - - // ========== 公用方法 ========== - - /** - * 过滤“未售后”的订单项列表 - * - * @param orderItems 订单项列表 - * @return 过滤后的订单项列表 - */ - default List filterOrderItemListByNoneAfterSale(List orderItems) { - return CollectionUtils.filterList(orderItems, - item -> TradeOrderItemAfterSaleStatusEnum.isNone(item.getAfterSaleStatus())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java deleted file mode 100644 index d28a643c6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static java.util.Collections.singletonList; - -/** - * 商品 SKU 库存的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeProductSkuOrderHandler implements TradeOrderHandler { - - @Resource - private ProductSkuApi productSkuApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convertNegative(orderItems)); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(orderItems)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(singletonList(orderItem))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java deleted file mode 100644 index 68227df7d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 秒杀订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeSeckillOrderHandler implements TradeOrderHandler { - - @Resource - private SeckillActivityApi seckillActivityApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "秒杀时,只允许选择一个商品"); - - // 扣减秒杀活动的库存 - seckillActivityApi.updateSeckillStockDecr(order.getSeckillActivityId(), - orderItems.get(0).getSkuId(), orderItems.get(0).getCount()); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "秒杀时,只允许选择一个商品"); - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - afterCancelOrderItem(order, orderItems.get(0)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 恢复秒杀活动的库存 - seckillActivityApi.updateSeckillStockIncr(order.getSeckillActivityId(), - orderItem.getSkuId(), orderItem.getCount()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java deleted file mode 100644 index d12451b22..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -import javax.validation.Valid; - -/** - * 价格计算 Service 接口 - * - * @author 芋道源码 - */ -public interface TradePriceService { - - /** - * 价格计算 - * - * @param calculateReqDTO 计算信息 - * @return 计算结果 - */ - TradePriceCalculateRespBO calculatePrice(@Valid TradePriceCalculateReqBO calculateReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java deleted file mode 100644 index c6e170fc3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculator; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_PAY_PRICE_ILLEGAL; - -/** - * 价格计算 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class TradePriceServiceImpl implements TradePriceService { - - @Resource - private ProductSkuApi productSkuApi; - @Resource - private ProductSpuApi productSpuApi; - - @Resource - private List priceCalculators; - - @Override - public TradePriceCalculateRespBO calculatePrice(TradePriceCalculateReqBO calculateReqBO) { - // 1.1 获得商品 SKU 数组 - List skuList = checkSkuList(calculateReqBO); - // 1.2 获得商品 SPU 数组 - List spuList = checkSpuList(skuList); - - // 2.1 计算价格 - TradePriceCalculateRespBO calculateRespBO = TradePriceCalculatorHelper - .buildCalculateResp(calculateReqBO, spuList, skuList); - priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO)); - // 2.2 如果最终支付金额小于等于 0,则抛出业务异常 - if (calculateRespBO.getPrice().getPayPrice() <= 0) { - log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]", - calculateReqBO, calculateRespBO); - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } - return calculateRespBO; - } - - private List checkSkuList(TradePriceCalculateReqBO reqBO) { - // 获得商品 SKU 数组 - Map skuIdCountMap = convertMap(reqBO.getItems(), - TradePriceCalculateReqBO.Item::getSkuId, TradePriceCalculateReqBO.Item::getCount); - List skus = productSkuApi.getSkuList(skuIdCountMap.keySet()).getCheckedData(); - - // 校验商品 SKU - skus.forEach(sku -> { - Integer count = skuIdCountMap.get(sku.getId()); - if (count == null) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - }); - return skus; - } - - private List checkSpuList(List skuList) { - // 获得商品 SPU 数组 - return productSpuApi.validateSpuList(convertSet(skuList, ProductSkuRespDTO::getSpuId)).getCheckedData(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java deleted file mode 100644 index 295dcd3bc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.bo; - -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 价格计算 Request BO - * - * @author yudao源码 - */ -@Data -public class TradePriceCalculateReqBO { - - /** - * 用户编号 - * - * 对应 MemberUserDO 的 id 编号 - */ - private Long userId; - - /** - * 优惠劵编号 - * - * 对应 CouponDO 的 id 编号 - */ - private Long couponId; - - /** - * 是否使用积分 - */ - @NotNull(message = "是否使用积分不能为空") - private Boolean pointStatus; - - /** - * 配送方式 - * - * 枚举 {@link DeliveryTypeEnum} - */ - private Integer deliveryType; - /** - * 收货地址编号 - * - * 对应 MemberAddressDO 的 id 编号 - */ - private Long addressId; - /** - * 自提门店编号 - * - * 对应 PickUpStoreDO 的 id 编号 - */ - private Long pickUpStoreId; - - /** - * 商品 SKU 数组 - */ - @NotNull(message = "商品数组不能为空") - private List items; - - // ========== 秒杀活动相关字段 ========== - /** - * 秒杀活动编号 - */ - private Long seckillActivityId; - - // ========== 拼团活动相关字段 ========== - /** - * 拼团活动编号 - */ - private Long combinationActivityId; - - /** - * 拼团团长编号 - */ - private Long combinationHeadId; - - // ========== 砍价活动相关字段 ========== - /** - * 砍价记录编号 - */ - private Long bargainRecordId; - - /** - * 商品 SKU - */ - @Data - @Valid - public static class Item { - - /** - * SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - /** - * SKU 数量 - */ - @NotNull(message = "商品 SKU 数量不能为空") - @Min(value = 0L, message = "商品 SKU 数量必须大于等于 0") - private Integer count; - - /** - * 购物车项的编号 - */ - private Long cartId; - - /** - * 是否选中 - */ - @NotNull(message = "是否选中不能为空") - private Boolean selected; - - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java deleted file mode 100644 index 93867f1e4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java +++ /dev/null @@ -1,311 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.bo; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 价格计算 Response BO - * - * 整体设计,参考 taobao 的技术文档: - * 1. 订单管理 - * 2. 常用订单金额说明 - * - * @author 芋道源码 - */ -@Data -public class TradePriceCalculateRespBO { - - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - - /** - * 订单价格 - */ - private Price price; - - /** - * 订单项数组 - */ - private List items; - - /** - * 营销活动数组 - * - * 只对应 {@link Price#items} 商品匹配的活动 - */ - private List promotions; - - /** - * 优惠劵编号 - */ - private Long couponId; - - /** - * 使用的积分 - */ - private Integer usePoint; - - /** - * 使用的积分 - */ - private Integer givePoint; - - /** - * 砍价活动编号 - */ - private Long bargainActivityId; - - /** - * 订单价格 - */ - @Data - public static class Price { - - /** - * 商品原价(总),单位:分 - * - * 基于 {@link OrderItem#getPrice()} * {@link OrderItem#getCount()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer totalPrice; - /** - * 订单优惠(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 优惠劵减免金额(总),单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - /** - * 最终购买金额(总),单位:分 - * - * = {@link #totalPrice} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - } - - /** - * 订单商品 SKU - */ - @Data - public static class OrderItem { - - /** - * SPU 编号 - */ - private Long spuId; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买数量 - */ - private Integer count; - /** - * 购物车项的编号 - */ - private Long cartId; - /** - * 是否选中 - */ - private Boolean selected; - - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer price; - /** - * 优惠金额(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额(总),单位:分 - */ - private Integer deliveryPrice; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 使用的积分 - */ - private Integer usePoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #price} * {@link #count} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 商品 SPU 信息 ========== - /** - * 商品名 - */ - private String spuName; - /** - * 商品图片 - * - * 优先级:SKU.picUrl > SPU.picUrl - */ - private String picUrl; - /** - * 分类编号 - */ - private Long categoryId; - - /** - * 运费模板 Id - */ - private Long deliveryTemplateId; - - // ========== 商品 SKU 信息 ========== - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 使用的积分 - */ - private Integer givePoint; - - } - - /** - * 营销明细 - */ - @Data - public static class Promotion { - - /** - * 营销编号 - * - * 例如说:营销活动的编号、优惠劵的编号 - */ - private Long id; - /** - * 营销名字 - */ - private String name; - /** - * 营销类型 - * - * 枚举 {@link PromotionTypeEnum} - */ - private Integer type; - /** - * 计算时的原价(总),单位:分 - */ - private Integer totalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - /** - * 匹配的商品 SKU 数组 - */ - private List items; - - // ========== 匹配情况 ========== - - /** - * 是否满足优惠条件 - */ - private Boolean match; - /** - * 满足条件的提示 - * - * 如果 {@link #match} = true 满足,则提示“圣诞价:省 150.00 元” - * 如果 {@link #match} = false 不满足,则提示“购满 85 元,可减 40 元” - */ - private String description; - - } - - /** - * 营销匹配的商品 SKU - */ - @Data - public static class PromotionItem { - - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 计算时的原价(总),单位:分 - */ - private Integer totalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java deleted file mode 100644 index a0cd38844..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO huihui:单测需要补充 -/** - * 砍价活动的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_BARGAIN_ACTIVITY) -public class TradeBargainActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private BargainRecordApi bargainRecordApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有拼团记录编号 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.BARGAIN.getType())) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "砍价时,只允许选择一个商品"); - Assert.isTrue(param.getItems().get(0).getCount() == 1, "砍价时,只允许选择一个商品"); - // 2. 校验是否可以参与砍价 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - BargainValidateJoinRespDTO bargainActivity = bargainRecordApi.validateJoinBargain( - param.getUserId(), param.getBargainRecordId(), orderItem.getSkuId()).getCheckedData(); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - bargainActivity.getBargainPrice() * orderItem.getCount(); - // TODO 芋艿:极端情况,优惠金额为负数,需要处理 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getSeckillActivityId(), bargainActivity.getName(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(), - StrUtil.format("砍价活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - // 4. 特殊:设置对应的砍价活动编号 - result.setBargainActivityId(bargainActivity.getActivityId()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java deleted file mode 100644 index 4ca8f4608..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO @puhui999:单测可以后补下 - -/** - * 拼团活动的 {@link TradePriceCalculator} 实现类 - * - * @author HUIHUI - */ -@Component -@Order(TradePriceCalculator.ORDER_COMBINATION_ACTIVITY) -public class TradeCombinationActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private CombinationRecordApi combinationRecordApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有拼团活动编号 - if (param.getCombinationActivityId() == null) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "拼团时,只允许选择一个商品"); - // 2. 校验是否可以参与拼团 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - CombinationValidateJoinRespDTO combinationActivity = combinationRecordApi.validateJoinCombination( - param.getUserId(), param.getCombinationActivityId(), param.getCombinationHeadId(), - orderItem.getSkuId(), orderItem.getCount()).getCheckedData(); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - combinationActivity.getCombinationPrice() * orderItem.getCount(); - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getCombinationActivityId(), combinationActivity.getName(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(), - StrUtil.format("拼团活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java deleted file mode 100644 index bb2c35f76..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.function.Predicate; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_MIN_PRICE; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_SPU; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER; - -/** - * 优惠劵的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_COUPON) -public class TradeCouponPriceCalculator implements TradePriceCalculator { - - @Resource - private CouponApi couponApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1.1 校验优惠劵 - if (param.getCouponId() == null) { - return; - } - CouponRespDTO coupon = couponApi.validateCoupon(new CouponValidReqDTO() - .setId(param.getCouponId()).setUserId(param.getUserId())).getCheckedData(); - Assert.notNull(coupon, "校验通过的优惠劵({}),不能为空", param.getCouponId()); - // 1.2 只有【普通】订单,才允许使用优惠劵 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - throw exception(PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER); - } - - // 2.1 获得匹配的商品 SKU 数组 - List orderItems = filterMatchCouponOrderItems(result, coupon); - if (CollUtil.isEmpty(orderItems)) { - throw exception(COUPON_NO_MATCH_SPU); - } - // 2.2 计算是否满足优惠劵的使用金额 - Integer totalPayPrice = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - if (totalPayPrice < coupon.getUsePrice()) { - throw exception(COUPON_NO_MATCH_MIN_PRICE); - } - - // 3.1 计算可以优惠的金额 - Integer couponPrice = getCouponPrice(coupon, totalPayPrice); - Assert.isTrue(couponPrice < totalPayPrice, - "优惠劵({}) 的优惠金额({}),不能大于订单总金额({})", coupon.getId(), couponPrice, totalPayPrice); - // 3.2 计算分摊的优惠金额 - List divideCouponPrices = TradePriceCalculatorHelper.dividePrice(orderItems, couponPrice); - - // 4.1 记录使用的优惠劵 - result.setCouponId(param.getCouponId()); - // 4.2 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - param.getCouponId(), coupon.getName(), PromotionTypeEnum.COUPON.getType(), - StrUtil.format("优惠劵:省 {} 元", TradePriceCalculatorHelper.formatPrice(couponPrice)), - divideCouponPrices); - // 4.3 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setCouponPrice(divideCouponPrices.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private Integer getCouponPrice(CouponRespDTO coupon, Integer totalPayPrice) { - if (PromotionDiscountTypeEnum.PRICE.getType().equals(coupon.getDiscountType())) { // 减价 - return coupon.getDiscountPrice(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(coupon.getDiscountType())) { // 打折 - int couponPrice = totalPayPrice * coupon.getDiscountPercent() / 100; - return coupon.getDiscountLimitPrice() == null ? couponPrice - : Math.min(couponPrice, coupon.getDiscountLimitPrice()); // 优惠上限 - } - throw new IllegalArgumentException(String.format("优惠劵(%s) 的优惠类型不正确", coupon)); - } - - /** - * 获得优惠劵可使用的订单项(商品)列表 - * - * @param result 计算结果 - * @param coupon 优惠劵 - * @return 订单项(商品)列表 - */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - CouponRespDTO coupon) { - Predicate matchPredicate = TradePriceCalculateRespBO.OrderItem::getSelected; - if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) { - matchPredicate = matchPredicate // 额外加如下条件 - .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId())); - } else if (PromotionProductScopeEnum.CATEGORY.getScope().equals(coupon.getProductScope())) { - matchPredicate = matchPredicate // 额外加如下条件 - .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getCategoryId())); - } - return filterList(result.getItems(), matchPredicate); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java deleted file mode 100644 index 798aff9f9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java +++ /dev/null @@ -1,226 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO.OrderItem; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 运费的 {@link TradePriceCalculator} 实现类 - * - * @author jason - */ -@Component -@Order(TradePriceCalculator.ORDER_DELIVERY) -@Slf4j -public class TradeDeliveryPriceCalculator implements TradePriceCalculator { - - @Resource - private MemberAddressApi addressApi; - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - @Resource - private DeliveryExpressTemplateService deliveryExpressTemplateService; - @Resource - private TradeConfigService tradeConfigService; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - if (param.getDeliveryType() == null) { - return; - } - if (DeliveryTypeEnum.PICK_UP.getType().equals(param.getDeliveryType())) { - calculateByPickUp(param); - } else if (DeliveryTypeEnum.EXPRESS.getType().equals(param.getDeliveryType())) { - calculateExpress(param, result); - } - } - - private void calculateByPickUp(TradePriceCalculateReqBO param) { - if (param.getPickUpStoreId() == null) { - // 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空 - return; - } - DeliveryPickUpStoreDO pickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(param.getPickUpStoreId()); - if (pickUpStore == null || CommonStatusEnum.DISABLE.getStatus().equals(pickUpStore.getStatus())) { - throw exception(PICK_UP_STORE_NOT_EXISTS); - } - } - - // ========= 快递发货 ========== - - private void calculateExpress(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 得到收件地址区域 - if (param.getAddressId() == null) { - // 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空 - return; - } - MemberAddressRespDTO address = addressApi.getAddress(param.getAddressId(), param.getUserId()).getCheckedData(); - Assert.notNull(address, "收件人({})的地址,不能为空", param.getUserId()); - - // 情况一:全局包邮 - if (isGlobalExpressFree(result)) { - return; - } - - // 情况二:快递模版 - // 2.1 过滤出已选中的商品 SKU - List selectedItem = filterList(result.getItems(), OrderItem::getSelected); - Set deliveryTemplateIds = convertSet(selectedItem, OrderItem::getDeliveryTemplateId); - Map expressTemplateMap = - deliveryExpressTemplateService.getExpressTemplateMapByIdsAndArea(deliveryTemplateIds, address.getAreaId()); - // 2.2 计算配送费用 - if (CollUtil.isEmpty(expressTemplateMap)) { - log.error("[calculate][找不到商品 templateIds {} areaId{} 对应的运费模板]", deliveryTemplateIds, address.getAreaId()); - throw exception(PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND); - } - calculateDeliveryPrice(selectedItem, expressTemplateMap, result); - } - - /** - * 是否全局包邮 - * - * @param result 计算结果 - * @return 是否包邮 - */ - private boolean isGlobalExpressFree(TradePriceCalculateRespBO result) { - TradeConfigDO config = tradeConfigService.getTradeConfig(); - return config != null - && Boolean.TRUE.equals(config.getDeliveryExpressFreeEnabled()) // 开启包邮 - && result.getPrice().getPayPrice() >= config.getDeliveryExpressFreePrice(); // 满足包邮的价格 - } - - private void calculateDeliveryPrice(List selectedSkus, - Map expressTemplateMap, - TradePriceCalculateRespBO result) { - // 按商品运费模板来计算商品的运费:相同的运费模板可能对应多条订单商品 SKU - Map> template2ItemMap = convertMultiMap(selectedSkus, OrderItem::getDeliveryTemplateId); - // 依次计算快递运费 - for (Map.Entry> entry : template2ItemMap.entrySet()) { - Long templateId = entry.getKey(); - List orderItems = entry.getValue(); - DeliveryExpressTemplateRespBO templateBO = expressTemplateMap.get(templateId); - if (templateBO == null) { - log.error("[calculateDeliveryPrice][不能计算快递运费,找不到 templateId({}) 对应的运费模板配置]", templateId); - continue; - } - // 1. 优先判断是否包邮。如果包邮不计算快递运费 - if (isExpressTemplateFree(orderItems, templateBO.getChargeMode(), templateBO.getFree())) { - continue; - } - // 2. 计算快递运费 - calculateExpressFeeByChargeMode(orderItems, templateBO.getChargeMode(), templateBO.getCharge()); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 按配送方式来计算运费 - * - * @param orderItems SKU 商品项目 - * @param chargeMode 配送计费方式 - * @param templateCharge 快递运费配置 - */ - private void calculateExpressFeeByChargeMode(List orderItems, Integer chargeMode, - DeliveryExpressTemplateRespBO.Charge templateCharge) { - if (templateCharge == null) { - log.error("[calculateExpressFeeByChargeMode][计算快递运费时,找不到 SKU({}) 对应的运费模版]", orderItems); - return; - } - double totalChargeValue = getTotalChargeValue(orderItems, chargeMode); - // 1. 计算 SKU 商品快递费用 - int deliveryPrice; - if (totalChargeValue <= templateCharge.getStartCount()) { - deliveryPrice = templateCharge.getStartPrice(); - } else { - double remainWeight = totalChargeValue - templateCharge.getStartCount(); - // 剩余重量/ 续件 = 续件的次数. 向上取整 - int extraNum = (int) Math.ceil(remainWeight / templateCharge.getExtraCount()); - int extraPrice = templateCharge.getExtraPrice() * extraNum; - deliveryPrice = templateCharge.getStartPrice() + extraPrice; - } - - // 2. 分摊快递费用到 SKU. 退费的时候,可能按照 SKU 考虑退费金额 - int remainPrice = deliveryPrice; - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem item = orderItems.get(i); - int partPrice; - double chargeValue = getChargeValue(item, chargeMode); - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (deliveryPrice * (chargeValue / totalChargeValue)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - // 更新快递运费 - item.setDeliveryPrice(partPrice); - TradePriceCalculatorHelper.recountPayPrice(item); - } - } - - /** - * 检查是否包邮 - * - * @param chargeMode 配送计费方式 - * @param templateFree 包邮配置 - */ - private boolean isExpressTemplateFree(List orderItems, Integer chargeMode, - DeliveryExpressTemplateRespBO.Free templateFree) { - if (templateFree == null) { - return false; - } - double totalChargeValue = getTotalChargeValue(orderItems, chargeMode); - double totalPrice = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - return totalChargeValue >= templateFree.getFreeCount() && totalPrice >= templateFree.getFreePrice(); - } - - private double getTotalChargeValue(List orderItems, Integer chargeMode) { - double total = 0; - for (OrderItem orderItem : orderItems) { - total += getChargeValue(orderItem, chargeMode); - } - return total; - } - - private double getChargeValue(OrderItem orderItem, Integer chargeMode) { - DeliveryExpressChargeModeEnum chargeModeEnum = DeliveryExpressChargeModeEnum.valueOf(chargeMode); - switch (chargeModeEnum) { - case COUNT: - return orderItem.getCount(); - case WEIGHT: - return orderItem.getWeight() != null ? orderItem.getWeight() * orderItem.getCount() : 0; - case VOLUME: - return orderItem.getVolume() != null ? orderItem.getVolume() * orderItem.getCount() : 0; - default: - throw new IllegalArgumentException(StrUtil.format("未知的计费模式({})", chargeMode)); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java deleted file mode 100644 index b63cfaae2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 限时折扣的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_DISCOUNT_ACTIVITY) -public class TradeDiscountActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private DiscountActivityApi discountActivityApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 获得 SKU 对应的限时折扣活动 - List discountProducts = discountActivityApi.getMatchDiscountProductList( - convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId)).getCheckedData(); - if (CollUtil.isEmpty(discountProducts)) { - return; - } - Map discountProductMap = convertMap(discountProducts, DiscountProductRespDTO::getSkuId); - - // 处理每个 SKU 的限时折扣 - result.getItems().forEach(orderItem -> { - // 1. 获取该 SKU 的优惠信息 - DiscountProductRespDTO discountProduct = discountProductMap.get(orderItem.getSkuId()); - if (discountProduct == null) { - return; - } - // 2. 计算优惠金额 - Integer newPayPrice = calculatePayPrice(discountProduct, orderItem); - Integer newDiscountPrice = orderItem.getPayPrice() - newPayPrice; - - // 3.1 记录优惠明细 - if (orderItem.getSelected()) { - // 注意,只有在选中的情况下,才会记录到优惠明细。否则仅仅是更新 SKU 优惠金额,用于展示 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - discountProduct.getActivityId(), discountProduct.getActivityName(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), - StrUtil.format("限时折扣:省 {} 元", formatPrice(newDiscountPrice)), - newDiscountPrice); - } - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + newDiscountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - }); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private Integer calculatePayPrice(DiscountProductRespDTO discountProduct, - TradePriceCalculateRespBO.OrderItem orderItem) { - Integer price = orderItem.getPayPrice(); - if (PromotionDiscountTypeEnum.PRICE.getType().equals(discountProduct.getDiscountType())) { // 减价 - price -= discountProduct.getDiscountPrice() * orderItem.getCount(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(discountProduct.getDiscountType())) { // 打折 - price = price * discountProduct.getDiscountPercent() / 100; - } else { - throw new IllegalArgumentException(String.format("优惠活动的商品(%s) 的优惠类型不正确", discountProduct)); - } - return price; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java deleted file mode 100644 index 3db99fd80..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 会员 VIP 折扣的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_MEMBER_LEVEL) -public class TradeMemberLevelPriceCalculator implements TradePriceCalculator { - - @Resource - private MemberLevelApi memberLevelApi; - @Resource - private MemberUserApi memberUserApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 1. 获得用户的会员等级 - MemberUserRespDTO user = memberUserApi.getUser(param.getUserId()).getCheckedData(); - if (user.getLevelId() == null || user.getLevelId() <= 0) { - return; - } - MemberLevelRespDTO level = memberLevelApi.getMemberLevel(user.getLevelId()).getCheckedData(); - if (level == null || level.getDiscountPercent() == null) { - return; - } - - // 2. 计算每个 SKU 的优惠金额 - result.getItems().forEach(orderItem -> { - // 2.1 计算优惠金额 - Integer vipPrice = calculateVipPrice(orderItem.getPayPrice(), level.getDiscountPercent()); - if (vipPrice <= 0) { - return; - } - - // 2.2 记录优惠明细 - if (orderItem.getSelected()) { - // 注意,只有在选中的情况下,才会记录到优惠明细。否则仅仅是更新 SKU 优惠金额,用于展示 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - level.getId(), level.getName(), PromotionTypeEnum.MEMBER_LEVEL.getType(), - String.format("会员等级折扣:省 %s 元", formatPrice(vipPrice)), - vipPrice); - } - - // 2.3 更新 SKU 的优惠金额 - orderItem.setVipPrice(vipPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - }); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 计算会员 VIP 优惠价格 - * - * @param price 原价 - * @param discountPercent 折扣 - * @return 优惠价格 - */ - public Integer calculateVipPrice(Integer price, Integer discountPercent) { - if (discountPercent == null) { - return 0; - } - Integer newPrice = price * discountPercent / 100; - return price - newPrice; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java deleted file mode 100644 index 18cb7be09..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.BooleanUtil; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; - -/** - * 赠送积分的 {@link TradePriceCalculator} 实现类 - * - * @author owen - */ -@Component -@Order(TradePriceCalculator.ORDER_POINT_GIVE) -@Slf4j -public class TradePointGiveCalculator implements TradePriceCalculator { - - @Resource - private MemberConfigApi memberConfigApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1.1 校验积分功能是否开启 - int givePointPerYuan = Optional.ofNullable(memberConfigApi.getConfig().getCheckedData()) - .filter(config -> BooleanUtil.isTrue(config.getPointTradeDeductEnable())) - .map(MemberConfigRespDTO::getPointTradeGivePoint) - .orElse(0); - if (givePointPerYuan <= 0) { - return; - } - // 1.2 校验支付金额 - if (result.getPrice().getPayPrice() <= 0) { - return; - } - - // 2.1 计算赠送积分 - int givePoint = MoneyUtils.calculateRatePriceFloor(result.getPrice().getPayPrice(), (double) givePointPerYuan); - // 2.2 计算分摊的赠送积分 - List orderItems = filterList(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSelected); - List dividePoints = TradePriceCalculatorHelper.dividePrice(orderItems, givePoint); - - // 3.2 更新 SKU 赠送积分 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - // 商品可能赠送了积分,所以这里要加上 - orderItem.setGivePoint(orderItem.getGivePoint() + dividePoints.get(i)); - } - // 3.3 更新订单赠送积分 - TradePriceCalculatorHelper.recountAllGivePoint(result); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java deleted file mode 100644 index 080879772..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_PAY_PRICE_ILLEGAL; - -/** - * 使用积分的 {@link TradePriceCalculator} 实现类 - * - * @author owen - */ -@Component -@Order(TradePriceCalculator.ORDER_POINT_USE) -@Slf4j -public class TradePointUsePriceCalculator implements TradePriceCalculator { - - @Resource - private MemberConfigApi memberConfigApi; - @Resource - private MemberUserApi memberUserApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 默认使用积分为 0 - result.setUsePoint(0); - // 1.1 校验是否使用积分 - if (!BooleanUtil.isTrue(param.getPointStatus())) { - result.setUsePoint(0); - return; - } - // 1.2 校验积分抵扣是否开启 - MemberConfigRespDTO config = memberConfigApi.getConfig().getCheckedData(); - if (!isDeductPointEnable(config)) { - return; - } - // 1.3 校验用户积分余额 - MemberUserRespDTO user = memberUserApi.getUser(param.getUserId()).getCheckedData(); - if (user.getPoint() == null || user.getPoint() <= 0) { - return; - } - - // 2.1 计算积分优惠金额 - int pointPrice = calculatePointPrice(config, user.getPoint(), result); - // 2.2 计算分摊的积分、抵扣金额 - List orderItems = filterList(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSelected); - List dividePointPrices = TradePriceCalculatorHelper.dividePrice(orderItems, pointPrice); - List divideUsePoints = TradePriceCalculatorHelper.dividePrice(orderItems, result.getUsePoint()); - - // 3.1 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - param.getUserId(), "积分抵扣", PromotionTypeEnum.POINT.getType(), - StrUtil.format("积分抵扣:省 {} 元", TradePriceCalculatorHelper.formatPrice(pointPrice)), - dividePointPrices); - // 3.2 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setPointPrice(dividePointPrices.get(i)); - orderItem.setUsePoint(divideUsePoints.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private boolean isDeductPointEnable(MemberConfigRespDTO config) { - return config != null && - BooleanUtil.isTrue(config.getPointTradeDeductEnable()) && // 积分功能是否启用 - config.getPointTradeDeductUnitPrice() != null && config.getPointTradeDeductUnitPrice() > 0; // 有没有配置:1 积分抵扣多少分 - } - - private Integer calculatePointPrice(MemberConfigRespDTO config, Integer usePoint, TradePriceCalculateRespBO result) { - // 每个订单最多可以使用的积分数量 - if (config.getPointTradeDeductMaxPrice() != null && config.getPointTradeDeductMaxPrice() > 0) { - usePoint = Math.min(usePoint, config.getPointTradeDeductMaxPrice()); - } - // TODO @疯狂:这里应该是,抵扣到只剩下 0.01; - // 积分优惠金额(分) - int pointPrice = usePoint * config.getPointTradeDeductUnitPrice(); - if (result.getPrice().getPayPrice() <= pointPrice) { - // 禁止 0 元购 - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } -// // 允许0 元购!!!:用户积分比较多时,积分可以抵扣的金额要大于支付金额,这时需要根据支付金额反推使用多少积分 -// if (result.getPrice().getPayPrice() < pointPrice) { -// pointPrice = result.getPrice().getPayPrice(); -// // 反推需要扣除的积分 -// usePoint = NumberUtil.toBigDecimal(pointPrice) -// .divide(NumberUtil.toBigDecimal(config.getPointTradeDeductUnitPrice()), 0, RoundingMode.HALF_UP) -// .intValue(); -// } - // 记录使用的积分 - result.setUsePoint(usePoint); - return pointPrice; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java deleted file mode 100644 index 1fc7e6915..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -/** - * 价格计算的计算器接口 - * - * 优惠计算顺序: - * 1. 积分抵现、会员价、优惠券、粉丝专享价、满减送哪个优先计算? - * - * @author 芋道源码 - */ -public interface TradePriceCalculator { - - int ORDER_MEMBER_LEVEL = 5; - - int ORDER_SECKILL_ACTIVITY = 8; - int ORDER_BARGAIN_ACTIVITY = 8; - int ORDER_COMBINATION_ACTIVITY = 8; - - int ORDER_DISCOUNT_ACTIVITY = 10; - int ORDER_REWARD_ACTIVITY = 20; - int ORDER_COUPON = 30; - int ORDER_POINT_USE = 40; - /** - * 快递运费的计算 - * - * 放在各种营销活动、优惠劵后面 - */ - int ORDER_DELIVERY = 50; - /** - * 赠送积分,放最后 - * - * 放在 {@link #ORDER_DELIVERY} 后面的原因,是运费也会产生费用,需要赠送对应积分 - */ - int ORDER_POINT_GIVE = 999; - - void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java deleted file mode 100644 index 2862012af..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java +++ /dev/null @@ -1,341 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; -import static java.util.Collections.singletonList; - -/** - * {@link TradePriceCalculator} 的工具类 - * - * 主要实现对 {@link TradePriceCalculateRespBO} 计算结果的操作 - * - * @author 芋道源码 - */ -public class TradePriceCalculatorHelper { - - public static TradePriceCalculateRespBO buildCalculateResp(TradePriceCalculateReqBO param, - List spuList, List skuList) { - // 创建 PriceCalculateRespDTO 对象 - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO(); - result.setType(getOrderType(param)); - result.setPromotions(new ArrayList<>()); - - // 创建它的 OrderItem 属性 - result.setItems(new ArrayList<>(param.getItems().size())); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map skuMap = convertMap(skuList, ProductSkuRespDTO::getId); - param.getItems().forEach(item -> { - ProductSkuRespDTO sku = skuMap.get(item.getSkuId()); - if (sku == null) { - return; - } - ProductSpuRespDTO spu = spuMap.get(sku.getSpuId()); - if (spu == null) { - return; - } - // 商品项 - TradePriceCalculateRespBO.OrderItem orderItem = new TradePriceCalculateRespBO.OrderItem(); - result.getItems().add(orderItem); - orderItem.setSpuId(sku.getSpuId()).setSkuId(sku.getId()) - .setCount(item.getCount()).setCartId(item.getCartId()).setSelected(item.getSelected()); - // sku 价格 - orderItem.setPrice(sku.getPrice()).setPayPrice(sku.getPrice() * item.getCount()) - .setDiscountPrice(0).setDeliveryPrice(0).setCouponPrice(0).setPointPrice(0).setVipPrice(0); - // sku 信息 - orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties()) - .setWeight(sku.getWeight()).setVolume(sku.getVolume()); - // spu 信息 - orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId()) - .setDeliveryTemplateId(spu.getDeliveryTemplateId()) - .setGivePoint(spu.getGiveIntegral()).setUsePoint(0); - if (orderItem.getPicUrl() == null) { - orderItem.setPicUrl(spu.getPicUrl()); - } - }); - - // 创建它的 Price 属性 - result.setPrice(new TradePriceCalculateRespBO.Price()); - recountAllPrice(result); - recountAllGivePoint(result); - return result; - } - - /** - * 计算订单类型 - * - * @param param 计算参数 - * @return 订单类型 - */ - private static Integer getOrderType(TradePriceCalculateReqBO param) { - if (param.getSeckillActivityId() != null) { - return TradeOrderTypeEnum.SECKILL.getType(); - } - if (param.getCombinationActivityId() != null) { - return TradeOrderTypeEnum.COMBINATION.getType(); - } - if (param.getBargainRecordId() != null) { - return TradeOrderTypeEnum.BARGAIN.getType(); - } - return TradeOrderTypeEnum.NORMAL.getType(); - } - - /** - * 基于订单项,重新计算 price 总价 - * - * @param result 计算结果 - */ - public static void recountAllPrice(TradePriceCalculateRespBO result) { - // 先重置 - TradePriceCalculateRespBO.Price price = result.getPrice(); - price.setTotalPrice(0).setDiscountPrice(0).setDeliveryPrice(0) - .setCouponPrice(0).setPointPrice(0).setVipPrice(0).setPayPrice(0); - // 再合计 item - result.getItems().forEach(item -> { - if (!item.getSelected()) { - return; - } - price.setTotalPrice(price.getTotalPrice() + item.getPrice() * item.getCount()); - price.setDiscountPrice(price.getDiscountPrice() + item.getDiscountPrice()); - price.setDeliveryPrice(price.getDeliveryPrice() + item.getDeliveryPrice()); - price.setCouponPrice(price.getCouponPrice() + item.getCouponPrice()); - price.setPointPrice(price.getPointPrice() + item.getPointPrice()); - price.setVipPrice(price.getVipPrice() + item.getVipPrice()); - price.setPayPrice(price.getPayPrice() + item.getPayPrice()); - }); - } - - /** - * 基于订单项,重新计算赠送积分 - * - * @param result 计算结果 - */ - public static void recountAllGivePoint(TradePriceCalculateRespBO result) { - result.setGivePoint(getSumValue(result.getItems(), item -> item.getSelected() ? item.getGivePoint() : 0, Integer::sum)); - } - - /** - * 重新计算单个订单项的支付金额 - * - * @param orderItem 订单项 - */ - public static void recountPayPrice(TradePriceCalculateRespBO.OrderItem orderItem) { - orderItem.setPayPrice(orderItem.getPrice() * orderItem.getCount() - - orderItem.getDiscountPrice() - + orderItem.getDeliveryPrice() - - orderItem.getCouponPrice() - - orderItem.getPointPrice() - - orderItem.getVipPrice() - ); - } - - /** - * 重新计算每个订单项的支付金额 - * - * 【目前主要是单测使用】 - * - * @param orderItems 订单项数组 - */ - public static void recountPayPrice(List orderItems) { - orderItems.forEach(orderItem -> { - if (orderItem.getDiscountPrice() == null) { - orderItem.setDiscountPrice(0); - } - if (orderItem.getDeliveryPrice() == null) { - orderItem.setDeliveryPrice(0); - } - if (orderItem.getCouponPrice() == null) { - orderItem.setCouponPrice(0); - } - if (orderItem.getPointPrice() == null) { - orderItem.setPointPrice(0); - } - if (orderItem.getUsePoint() == null) { - orderItem.setUsePoint(0); - } - if (orderItem.getGivePoint() == null) { - orderItem.setGivePoint(0); - } - if (orderItem.getVipPrice() == null) { - orderItem.setVipPrice(0); - } - recountPayPrice(orderItem); - }); - } - - /** - * 计算已选中的订单项,总支付金额 - * - * @param orderItems 订单项数组 - * @return 总支付金额 - */ - public static Integer calculateTotalPayPrice(List orderItems) { - return getSumValue(orderItems, - orderItem -> orderItem.getSelected() ? orderItem.getPayPrice() : 0, // 未选中的情况下,不计算支付金额 - Integer::sum); - } - - /** - * 计算已选中的订单项,总商品数 - * - * @param orderItems 订单项数组 - * @return 总商品数 - */ - public static Integer calculateTotalCount(List orderItems) { - return getSumValue(orderItems, - orderItem -> orderItem.getSelected() ? orderItem.getCount() : 0, // 未选中的情况下,不计算数量 - Integer::sum); - } - - /** - * 按照支付金额,返回每个订单项的分摊金额数组 - * - * 实际上 price 不仅仅可以传递的是金额,也可以是积分。因为它的实现逻辑,就是根据 payPrice 做分摊而已 - * - * @param orderItems 订单项数组 - * @param price 金额 - * @return 分摊金额数组,和传入的 orderItems 一一对应 - */ - public static List dividePrice(List orderItems, Integer price) { - Integer total = calculateTotalPayPrice(orderItems); - assert total != null; - // 遍历每一个,进行分摊 - List prices = new ArrayList<>(orderItems.size()); - int remainPrice = price; - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - // 1. 如果是未选中,则分摊为 0 - if (!orderItem.getSelected()) { - prices.add(0); - continue; - } - // 2. 如果选中,则按照百分比,进行分摊 - int partPrice; - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getPayPrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - prices.add(partPrice); - } - return prices; - } - - /** - * 计算订单调价价格分摊 - * - * 和 {@link #dividePrice(List, Integer)} 逻辑一致,只是传入的是 TradeOrderItemDO 对象 - * - * @param items 订单项 - * @param price 订单支付金额 - * @return 分摊金额数组,和传入的 orderItems 一一对应 - */ - public static List dividePrice2(List items, Integer price) { - Integer total = getSumValue(items, TradeOrderItemDO::getPayPrice, Integer::sum); - assert total != null; - // 遍历每一个,进行分摊 - List prices = new ArrayList<>(items.size()); - int remainPrice = price; - for (int i = 0; i < items.size(); i++) { - TradeOrderItemDO orderItem = items.get(i); - int partPrice; - if (i < items.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getPrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - prices.add(partPrice); - } - return prices; - } - - /** - * 添加【匹配】单个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItem 单个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - * @param discountPrice 单个订单商品 SKU 的优惠价格(总) - */ - public static void addPromotion(TradePriceCalculateRespBO result, TradePriceCalculateRespBO.OrderItem orderItem, - Long id, String name, Integer type, String description, Integer discountPrice) { - addPromotion(result, singletonList(orderItem), id, name, type, description, singletonList(discountPrice)); - } - - /** - * 添加【匹配】多个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - * @param discountPrices 多个订单商品 SKU 的优惠价格(总),和 orderItems 一一对应 - */ - public static void addPromotion(TradePriceCalculateRespBO result, List orderItems, - Long id, String name, Integer type, String description, List discountPrices) { - // 创建营销明细 Item - List promotionItems = new ArrayList<>(discountPrices.size()); - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - promotionItems.add(new TradePriceCalculateRespBO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setTotalPrice(orderItem.getPayPrice()).setDiscountPrice(discountPrices.get(i))); - } - // 创建营销明细 - TradePriceCalculateRespBO.Promotion promotion = new TradePriceCalculateRespBO.Promotion() - .setId(id).setName(name).setType(type) - .setTotalPrice(calculateTotalPayPrice(orderItems)) - .setDiscountPrice(getSumValue(discountPrices, value -> value, Integer::sum)) - .setItems(promotionItems).setMatch(true).setDescription(description); - result.getPromotions().add(promotion); - } - - /** - * 添加【不匹配】多个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - */ - public static void addNotMatchPromotion(TradePriceCalculateRespBO result, List orderItems, - Long id, String name, Integer type, String description) { - // 创建营销明细 Item - List promotionItems = CollectionUtils.convertList(orderItems, - orderItem -> new TradePriceCalculateRespBO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setTotalPrice(orderItem.getPayPrice()).setDiscountPrice(0)); - // 创建营销明细 - TradePriceCalculateRespBO.Promotion promotion = new TradePriceCalculateRespBO.Promotion() - .setId(id).setName(name).setType(type) - .setTotalPrice(calculateTotalPayPrice(orderItems)) - .setDiscountPrice(0) - .setItems(promotionItems).setMatch(false).setDescription(description); - result.getPromotions().add(promotion); - } - - public static String formatPrice(Integer price) { - return String.format("%.2f", price / 100d); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java deleted file mode 100644 index b0900b2ea..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 满减送活动的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_REWARD_ACTIVITY) -public class TradeRewardActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private RewardActivityApi rewardActivityApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 获得 SKU 对应的满减送活动 - List rewardActivities = rewardActivityApi.getMatchRewardActivityList( - convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId)).getCheckedData(); - if (CollUtil.isEmpty(rewardActivities)) { - return; - } - - // 处理每个满减送活动 - rewardActivities.forEach(rewardActivity -> calculate(param, result, rewardActivity)); - } - - private void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { - // 1.1 获得满减送的订单项(商品)列表 - List orderItems = filterMatchCouponOrderItems(result, rewardActivity); - if (CollUtil.isEmpty(orderItems)) { - return; - } - // 1.2 获得最大匹配的满减送活动的规则 - RewardActivityMatchRespDTO.Rule rule = getMaxMatchRewardActivityRule(rewardActivity, orderItems); - if (rule == null) { - TradePriceCalculatorHelper.addNotMatchPromotion(result, orderItems, - rewardActivity.getId(), rewardActivity.getName(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - getRewardActivityNotMeetTip(rewardActivity)); - return; - } - - // 2.1 计算可以优惠的金额 - Integer newDiscountPrice = rule.getDiscountPrice(); - // 2.2 计算分摊的优惠金额 - List divideDiscountPrices = TradePriceCalculatorHelper.dividePrice(orderItems, newDiscountPrice); - - // 3.1 记录使用的优惠劵 - result.setCouponId(param.getCouponId()); - // 3.2 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - rewardActivity.getId(), rewardActivity.getName(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - StrUtil.format("满减送:省 {} 元", formatPrice(rule.getDiscountPrice())), - divideDiscountPrices); - // 3.3 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + divideDiscountPrices.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 获得满减送的订单项(商品)列表 - * - * @param result 计算结果 - * @param rewardActivity 满减送活动 - * @return 订单项(商品)列表 - */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { - return filterList(result.getItems(), - orderItem -> CollUtil.contains(rewardActivity.getSpuIds(), orderItem.getSpuId())); - } - - /** - * 获得最大匹配的满减送活动的规则 - * - * @param rewardActivity 满减送活动 - * @param orderItems 商品项 - * @return 匹配的活动规则 - */ - private RewardActivityMatchRespDTO.Rule getMaxMatchRewardActivityRule(RewardActivityMatchRespDTO rewardActivity, - List orderItems) { - // 1. 计算数量和价格 - Integer count = TradePriceCalculatorHelper.calculateTotalCount(orderItems); - Integer price = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - assert count != null && price != null; - - // 2. 倒序找一个最大优惠的规则 - for (int i = rewardActivity.getRules().size() - 1; i >= 0; i--) { - RewardActivityMatchRespDTO.Rule rule = rewardActivity.getRules().get(i); - if (PromotionConditionTypeEnum.PRICE.getType().equals(rewardActivity.getConditionType()) - && price >= rule.getLimit()) { - return rule; - } - if (PromotionConditionTypeEnum.COUNT.getType().equals(rewardActivity.getConditionType()) - && count >= rule.getLimit()) { - return rule; - } - } - return null; - } - - /** - * 获得满减送活动部匹配时的提示 - * - * @param rewardActivity 满减送活动 - * @return 提示 - */ - private String getRewardActivityNotMeetTip(RewardActivityMatchRespDTO rewardActivity) { - // TODO 芋艿:后面再想想;应该找第一个规则,算下还差多少即可。 - return "TODO"; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java deleted file mode 100644 index ddda8239d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT; - -// TODO huihui:单测需要补充 -/** - * 秒杀活动的 {@link TradePriceCalculator} 实现类 - * - * @author HUIHUI - */ -@Component -@Order(TradePriceCalculator.ORDER_SECKILL_ACTIVITY) -public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private SeckillActivityApi seckillActivityApi; - - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有秒杀活动编号 - if (param.getSeckillActivityId() == null) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "秒杀时,只允许选择一个商品"); - // 2. 校验是否可以参与秒杀 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - SeckillValidateJoinRespDTO seckillActivity = validateJoinSeckill( - param.getUserId(), param.getSeckillActivityId(), - orderItem.getSkuId(), orderItem.getCount()); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice() * orderItem.getCount(); - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getSeckillActivityId(), seckillActivity.getName(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(), - StrUtil.format("秒杀活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private SeckillValidateJoinRespDTO validateJoinSeckill(Long userId, Long activityId, Long skuId, Integer count) { - // 1. 校验是否可以参与秒杀 - SeckillValidateJoinRespDTO seckillActivity = seckillActivityApi.validateJoinSeckill(activityId, skuId, count).getCheckedData(); - // 2. 校验总限购数量,目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - int seckillProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId); - if (seckillProductCount + count > seckillActivity.getTotalLimitCount()) { - throw exception(PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT); - } - return seckillActivity; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index d36082139..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,104 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 - tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 0eb64a387..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,128 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 - tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application.yaml deleted file mode 100644 index bc4ff8bc5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,123 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.trade - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - trade: - order: - app-id: 1 # 商户编号 - pay-expire-time: 2h # 支付的过期时间 - receive-expire-time: 14d # 收货的过期时间 - comment-expire-time: 7d # 评论的过期时间 - express: - client: kd_niao - kd-niao: - api-key: cb022f1e-48f1-4c4a-a723-9001ac9676b8 - business-id: 1809751 - kd100: - key: pLXUGAwK5305 - customer: E77DF18BE109F454A5CD319E44BF5177 - -debug: false diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 9a19ce79b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: trade-server - - profiles: - active: local - -server: - port: 48102 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml deleted file mode 100644 index 066f75d4e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 8ba2503d9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,59 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - trade: - order: - app-id: 1 - merchant-order-id: 1 - express: - kd-niao: - api-key: xxxx - business-id: xxxxx - kd100: - customer: xxxxx - key: xxxxx - client: not_provide \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index f7f3477cc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM trade_order; -DELETE FROM trade_order_item; -DELETE FROM trade_after_sale; -DELETE FROM trade_after_sale_log; -DELETE FROM trade_brokerage_user; -DELETE FROM trade_brokerage_record; -DELETE FROM "trade_brokerage_withdraw"; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index d263fdfb9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,191 +0,0 @@ -CREATE TABLE IF NOT EXISTS "trade_order" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "type" int NOT NULL, - "terminal" int NOT NULL, - "user_id" bigint NOT NULL, - "user_ip" varchar NOT NULL, - "user_remark" varchar, - "status" int NOT NULL, - "product_count" int NOT NULL, - "cancel_type" int, - "remark" varchar, - "pay_status" bit NOT NULL, - "pay_time" datetime, - "finish_time" datetime, - "cancel_time" datetime, - "original_price" int NOT NULL, - "order_price" int NOT NULL, - "discount_price" int NOT NULL, - "delivery_price" int NOT NULL, - "adjust_price" int NOT NULL, - "pay_price" int NOT NULL, - "pay_order_id" bigint, - "pay_channel_code" varchar, - "delivery_template_id" bigint, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" datetime, - "receive_time" datetime, - "receiver_name" varchar NOT NULL, - "receiver_mobile" varchar NOT NULL, - "receiver_area_id" int NOT NULL, - "receiver_post_code" int, - "receiver_detail_address" varchar NOT NULL, - "after_sale_status" int NOT NULL, - "refund_price" int NOT NULL, - "coupon_id" bigint NOT NULL, - "coupon_price" int NOT NULL, - "point_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单表'; - -CREATE TABLE IF NOT EXISTS "trade_order_item" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "original_price" int NOT NULL, - "original_unit_price" int NOT NULL, - "discount_price" int NOT NULL, - "pay_price" int NOT NULL, - "order_part_price" int NOT NULL, - "order_divide_price" int NOT NULL, - "after_sale_status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单明细表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "status" int NOT NULL, - "type" int NOT NULL, - "way" int NOT NULL, - "user_id" bigint NOT NULL, - "apply_reason" varchar NOT NULL, - "apply_description" varchar, - "apply_pic_urls" varchar, - "order_id" bigint NOT NULL, - "order_no" varchar NOT NULL, - "order_item_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "audit_time" varchar, - "audit_user_id" bigint, - "audit_reason" varchar, - "refund_price" int NOT NULL, - "pay_refund_id" bigint, - "refund_time" varchar, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" varchar, - "receive_time" varchar, - "receive_reason" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" int NOT NULL, - "after_sale_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "order_item_id" bigint NOT NULL, - "before_status" int, - "after_status" int NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后日志'; - -CREATE TABLE IF NOT EXISTS "trade_brokerage_user" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "bind_user_id" bigint NOT NULL, - "bind_user_time" varchar, - "brokerage_enabled" bit NOT NULL, - "brokerage_time" varchar, - "price" int NOT NULL, - "frozen_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL DEFAULT '0', - PRIMARY KEY ("id") -) COMMENT '分销用户'; -CREATE TABLE IF NOT EXISTS "trade_brokerage_record" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "biz_id" varchar NOT NULL, - "biz_type" varchar NOT NULL, - "title" varchar NOT NULL, - "price" int NOT NULL, - "total_price" int NOT NULL, - "description" varchar NOT NULL, - "status" varchar NOT NULL, - "frozen_days" int NOT NULL, - "unfreeze_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金记录'; -CREATE TABLE IF NOT EXISTS "trade_brokerage_withdraw" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "price" int NOT NULL, - "fee_price" int NOT NULL, - "total_price" int NOT NULL, - "type" varchar NOT NULL, - "name" varchar, - "account_no" varchar, - "bank_name" varchar, - "bank_address" varchar, - "account_qr_code_url" varchar, - "status" varchar NOT NULL, - "audit_reason" varchar, - "audit_time" varchar, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金提现'; \ No newline at end of file diff --git a/yudao-module-member/pom.xml b/yudao-module-member/pom.xml deleted file mode 100644 index f481f6b26..000000000 --- a/yudao-module-member/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - - yudao-module-member-api - yudao-module-member-biz - - yudao-module-member - pom - - ${project.artifactId} - - member 模块,我们放会员业务。 - 例如说:会员中心等等 - - - diff --git a/yudao-module-member/yudao-module-member-api/pom.xml b/yudao-module-member/yudao-module-member-api/pom.xml deleted file mode 100644 index 0098db69f..000000000 --- a/yudao-module-member/yudao-module-member-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-member - ${revision} - - 4.0.0 - yudao-module-member-api - jar - - ${project.artifactId} - - member 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApi.java deleted file mode 100644 index 5dd696a72..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApi.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.api.address; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 用户收件地址") -public interface MemberAddressApi { - - String PREFIX = ApiConstants.PREFIX + "/address"; - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得用户收件地址") - @Parameters({ - @Parameter(name = "id", description = "收件地址编号", required = true, example = "1024"), - @Parameter(name = "userId", description = "用户编号", required = true, example = "2048"), - }) - CommonResult getAddress(@RequestParam("id") Long id, - @RequestParam("userId") Long userId); - - @GetMapping(PREFIX + "/get-default") - @Operation(summary = "获得用户默认收件地址") - @Parameter(name = "userId", description = "用户编号", required = true, example = "2048") - CommonResult getDefaultAddress(@RequestParam("userId") Long userId); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/MemberAddressRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/MemberAddressRespDTO.java deleted file mode 100644 index e2b88744a..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/address/dto/MemberAddressRespDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.api.address.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 用户收件地址 Response DTO") -@Data -public class MemberAddressRespDTO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - private String mobile; - - @Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2666") - private Integer areaId; - - @Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码 88 小区 106 号") - private String detailAddress; - - @Schema(description = "是否默认", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApi.java deleted file mode 100644 index 3a65f47fd..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApi.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.member.api.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 用户配置") -public interface MemberConfigApi { - - String PREFIX = ApiConstants.PREFIX + "/config"; - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得用户配置") - CommonResult getConfig(); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/dto/MemberConfigRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/dto/MemberConfigRespDTO.java deleted file mode 100644 index d14fe1af3..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/config/dto/MemberConfigRespDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.api.config.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 用户信息 Response DTO") -@Data -public class MemberConfigRespDTO { - - @Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean pointTradeDeductEnable; - - @Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointTradeDeductUnitPrice; // 1 积分抵扣多少分 - - @Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer pointTradeDeductMaxPrice; - - @Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointTradeGivePoint; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java deleted file mode 100644 index 615fcd2d6..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApi.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.api.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 会员等级") -public interface MemberLevelApi { - - String PREFIX = ApiConstants.PREFIX + "/level"; - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得会员等级") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - CommonResult getMemberLevel(@RequestParam("id") Long id); - - @PostMapping(PREFIX + "/add") - @Operation(summary = "增加会员经验") - @Parameters({ - @Parameter(name = "userId", description = "会员编号", required = true, example = "1024"), - @Parameter(name = "experience", description = "经验值", required = true, example = "100"), - @Parameter(name = "bizType", description = "业务类型", required = true, example = "1"), - @Parameter(name = "bizId", description = "业务编号", required = true, example = "1") - }) - CommonResult addExperience(@RequestParam("userId") Long userId, - @RequestParam("experience") Integer experience, - @RequestParam("bizType") Integer bizType, - @RequestParam("bizId") String bizId); - - @PostMapping(PREFIX + "/reduce") - @Operation(summary = "扣减会员经验") - @Parameters({ - @Parameter(name = "userId", description = "会员编号", required = true, example = "1024"), - @Parameter(name = "experience", description = "经验值", required = true, example = "100"), - @Parameter(name = "bizType", description = "业务类型", required = true, example = "1"), - @Parameter(name = "bizId", description = "业务编号", required = true, example = "1") - }) - CommonResult reduceExperience(@RequestParam("userId") Long userId, - @RequestParam("experience") Integer experience, - @RequestParam("bizType") Integer bizType, - @RequestParam("bizId") String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/dto/MemberLevelRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/dto/MemberLevelRespDTO.java deleted file mode 100644 index 3402f35a3..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/level/dto/MemberLevelRespDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.member.api.level.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 会员等级 Response DTO") -@Data -public class MemberLevelRespDTO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "普通会员") - private String name; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer level; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer experience; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPercent; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; // 参见 CommonStatusEnum 枚举 - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java deleted file mode 100644 index 56cd9857f..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * member API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.member.api; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java deleted file mode 100644 index 84d546817..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApi.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.member.api.point; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.constraints.Min; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 用户积分") -public interface MemberPointApi { - - String PREFIX = ApiConstants.PREFIX + "/point"; - - @PostMapping(PREFIX + "/add") - @Operation(summary = "增加用户积分") - @Parameters({ - @Parameter(name = "userId", description = "会员编号", required = true, example = "1024"), - @Parameter(name = "point", description = "积分", required = true, example = "100"), - @Parameter(name = "bizType", description = "业务类型", required = true, example = "1"), - @Parameter(name = "bizId", description = "业务编号", required = true, example = "1") - }) - CommonResult addPoint(@RequestParam("userId") Long userId, - @RequestParam("point") @Min(value = 1L, message = "积分必须是正数") Integer point, - @RequestParam("bizType") Integer bizType, - @RequestParam("bizId") String bizId); - - @PostMapping(PREFIX + "/reducePoint") - @Operation(summary = "减少用户积分") - @Parameters({ - @Parameter(name = "userId", description = "会员编号", required = true, example = "1024"), - @Parameter(name = "point", description = "积分", required = true, example = "100"), - @Parameter(name = "bizType", description = "业务类型", required = true, example = "1"), - @Parameter(name = "bizId", description = "业务编号", required = true, example = "1") - }) - CommonResult reducePoint(@RequestParam("userId") Long userId, - @RequestParam("point") @Min(value = 1L, message = "积分必须是正数") Integer point, - @RequestParam("bizType") Integer bizType, - @RequestParam("bizId") String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java deleted file mode 100644 index 07cc581c6..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.member.api.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 会员用户") -public interface MemberUserApi { - - String PREFIX = ApiConstants.PREFIX + "/user"; - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得会员用户信息") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - CommonResult getUser(@RequestParam("id") Long id); - - @GetMapping(PREFIX + "/list") - @Operation(summary = "获得会员用户信息们") - @Parameter(name = "ids", description = "用户编号的数组", example = "1,2", required = true) - CommonResult> getUserList(@RequestParam("ids") Collection ids); - - /** - * 获得会员用户 Map - * - * @param ids 用户编号的数组 - * @return 会员用户 Map - */ - default Map getUserMap(Collection ids) { - List list = getUserList(ids).getCheckedData(); - return convertMap(list, MemberUserRespDTO::getId); - } - - @GetMapping(PREFIX + "/list-by-nickname") - @Operation(summary = "基于用户昵称,模糊匹配用户列表") - @Parameter(name = "nickname", description = "用户昵称,模糊匹配", required = true, example = "土豆") - CommonResult> getUserListByNickname(@RequestParam("nickname") String nickname); - - @GetMapping(PREFIX + "/get-by-mobile") - @Operation(summary = "基于手机号,精准匹配用户") - @Parameter(name = "mobile", description = "基于手机号,精准匹配用户", required = true, example = "1560") - CommonResult getUserByMobile(@RequestParam("mobile") String mobile); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java deleted file mode 100644 index 79be9e521..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.member.api.user.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "RPC 服务 - 用户信息 Response DTO") -@Data -public class MemberUserRespDTO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "昵称", example = "小王同学") - private String nickname; - - @Schema(description = "帐号状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; // 参见 CommonStatusEnum 枚举 - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "手机号", example = "15601691300") - private String mobile; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 其它信息 ========== - - @Schema(description = "会员级别编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long levelId; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "886") - private Integer point; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ApiConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ApiConstants.java deleted file mode 100644 index 4a6f1b75f..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "member-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/member"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java deleted file mode 100644 index c87cbb901..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/DictTypeConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -/** - * Member 字典类型的枚举类 - * - * @author owen - */ -public interface DictTypeConstants { - - /** - * 会员经验记录 - 业务类型 - */ - String MEMBER_EXPERIENCE_BIZ_TYPE = "member_experience_biz_type"; - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java deleted file mode 100644 index ee970a54c..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Member 错误码枚举类 - *

- * member 系统,使用 1-004-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 用户相关 1-004-001-000 ============ - ErrorCode USER_NOT_EXISTS = new ErrorCode(1_004_001_000, "用户不存在"); - ErrorCode USER_MOBILE_NOT_EXISTS = new ErrorCode(1_004_001_001, "手机号未注册用户"); - ErrorCode USER_MOBILE_USED = new ErrorCode(1_004_001_002, "修改手机失败,该手机号({})已经被使用"); - ErrorCode USER_POINT_NOT_ENOUGH = new ErrorCode(1_004_001_003, "用户积分余额不足"); - - // ========== AUTH 模块 1-004-003-000 ========== - ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1_004_003_000, "登录失败,账号密码不正确"); - ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1_004_003_001, "登录失败,账号被禁用"); - ErrorCode AUTH_SOCIAL_USER_NOT_FOUND = new ErrorCode(1_004_003_005, "登录失败,解析不到三方登录信息"); - ErrorCode AUTH_MOBILE_USED = new ErrorCode(1_004_003_007, "手机号已经被使用"); - - // ========== 用户收件地址 1-004-004-000 ========== - ErrorCode ADDRESS_NOT_EXISTS = new ErrorCode(1_004_004_000, "用户收件地址不存在"); - - //========== 用户标签 1-004-006-000 ========== - ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_004_006_000, "用户标签不存在"); - ErrorCode TAG_NAME_EXISTS = new ErrorCode(1_004_006_001, "用户标签已经存在"); - ErrorCode TAG_HAS_USER = new ErrorCode(1_004_006_002, "用户标签下存在用户,无法删除"); - - //========== 积分配置 1-004-007-000 ========== - - //========== 积分记录 1-004-008-000 ========== - ErrorCode POINT_RECORD_BIZ_NOT_SUPPORT = new ErrorCode(1_004_008_000, "用户积分记录业务类型不支持"); - - //========== 签到配置 1-004-009-000 ========== - ErrorCode SIGN_IN_CONFIG_NOT_EXISTS = new ErrorCode(1_004_009_000, "签到天数规则不存在"); - ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(1_004_009_001, "签到天数规则已存在"); - - //========== 签到配置 1-004-010-000 ========== - ErrorCode SIGN_IN_RECORD_TODAY_EXISTS = new ErrorCode(1_004_010_000, "今日已签到,请勿重复签到"); - - //========== 用户等级 1-004-011-000 ========== - ErrorCode LEVEL_NOT_EXISTS = new ErrorCode(1_004_011_000, "用户等级不存在"); - ErrorCode LEVEL_NAME_EXISTS = new ErrorCode(1_004_011_001, "用户等级名称[{}]已被使用"); - ErrorCode LEVEL_VALUE_EXISTS = new ErrorCode(1_004_011_002, "用户等级值[{}]已被[{}]使用"); - ErrorCode LEVEL_EXPERIENCE_MIN = new ErrorCode(1_004_011_003, "升级经验必须大于上一个等级[{}]设置的升级经验[{}]"); - ErrorCode LEVEL_EXPERIENCE_MAX = new ErrorCode(1_004_011_004, "升级经验必须小于下一个等级[{}]设置的升级经验[{}]"); - ErrorCode LEVEL_HAS_USER = new ErrorCode(1_004_011_005, "用户等级下存在用户,无法删除"); - - ErrorCode EXPERIENCE_BIZ_NOT_SUPPORT = new ErrorCode(1_004_011_201, "用户经验业务类型不支持"); - - //========== 用户分组 1-004-012-000 ========== - ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1_004_012_000, "用户分组不存在"); - ErrorCode GROUP_HAS_USER = new ErrorCode(1_004_012_001, "用户分组下存在用户,无法删除"); - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java deleted file mode 100644 index 3038dba31..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/MemberExperienceBizTypeEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.member.enums; - -import cn.hutool.core.util.EnumUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 会员经验 - 业务类型 - * - * @author owen - */ -@Getter -@AllArgsConstructor -public enum MemberExperienceBizTypeEnum { - - /** - * 管理员调整、邀请新用户、下单、退单、签到、抽奖 - */ - ADMIN(0, "管理员调整", "管理员调整获得 {} 经验", true), - INVITE_REGISTER(1, "邀新奖励", "邀请好友获得 {} 经验", true), - SIGN_IN(4, "签到奖励", "签到获得 {} 经验", true), - LOTTERY(5, "抽奖奖励", "抽奖获得 {} 经验", true), - ORDER_GIVE(11, "下单奖励", "下单获得 {} 经验", true), - ORDER_GIVE_CANCEL(12, "下单奖励(整单取消)", "取消订单获得 {} 经验", false), // ORDER_GIVE 的取消 - ORDER_GIVE_CANCEL_ITEM(13, "下单奖励(单个退款)", "退款订单获得 {} 经验", false), // ORDER_GIVE 的取消 - ; - - /** - * 业务类型 - */ - private final int type; - /** - * 标题 - */ - private final String title; - /** - * 描述 - */ - private final String description; - /** - * 是否为扣减积分 - */ - private final boolean add; - - public static MemberExperienceBizTypeEnum getByType(Integer type) { - return EnumUtil.getBy(MemberExperienceBizTypeEnum.class, - e -> Objects.equals(type, e.getType())); - } -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java deleted file mode 100644 index ef491f42a..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/point/MemberPointBizTypeEnum.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.member.enums.point; - -import cn.hutool.core.util.EnumUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 会员积分的业务类型枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum MemberPointBizTypeEnum implements IntArrayValuable { - - SIGN(1, "签到", "签到获得 {} 积分", true), - ADMIN(2, "管理员修改", "管理员修改 {} 积分", true), - - ORDER_USE(11, "订单积分抵扣", "下单使用 {} 积分", false), // 下单时,扣减积分 - ORDER_USE_CANCEL(12, "订单积分抵扣(整单取消)", "订单取消,退还 {} 积分", true), // ORDER_USE 的取消 - ORDER_USE_CANCEL_ITEM(13, "订单积分抵扣(单个退款)", "订单退款,退还 {} 积分", true), // ORDER_USE 的取消 - - ORDER_GIVE(21, "订单积分奖励", "下单获得 {} 积分", true), // 支付订单时,赠送积分 - ORDER_GIVE_CANCEL(22, "订单积分奖励(整单取消)", "订单取消,退还 {} 积分", false), // ORDER_GIVE 的取消 - ORDER_GIVE_CANCEL_ITEM(23, "订单积分奖励(单个退款)", "订单退款,扣除赠送的 {} 积分", false) // ORDER_GIVE 的取消 - ; - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - /** - * 描述 - */ - private final String description; - /** - * 是否为扣减积分 - */ - private final boolean add; - - @Override - public int[] array() { - return new int[0]; - } - - public static MemberPointBizTypeEnum getByType(Integer type) { - return EnumUtil.getBy(MemberPointBizTypeEnum.class, - e -> Objects.equals(type, e.getType())); - } - -} diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/package-info.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/package-info.java deleted file mode 100644 index 6ae3b6448..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.member.message; diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/user/MemberUserCreateMessage.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/user/MemberUserCreateMessage.java deleted file mode 100644 index cfb24eb72..000000000 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/message/user/MemberUserCreateMessage.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.member.message.user; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 会员用户创建消息 - * - * @author owen - */ -@Data -public class MemberUserCreateMessage { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-member/yudao-module-member-biz/Dockerfile b/yudao-module-member/yudao-module-member-biz/Dockerfile deleted file mode 100644 index 5d3b6a87d..000000000 --- a/yudao-module-member/yudao-module-member-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-member-biz -WORKDIR /yudao-module-member-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-member-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48087 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-member/yudao-module-member-biz/pom.xml b/yudao-module-member/yudao-module-member-biz/pom.xml deleted file mode 100644 index 9fe3591a6..000000000 --- a/yudao-module-member/yudao-module-member-biz/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-member - ${revision} - - 4.0.0 - yudao-module-member-biz - jar - - ${project.artifactId} - - member 模块,我们放会员业务。 - 例如说:会员中心等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mq - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/MemberServerApplication.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/MemberServerApplication.java deleted file mode 100644 index d363501d2..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/MemberServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class MemberServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(MemberServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApiImpl.java deleted file mode 100644 index f81b297f8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/address/MemberAddressApiImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.api.address; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.service.address.AddressService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 用户收件地址 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class MemberAddressApiImpl implements MemberAddressApi { - - @Resource - private AddressService addressService; - - @Override - public CommonResult getAddress(Long id, Long userId) { - return success(AddressConvert.INSTANCE.convert02(addressService.getAddress(userId, id))); - } - - @Override - public CommonResult getDefaultAddress(Long userId) { - return success(AddressConvert.INSTANCE.convert02(addressService.getDefaultUserAddress(userId))); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApiImpl.java deleted file mode 100644 index a710b5eca..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/config/MemberConfigApiImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.api.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; -import cn.iocoder.yudao.module.member.service.config.MemberConfigService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 用户配置 API 实现类 - * - * @author owen - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class MemberConfigApiImpl implements MemberConfigApi { - - @Resource - private MemberConfigService memberConfigService; - - @Override - public CommonResult getConfig() { - return success(MemberConfigConvert.INSTANCE.convert01(memberConfigService.getConfig())); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java deleted file mode 100644 index 6d126e082..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/level/MemberLevelApiImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.member.api.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT; - -/** - * 会员等级 API 实现类 - * - * @author owen - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class MemberLevelApiImpl implements MemberLevelApi { - - @Resource - private MemberLevelService memberLevelService; - - @Override - public CommonResult getMemberLevel(Long id) { - return success(MemberLevelConvert.INSTANCE.convert02(memberLevelService.getLevel(id))); - } - - @Override - public CommonResult addExperience(Long userId, Integer experience, Integer bizType, String bizId) { - MemberExperienceBizTypeEnum bizTypeEnum = MemberExperienceBizTypeEnum.getByType(bizType); - if (bizTypeEnum == null) { - throw exception(EXPERIENCE_BIZ_NOT_SUPPORT); - } - memberLevelService.addExperience(userId, experience, bizTypeEnum, bizId); - return success(true); - } - - @Override - public CommonResult reduceExperience(Long userId, Integer experience, Integer bizType, String bizId) { - return addExperience(userId, -experience, bizType, bizId); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java deleted file mode 100644 index 5f97979b8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.member.api; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java deleted file mode 100644 index 7c37c64c6..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/point/MemberPointApiImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.member.api.point; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.POINT_RECORD_BIZ_NOT_SUPPORT; - -/** - * 用户积分的 API 实现类 - * - * @author owen - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class MemberPointApiImpl implements MemberPointApi { - - @Resource - private MemberPointRecordService memberPointRecordService; - - @Override - public CommonResult addPoint(Long userId, Integer point, Integer bizType, String bizId) { - Assert.isTrue(point > 0); - MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType); - if (bizTypeEnum == null) { - throw exception(POINT_RECORD_BIZ_NOT_SUPPORT); - } - memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId); - return success(true); - } - - @Override - public CommonResult reducePoint(Long userId, Integer point, Integer bizType, String bizId) { - Assert.isTrue(point > 0); - MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType); - if (bizTypeEnum == null) { - throw exception(POINT_RECORD_BIZ_NOT_SUPPORT); - } - memberPointRecordService.createPointRecord(userId, -point, bizTypeEnum, bizId); - return success(true); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java deleted file mode 100644 index 20ef36473..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.member.api.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 会员用户的 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class MemberUserApiImpl implements MemberUserApi { - - @Resource - private MemberUserService userService; - - @Override - public CommonResult getUser(Long id) { - MemberUserDO user = userService.getUser(id); - return success(MemberUserConvert.INSTANCE.convert2(user)); - } - - @Override - public CommonResult> getUserList(Collection ids) { - return success(MemberUserConvert.INSTANCE.convertList2(userService.getUserList(ids))); - } - - @Override - public CommonResult> getUserListByNickname(String nickname) { - return success(MemberUserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname))); - } - - @Override - public CommonResult getUserByMobile(String mobile) { - return success(MemberUserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile))); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java deleted file mode 100644 index 0363634c5..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/AddressController.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.service.address.AddressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 用户收件地址") -@RestController -@RequestMapping("/member/address") -@Validated -public class AddressController { - - @Resource - private AddressService addressService; - - @GetMapping("/list") - @Operation(summary = "获得用户收件地址列表") - @Parameter(name = "userId", description = "用户编号", required = true) - @PreAuthorize("@ss.hasPermission('member:user:query')") - public CommonResult> getAddressList(@RequestParam("userId") Long userId) { - List list = addressService.getAddressList(userId); - return success(AddressConvert.INSTANCE.convertList2(list)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/package-info.java deleted file mode 100644 index 652bbb6f1..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressBaseVO.java deleted file mode 100644 index a00df44ac..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressBaseVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import javax.validation.constraints.NotNull; - -/** - * 用户收件地址 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class AddressBaseVO { - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotNull(message = "收件人名称不能为空") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "手机号不能为空") - private String mobile; - - @Schema(description = "地区编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "15716") - @NotNull(message = "地区编码不能为空") - private Long areaId; - - @Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收件详细地址不能为空") - private String detailAddress; - - @Schema(description = "是否默认", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "是否默认不能为空") - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java deleted file mode 100644 index 26a4988af..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.address.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户收件地址 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AddressRespVO extends AddressBaseVO { - - @Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/MemberConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/MemberConfigController.java deleted file mode 100644 index 730358f9b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/MemberConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import cn.iocoder.yudao.module.member.service.config.MemberConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员设置") -@RestController -@RequestMapping("/member/config") -@Validated -public class MemberConfigController { - - @Resource - private MemberConfigService memberConfigService; - - @PutMapping("/save") - @Operation(summary = "保存会员配置") - @PreAuthorize("@ss.hasPermission('member:config:save')") - public CommonResult saveConfig(@Valid @RequestBody MemberConfigSaveReqVO saveReqVO) { - memberConfigService.saveConfig(saveReqVO); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员配置") - @PreAuthorize("@ss.hasPermission('member:config:query')") - public CommonResult getConfig() { - MemberConfigDO config = memberConfigService.getConfig(); - return success(MemberConfigConvert.INSTANCE.convert(config)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigBaseVO.java deleted file mode 100644 index a9a6b3195..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 会员配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberConfigBaseVO { - - @Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "积分抵扣开发不能为空") - private Boolean pointTradeDeductEnable; - - @Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506") - @NotNull(message = "积分抵扣不能为空") - private Integer pointTradeDeductUnitPrice; - - @Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "32428") - @NotNull(message = "积分抵扣最大值不能为空") - private Integer pointTradeDeductMaxPrice; - - @Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "1 元赠送积分不能为空") - private Integer pointTradeGivePoint; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigRespVO.java deleted file mode 100644 index 04f14f3d1..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员配置 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberConfigRespVO extends MemberConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigSaveReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigSaveReqVO.java deleted file mode 100644 index 8348f1f3c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/config/vo/MemberConfigSaveReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员配置保存 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberConfigSaveReqVO extends MemberConfigBaseVO { -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java deleted file mode 100644 index 566e516a1..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/MemberGroupController.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.*; -import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.service.group.MemberGroupService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - 用户分组") -@RestController -@RequestMapping("/member/group") -@Validated -public class MemberGroupController { - - @Resource - private MemberGroupService groupService; - - @PostMapping("/create") - @Operation(summary = "创建用户分组") - @PreAuthorize("@ss.hasPermission('member:group:create')") - public CommonResult createGroup(@Valid @RequestBody MemberGroupCreateReqVO createReqVO) { - return success(groupService.createGroup(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户分组") - @PreAuthorize("@ss.hasPermission('member:group:update')") - public CommonResult updateGroup(@Valid @RequestBody MemberGroupUpdateReqVO updateReqVO) { - groupService.updateGroup(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户分组") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('member:group:delete')") - public CommonResult deleteGroup(@RequestParam("id") Long id) { - groupService.deleteGroup(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户分组") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:group:query')") - public CommonResult getGroup(@RequestParam("id") Long id) { - MemberGroupDO group = groupService.getGroup(id); - return success(MemberGroupConvert.INSTANCE.convert(group)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取会员分组精简信息列表", description = "只包含被开启的会员分组,主要用于前端的下拉选项") - public CommonResult> getSimpleGroupList() { - // 获用户列表,只要开启状态的 - List list = groupService.getEnableGroupList(); - return success(MemberGroupConvert.INSTANCE.convertSimpleList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得用户分组分页") - @PreAuthorize("@ss.hasPermission('member:group:query')") - public CommonResult> getGroupPage(@Valid MemberGroupPageReqVO pageVO) { - PageResult pageResult = groupService.getGroupPage(pageVO); - return success(MemberGroupConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java deleted file mode 100644 index 0519bd968..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 用户分组 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberGroupBaseVO { - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "购物达人") - @NotNull(message = "名称不能为空") - private String name; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String remark; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java deleted file mode 100644 index ef3f83343..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 用户分组创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupCreateReqVO extends MemberGroupBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java deleted file mode 100644 index ae67d5f6c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 用户分组分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupPageReqVO extends PageParam { - - @Schema(description = "名称", example = "购物达人") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java deleted file mode 100644 index 97365382a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户分组 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupRespVO extends MemberGroupBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20357") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java deleted file mode 100644 index ee7d905d0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupSimpleRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 用户分组 Response VO") -@Data -@ToString(callSuper = true) -public class MemberGroupSimpleRespVO { - - @Schema(description = "编号", example = "6103") - private Long id; - - @Schema(description = "等级名称", example = "芋艿") - private String name; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java deleted file mode 100644 index 75910883b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/group/vo/MemberGroupUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.group.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户分组更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberGroupUpdateReqVO extends MemberGroupBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20357") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java deleted file mode 100644 index cdbd76046..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceRecordController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.service.level.MemberExperienceRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员经验记录") -@RestController -@RequestMapping("/member/experience-record") -@Validated -public class MemberExperienceRecordController { - - @Resource - private MemberExperienceRecordService experienceLogService; - - @GetMapping("/get") - @Operation(summary = "获得会员经验记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:experience-record:query')") - public CommonResult getExperienceRecord(@RequestParam("id") Long id) { - MemberExperienceRecordDO experienceLog = experienceLogService.getExperienceRecord(id); - return success(MemberExperienceRecordConvert.INSTANCE.convert(experienceLog)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员经验记录分页") - @PreAuthorize("@ss.hasPermission('member:experience-record:query')") - public CommonResult> getExperienceRecordPage( - @Valid MemberExperienceRecordPageReqVO pageVO) { - PageResult pageResult = experienceLogService.getExperienceRecordPage(pageVO); - return success(MemberExperienceRecordConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java deleted file mode 100644 index 195800e98..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.*; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员等级") -@RestController -@RequestMapping("/member/level") -@Validated -public class MemberLevelController { - - @Resource - private MemberLevelService levelService; - - @PostMapping("/create") - @Operation(summary = "创建会员等级") - @PreAuthorize("@ss.hasPermission('member:level:create')") - public CommonResult createLevel(@Valid @RequestBody MemberLevelCreateReqVO createReqVO) { - return success(levelService.createLevel(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新会员等级") - @PreAuthorize("@ss.hasPermission('member:level:update')") - public CommonResult updateLevel(@Valid @RequestBody MemberLevelUpdateReqVO updateReqVO) { - levelService.updateLevel(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除会员等级") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('member:level:delete')") - public CommonResult deleteLevel(@RequestParam("id") Long id) { - levelService.deleteLevel(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员等级") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:level:query')") - public CommonResult getLevel(@RequestParam("id") Long id) { - MemberLevelDO level = levelService.getLevel(id); - return success(MemberLevelConvert.INSTANCE.convert(level)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取会员等级精简信息列表", description = "只包含被开启的会员等级,主要用于前端的下拉选项") - public CommonResult> getSimpleLevelList() { - // 获用户列表,只要开启状态的 - List list = levelService.getEnableLevelList(); - // 排序后,返回给前端 - return success(MemberLevelConvert.INSTANCE.convertSimpleList(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得会员等级列表") - @PreAuthorize("@ss.hasPermission('member:level:query')") - public CommonResult> getLevelList(@Valid MemberLevelListReqVO listReqVO) { - List result = levelService.getLevelList(listReqVO); - return success(MemberLevelConvert.INSTANCE.convertList(result)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java deleted file mode 100644 index b54a54da0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelRecordController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员等级记录") -@RestController -@RequestMapping("/member/level-record") -@Validated -public class MemberLevelRecordController { - - @Resource - private MemberLevelRecordService levelLogService; - - @GetMapping("/get") - @Operation(summary = "获得会员等级记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:level-record:query')") - public CommonResult getLevelRecord(@RequestParam("id") Long id) { - MemberLevelRecordDO levelLog = levelLogService.getLevelRecord(id); - return success(MemberLevelRecordConvert.INSTANCE.convert(levelLog)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员等级记录分页") - @PreAuthorize("@ss.hasPermission('member:level-record:query')") - public CommonResult> getLevelRecordPage( - @Valid MemberLevelRecordPageReqVO pageVO) { - PageResult pageResult = levelLogService.getLevelRecordPage(pageVO); - return success(MemberLevelRecordConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java deleted file mode 100644 index 7c71f8270..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 会员经验记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberExperienceRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3638") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12164") - @NotNull(message = "业务编号不能为空") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "增加经验") - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "经验不能为空") - private Integer experience; - - @Schema(description = "变更后的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - @NotNull(message = "变更后的经验不能为空") - private Integer totalExperience; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加 100 经验") - @NotNull(message = "描述不能为空") - private String description; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java deleted file mode 100644 index d18201d7c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员经验记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberExperienceRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "3638") - private Long userId; - - @Schema(description = "业务编号", example = "12164") - private String bizId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "标题", example = "增加经验") - private String title; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java deleted file mode 100644 index 5e652fcf0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceRecordRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.experience; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员经验记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberExperienceRecordRespVO extends MemberExperienceRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19610") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java deleted file mode 100644 index 9580647f8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Positive; - -/** - * 会员等级 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberLevelBaseVO { - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotBlank(message = "等级名称不能为空") - private String name; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "升级经验不能为空") - @Positive(message = "升级经验必须大于 0") - private Integer experience; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "等级不能为空") - @Positive(message = "等级必须大于 0") - private Integer level; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98") - @NotNull(message = "享受折扣不能为空") - @Range(min = 0, max = 100, message = "享受折扣的范围为 0-100") - private Integer discountPercent; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "等级图标必须是 URL 格式") - private String icon; - - @Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "等级背景图必须是 URL 格式") - private String backgroundUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java deleted file mode 100644 index f51a7d967..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员等级创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelCreateReqVO extends MemberLevelBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java deleted file mode 100644 index 348e78e8e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员等级列表筛选 Request VO") -@Data -@ToString(callSuper = true) -public class MemberLevelListReqVO { - - @Schema(description = "等级名称", example = "芋艿") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java deleted file mode 100644 index df91a814f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员等级 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelRespVO extends MemberLevelBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java deleted file mode 100644 index 96c515c8b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员等级 Response VO") -@Data -@ToString(callSuper = true) -public class MemberLevelSimpleRespVO { - - @Schema(description = "编号", example = "6103") - private Long id; - - @Schema(description = "等级名称", example = "芋艿") - private String name; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java deleted file mode 100644 index 83ad768de..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 会员等级更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelUpdateReqVO extends MemberLevelBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6103") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordBaseVO.java deleted file mode 100644 index 99df53648..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordBaseVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 会员等级记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberLevelRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25923") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "等级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25985") - @NotNull(message = "等级编号不能为空") - private Long levelId; - - @Schema(description = "会员等级", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "会员等级不能为空") - private Integer level; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") - @NotNull(message = "享受折扣不能为空") - private Integer discountPercent; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") - @NotNull(message = "升级经验不能为空") - private Integer experience; - - @Schema(description = "会员此时的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "13319") - @NotNull(message = "会员此时的经验不能为空") - private Integer userExperience; - - @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要") - @NotNull(message = "备注不能为空") - private String remark; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "升级为金牌会员") - @NotNull(message = "描述不能为空") - private String description; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordPageReqVO.java deleted file mode 100644 index 2590cfba6..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员等级记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "25923") - private Long userId; - - @Schema(description = "等级编号", example = "25985") - private Long levelId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordRespVO.java deleted file mode 100644 index caf98ea4e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/record/MemberLevelRecordRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员等级记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberLevelRecordRespVO extends MemberLevelRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8741") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java deleted file mode 100644 index 48972244d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/MemberPointRecordController.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.point; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.util.CollectionUtils; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 签到记录") -@RestController -@RequestMapping("/member/point/record") -@Validated -public class MemberPointRecordController { - - @Resource - private MemberPointRecordService pointRecordService; - - @Resource - private MemberUserService memberUserService; - - @GetMapping("/page") - @Operation(summary = "获得用户积分记录分页") - @PreAuthorize("@ss.hasPermission('point:record:query')") - public CommonResult> getPointRecordPage(@Valid MemberPointRecordPageReqVO pageVO) { - // 执行分页查询 - PageResult pageResult = pointRecordService.getPointRecordPage(pageVO); - if (CollectionUtils.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接结果返回 - List users = memberUserService.getUserList( - convertSet(pageResult.getList(), MemberPointRecordDO::getUserId)); - return success(MemberPointRecordConvert.INSTANCE.convertPage(pageResult, users)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java deleted file mode 100644 index 63cc80006..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 用户积分记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberPointRecordPageReqVO extends PageParam { - - @Schema(description = "用户昵称", example = "张三") - private String nickname; - - @Schema(description = "用户编号", example = "123") - private Long userId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "积分标题", example = "呵呵") - private String title; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java deleted file mode 100644 index 6714aa87f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/point/vo/recrod/MemberPointRecordRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户积分记录 Response VO") -@Data -public class MemberPointRecordRespVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "昵称", example = "张三") - private String nickname; - - @Schema(description = "业务编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "22706") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String title; - - @Schema(description = "积分描述", example = "你猜") - private String description; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer point; - - @Schema(description = "变动后的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalPoint; - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java deleted file mode 100644 index 65bfe44c2..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -// TODO 芋艿:url -@Tag(name = "管理后台 - 签到规则") -@RestController -@RequestMapping("/member/sign-in/config") -@Validated -public class MemberSignInConfigController { - - @Resource - private MemberSignInConfigService signInConfigService; - - @PostMapping("/create") - @Operation(summary = "创建签到规则") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:create')") - public CommonResult createSignInConfig(@Valid @RequestBody MemberSignInConfigCreateReqVO createReqVO) { - return success(signInConfigService.createSignInConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新签到规则") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:update')") - public CommonResult updateSignInConfig(@Valid @RequestBody MemberSignInConfigUpdateReqVO updateReqVO) { - signInConfigService.updateSignInConfig(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除签到规则") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('point:sign-in-config:delete')") - public CommonResult deleteSignInConfig(@RequestParam("id") Long id) { - signInConfigService.deleteSignInConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得签到规则") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") - public CommonResult getSignInConfig(@RequestParam("id") Long id) { - MemberSignInConfigDO signInConfig = signInConfigService.getSignInConfig(id); - return success(MemberSignInConfigConvert.INSTANCE.convert(signInConfig)); - } - - @GetMapping("/list") - @Operation(summary = "获得签到规则列表") - @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") - public CommonResult> getSignInConfigList() { - List list = signInConfigService.getSignInConfigList(); - return success(MemberSignInConfigConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java deleted file mode 100644 index 8bf179650..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.util.CollectionUtils; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 签到记录") -@RestController -@RequestMapping("/member/sign-in/record") -@Validated -public class MemberSignInRecordController { - - @Resource - private MemberSignInRecordService signInRecordService; - - @Resource - private MemberUserService memberUserService; - - @GetMapping("/page") - @Operation(summary = "获得签到记录分页") - @PreAuthorize("@ss.hasPermission('point:sign-in-record:query')") - public CommonResult> getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) { - // 执行分页查询 - PageResult pageResult = signInRecordService.getSignInRecordPage(pageVO); - if (CollectionUtils.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接结果返回 - List users = memberUserService.getUserList( - convertSet(pageResult.getList(), MemberSignInRecordDO::getUserId)); - return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult, users)); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigBaseVO.java deleted file mode 100644 index 2ddeeb9be..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigBaseVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; - -/** - * 签到规则 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberSignInConfigBaseVO { - - @Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - @NotNull(message = "签到天数不能为空") - private Integer day; - - @Schema(description = "奖励积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "奖励积分不能为空") - @PositiveOrZero(message = "奖励积分不能小于 0") - private Integer point; - - @Schema(description = "奖励经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "奖励经验不能为空") - @PositiveOrZero(message = "奖励经验不能小于 0") - private Integer experience; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @AssertTrue(message = "签到奖励积分和经验不能同时为空") - @JsonIgnore - public boolean isConfigAward() { - return ObjUtil.notEqual(point, 0) || ObjUtil.notEqual(experience, 0); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigCreateReqVO.java deleted file mode 100644 index 7ca03fa93..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 签到规则创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInConfigCreateReqVO extends MemberSignInConfigBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigRespVO.java deleted file mode 100644 index 8d423b25c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 签到规则 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInConfigRespVO extends MemberSignInConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20937") - private Integer id; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigUpdateReqVO.java deleted file mode 100644 index 89b6de15c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/config/MemberSignInConfigUpdateReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 签到规则更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInConfigUpdateReqVO extends MemberSignInConfigBaseVO { - - @Schema(description = "规则自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13653") - @NotNull(message = "规则自增主键不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java deleted file mode 100644 index b46712b6e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 签到记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberSignInRecordPageReqVO extends PageParam { - - @Schema(description = "签到用户", example = "土豆") - private String nickname; - - @Schema(description = "第几天签到", example = "10") - private Integer day; - - @Schema(description = "用户编号", example = "123") - private Long userId; - - @Schema(description = "签到时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordRespVO.java deleted file mode 100644 index b5755ba53..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/record/MemberSignInRecordRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.signin.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 签到记录 Response VO") -@Data -public class MemberSignInRecordRespVO { - - @Schema(description = "签到自增 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11903") - private Long id; - - @Schema(description = "签到用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "6507") - private Long userId; - - @Schema(description = "昵称", example = "张三") - private String nickname; - - @Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer day; - - @Schema(description = "签到的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - - @Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java deleted file mode 100644 index 34f3c20cc..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagRespVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.tag.MemberTagConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.service.tag.MemberTagService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员标签") -@RestController -@RequestMapping("/member/tag") -@Validated -public class MemberTagController { - - @Resource - private MemberTagService tagService; - - @PostMapping("/create") - @Operation(summary = "创建会员标签") - @PreAuthorize("@ss.hasPermission('member:tag:create')") - public CommonResult createTag(@Valid @RequestBody MemberTagCreateReqVO createReqVO) { - return success(tagService.createTag(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新会员标签") - @PreAuthorize("@ss.hasPermission('member:tag:update')") - public CommonResult updateTag(@Valid @RequestBody MemberTagUpdateReqVO updateReqVO) { - tagService.updateTag(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除会员标签") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('member:tag:delete')") - public CommonResult deleteTag(@RequestParam("id") Long id) { - tagService.deleteTag(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员标签") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:tag:query')") - public CommonResult getMemberTag(@RequestParam("id") Long id) { - MemberTagDO tag = tagService.getTag(id); - return success(MemberTagConvert.INSTANCE.convert(tag)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取会员标签精简信息列表", description = "只包含被开启的会员标签,主要用于前端的下拉选项") - public CommonResult> getSimpleTagList() { - // 获用户列表,只要开启状态的 - List list = tagService.getTagList(); - // 排序后,返回给前端 - return success(MemberTagConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得会员标签列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('member:tag:query')") - public CommonResult> getMemberTagList(@RequestParam("ids") Collection ids) { - List list = tagService.getTagList(ids); - return success(MemberTagConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员标签分页") - @PreAuthorize("@ss.hasPermission('member:tag:query')") - public CommonResult> getTagPage(@Valid MemberTagPageReqVO pageVO) { - PageResult pageResult = tagService.getTagPage(pageVO); - return success(MemberTagConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagBaseVO.java deleted file mode 100644 index bc0efea68..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagBaseVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 会员标签 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberTagBaseVO { - - @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "标签名称不能为空") - private String name; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagCreateReqVO.java deleted file mode 100644 index b61f26bb2..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 会员标签创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagCreateReqVO extends MemberTagBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagPageReqVO.java deleted file mode 100644 index 99f59b068..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员标签分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagPageReqVO extends PageParam { - - @Schema(description = "标签名称", example = "李四") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagRespVO.java deleted file mode 100644 index 2c21f53e3..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 会员标签 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagRespVO extends MemberTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "907") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagUpdateReqVO.java deleted file mode 100644 index 2fe0e614d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/vo/MemberTagUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 会员标签更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberTagUpdateReqVO extends MemberTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "907") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java deleted file mode 100644 index b382c1caf..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.*; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.group.MemberGroupService; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import cn.iocoder.yudao.module.member.service.tag.MemberTagService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 会员用户") -@RestController -@RequestMapping("/member/user") -@Validated -public class MemberUserController { - - @Resource - private MemberUserService memberUserService; - @Resource - private MemberTagService memberTagService; - @Resource - private MemberLevelService memberLevelService; - @Resource - private MemberGroupService memberGroupService; - @Resource - private MemberPointRecordService memberPointRecordService; - - @PutMapping("/update") - @Operation(summary = "更新会员用户") - @PreAuthorize("@ss.hasPermission('member:user:update')") - public CommonResult updateUser(@Valid @RequestBody MemberUserUpdateReqVO updateReqVO) { - memberUserService.updateUser(updateReqVO); - return success(true); - } - - @PutMapping("/update-level") - @Operation(summary = "更新会员用户等级") - @PreAuthorize("@ss.hasPermission('member:user:update-level')") - public CommonResult updateUserLevel(@Valid @RequestBody MemberUserUpdateLevelReqVO updateReqVO) { - memberLevelService.updateUserLevel(updateReqVO); - return success(true); - } - - @PutMapping("/update-point") - @Operation(summary = "更新会员用户积分") - @PreAuthorize("@ss.hasPermission('member:user:update-point')") - public CommonResult updateUserPoint(@Valid @RequestBody MemberUserUpdatePointReqVO updateReqVO) { - memberPointRecordService.createPointRecord(updateReqVO.getId(), updateReqVO.getPoint(), - MemberPointBizTypeEnum.ADMIN, String.valueOf(getLoginUserId())); - return success(true); - } - - @PutMapping("/update-balance") - @Operation(summary = "更新会员用户余额") - @PreAuthorize("@ss.hasPermission('member:user:update-balance')") - public CommonResult updateUserBalance(@Valid @RequestBody Long id) { - // todo @jason:增加一个【修改余额】 - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得会员用户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('member:user:query')") - public CommonResult getUser(@RequestParam("id") Long id) { - MemberUserDO user = memberUserService.getUser(id); - return success(MemberUserConvert.INSTANCE.convert03(user)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员用户分页") - @PreAuthorize("@ss.hasPermission('member:user:query')") - public CommonResult> getUserPage(@Valid MemberUserPageReqVO pageVO) { - PageResult pageResult = memberUserService.getUserPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 处理用户标签返显 - Set tagIds = pageResult.getList().stream() - .map(MemberUserDO::getTagIds) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .collect(Collectors.toSet()); - List tags = memberTagService.getTagList(tagIds); - // 处理用户级别返显 - List levels = memberLevelService.getLevelList( - convertSet(pageResult.getList(), MemberUserDO::getLevelId)); - // 处理用户分组返显 - List groups = memberGroupService.getGroupList( - convertSet(pageResult.getList(), MemberUserDO::getGroupId)); - return success(MemberUserConvert.INSTANCE.convertPage(pageResult, tags, levels, groups)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java deleted file mode 100644 index e20963e5e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserBaseVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -/** - * 会员用户 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MemberUserBaseVO { - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - @NotNull(message = "手机号不能为空") - private String mobile; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Byte status; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "用户昵称不能为空") - private String nickname; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/x.png") - @URL(message = "头像必须是 URL 格式") - private String avatar; - - @Schema(description = "用户昵称", example = "李四") - private String name; - - @Schema(description = "用户性别", example = "1") - private Byte sex; - - @Schema(description = "所在地编号", example = "4371") - private Long areaId; - - @Schema(description = "所在地全程", example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "出生日期", example = "2023-03-12") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime birthday; - - @Schema(description = "会员备注", example = "我是小备注") - private String mark; - - @Schema(description = "会员标签", example = "[1, 2]") - private List tagIds; - - @Schema(description = "会员等级编号", example = "1") - private Long levelId; - - @Schema(description = "用户分组编号", example = "1") - private Long groupId; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java deleted file mode 100644 index abb94285e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员用户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberUserPageReqVO extends PageParam { - - @Schema(description = "手机号", example = "15601691300") - private String mobile; - - @Schema(description = "用户昵称", example = "李四") - private String nickname; - - @Schema(description = "最后登录时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] loginDate; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "会员标签编号列表", example = "[1, 2]") - private List tagIds; - - @Schema(description = "会员等级编号", example = "1") - private Long levelId; - - @Schema(description = "用户分组编号", example = "1") - private Long groupId; - - // TODO 芋艿:注册用户类型; - - // TODO 芋艿:登录用户类型; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java deleted file mode 100644 index 1cd228335..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 会员用户 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberUserRespVO extends MemberUserBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - private Long id; - - @Schema(description = "注册 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String registerIp; - - @Schema(description = "最后登录IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String loginIp; - - @Schema(description = "最后登录时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime loginDate; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 其它信息 ========== - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer point; - - @Schema(description = "总积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer totalPoint; - - @Schema(description = "会员标签", example = "[红色, 快乐]") - private List tagNames; - - @Schema(description = "会员等级", example = "黄金会员") - private String levelName; - - @Schema(description = "用户分组", example = "购物达人") - private String groupName; - - @Schema(description = "用户经验值", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer experience; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java deleted file mode 100644 index dba48f670..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateLevelReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户修改等级 Request VO") -@Data -@ToString(callSuper = true) -public class MemberUserUpdateLevelReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - @NotNull(message = "用户编号不能为空") - private Long id; - - /** - * 取消用户等级时,值为空 - */ - @Schema(description = "用户等级编号", example = "1") - private Long levelId; - - @Schema(description = "修改原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "推广需要") - @NotBlank(message = "修改原因不能为空") - private String reason; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePointReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePointReqVO.java deleted file mode 100644 index a072c0726..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdatePointReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户修改积分 Request VO") -@Data -@ToString(callSuper = true) -public class MemberUserUpdatePointReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "变动积分,正数为增加,负数为减少", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "变动积分不能为空") - private Integer point; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateReqVO.java deleted file mode 100644 index c6a92758d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/vo/MemberUserUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 会员用户更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MemberUserUpdateReqVO extends MemberUserBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23788") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.http deleted file mode 100644 index 6bae7c7eb..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.http +++ /dev/null @@ -1,54 +0,0 @@ -### 请求 /create 接口 => 成功 -POST {{appApi}}//member/address/create -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -{ - "name": "yunai", - "mobile": "15601691300", - "areaId": "610632", - "postCode": "200000", - "detailAddress": "芋道源码 233 号 666 室", - "defaulted": true -} - -### 请求 /update 接口 => 成功 -PUT {{appApi}}//member/address/update -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -{ - "id": "1", - "name": "yunai888", - "mobile": "15601691300", - "areaId": "610632", - "postCode": "200000", - "detailAddress": "芋道源码 233 号 666 室", - "defaulted": false -} - -### 请求 /delete 接口 => 成功 -DELETE {{appApi}}//member/address/delete?id=2 -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /get 接口 => 成功 -GET {{appApi}}//member/address/get?id=1 -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /get-default 接口 => 成功 -GET {{appApi}}//member/address/get-default -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /list 接口 => 成功 -GET {{appApi}}//member/address/list -Content-Type: application/json -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.java deleted file mode 100644 index 7ba55c3bd..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/AppAddressController.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.service.address.AddressService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 用户收件地址") -@RestController -@RequestMapping("/member/address") -@Validated -public class AppAddressController { - - @Resource - private AddressService addressService; - - @PostMapping("/create") - @Operation(summary = "创建用户收件地址") - @PreAuthenticated - public CommonResult createAddress(@Valid @RequestBody AppAddressCreateReqVO createReqVO) { - return success(addressService.createAddress(getLoginUserId(), createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户收件地址") - @PreAuthenticated - public CommonResult updateAddress(@Valid @RequestBody AppAddressUpdateReqVO updateReqVO) { - addressService.updateAddress(getLoginUserId(), updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户收件地址") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthenticated - public CommonResult deleteAddress(@RequestParam("id") Long id) { - addressService.deleteAddress(getLoginUserId(), id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户收件地址") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult getAddress(@RequestParam("id") Long id) { - MemberAddressDO address = addressService.getAddress(getLoginUserId(), id); - return success(AddressConvert.INSTANCE.convert(address)); - } - - @GetMapping("/get-default") - @Operation(summary = "获得默认的用户收件地址") - @PreAuthenticated - public CommonResult getDefaultUserAddress() { - MemberAddressDO address = addressService.getDefaultUserAddress(getLoginUserId()); - return success(AddressConvert.INSTANCE.convert(address)); - } - - @GetMapping("/list") - @Operation(summary = "获得用户收件地址列表") - @PreAuthenticated - public CommonResult> getAddressList() { - List list = addressService.getAddressList(getLoginUserId()); - return success(AddressConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java deleted file mode 100644 index 076ce36ff..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -// TODO 芋艿:example 缺失 -/** -* 用户收件地址 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class AppAddressBaseVO { - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收件人名称不能为空") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "手机号不能为空") - private String mobile; - - @Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "地区编号不能为空") - private Long areaId; - - @Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收件详细地址不能为空") - private String detailAddress; - - @Schema(description = "是否默认地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "是否默认地址不能为空") - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressCreateReqVO.java deleted file mode 100644 index c92687f27..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "用户 APP - 用户收件地址创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppAddressCreateReqVO extends AppAddressBaseVO { - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java deleted file mode 100644 index d3e2f9ffd..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 APP - 用户收件地址 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppAddressRespVO extends AppAddressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java deleted file mode 100644 index 19b58d807..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.address.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "用户 APP - 用户收件地址更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppAddressUpdateReqVO extends AppAddressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.http deleted file mode 100644 index 5b68d6984..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.http +++ /dev/null @@ -1,67 +0,0 @@ -### 请求 /login 接口 => 成功 -POST {{appApi}}/member/auth/login -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "mobile": "15601691388", - "password": "admin123" -} - -### 请求 /send-sms-code 接口 => 成功 -POST {{appApi}}/member/auth/send-sms-code -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "mobile": "15601691388", - "scene": 1 -} - -### 请求 /sms-login 接口 => 成功 -POST {{appApi}}/member/auth/sms-login -Content-Type: application/json -tenant-id: {{appTenentId}} -terminal: 30 - -{ - "mobile": "15601691388", - "code": 9999 -} - -### 请求 /social-login 接口 => 成功 -POST {{appApi}}/member/auth/social-login -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "type": 34, - "code": "0e1oc9000CTjFQ1oim200bhtb61oc90g", - "state": "default" -} - -### 请求 /weixin-mini-app-login 接口 => 成功 -POST {{appApi}}/member/auth/weixin-mini-app-login -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "phoneCode": "618e6412e0c728f5b8fc7164497463d0158a923c9e7fd86af8bba393b9decbc5", - "loginCode": "001frTkl21JUf94VGxol2hSlff1frTkR" -} - -### 请求 /logout 接口 => 成功 -POST {{appApi}}/member/auth/logout -Content-Type: application/json -Authorization: Bearer c1b76bdaf2c146c581caa4d7fd81ee66 -tenant-id: {{appTenentId}} - -### 请求 /auth/refresh-token 接口 => 成功 -POST {{appApi}}/member/auth/refresh-token?refreshToken=bc43d929094849a28b3a69f6e6940d70 -Content-Type: application/json -tenant-id: {{appTenentId}} - -### 请求 /auth/create-weixin-jsapi-signature 接口 => 成功 -POST {{appApi}}/member/auth/create-weixin-jsapi-signature?url=http://www.iocoder.cn -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java deleted file mode 100644 index 1f3cd8def..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; -import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; -import cn.iocoder.yudao.module.member.service.auth.MemberAuthService; -import cn.iocoder.yudao.module.system.api.social.SocialClientApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 认证") -@RestController -@RequestMapping("/member/auth") -@Validated -@Slf4j -public class AppAuthController { - - @Resource - private MemberAuthService authService; - - @Resource - private SocialClientApi socialClientApi; - - @Resource - private SecurityProperties securityProperties; - - @PostMapping("/login") - @Operation(summary = "使用手机 + 密码登录") - public CommonResult login(@RequestBody @Valid AppAuthLoginReqVO reqVO) { - return success(authService.login(reqVO)); - } - - @PostMapping("/logout") - @PermitAll - @Operation(summary = "登出系统") - public CommonResult logout(HttpServletRequest request) { - String token = SecurityFrameworkUtils.obtainAuthorization(request, - securityProperties.getTokenHeader(), securityProperties.getTokenParameter()); - if (StrUtil.isNotBlank(token)) { - authService.logout(token); - } - return success(true); - } - - @PostMapping("/refresh-token") - @Operation(summary = "刷新令牌") - @Parameter(name = "refreshToken", description = "刷新令牌", required = true) - public CommonResult refreshToken(@RequestParam("refreshToken") String refreshToken) { - return success(authService.refreshToken(refreshToken)); - } - - // ========== 短信登录相关 ========== - - @PostMapping("/sms-login") - @Operation(summary = "使用手机 + 验证码登录") - public CommonResult smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO) { - return success(authService.smsLogin(reqVO)); - } - - @PostMapping("/send-sms-code") - @Operation(summary = "发送手机验证码") - public CommonResult sendSmsCode(@RequestBody @Valid AppAuthSmsSendReqVO reqVO) { - authService.sendSmsCode(getLoginUserId(), reqVO); - return success(true); - } - - @PostMapping("/validate-sms-code") - @Operation(summary = "校验手机验证码") - public CommonResult validateSmsCode(@RequestBody @Valid AppAuthSmsValidateReqVO reqVO) { - authService.validateSmsCode(getLoginUserId(), reqVO); - return success(true); - } - - // ========== 社交登录相关 ========== - - @GetMapping("/social-auth-redirect") - @Operation(summary = "社交授权的跳转") - @Parameters({ - @Parameter(name = "type", description = "社交类型", required = true), - @Parameter(name = "redirectUri", description = "回调路径") - }) - public CommonResult socialAuthRedirect(@RequestParam("type") Integer type, - @RequestParam("redirectUri") String redirectUri) { - return CommonResult.success(authService.getSocialAuthorizeUrl(type, redirectUri)); - } - - @PostMapping("/social-login") - @Operation(summary = "社交快捷登录,使用 code 授权码", description = "适合未登录的用户,但是社交账号已绑定用户") - public CommonResult socialLogin(@RequestBody @Valid AppAuthSocialLoginReqVO reqVO) { - return success(authService.socialLogin(reqVO)); - } - - @PostMapping("/weixin-mini-app-login") - @Operation(summary = "微信小程序的一键登录") - public CommonResult weixinMiniAppLogin(@RequestBody @Valid AppAuthWeixinMiniAppLoginReqVO reqVO) { - return success(authService.weixinMiniAppLogin(reqVO)); - } - - @PostMapping("/create-weixin-jsapi-signature") - @Operation(summary = "创建微信 JS SDK 初始化所需的签名", - description = "参考 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html 文档") - public CommonResult createWeixinMpJsapiSignature(@RequestParam("url") String url) { - SocialWxJsapiSignatureRespDTO signature = socialClientApi.createWxMpJsapiSignature( - UserTypeEnum.MEMBER.getValue(), url).getCheckedData(); - return success(AuthConvert.INSTANCE.convert(signature)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthCheckCodeReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthCheckCodeReqVO.java deleted file mode 100644 index eee7062cb..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthCheckCodeReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -// TODO 芋艿:code review 相关逻辑 -@Schema(description = "用户 APP - 校验验证码 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthCheckCodeReqVO { - - @Schema(description = "手机号", example = "15601691234") - @NotBlank(message = "手机号不能为空") - @Mobile - private String mobile; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotBlank(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - @Schema(description = "发送场景,对应 SmsSceneEnum 枚举", example = "1") - @NotNull(message = "发送场景不能为空") - @InEnum(SmsSceneEnum.class) - private Integer scene; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginReqVO.java deleted file mode 100644 index e64209de8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginReqVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; - -@Schema(description = "用户 APP - 手机 + 密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthLoginReqVO { - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - @NotEmpty(message = "手机号不能为空") - @Mobile - private String mobile; - - @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") - @NotEmpty(message = "密码不能为空") - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") - private String password; - - // ========== 绑定社交登录时,需要传递如下参数 ========== - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - private Integer socialType; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String socialCode; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - private String socialState; - - @AssertTrue(message = "授权码不能为空") - public boolean isSocialCodeValid() { - return socialType == null || StrUtil.isNotEmpty(socialCode); - } - - @AssertTrue(message = "授权 state 不能为空") - public boolean isSocialState() { - return socialType == null || StrUtil.isNotEmpty(socialState); - } - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginRespVO.java deleted file mode 100644 index 072ec9e4b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthLoginRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 登录 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthLoginRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "访问令牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "happy") - private String accessToken; - - @Schema(description = "刷新令牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "nice") - private String refreshToken; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime expiresTime; - - /** - * 仅社交登录、社交绑定时会返回 - * - * 为什么需要返回?微信公众号、微信小程序支付需要传递 openid 给支付接口 - */ - @Schema(description = "社交用户 openid", example = "qq768") - private String openid; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java deleted file mode 100644 index 8225269a3..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsLoginReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 手机 + 验证码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthSmsLoginReqVO { - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - @NotEmpty(message = "手机号不能为空") - @Mobile - private String mobile; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - // ========== 绑定社交登录时,需要传递如下参数 ========== - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - private Integer socialType; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String socialCode; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - private String socialState; - - @AssertTrue(message = "授权码不能为空") - public boolean isSocialCodeValid() { - return socialType == null || StrUtil.isNotEmpty(socialCode); - } - - @AssertTrue(message = "授权 state 不能为空") - public boolean isSocialState() { - return socialType == null || StrUtil.isNotEmpty(socialState); - } - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsSendReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsSendReqVO.java deleted file mode 100644 index 5f4b030f3..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsSendReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 发送手机验证码 Request VO") -@Data -@Accessors(chain = true) -public class AppAuthSmsSendReqVO { - - @Schema(description = "手机号", example = "15601691234") - @Mobile - private String mobile; - - @Schema(description = "发送场景,对应 SmsSceneEnum 枚举", example = "1") - @NotNull(message = "发送场景不能为空") - @InEnum(SmsSceneEnum.class) - private Integer scene; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsValidateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsValidateReqVO.java deleted file mode 100644 index 1a57be74b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSmsValidateReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 校验手机验证码 Request VO") -@Data -@Accessors(chain = true) -public class AppAuthSmsValidateReqVO { - - @Schema(description = "手机号", example = "15601691234") - @Mobile - private String mobile; - - @Schema(description = "发送场景,对应 SmsSceneEnum 枚举", example = "1") - @NotNull(message = "发送场景不能为空") - @InEnum(SmsSceneEnum.class) - private Integer scene; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSocialLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSocialLoginReqVO.java deleted file mode 100644 index d3bac4799..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthSocialLoginReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 社交快捷登录 Request VO,使用 code 授权码") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthSocialLoginReqVO { - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "授权码不能为空") - private String code; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - @NotEmpty(message = "state 不能为空") - private String state; - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java deleted file mode 100644 index b14f18295..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "用户 APP - 微信小程序手机登录 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppAuthWeixinMiniAppLoginReqVO { - - @Schema(description = "手机 code,小程序通过 wx.getPhoneNumber 方法获得", requiredMode = Schema.RequiredMode.REQUIRED, example = "hello") - @NotEmpty(message = "手机 code 不能为空") - private String phoneCode; - - @Schema(description = "登录 code,小程序通过 wx.login 方法获得", requiredMode = Schema.RequiredMode.REQUIRED, example = "word") - @NotEmpty(message = "登录 code 不能为空") - private String loginCode; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - @NotEmpty(message = "state 不能为空") - private String state; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AuthWeixinJsapiSignatureRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AuthWeixinJsapiSignatureRespVO.java deleted file mode 100644 index 37e63652b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AuthWeixinJsapiSignatureRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.auth.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "用户 APP - 微信公众号 JSAPI 签名 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AuthWeixinJsapiSignatureRespVO { - - @Schema(description = "微信公众号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "hello") - private String appId; - - @Schema(description = "匿名串", requiredMode = Schema.RequiredMode.REQUIRED, example = "world") - private String nonceStr; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long timestamp; - - @Schema(description = "URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String url; - - @Schema(description = "签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "阿巴阿巴") - private String signature; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberExperienceRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberExperienceRecordController.java deleted file mode 100644 index 5c33e5c1b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberExperienceRecordController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.level.vo.experience.AppMemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.service.level.MemberExperienceRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 会员经验记录") -@RestController -@RequestMapping("/member/experience-record") -@Validated -public class AppMemberExperienceRecordController { - - @Resource - private MemberExperienceRecordService experienceLogService; - - @GetMapping("/page") - @Operation(summary = "获得会员经验记录分页") - @PreAuthenticated - public CommonResult> getExperienceRecordPage( - @Valid PageParam pageParam) { - PageResult pageResult = experienceLogService.getExperienceRecordPage( - getLoginUserId(), pageParam); - return success(MemberExperienceRecordConvert.INSTANCE.convertPage02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberLevelController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberLevelController.java deleted file mode 100644 index d4a4483af..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/AppMemberLevelController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.app.level.vo.level.AppMemberLevelRespVO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 会员等级") -@RestController -@RequestMapping("/member/level") -@Validated -public class AppMemberLevelController { - - @Resource - private MemberLevelService levelService; - - @GetMapping("/list") - @Operation(summary = "获得会员等级列表") - public CommonResult> getLevelList() { - List result = levelService.getEnableLevelList(); - return success(MemberLevelConvert.INSTANCE.convertList02(result)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/experience/AppMemberExperienceRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/experience/AppMemberExperienceRecordRespVO.java deleted file mode 100644 index e2d7bb0c3..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/experience/AppMemberExperienceRecordRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level.vo.experience; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 会员经验记录 Response VO") -@Data -public class AppMemberExperienceRecordRespVO { - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "增加经验") - private String title; - - @Schema(description = "经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer experience; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加 100 经验") - private String description; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/level/AppMemberLevelRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/level/AppMemberLevelRespVO.java deleted file mode 100644 index fdade172f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/level/vo/level/AppMemberLevelRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.level.vo.level; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 会员等级 Response VO") -@Data -public class AppMemberLevelRespVO { - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String name; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer level; - - @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer experience; - - @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98") - private Integer discountPercent; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - @Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg") - private String backgroundUrl; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java deleted file mode 100644 index 3871b5446..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/AppMemberPointRecordController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.point; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.convert.point.MemberPointRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 签到记录") -@RestController -@RequestMapping("/member/point/record") -@Validated -public class AppMemberPointRecordController { - - @Resource - private MemberPointRecordService pointRecordService; - - @GetMapping("/page") - @Operation(summary = "获得用户积分记录分页") - @PreAuthenticated - public CommonResult> getPointRecordPage( - @Valid AppMemberPointRecordPageReqVO pageReqVO) { - PageResult pageResult = pointRecordService.getPointRecordPage(getLoginUserId(), pageReqVO); - return success(BeanUtils.toBean(pageResult, AppMemberPointRecordRespVO.class)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordPageReqVO.java deleted file mode 100644 index 5e51ce658..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordPageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.point.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "用户 App - 用户积分记录分页 Request VO") -@Data -public class AppMemberPointRecordPageReqVO extends PageParam { - - @Schema(description = "是否增加积分", example = "true") - private Boolean addStatus; // true - 增加;false - 减少;null - 不筛选 - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java deleted file mode 100644 index 51bbe7b00..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.point.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 用户积分记录 Response VO") -@Data -public class AppMemberPointRecordRespVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457") - private Long id; - - @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String title; - - @Schema(description = "积分描述", example = "你猜") - private String description; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer point; - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java deleted file mode 100644 index 62a52e3d8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInConfigController.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.config.AppMemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 签到规则") -@RestController -@RequestMapping("/member/sign-in/config") -@Validated -public class AppMemberSignInConfigController { - - @Resource - private MemberSignInConfigService signInConfigService; - - @GetMapping("/list") - @Operation(summary = "获得签到规则列表") - public CommonResult> getSignInConfigList() { - List pageResult = signInConfigService.getSignInConfigList(CommonStatusEnum.ENABLE.getStatus()); - return success(MemberSignInConfigConvert.INSTANCE.convertList02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java deleted file mode 100644 index 2f7afa042..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInRecordController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 签到记录") -@RestController -@RequestMapping("/member/sign-in/record") -@Validated -public class AppMemberSignInRecordController { - - @Resource - private MemberSignInRecordService signInRecordService; - - @GetMapping("/get-summary") - @Operation(summary = "获得个人签到统计") - @PreAuthenticated - public CommonResult getSignInRecordSummary() { - return success(signInRecordService.getSignInRecordSummary(getLoginUserId())); - } - - @PostMapping("/create") - @Operation(summary = "签到") - @PreAuthenticated - public CommonResult createSignInRecord() { - MemberSignInRecordDO recordDO = signInRecordService.createSignRecord(getLoginUserId()); - return success(MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO)); - } - - @GetMapping("/page") - @Operation(summary = "获得签到记录分页") - @PreAuthenticated - public CommonResult> getSignRecordPage(PageParam pageParam) { - PageResult pageResult = signInRecordService.getSignRecordPage(getLoginUserId(), pageParam); - return success(MemberSignInRecordConvert.INSTANCE.convertPage02(pageResult)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/config/AppMemberSignInConfigRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/config/AppMemberSignInConfigRespVO.java deleted file mode 100644 index a18d3a28e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/config/AppMemberSignInConfigRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 签到规则 Response VO") -@Data -public class AppMemberSignInConfigRespVO { - - @Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - private Integer day; - - @Schema(description = "奖励积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordRespVO.java deleted file mode 100644 index 2d910d0c6..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 签到记录 Response VO") -@Data -public class AppMemberSignInRecordRespVO { - - @Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer day; - - @Schema(description = "签到的分数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - - @Schema(description = "签到的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer experience; - - @Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordSummaryRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordSummaryRespVO.java deleted file mode 100644 index 30fb66a15..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/record/AppMemberSignInRecordSummaryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.signin.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 个人签到统计 Response VO") -@Data -public class AppMemberSignInRecordSummaryRespVO { - - @Schema(description = "总签到天数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer totalDay; - - @Schema(description = "连续签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer continuousDay; - - @Schema(description = "今天是否已签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean todaySignIn; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java deleted file mode 100644 index d6d89adcb..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserBindReqVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserRespVO; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 社交用户") -@RestController -@RequestMapping("/member/social-user") -@Validated -public class AppSocialUserController { - - @Resource - private SocialUserApi socialUserApi; - - @PostMapping("/bind") - @Operation(summary = "社交绑定,使用 code 授权码") - public CommonResult socialBind(@RequestBody @Valid AppSocialUserBindReqVO reqVO) { - SocialUserBindReqDTO reqDTO = new SocialUserBindReqDTO(getLoginUserId(), UserTypeEnum.MEMBER.getValue(), - reqVO.getType(), reqVO.getCode(), reqVO.getState()); - String openid = socialUserApi.bindSocialUser(reqDTO).getCheckedData(); - return success(openid); - } - - @DeleteMapping("/unbind") - @Operation(summary = "取消社交绑定") - @PreAuthenticated - public CommonResult socialUnbind(@RequestBody AppSocialUserUnbindReqVO reqVO) { - SocialUserUnbindReqDTO reqDTO = new SocialUserUnbindReqDTO(getLoginUserId(), UserTypeEnum.MEMBER.getValue(), - reqVO.getType(), reqVO.getOpenid()); - socialUserApi.unbindSocialUser(reqDTO).getCheckedData(); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得社交用户") - @Parameter(name = "type", description = "社交平台的类型,参见 SocialTypeEnum 枚举值", required = true, example = "10") - @PreAuthenticated - public CommonResult getSocialUser(@RequestParam("type") Integer type) { - SocialUserRespDTO socialUser = socialUserApi.getSocialUserByUserId(UserTypeEnum.MEMBER.getValue(), getLoginUserId(), type).getCheckedData(); - return success(BeanUtils.toBean(socialUser, AppSocialUserRespVO.class)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserBindReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserBindReqVO.java deleted file mode 100644 index 289336356..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserBindReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 社交绑定 Request VO,使用 code 授权码") -@Data -public class AppSocialUserBindReqVO { - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; - - @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "授权码不能为空") - private String code; - - @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") - @NotEmpty(message = "state 不能为空") - private String state; - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserRespVO.java deleted file mode 100644 index f37ced800..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 社交用户 Response VO") -@Data -public class AppSocialUserRespVO { - - @Schema(description = "社交用户的 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "IPRmJ0wvBptiPIlGEZiPewGwiEiE") - private String openid; - - @Schema(description = "社交用户的昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String nickname; - - @Schema(description = "社交用户的头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String avatar; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserUnbindReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserUnbindReqVO.java deleted file mode 100644 index 7409ab26c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialUserUnbindReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.social.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 APP - 取消社交绑定 Request VO") -@Data -public class AppSocialUserUnbindReqVO { - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; - - @Schema(description = "社交用户的 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "IPRmJ0wvBptiPIlGEZiPewGwiEiE") - @NotEmpty(message = "社交用户的 openid 不能为空") - private String openid; - -} \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http deleted file mode 100644 index 745556f75..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 请求 /member/user/profile/get 接口 => 没有权限 -GET {{appApi}}/member/user/get -Authorization: Bearer test245 -tenant-id: {{appTenentId}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java deleted file mode 100644 index 3a268e86f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppMemberUserController.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.controller.app.user.vo.*; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 用户个人中心") -@RestController -@RequestMapping("/member/user") -@Validated -@Slf4j -public class AppMemberUserController { - - @Resource - private MemberUserService userService; - @Resource - private MemberLevelService levelService; - - @GetMapping("/get") - @Operation(summary = "获得基本信息") - @PreAuthenticated - public CommonResult getUserInfo() { - MemberUserDO user = userService.getUser(getLoginUserId()); - MemberLevelDO level = levelService.getLevel(user.getLevelId()); - return success(MemberUserConvert.INSTANCE.convert(user, level)); - } - - @PutMapping("/update") - @Operation(summary = "修改基本信息") - @PreAuthenticated - public CommonResult updateUser(@RequestBody @Valid AppMemberUserUpdateReqVO reqVO) { - userService.updateUser(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/update-mobile") - @Operation(summary = "修改用户手机") - @PreAuthenticated - public CommonResult updateUserMobile(@RequestBody @Valid AppMemberUserUpdateMobileReqVO reqVO) { - userService.updateUserMobile(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/update-mobile-by-weixin") - @Operation(summary = "基于微信小程序的授权码,修改用户手机") - @PreAuthenticated - public CommonResult updateUserMobileByWeixin(@RequestBody @Valid AppMemberUserUpdateMobileByWeixinReqVO reqVO) { - userService.updateUserMobileByWeixin(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/update-password") - @Operation(summary = "修改用户密码", description = "用户修改密码时使用") - @PreAuthenticated - public CommonResult updateUserPassword(@RequestBody @Valid AppMemberUserUpdatePasswordReqVO reqVO) { - userService.updateUserPassword(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/reset-password") - @Operation(summary = "重置密码", description = "用户忘记密码时使用") - public CommonResult resetUserPassword(@RequestBody @Valid AppMemberUserResetPasswordReqVO reqVO) { - userService.resetUserPassword(reqVO); - return success(true); - } - -} - diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserInfoRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserInfoRespVO.java deleted file mode 100644 index fa05e16d0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserInfoRespVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "用户 APP - 用户个人信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AppMemberUserInfoRespVO { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png") - private String avatar; - - @Schema(description = "用户手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - private String mobile; - - @Schema(description = "用户性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sex; - - @Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer point; - - @Schema(description = "经验值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer experience; - - @Schema(description = "用户等级") - private Level level; - - @Schema(description = "是否成为推广员", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "用户 App - 会员等级") - @Data - public static class Level { - - @Schema(description = "等级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "等级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String name; - - @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer level; - - @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserResetPasswordReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserResetPasswordReqVO.java deleted file mode 100644 index 22cbf55ee..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserResetPasswordReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 重置密码 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppMemberUserResetPasswordReqVO { - - @Schema(description = "新密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") - @NotEmpty(message = "新密码不能为空") - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") - private String password; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - @Schema(description = "手机号",requiredMode = Schema.RequiredMode.REQUIRED,example = "15878962356") - @NotBlank(message = "手机号不能为空") - @Mobile - private String mobile; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileByWeixinReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileByWeixinReqVO.java deleted file mode 100644 index 0ba49a6f5..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileByWeixinReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "用户 APP - 基于微信小程序的授权码,修改手机 Request VO") -@Data -public class AppMemberUserUpdateMobileByWeixinReqVO { - - @Schema(description = "手机 code,小程序通过 wx.getPhoneNumber 方法获得", - requiredMode = Schema.RequiredMode.REQUIRED, example = "hello") - @NotEmpty(message = "手机 code 不能为空") - private String code; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileReqVO.java deleted file mode 100644 index a722365c7..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateMobileReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 修改手机 Request VO") -@Data -public class AppMemberUserUpdateMobileReqVO { - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - - @Schema(description = "手机号",requiredMode = Schema.RequiredMode.REQUIRED, example = "15823654487") - @NotBlank(message = "手机号不能为空") - @Length(min = 8, max = 11, message = "手机号码长度为 8-11 位") - @Mobile - private String mobile; - - @Schema(description = "原手机验证码", example = "1024") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String oldCode; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdatePasswordReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdatePasswordReqVO.java deleted file mode 100644 index cc78ca832..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdatePasswordReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -@Schema(description = "用户 APP - 修改密码 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class AppMemberUserUpdatePasswordReqVO { - - @Schema(description = "新密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") - @NotEmpty(message = "新密码不能为空") - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") - private String password; - - @Schema(description = "手机验证码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "手机验证码不能为空") - @Length(min = 4, max = 6, message = "手机验证码长度为 4-6 位") - @Pattern(regexp = "^[0-9]+$", message = "手机验证码必须都是数字") - private String code; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateReqVO.java deleted file mode 100644 index cca08e926..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/vo/AppMemberUserUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.member.controller.app.user.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.common.SexEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -@Schema(description = "用户 App - 会员用户更新 Request VO") -@Data -public class AppMemberUserUpdateReqVO { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String nickname; - - @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/x.png") - @URL(message = "头像必须是 URL 格式") - private String avatar; - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sex; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/package-info.java deleted file mode 100644 index 9e2888c69..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.member.controller; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java deleted file mode 100644 index 39dc9fa98..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.address; - -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 用户收件地址 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface AddressConvert { - - AddressConvert INSTANCE = Mappers.getMapper(AddressConvert.class); - - MemberAddressDO convert(AppAddressCreateReqVO bean); - - MemberAddressDO convert(AppAddressUpdateReqVO bean); - - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - AppAddressRespVO convert(MemberAddressDO bean); - - List convertList(List list); - - MemberAddressRespDTO convert02(MemberAddressDO bean); - - @Named("convertAreaIdToAreaName") - default String convertAreaIdToAreaName(Integer areaId) { - return AreaUtils.format(areaId); - } - - List convertList2(List list); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java deleted file mode 100644 index 29e8f4fdc..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/auth/AuthConvert.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.auth; - -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; -import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeValidateReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AuthConvert { - - AuthConvert INSTANCE = Mappers.getMapper(AuthConvert.class); - - SocialUserBindReqDTO convert(Long userId, Integer userType, AppAuthSocialLoginReqVO reqVO); - SocialUserUnbindReqDTO convert(Long userId, Integer userType, AppSocialUserUnbindReqVO reqVO); - - SmsCodeSendReqDTO convert(AppAuthSmsSendReqVO reqVO); - SmsCodeUseReqDTO convert(AppMemberUserResetPasswordReqVO reqVO, SmsSceneEnum scene, String usedIp); - SmsCodeUseReqDTO convert(AppAuthSmsLoginReqVO reqVO, Integer scene, String usedIp); - - AppAuthLoginRespVO convert(OAuth2AccessTokenRespDTO bean, String openid); - - SmsCodeValidateReqDTO convert(AppAuthSmsValidateReqVO bean); - - SocialWxJsapiSignatureRespDTO convert(SocialWxJsapiSignatureRespDTO bean); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/config/MemberConfigConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/config/MemberConfigConvert.java deleted file mode 100644 index 9847645f9..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/config/MemberConfigConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.config; - -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 会员配置 Convert - * - * @author QingX - */ -@Mapper -public interface MemberConfigConvert { - - MemberConfigConvert INSTANCE = Mappers.getMapper(MemberConfigConvert.class); - - MemberConfigRespVO convert(MemberConfigDO bean); - - MemberConfigDO convert(MemberConfigSaveReqVO bean); - - MemberConfigRespDTO convert01(MemberConfigDO config); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/group/MemberGroupConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/group/MemberGroupConvert.java deleted file mode 100644 index 06f49d60c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/group/MemberGroupConvert.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.group; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupRespVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupSimpleRespVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 用户分组 Convert - * - * @author owen - */ -@Mapper -public interface MemberGroupConvert { - - MemberGroupConvert INSTANCE = Mappers.getMapper(MemberGroupConvert.class); - - MemberGroupDO convert(MemberGroupCreateReqVO bean); - - MemberGroupDO convert(MemberGroupUpdateReqVO bean); - - MemberGroupRespVO convert(MemberGroupDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertSimpleList(List list); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberExperienceRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberExperienceRecordConvert.java deleted file mode 100644 index 93f864f08..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberExperienceRecordConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.level.vo.experience.AppMemberExperienceRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员经验记录 Convert - * - * @author owen - */ -@Mapper -public interface MemberExperienceRecordConvert { - - MemberExperienceRecordConvert INSTANCE = Mappers.getMapper(MemberExperienceRecordConvert.class); - - MemberExperienceRecordRespVO convert(MemberExperienceRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - MemberExperienceRecordDO convert(Long userId, Integer experience, Integer totalExperience, - String bizId, Integer bizType, - String title, String description); - - PageResult convertPage02(PageResult page); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java deleted file mode 100644 index f2282815e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.level; - -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelRespVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelSimpleRespVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.level.vo.level.AppMemberLevelRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员等级 Convert - * - * @author owen - */ -@Mapper -public interface MemberLevelConvert { - - MemberLevelConvert INSTANCE = Mappers.getMapper(MemberLevelConvert.class); - - MemberLevelDO convert(MemberLevelCreateReqVO bean); - - MemberLevelDO convert(MemberLevelUpdateReqVO bean); - - MemberLevelRespVO convert(MemberLevelDO bean); - - List convertList(List list); - - List convertSimpleList(List list); - - List convertList02(List list); - - MemberLevelRespDTO convert02(MemberLevelDO bean); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelRecordConvert.java deleted file mode 100644 index d01f1b63c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelRecordConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员等级记录 Convert - * - * @author owen - */ -@Mapper -public interface MemberLevelRecordConvert { - - MemberLevelRecordConvert INSTANCE = Mappers.getMapper(MemberLevelRecordConvert.class); - - MemberLevelRecordRespVO convert(MemberLevelRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default MemberLevelRecordDO copyTo(MemberLevelDO from, MemberLevelRecordDO to) { - if (from != null) { - to.setLevelId(from.getId()); - to.setLevel(from.getLevel()); - to.setDiscountPercent(from.getDiscountPercent()); - to.setExperience(from.getExperience()); - } - return to; - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/package-info.java deleted file mode 100644 index 6523a6656..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.member.convert; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java deleted file mode 100644 index 896ae350a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/point/MemberPointRecordConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.point; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 用户积分记录 Convert - * - * @author QingX - */ -@Mapper -public interface MemberPointRecordConvert { - - MemberPointRecordConvert INSTANCE = Mappers.getMapper(MemberPointRecordConvert.class); - - default PageResult convertPage(PageResult pageResult, List users) { - PageResult voPageResult = convertPage(pageResult); - // user 拼接 - Map userMap = convertMap(users, MemberUserDO::getId); - voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getUserId(), - memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()))); - return voPageResult; - } - PageResult convertPage(PageResult pageResult); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInConfigConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInConfigConvert.java deleted file mode 100644 index 5acd87151..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInConfigConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.signin; - -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.config.AppMemberSignInConfigRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 签到规则 Convert - * - * @author QingX - */ -@Mapper -public interface MemberSignInConfigConvert { - - MemberSignInConfigConvert INSTANCE = Mappers.getMapper(MemberSignInConfigConvert.class); - - MemberSignInConfigDO convert(MemberSignInConfigCreateReqVO bean); - - MemberSignInConfigDO convert(MemberSignInConfigUpdateReqVO bean); - - MemberSignInConfigRespVO convert(MemberSignInConfigDO bean); - - List convertList(List list); - - List convertList02(List list); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java deleted file mode 100644 index 9da5927f1..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.signin; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 签到记录 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface MemberSignInRecordConvert { - - MemberSignInRecordConvert INSTANCE = Mappers.getMapper(MemberSignInRecordConvert.class); - - default PageResult convertPage(PageResult pageResult, List users) { - PageResult voPageResult = convertPage(pageResult); - // user 拼接 - Map userMap = convertMap(users, MemberUserDO::getId); - voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getUserId(), - memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()))); - return voPageResult; - } - - PageResult convertPage(PageResult pageResult); - - PageResult convertPage02(PageResult pageResult); - - AppMemberSignInRecordRespVO coverRecordToAppRecordVo(MemberSignInRecordDO memberSignInRecordDO); - - default MemberSignInRecordDO convert(Long userId, MemberSignInRecordDO lastRecord, List configs) { - // 1. 计算是第几天签到 - configs.sort(Comparator.comparing(MemberSignInConfigDO::getDay)); - MemberSignInConfigDO lastConfig = CollUtil.getLast(configs); // 最大签到天数配置 - // 1.2. 计算今天是第几天签到 (只有连续签到才加否则重置为 1) - int day = 1; - if (lastRecord != null && DateUtils.isYesterday(lastRecord.getCreateTime())) { - day = lastRecord.getDay() + 1; - } - // 1.3 判断是否超出了最大签到配置 - if (day > lastConfig.getDay()) { - day = 1; // 超过最大配置的天数,重置到第一天。(也就是说开启下一轮签到) - } - - // 2.1 初始化签到信息 - MemberSignInRecordDO record = new MemberSignInRecordDO().setUserId(userId) - .setDay(day).setPoint(0).setExperience(0); - // 2.2 获取签到对应的积分 - MemberSignInConfigDO config = CollUtil.findOne(configs, item -> ObjUtil.equal(item.getDay(), record.getDay())); - if (config == null) { - return record; - } - record.setPoint(config.getPoint()); - record.setExperience(config.getExperience()); - return record; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/tag/MemberTagConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/tag/MemberTagConvert.java deleted file mode 100644 index 9d3a41f1a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/tag/MemberTagConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagRespVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 会员标签 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface MemberTagConvert { - - MemberTagConvert INSTANCE = Mappers.getMapper(MemberTagConvert.class); - - MemberTagDO convert(MemberTagCreateReqVO bean); - - MemberTagDO convert(MemberTagUpdateReqVO bean); - - MemberTagRespVO convert(MemberTagDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java deleted file mode 100644 index aae9a7601..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.member.convert.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserRespVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserInfoRespVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper(uses = {AddressConvert.class}) -public interface MemberUserConvert { - - MemberUserConvert INSTANCE = Mappers.getMapper(MemberUserConvert.class); - - AppMemberUserInfoRespVO convert(MemberUserDO bean); - - @Mapping(source = "level", target = "level") - @Mapping(source = "bean.experience", target = "experience") - AppMemberUserInfoRespVO convert(MemberUserDO bean, MemberLevelDO level); - - MemberUserRespDTO convert2(MemberUserDO bean); - - List convertList2(List list); - - MemberUserDO convert(MemberUserUpdateReqVO bean); - - PageResult convertPage(PageResult page); - - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - MemberUserRespVO convert03(MemberUserDO bean); - - default PageResult convertPage(PageResult pageResult, - List tags, - List levels, - List groups) { - PageResult result = convertPage(pageResult); - // 处理关联数据 - Map tagMap = convertMap(tags, MemberTagDO::getId, MemberTagDO::getName); - Map levelMap = convertMap(levels, MemberLevelDO::getId, MemberLevelDO::getName); - Map groupMap = convertMap(groups, MemberGroupDO::getId, MemberGroupDO::getName); - // 填充关联数据 - result.getList().forEach(user -> { - user.setTagNames(convertList(user.getTagIds(), tagMap::get)); - user.setLevelName(levelMap.get(user.getLevelId())); - user.setGroupName(groupMap.get(user.getGroupId())); - }); - return result; - } - -} diff --git "a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b7..000000000 --- "a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java deleted file mode 100644 index f2e43b563..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.address; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 用户收件地址 DO - * - * @author 芋道源码 - */ -@TableName("member_address") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberAddressDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 收件人名称 - */ - private String name; - /** - * 手机号 - */ - private String mobile; - /** - * 地区编号 - */ - private Long areaId; - /** - * 收件详细地址 - */ - private String detailAddress; - /** - * 是否默认 - * - * true - 默认收件地址 - */ - private Boolean defaultStatus; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/config/MemberConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/config/MemberConfigDO.java deleted file mode 100644 index 6efb4a1c0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/config/MemberConfigDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.config; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员配置 DO - * - * @author QingX - */ -@TableName(value = "member_config", autoResultMap = true) -@KeySequence("member_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberConfigDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - /** - * 积分抵扣开关 - */ - private Boolean pointTradeDeductEnable; - /** - * 积分抵扣,单位:分 - * - * 1 积分抵扣多少分 - */ - private Integer pointTradeDeductUnitPrice; - /** - * 积分抵扣最大值 - */ - private Integer pointTradeDeductMaxPrice; - /** - * 1 元赠送多少分 - */ - private Integer pointTradeGivePoint; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/group/MemberGroupDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/group/MemberGroupDO.java deleted file mode 100644 index c9a82ab5d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/group/MemberGroupDO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.group; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 用户分组 DO - * - * @author owen - */ -@TableName("member_group") -@KeySequence("member_group_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberGroupDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 名称 - */ - private String name; - /** - * 备注 - */ - private String remark; - /** - * 状态 - *

- * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberExperienceRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberExperienceRecordDO.java deleted file mode 100644 index d7c06d4ba..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberExperienceRecordDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.level; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员经验记录 DO - * - * @author owen - */ -@TableName("member_experience_record") -@KeySequence("member_experience_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberExperienceRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 {@link MemberUserDO#getId()} 字段 - */ - private Long userId; - /** - * 业务类型 - *

- * 枚举 {@link MemberExperienceBizTypeEnum} - */ - private Integer bizType; - /** - * 业务编号 - */ - private String bizId; - /** - * 标题 - */ - private String title; - /** - * 描述 - */ - private String description; - /** - * 经验 - */ - private Integer experience; - /** - * 变更后的经验 - */ - private Integer totalExperience; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java deleted file mode 100644 index 05035ffe5..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员等级 DO - * - * 配置每个等级需要的积分 - * - * @author owen - */ -@TableName("member_level") -@KeySequence("member_level_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberLevelDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 等级名称 - */ - private String name; - /** - * 等级 - */ - private Integer level; - /** - * 升级经验 - */ - private Integer experience; - /** - * 享受折扣 - */ - private Integer discountPercent; - - /** - * 等级图标 - */ - private String icon; - /** - * 等级背景图 - */ - private String backgroundUrl; - /** - * 状态 - *

- * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelRecordDO.java deleted file mode 100644 index 8b5451d45..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelRecordDO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.level; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员等级记录 DO - * - * 用户每次等级发生变更时,记录一条日志 - * - * @author owen - */ -@TableName("member_level_record") -@KeySequence("member_level_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberLevelRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 {@link MemberUserDO#getId()} 字段 - */ - private Long userId; - /** - * 等级编号 - * - * 关联 {@link MemberLevelDO#getId()} 字段 - */ - private Long levelId; - /** - * 会员等级 - * - * 冗余 {@link MemberLevelDO#getLevel()} 字段 - */ - private Integer level; - /** - * 享受折扣 - */ - private Integer discountPercent; - /** - * 升级经验 - */ - private Integer experience; - /** - * 会员此时的经验 - */ - private Integer userExperience; - /** - * 备注 - */ - private String remark; - /** - * 描述 - */ - private String description; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java deleted file mode 100644 index f884f08d8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/point/MemberPointRecordDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.point; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 用户积分记录 DO - * - * @author QingX - */ -@TableName("member_point_record") -@KeySequence("member_point_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberPointRecordDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 对应 MemberUserDO 的 id 属性 - */ - private Long userId; - - /** - * 业务编码 - */ - private String bizId; - /** - * 业务类型 - * - * 枚举 {@link MemberPointBizTypeEnum} - */ - private Integer bizType; - - /** - * 积分标题 - */ - private String title; - /** - * 积分描述 - */ - private String description; - - /** - * 变动积分 - * - * 1、正数表示获得积分 - * 2、负数表示消耗积分 - */ - private Integer point; - /** - * 变动后的积分 - */ - private Integer totalPoint; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java deleted file mode 100644 index 76d55c9bf..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.signin; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 签到规则 DO - * - * @author QingX - */ -@TableName("member_sign_in_config") -@KeySequence("member_sign_in_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberSignInConfigDO extends BaseDO { - - /** - * 规则自增主键 - */ - @TableId - private Long id; - /** - * 签到第 x 天 - */ - private Integer day; - /** - * 奖励积分 - */ - private Integer point; - /** - * 奖励经验 - */ - private Integer experience; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java deleted file mode 100644 index b07b5efbc..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.signin; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 签到记录 DO - * - * @author 芋道源码 - */ -@TableName("member_sign_in_record") -@KeySequence("member_sign_in_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberSignInRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 签到用户 - */ - private Long userId; - /** - * 第几天签到 - */ - private Integer day; - /** - * 签到的积分 - */ - private Integer point; - /** - * 签到的经验 - */ - private Integer experience; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/tag/MemberTagDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/tag/MemberTagDO.java deleted file mode 100644 index b984064e0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/tag/MemberTagDO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.tag; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 会员标签 DO - * - * @author 芋道源码 - */ -@TableName("member_tag") -@KeySequence("member_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberTagDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 标签名称 - */ - private String name; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java deleted file mode 100644 index 97ddc191d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.dataobject.user; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.system.enums.common.SexEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员用户 DO - * - * uk_mobile 索引:基于 {@link #mobile} 字段 - * - * @author 芋道源码 - */ -@TableName(value = "member_user", autoResultMap = true) -@KeySequence("member_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MemberUserDO extends TenantBaseDO { - - // ========== 账号信息 ========== - - /** - * 用户ID - */ - @TableId - private Long id; - /** - * 手机 - */ - private String mobile; - /** - * 加密后的密码 - * - * 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐 - */ - private String password; - /** - * 帐号状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 注册 IP - */ - private String registerIp; - /** - * 注册终端 - * 枚举 {@link TerminalEnum} - */ - private Integer registerTerminal; - /** - * 最后登录IP - */ - private String loginIp; - /** - * 最后登录时间 - */ - private LocalDateTime loginDate; - - // ========== 基础信息 ========== - - /** - * 用户昵称 - */ - private String nickname; - /** - * 用户头像 - */ - private String avatar; - - /** - * 真实名字 - */ - private String name; - /** - * 性别 - * - * 枚举 {@link SexEnum} - */ - private Integer sex; - /** - * 出生日期 - */ - private LocalDateTime birthday; - /** - * 所在地 - * - * 关联 {@link Area#getId()} 字段 - */ - private Integer areaId; - /** - * 用户备注 - */ - private String mark; - - // ========== 其它信息 ========== - - /** - * 积分 - */ - private Integer point; - // TODO 疯狂:增加一个 totalPoint;个人信息接口要返回 - - /** - * 会员标签列表,以逗号分隔 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List tagIds; - - /** - * 会员级别编号 - * - * 关联 {@link MemberLevelDO#getId()} 字段 - */ - private Long levelId; - /** - * 会员经验 - */ - private Integer experience; - /** - * 用户分组编号 - * - * 关联 {@link MemberGroupDO#getId()} 字段 - */ - private Long groupId; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/MemberAddressMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/MemberAddressMapper.java deleted file mode 100644 index 3df68c51a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/MemberAddressMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.address; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MemberAddressMapper extends BaseMapperX { - - default MemberAddressDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(MemberAddressDO::getId, id, MemberAddressDO::getUserId, userId); - } - - default List selectListByUserIdAndDefaulted(Long userId, Boolean defaulted) { - return selectList(new LambdaQueryWrapperX().eq(MemberAddressDO::getUserId, userId) - .eqIfPresent(MemberAddressDO::getDefaultStatus, defaulted)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/config/MemberConfigMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/config/MemberConfigMapper.java deleted file mode 100644 index e03938378..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/config/MemberConfigMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.config; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 积分设置 Mapper - * - * @author QingX - */ -@Mapper -public interface MemberConfigMapper extends BaseMapperX { -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/group/MemberGroupMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/group/MemberGroupMapper.java deleted file mode 100644 index da4f7b7a8..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/group/MemberGroupMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.group; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 用户分组 Mapper - * - * @author owen - */ -@Mapper -public interface MemberGroupMapper extends BaseMapperX { - - default PageResult selectPage(MemberGroupPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MemberGroupDO::getName, reqVO.getName()) - .eqIfPresent(MemberGroupDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(MemberGroupDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberGroupDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(MemberGroupDO::getStatus, status); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberExperienceRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberExperienceRecordMapper.java deleted file mode 100644 index 4e5f6f567..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberExperienceRecordMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.level; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * 会员经验记录 Mapper - * - * @author owen - */ -@Mapper -public interface MemberExperienceRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberExperienceRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberExperienceRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberExperienceRecordDO::getBizId, reqVO.getBizId()) - .eqIfPresent(MemberExperienceRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(MemberExperienceRecordDO::getTitle, reqVO.getTitle()) - .betweenIfPresent(MemberExperienceRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberExperienceRecordDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapper() - .eq(MemberExperienceRecordDO::getUserId, userId) - .orderByDesc(MemberExperienceRecordDO::getId)); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java deleted file mode 100644 index d2dcb6cb4..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.level; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 会员等级 Mapper - * - * @author owen - */ -@Mapper -public interface MemberLevelMapper extends BaseMapperX { - - default List selectList(MemberLevelListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(MemberLevelDO::getName, reqVO.getName()) - .eqIfPresent(MemberLevelDO::getStatus, reqVO.getStatus()) - .orderByAsc(MemberLevelDO::getLevel)); - } - - - default List selectListByStatus(Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(MemberLevelDO::getStatus, status) - .orderByAsc(MemberLevelDO::getLevel)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelRecordMapper.java deleted file mode 100644 index 6808b957a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelRecordMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 会员等级记录 Mapper - * - * @author owen - */ -@Mapper -public interface MemberLevelRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberLevelRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberLevelRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberLevelRecordDO::getLevelId, reqVO.getLevelId()) - .betweenIfPresent(MemberLevelRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberLevelRecordDO::getId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java deleted file mode 100644 index d0e2452c7..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/point/MemberPointRecordMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.point; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Set; - -/** - * 用户积分记录 Mapper - * - * @author QingX - */ -@Mapper -public interface MemberPointRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberPointRecordPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(MemberPointRecordDO::getUserId, userIds) - .eqIfPresent(MemberPointRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberPointRecordDO::getBizType, reqVO.getBizType()) - .likeIfPresent(MemberPointRecordDO::getTitle, reqVO.getTitle()) - .orderByDesc(MemberPointRecordDO::getId)); - } - - default PageResult selectPage(Long userId, AppMemberPointRecordPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(MemberPointRecordDO::getUserId, userId) - .betweenIfPresent(MemberPointRecordDO::getCreateTime, pageReqVO.getCreateTime()) - .gt(Boolean.TRUE.equals(pageReqVO.getAddStatus()), - MemberPointRecordDO::getPoint, 0) - .lt(Boolean.FALSE.equals(pageReqVO.getAddStatus()), - MemberPointRecordDO::getPoint, 0) - .orderByDesc(MemberPointRecordDO::getId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java deleted file mode 100644 index 211ead33d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.signin; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 签到规则 Mapper - * - * @author QingX - */ -@Mapper -public interface MemberSignInConfigMapper extends BaseMapperX { - - default MemberSignInConfigDO selectByDay(Integer day) { - return selectOne(MemberSignInConfigDO::getDay, day); - } - - default List selectListByStatus(Integer status) { - return selectList(MemberSignInConfigDO::getStatus, status); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java deleted file mode 100644 index 36400b81a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.signin; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Set; - -/** - * 签到记录 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MemberSignInRecordMapper extends BaseMapperX { - - default PageResult selectPage(MemberSignInRecordPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(MemberSignInRecordDO::getUserId, userIds) - .eqIfPresent(MemberSignInRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(MemberSignInRecordDO::getDay, reqVO.getDay()) - .betweenIfPresent(MemberSignInRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberSignInRecordDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(MemberSignInRecordDO::getUserId, userId) - .orderByDesc(MemberSignInRecordDO::getId)); - } - - /** - * 获取用户最近的签到记录信息,根据签到时间倒序 - * - * @param userId 用户编号 - * @return 签到记录列表 - */ - default MemberSignInRecordDO selectLastRecordByUserId(Long userId) { - return selectOne(new QueryWrapper() - .eq("user_id", userId) - .orderByDesc("create_time") - .last("limit 1")); - } - - default Long selectCountByUserId(Long userId) { - return selectCount(MemberSignInRecordDO::getUserId, userId); - } - - /** - * 获取用户的签到记录列表信息 - * - * @param userId 用户编号 - * @return 签到记录信息 - */ - default List selectListByUserId(Long userId) { - return selectList(MemberSignInRecordDO::getUserId, userId); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/tag/MemberTagMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/tag/MemberTagMapper.java deleted file mode 100644 index f4723e282..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/tag/MemberTagMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 会员标签 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MemberTagMapper extends BaseMapperX { - - default PageResult selectPage(MemberTagPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MemberTagDO::getName, reqVO.getName()) - .betweenIfPresent(MemberTagDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MemberTagDO::getId)); - } - - default MemberTagDO selelctByName(String name) { - return selectOne(MemberTagDO::getName, name); - } -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java deleted file mode 100644 index 3f871020c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.member.dal.mysql.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * 会员 User Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MemberUserMapper extends BaseMapperX { - - default MemberUserDO selectByMobile(String mobile) { - return selectOne(MemberUserDO::getMobile, mobile); - } - - default List selectListByNicknameLike(String nickname) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(MemberUserDO::getNickname, nickname)); - } - - default PageResult selectPage(MemberUserPageReqVO reqVO) { - // 处理 tagIds 过滤条件 - String tagIdSql = ""; - if (CollUtil.isNotEmpty(reqVO.getTagIds())) { - tagIdSql = reqVO.getTagIds().stream() - .map(tagId -> "FIND_IN_SET(" + tagId + ", tag_ids)") - .collect(Collectors.joining(" OR ")); - } - // 分页查询 - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MemberUserDO::getMobile, reqVO.getMobile()) - .betweenIfPresent(MemberUserDO::getLoginDate, reqVO.getLoginDate()) - .likeIfPresent(MemberUserDO::getNickname, reqVO.getNickname()) - .betweenIfPresent(MemberUserDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(MemberUserDO::getLevelId, reqVO.getLevelId()) - .eqIfPresent(MemberUserDO::getGroupId, reqVO.getGroupId()) - .apply(StrUtil.isNotEmpty(tagIdSql), tagIdSql) - .orderByDesc(MemberUserDO::getId)); - } - - default Long selectCountByGroupId(Long groupId) { - return selectCount(MemberUserDO::getGroupId, groupId); - } - - default Long selectCountByLevelId(Long levelId) { - return selectCount(MemberUserDO::getLevelId, levelId); - } - - default Long selectCountByTagId(Long tagId) { - return selectCount(new LambdaQueryWrapperX() - .apply("FIND_IN_SET({0}, tag_ids)", tagId)); - } - - /** - * 更新用户积分(增加) - * - * @param id 用户编号 - * @param incrCount 增加积分(正数) - */ - default void updatePointIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" point = point + " + incrCount) - .eq(MemberUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户积分(减少) - * - * @param id 用户编号 - * @param incrCount 增加积分(负数) - * @return 更新行数 - */ - default int updatePointDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" point = point + " + incrCount) // 负数,所以使用 + 号 - .eq(MemberUserDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/package-info.java deleted file mode 100644 index a45c2a161..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * DAL = Data Access Layer 数据访问层 - * 1. data object:数据对象 - * 2. redis:Redis 的 CRUD 操作 - * 3. mysql:MySQL 的 CRUD 操作 - * - * 其中,MySQL 的表以 member_ 作为前缀 - */ -package cn.iocoder.yudao.module.member.dal; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/redis/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/redis/package-info.java deleted file mode 100644 index 8dfa9fb20..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/redis/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,后续有类后,可以删除,避免 package 无法提交到 Git 上 - */ -package cn.iocoder.yudao.module.member.dal.redis; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java deleted file mode 100644 index 7e9ca95de..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 member 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.member.framework; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/rpc/config/RpcConfiguration.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index e09570c3f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.member.framework.rpc.config; - -import cn.iocoder.yudao.module.system.api.logger.LoginLogApi; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.social.SocialClientApi; -import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {SmsCodeApi.class, LoginLogApi.class, SocialUserApi.class, SocialClientApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/rpc/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/rpc/package-info.java deleted file mode 100644 index 64446f592..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.member.framework.rpc; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/security/config/SecurityConfiguration.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index f83ce068a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Member 模块的 Security 配置 - */ -@Configuration("memberSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("memberAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/security/core/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/security/core/package-info.java deleted file mode 100644 index 3abf5630f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.member.framework.security.core; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/package-info.java deleted file mode 100644 index 521f60b8c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/consumer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消费者 - */ -package cn.iocoder.yudao.module.member.mq.consumer; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/message/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/message/package-info.java deleted file mode 100644 index 6489394a1..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.member.mq.message; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/package-info.java deleted file mode 100644 index dff4c99a9..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的生产者 - */ -package cn.iocoder.yudao.module.member.mq.producer; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/user/MemberUserProducer.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/user/MemberUserProducer.java deleted file mode 100644 index 8687bb071..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/mq/producer/user/MemberUserProducer.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.member.mq.producer.user; - -import cn.iocoder.yudao.module.member.message.user.MemberUserCreateMessage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 会员用户 Producer - * - * @author owen - */ -@Slf4j -@Component -public class MemberUserProducer { - - @Resource - private ApplicationContext applicationContext; - - /** - * 发送 {@link MemberUserCreateMessage} 消息 - * - * @param userId 用户编号 - */ - public void sendUserCreateMessage(Long userId) { - applicationContext.publishEvent(new MemberUserCreateMessage().setUserId(userId)); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/package-info.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/package-info.java deleted file mode 100644 index 405aa4cbf..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * member 模块,我们放会员业务。 - * 例如说:会员中心等等 - * - * 1. Controller URL:以 /member/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 member_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.member; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java deleted file mode 100644 index 099c49c42..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressService.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.member.service.address; - -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 用户收件地址 Service 接口 - * - * @author 芋道源码 - */ -public interface AddressService { - - /** - * 创建用户收件地址 - * - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAddress(Long userId, @Valid AppAddressCreateReqVO createReqVO); - - /** - * 更新用户收件地址 - * - * @param userId 用户编号 - * @param updateReqVO 更新信息 - */ - void updateAddress(Long userId, @Valid AppAddressUpdateReqVO updateReqVO); - - /** - * 删除用户收件地址 - * - * @param userId 用户编号 - * @param id 编号 - */ - void deleteAddress(Long userId, Long id); - - /** - * 获得用户收件地址 - * - * @param id 编号 - * @return 用户收件地址 - */ - MemberAddressDO getAddress(Long userId, Long id); - - /** - * 获得用户收件地址列表 - * - * @param userId 用户编号 - * @return 用户收件地址列表 - */ - List getAddressList(Long userId); - - /** - * 获得用户默认的收件地址 - * - * @param userId 用户编号 - * @return 用户收件地址 - */ - MemberAddressDO getDefaultUserAddress(Long userId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java deleted file mode 100644 index 901f1b340..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.member.service.address; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; -import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.address.AddressConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; -import cn.iocoder.yudao.module.member.dal.mysql.address.MemberAddressMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.ADDRESS_NOT_EXISTS; - -/** - * 用户收件地址 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AddressServiceImpl implements AddressService { - - @Resource - private MemberAddressMapper memberAddressMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createAddress(Long userId, AppAddressCreateReqVO createReqVO) { - // 如果添加的是默认收件地址,则将原默认地址修改为非默认 - if (Boolean.TRUE.equals(createReqVO.getDefaultStatus())) { - List addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true); - addresses.forEach(address -> memberAddressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false))); - } - - // 插入 - MemberAddressDO address = AddressConvert.INSTANCE.convert(createReqVO); - address.setUserId(userId); - memberAddressMapper.insert(address); - // 返回 - return address.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateAddress(Long userId, AppAddressUpdateReqVO updateReqVO) { - // 校验存在,校验是否能够操作 - validAddressExists(userId, updateReqVO.getId()); - - // 如果修改的是默认收件地址,则将原默认地址修改为非默认 - if (Boolean.TRUE.equals(updateReqVO.getDefaultStatus())) { - List addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true); - addresses.stream().filter(u -> !u.getId().equals(updateReqVO.getId())) // 排除自己 - .forEach(address -> memberAddressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false))); - } - - // 更新 - MemberAddressDO updateObj = AddressConvert.INSTANCE.convert(updateReqVO); - memberAddressMapper.updateById(updateObj); - } - - @Override - public void deleteAddress(Long userId, Long id) { - // 校验存在,校验是否能够操作 - validAddressExists(userId, id); - // 删除 - memberAddressMapper.deleteById(id); - } - - private void validAddressExists(Long userId, Long id) { - MemberAddressDO addressDO = getAddress(userId, id); - if (addressDO == null) { - throw exception(ADDRESS_NOT_EXISTS); - } - } - - @Override - public MemberAddressDO getAddress(Long userId, Long id) { - return memberAddressMapper.selectByIdAndUserId(id, userId); - } - - @Override - public List getAddressList(Long userId) { - return memberAddressMapper.selectListByUserIdAndDefaulted(userId, null); - } - - @Override - public MemberAddressDO getDefaultUserAddress(Long userId) { - List addresses = memberAddressMapper.selectListByUserIdAndDefaulted(userId, true); - return CollUtil.getFirst(addresses); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java deleted file mode 100644 index 8afc09ebb..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.member.service.auth; - -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; - -import javax.validation.Valid; - -/** - * 会员的认证 Service 接口 - * - * 提供用户的账号密码登录、token 的校验等认证相关的功能 - * - * @author 芋道源码 - */ -public interface MemberAuthService { - - /** - * 手机 + 密码登录 - * - * @param reqVO 登录信息 - * @return 登录结果 - */ - AppAuthLoginRespVO login(@Valid AppAuthLoginReqVO reqVO); - - /** - * 基于 token 退出登录 - * - * @param token token - */ - void logout(String token); - - /** - * 手机 + 验证码登陆 - * - * @param reqVO 登陆信息 - * @return 登录结果 - */ - AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO); - - /** - * 社交登录,使用 code 授权码 - * - * @param reqVO 登录信息 - * @return 登录结果 - */ - AppAuthLoginRespVO socialLogin(@Valid AppAuthSocialLoginReqVO reqVO); - - /** - * 微信小程序的一键登录 - * - * @param reqVO 登录信息 - * @return 登录结果 - */ - AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO); - - /** - * 获得社交认证 URL - * - * @param type 社交平台类型 - * @param redirectUri 跳转地址 - * @return 认证 URL - */ - String getSocialAuthorizeUrl(Integer type, String redirectUri); - - /** - * 给用户发送短信验证码 - * - * @param userId 用户编号 - * @param reqVO 发送信息 - */ - void sendSmsCode(Long userId, AppAuthSmsSendReqVO reqVO); - - /** - * 校验短信验证码是否正确 - * - * @param userId 用户编号 - * @param reqVO 校验信息 - */ - void validateSmsCode(Long userId, AppAuthSmsValidateReqVO reqVO); - - /** - * 刷新访问令牌 - * - * @param refreshToken 刷新令牌 - * @return 登录结果 - */ - AppAuthLoginRespVO refreshToken(String refreshToken); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java deleted file mode 100644 index 11763d4ce..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ /dev/null @@ -1,280 +0,0 @@ -package cn.iocoder.yudao.module.member.service.auth; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; -import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import cn.iocoder.yudao.module.system.api.logger.LoginLogApi; -import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.social.SocialClientApi; -import cn.iocoder.yudao.module.system.api.social.SocialUserApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; -import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; -import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; -import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getTerminal; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员的认证 Service 接口 - * - * @author 芋道源码 - */ -@Service -@Slf4j -public class MemberAuthServiceImpl implements MemberAuthService { - - @Resource - private MemberUserService userService; - @Resource - private SmsCodeApi smsCodeApi; - @Resource - private LoginLogApi loginLogApi; - @Resource - private SocialUserApi socialUserApi; - @Resource - private SocialClientApi socialClientApi; - @Resource - private OAuth2TokenApi oauth2TokenApi; - - @Override - public AppAuthLoginRespVO login(AppAuthLoginReqVO reqVO) { - // 使用手机 + 密码,进行登录。 - MemberUserDO user = login0(reqVO.getMobile(), reqVO.getPassword()); - - // 如果 socialType 非空,说明需要绑定社交用户 - String openid = null; - if (reqVO.getSocialType() != null) { - openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())).getCheckedData(); - } - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, reqVO.getMobile(), LoginLogTypeEnum.LOGIN_MOBILE, openid); - } - - @Override - @Transactional - public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO) { - // 校验验证码 - String userIp = getClientIP(); - smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp)).getCheckedData(); - - // 获得获得注册用户 - MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp, getTerminal()); - Assert.notNull(user, "获取用户失败,结果为空"); - - // 如果 socialType 非空,说明需要绑定社交用户 - String openid = null; - if (reqVO.getSocialType() != null) { - openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())).getCheckedData(); - } - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, reqVO.getMobile(), LoginLogTypeEnum.LOGIN_SMS, openid); - } - - @Override - @Transactional - public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO) { - // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号 - SocialUserRespDTO socialUser = socialUserApi.getSocialUserByCode(UserTypeEnum.MEMBER.getValue(), reqVO.getType(), - reqVO.getCode(), reqVO.getState()).getCheckedData(); - if (socialUser == null) { - throw exception(AUTH_SOCIAL_USER_NOT_FOUND); - } - - // 情况一:已绑定,直接读取用户信息 - MemberUserDO user; - if (socialUser.getUserId() != null) { - user = userService.getUser(socialUser.getUserId()); - // 情况二:未绑定,注册用户 + 绑定用户 - } else { - user = userService.createUser(socialUser.getNickname(), socialUser.getAvatar(), getClientIP(), getTerminal()); - socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - reqVO.getType(), reqVO.getCode(), reqVO.getState())); - } - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, socialUser.getOpenid()); - } - - @Override - public AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO) { - // 获得对应的手机号信息 - SocialWxPhoneNumberInfoRespDTO phoneNumberInfo = socialClientApi.getWxMaPhoneNumberInfo( - UserTypeEnum.MEMBER.getValue(), reqVO.getPhoneCode()).getCheckedData(); - Assert.notNull(phoneNumberInfo, "获得手机信息失败,结果为空"); - - // 获得获得注册用户 - MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), - getClientIP(), TerminalEnum.WECHAT_MINI_PROGRAM.getTerminal()); - Assert.notNull(user, "获取用户失败,结果为空"); - - // 绑定社交用户 - String openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - SocialTypeEnum.WECHAT_MINI_APP.getType(), reqVO.getLoginCode(), reqVO.getState())).getCheckedData(); - - // 创建 Token 令牌,记录登录日志 - return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, openid); - } - - private AppAuthLoginRespVO createTokenAfterLoginSuccess(MemberUserDO user, String mobile, - LoginLogTypeEnum logType, String openid) { - // 插入登陆日志 - createLoginLog(user.getId(), mobile, logType, LoginResultEnum.SUCCESS); - // 创建 Token 令牌 - OAuth2AccessTokenRespDTO accessTokenRespDTO = oauth2TokenApi.createAccessToken(new OAuth2AccessTokenCreateReqDTO() - .setUserId(user.getId()).setUserType(getUserType().getValue()) - .setClientId(OAuth2ClientConstants.CLIENT_ID_DEFAULT)).getCheckedData(); - // 构建返回结果 - return AuthConvert.INSTANCE.convert(accessTokenRespDTO, openid); - } - - @Override - public String getSocialAuthorizeUrl(Integer type, String redirectUri) { - return socialClientApi.getAuthorizeUrl(type, UserTypeEnum.MEMBER.getValue(), redirectUri).getCheckedData(); - } - - private MemberUserDO login0(String mobile, String password) { - final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_MOBILE; - // 校验账号是否存在 - MemberUserDO user = userService.getUserByMobile(mobile); - if (user == null) { - createLoginLog(null, mobile, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS); - throw exception(AUTH_LOGIN_BAD_CREDENTIALS); - } - if (!userService.isPasswordMatch(password, user.getPassword())) { - createLoginLog(user.getId(), mobile, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS); - throw exception(AUTH_LOGIN_BAD_CREDENTIALS); - } - // 校验是否禁用 - if (ObjectUtil.notEqual(user.getStatus(), CommonStatusEnum.ENABLE.getStatus())) { - createLoginLog(user.getId(), mobile, logTypeEnum, LoginResultEnum.USER_DISABLED); - throw exception(AUTH_LOGIN_USER_DISABLED); - } - return user; - } - - private void createLoginLog(Long userId, String mobile, LoginLogTypeEnum logType, LoginResultEnum loginResult) { - // 插入登录日志 - LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO(); - reqDTO.setLogType(logType.getType()); - reqDTO.setTraceId(TracerUtils.getTraceId()); - reqDTO.setUserId(userId); - reqDTO.setUserType(getUserType().getValue()); - reqDTO.setUsername(mobile); - reqDTO.setUserAgent(ServletUtils.getUserAgent()); - reqDTO.setUserIp(getClientIP()); - reqDTO.setResult(loginResult.getResult()); - loginLogApi.createLoginLog(reqDTO); - // 更新最后登录时间 - if (userId != null && Objects.equals(LoginResultEnum.SUCCESS.getResult(), loginResult.getResult())) { - userService.updateUserLogin(userId, getClientIP()); - } - } - - @Override - public void logout(String token) { - // 删除访问令牌 - OAuth2AccessTokenRespDTO accessTokenRespDTO = oauth2TokenApi.removeAccessToken(token).getCheckedData(); - if (accessTokenRespDTO == null) { - return; - } - // 删除成功,则记录登出日志 - createLogoutLog(accessTokenRespDTO.getUserId()); - } - - @Override - public void sendSmsCode(Long userId, AppAuthSmsSendReqVO reqVO) { - // 情况 1:如果是修改手机场景,需要校验新手机号是否已经注册,说明不能使用该手机了 - if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene())) { - MemberUserDO user = userService.getUserByMobile(reqVO.getMobile()); - if (user != null && !Objects.equals(user.getId(), userId)) { - throw exception(AUTH_MOBILE_USED); - } - } - // 情况 2:如果是重置密码场景,需要校验手机号是存在的 - if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_RESET_PASSWORD.getScene())) { - MemberUserDO user = userService.getUserByMobile(reqVO.getMobile()); - if (user == null) { - throw exception(USER_MOBILE_NOT_EXISTS); - } - } - // 情况 3:如果是修改密码场景,需要查询手机号,无需前端传递 - if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_UPDATE_PASSWORD.getScene())) { - MemberUserDO user = userService.getUser(userId); - // TODO 芋艿:后续 member user 手机非强绑定,这块需要做下调整; - reqVO.setMobile(user.getMobile()); - } - - // 执行发送 - smsCodeApi.sendSmsCode(AuthConvert.INSTANCE.convert(reqVO).setCreateIp(getClientIP())); - } - - @Override - public void validateSmsCode(Long userId, AppAuthSmsValidateReqVO reqVO) { - smsCodeApi.validateSmsCode(AuthConvert.INSTANCE.convert(reqVO)); - } - - @Override - public AppAuthLoginRespVO refreshToken(String refreshToken) { - OAuth2AccessTokenRespDTO accessTokenDO = oauth2TokenApi.refreshAccessToken(refreshToken, - OAuth2ClientConstants.CLIENT_ID_DEFAULT).getCheckedData(); - return AuthConvert.INSTANCE.convert(accessTokenDO, null); - } - - private void createLogoutLog(Long userId) { - LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO(); - reqDTO.setLogType(LoginLogTypeEnum.LOGOUT_SELF.getType()); - reqDTO.setTraceId(TracerUtils.getTraceId()); - reqDTO.setUserId(userId); - reqDTO.setUserType(getUserType().getValue()); - reqDTO.setUsername(getMobile(userId)); - reqDTO.setUserAgent(ServletUtils.getUserAgent()); - reqDTO.setUserIp(getClientIP()); - reqDTO.setResult(LoginResultEnum.SUCCESS.getResult()); - loginLogApi.createLoginLog(reqDTO); - } - - private String getMobile(Long userId) { - if (userId == null) { - return null; - } - MemberUserDO user = userService.getUser(userId); - return user != null ? user.getMobile() : null; - } - - private UserTypeEnum getUserType() { - return UserTypeEnum.MEMBER; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigService.java deleted file mode 100644 index fc4545425..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.member.service.config; - -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; - -import javax.validation.Valid; - -/** - * 会员配置 Service 接口 - * - * @author QingX - */ -public interface MemberConfigService { - - /** - * 保存会员配置 - * - * @param saveReqVO 更新信息 - */ - void saveConfig(@Valid MemberConfigSaveReqVO saveReqVO); - - /** - * 获得会员配置 - * - * @return 积分配置 - */ - MemberConfigDO getConfig(); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigServiceImpl.java deleted file mode 100644 index be56f8a8a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/config/MemberConfigServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.member.service.config; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.member.controller.admin.config.vo.MemberConfigSaveReqVO; -import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.config.MemberConfigDO; -import cn.iocoder.yudao.module.member.dal.mysql.config.MemberConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 会员配置 Service 实现类 - * - * @author QingX - */ -@Service -@Validated -public class MemberConfigServiceImpl implements MemberConfigService { - - @Resource - private MemberConfigMapper memberConfigMapper; - - @Override - public void saveConfig(MemberConfigSaveReqVO saveReqVO) { - // 存在,则进行更新 - MemberConfigDO dbConfig = getConfig(); - if (dbConfig != null) { - memberConfigMapper.updateById(MemberConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); - return; - } - // 不存在,则进行插入 - memberConfigMapper.insert(MemberConfigConvert.INSTANCE.convert(saveReqVO)); - } - - @Override - public MemberConfigDO getConfig() { - List list = memberConfigMapper.selectList(); - return CollectionUtils.getFirst(list); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupService.java deleted file mode 100644 index 2a8303efc..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.member.service.group; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 用户分组 Service 接口 - * - * @author owen - */ -public interface MemberGroupService { - - /** - * 创建用户分组 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createGroup(@Valid MemberGroupCreateReqVO createReqVO); - - /** - * 更新用户分组 - * - * @param updateReqVO 更新信息 - */ - void updateGroup(@Valid MemberGroupUpdateReqVO updateReqVO); - - /** - * 删除用户分组 - * - * @param id 编号 - */ - void deleteGroup(Long id); - - /** - * 获得用户分组 - * - * @param id 编号 - * @return 用户分组 - */ - MemberGroupDO getGroup(Long id); - - /** - * 获得用户分组列表 - * - * @param ids 编号 - * @return 用户分组列表 - */ - List getGroupList(Collection ids); - - /** - * 获得用户分组分页 - * - * @param pageReqVO 分页查询 - * @return 用户分组分页 - */ - PageResult getGroupPage(MemberGroupPageReqVO pageReqVO); - - /** - * 获得指定状态的用户分组列表 - * - * @param status 状态 - * @return 用户分组列表 - */ - List getGroupListByStatus(Integer status); - - /** - * 获得开启状态的用户分组列表 - * - * @return 用户分组列表 - */ - default List getEnableGroupList() { - return getGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImpl.java deleted file mode 100644 index cdf1e4fee..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/group/MemberGroupServiceImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.member.service.group; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO; -import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_HAS_USER; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.GROUP_NOT_EXISTS; - -/** - * 用户分组 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberGroupServiceImpl implements MemberGroupService { - - @Resource - private MemberGroupMapper memberGroupMapper; - - @Resource - private MemberUserService memberUserService; - - @Override - public Long createGroup(MemberGroupCreateReqVO createReqVO) { - // 插入 - MemberGroupDO group = MemberGroupConvert.INSTANCE.convert(createReqVO); - memberGroupMapper.insert(group); - // 返回 - return group.getId(); - } - - @Override - public void updateGroup(MemberGroupUpdateReqVO updateReqVO) { - // 校验存在 - validateGroupExists(updateReqVO.getId()); - // 更新 - MemberGroupDO updateObj = MemberGroupConvert.INSTANCE.convert(updateReqVO); - memberGroupMapper.updateById(updateObj); - } - - @Override - public void deleteGroup(Long id) { - // 校验存在 - validateGroupExists(id); - // 校验分组下是否有用户 - validateGroupHasUser(id); - // 删除 - memberGroupMapper.deleteById(id); - } - - void validateGroupExists(Long id) { - if (memberGroupMapper.selectById(id) == null) { - throw exception(GROUP_NOT_EXISTS); - } - } - - void validateGroupHasUser(Long id) { - Long count = memberUserService.getUserCountByGroupId(id); - if (count > 0) { - throw exception(GROUP_HAS_USER); - } - } - - @Override - public MemberGroupDO getGroup(Long id) { - return memberGroupMapper.selectById(id); - } - - @Override - public List getGroupList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return memberGroupMapper.selectBatchIds(ids); - } - - @Override - public PageResult getGroupPage(MemberGroupPageReqVO pageReqVO) { - return memberGroupMapper.selectPage(pageReqVO); - } - - @Override - public List getGroupListByStatus(Integer status) { - return memberGroupMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordService.java deleted file mode 100644 index 76470f72a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordService.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; - -/** - * 会员经验记录 Service 接口 - * - * @author owen - */ -public interface MemberExperienceRecordService { - - /** - * 获得会员经验记录 - * - * @param id 编号 - * @return 会员经验记录 - */ - MemberExperienceRecordDO getExperienceRecord(Long id); - - /** - * 【管理员】获得会员经验记录分页 - * - * @param pageReqVO 分页查询 - * @return 会员经验记录分页 - */ - PageResult getExperienceRecordPage(MemberExperienceRecordPageReqVO pageReqVO); - - /** - * 【会员】获得会员经验记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 会员经验记录分页 - */ - PageResult getExperienceRecordPage(Long userId, PageParam pageParam); - - /** - * 根据业务类型, 创建 经验变动记录 - * - * @param userId 会员编号 - * @param experience 变动经验值 - * @param totalExperience 会员当前的经验 - * @param bizType 业务类型 - * @param bizId 业务ID - */ - void createExperienceRecord(Long userId, Integer experience, Integer totalExperience, - MemberExperienceBizTypeEnum bizType, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordServiceImpl.java deleted file mode 100644 index 3c1f6ec95..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberExperienceRecordServiceImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.experience.MemberExperienceRecordPageReqVO; -import cn.iocoder.yudao.module.member.convert.level.MemberExperienceRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberExperienceRecordDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberExperienceRecordMapper; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -/** - * 会员经验记录 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberExperienceRecordServiceImpl implements MemberExperienceRecordService { - - @Resource - private MemberExperienceRecordMapper experienceLogMapper; - - @Override - public MemberExperienceRecordDO getExperienceRecord(Long id) { - return experienceLogMapper.selectById(id); - } - - @Override - public PageResult getExperienceRecordPage(MemberExperienceRecordPageReqVO pageReqVO) { - return experienceLogMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getExperienceRecordPage(Long userId, PageParam pageParam) { - return experienceLogMapper.selectPage(userId, pageParam); - } - - @Override - public void createExperienceRecord(Long userId, Integer experience, Integer totalExperience, - MemberExperienceBizTypeEnum bizType, String bizId) { - String description = StrUtil.format(bizType.getDescription(), experience); - MemberExperienceRecordDO record = MemberExperienceRecordConvert.INSTANCE.convert( - userId, experience, totalExperience, - bizId, bizType.getType(), bizType.getTitle(), description); - experienceLogMapper.insert(record); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordService.java deleted file mode 100644 index b5e4f669e..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordService.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; - -/** - * 会员等级记录 Service 接口 - * - * @author owen - */ -public interface MemberLevelRecordService { - - /** - * 获得会员等级记录 - * - * @param id 编号 - * @return 会员等级记录 - */ - MemberLevelRecordDO getLevelRecord(Long id); - - /** - * 获得会员等级记录分页 - * - * @param pageReqVO 分页查询 - * @return 会员等级记录分页 - */ - PageResult getLevelRecordPage(MemberLevelRecordPageReqVO pageReqVO); - - /** - * 创建会员等级记录 - * - * @param levelRecord 会员等级记录 - */ - void createLevelRecord(MemberLevelRecordDO levelRecord); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordServiceImpl.java deleted file mode 100644 index 810961241..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelRecordServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.record.MemberLevelRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelRecordMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -/** - * 会员等级记录 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberLevelRecordServiceImpl implements MemberLevelRecordService { - - @Resource - private MemberLevelRecordMapper levelLogMapper; - - @Override - public MemberLevelRecordDO getLevelRecord(Long id) { - return levelLogMapper.selectById(id); - } - - @Override - public PageResult getLevelRecordPage(MemberLevelRecordPageReqVO pageReqVO) { - return levelLogMapper.selectPage(pageReqVO); - } - - @Override - public void createLevelRecord(MemberLevelRecordDO levelRecord) { - levelLogMapper.insert(levelRecord); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java deleted file mode 100644 index 76d46e5c3..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 会员等级 Service 接口 - * - * @author owen - */ -public interface MemberLevelService { - - /** - * 创建会员等级 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createLevel(@Valid MemberLevelCreateReqVO createReqVO); - - /** - * 更新会员等级 - * - * @param updateReqVO 更新信息 - */ - void updateLevel(@Valid MemberLevelUpdateReqVO updateReqVO); - - /** - * 删除会员等级 - * - * @param id 编号 - */ - void deleteLevel(Long id); - - /** - * 获得会员等级 - * - * @param id 编号 - * @return 会员等级 - */ - MemberLevelDO getLevel(Long id); - - /** - * 获得会员等级列表 - * - * @param ids 编号 - * @return 会员等级列表 - */ - List getLevelList(Collection ids); - - /** - * 获得会员等级列表 - * - * @param listReqVO 查询参数 - * @return 会员等级列表 - */ - List getLevelList(MemberLevelListReqVO listReqVO); - - /** - * 获得指定状态的会员等级列表 - * - * @param status 状态 - * @return 会员等级列表 - */ - List getLevelListByStatus(Integer status); - - /** - * 获得开启状态的会员等级列表 - * - * @return 会员等级列表 - */ - default List getEnableLevelList() { - return getLevelListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - - /** - * 修改会员的等级 - * - * @param updateReqVO 修改参数 - */ - void updateUserLevel(MemberUserUpdateLevelReqVO updateReqVO); - - /** - * 增加会员经验 - * - * @param userId 会员ID - * @param experience 经验 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void addExperience(Long userId, Integer experience, MemberExperienceBizTypeEnum bizType, String bizId); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java deleted file mode 100644 index c68e4f088..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java +++ /dev/null @@ -1,298 +0,0 @@ -package cn.iocoder.yudao.module.member.service.level; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; -import cn.iocoder.yudao.module.member.convert.level.MemberLevelRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; -import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员等级 Service 实现类 - * - * @author owen - */ -@Slf4j -@Service -@Validated -public class MemberLevelServiceImpl implements MemberLevelService { - - @Resource - private MemberLevelMapper memberLevelMapper; - - @Resource - private MemberLevelRecordService memberLevelRecordService; - @Resource - private MemberExperienceRecordService memberExperienceRecordService; - @Resource - private MemberUserService memberUserService; - - @Override - public Long createLevel(MemberLevelCreateReqVO createReqVO) { - // 校验配置是否有效 - validateConfigValid(null, createReqVO.getName(), createReqVO.getLevel(), createReqVO.getExperience()); - - // 插入 - MemberLevelDO level = MemberLevelConvert.INSTANCE.convert(createReqVO); - memberLevelMapper.insert(level); - // 返回 - return level.getId(); - } - - @Override - public void updateLevel(MemberLevelUpdateReqVO updateReqVO) { - // 校验存在 - validateLevelExists(updateReqVO.getId()); - // 校验配置是否有效 - validateConfigValid(updateReqVO.getId(), updateReqVO.getName(), updateReqVO.getLevel(), updateReqVO.getExperience()); - - // 更新 - MemberLevelDO updateObj = MemberLevelConvert.INSTANCE.convert(updateReqVO); - memberLevelMapper.updateById(updateObj); - } - - @Override - public void deleteLevel(Long id) { - // 校验存在 - validateLevelExists(id); - // 校验分组下是否有用户 - validateLevelHasUser(id); - // 删除 - memberLevelMapper.deleteById(id); - } - - @VisibleForTesting - MemberLevelDO validateLevelExists(Long id) { - MemberLevelDO levelDO = memberLevelMapper.selectById(id); - if (levelDO == null) { - throw exception(LEVEL_NOT_EXISTS); - } - return levelDO; - } - - @VisibleForTesting - void validateNameUnique(List list, Long id, String name) { - for (MemberLevelDO levelDO : list) { - if (ObjUtil.notEqual(levelDO.getName(), name)) { - continue; - } - if (id == null || !id.equals(levelDO.getId())) { - throw exception(LEVEL_NAME_EXISTS, levelDO.getName()); - } - } - } - - @VisibleForTesting - void validateLevelUnique(List list, Long id, Integer level) { - for (MemberLevelDO levelDO : list) { - if (ObjUtil.notEqual(levelDO.getLevel(), level)) { - continue; - } - - if (id == null || !id.equals(levelDO.getId())) { - throw exception(LEVEL_VALUE_EXISTS, levelDO.getLevel(), levelDO.getName()); - } - } - } - - @VisibleForTesting - void validateExperienceOutRange(List list, Long id, Integer level, Integer experience) { - for (MemberLevelDO levelDO : list) { - if (levelDO.getId().equals(id)) { - continue; - } - - if (levelDO.getLevel() < level) { - // 经验大于前一个等级 - if (experience <= levelDO.getExperience()) { - throw exception(LEVEL_EXPERIENCE_MIN, levelDO.getName(), levelDO.getExperience()); - } - } else if (levelDO.getLevel() > level) { - //小于下一个级别 - if (experience >= levelDO.getExperience()) { - throw exception(LEVEL_EXPERIENCE_MAX, levelDO.getName(), levelDO.getExperience()); - } - } - } - } - - @VisibleForTesting - void validateConfigValid(Long id, String name, Integer level, Integer experience) { - List list = memberLevelMapper.selectList(); - // 校验名称唯一 - validateNameUnique(list, id, name); - // 校验等级唯一 - validateLevelUnique(list, id, level); - // 校验升级所需经验是否有效: 大于前一个等级,小于下一个级别 - validateExperienceOutRange(list, id, level, experience); - } - - @VisibleForTesting - void validateLevelHasUser(Long id) { - Long count = memberUserService.getUserCountByLevelId(id); - if (count > 0) { - throw exception(LEVEL_HAS_USER); - } - } - - @Override - public MemberLevelDO getLevel(Long id) { - return id != null && id > 0 ? memberLevelMapper.selectById(id) : null; - } - - @Override - public List getLevelList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return memberLevelMapper.selectBatchIds(ids); - } - - @Override - public List getLevelList(MemberLevelListReqVO listReqVO) { - return memberLevelMapper.selectList(listReqVO); - } - - @Override - public List getLevelListByStatus(Integer status) { - return memberLevelMapper.selectListByStatus(status); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateUserLevel(MemberUserUpdateLevelReqVO updateReqVO) { - MemberUserDO user = memberUserService.getUser(updateReqVO.getId()); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - // 等级未发生变化 - if (ObjUtil.equal(user.getLevelId(), updateReqVO.getLevelId())) { - return; - } - - // 1. 记录等级变动 - MemberLevelRecordDO levelRecord = new MemberLevelRecordDO() - .setUserId(user.getId()).setRemark(updateReqVO.getReason()); - MemberLevelDO memberLevel = null; - if (updateReqVO.getLevelId() == null) { - // 取消用户等级时,需要扣减经验 - levelRecord.setExperience(-user.getExperience()); - levelRecord.setUserExperience(0); - levelRecord.setDescription("管理员取消了等级"); - } else { - // 复制等级配置 - memberLevel = validateLevelExists(updateReqVO.getLevelId()); - MemberLevelRecordConvert.INSTANCE.copyTo(memberLevel, levelRecord); - // 变动经验值 = 等级的升级经验 - 会员当前的经验;正数为增加经验,负数为扣减经验 - levelRecord.setExperience(memberLevel.getExperience() - user.getExperience()); - levelRecord.setUserExperience(memberLevel.getExperience()); // 会员当前的经验 = 等级的升级经验 - levelRecord.setDescription("管理员调整为:" + memberLevel.getName()); - } - memberLevelRecordService.createLevelRecord(levelRecord); - - // 2. 记录会员经验变动 - memberExperienceRecordService.createExperienceRecord(user.getId(), - levelRecord.getExperience(), levelRecord.getUserExperience(), - MemberExperienceBizTypeEnum.ADMIN, String.valueOf(MemberExperienceBizTypeEnum.ADMIN.getType())); - - // 3. 更新会员表上的等级编号、经验值 - memberUserService.updateUserLevel(user.getId(), updateReqVO.getLevelId(), - levelRecord.getUserExperience()); - - // 4. 给会员发送等级变动消息 - notifyMemberLevelChange(user.getId(), memberLevel); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addExperience(Long userId, Integer experience, MemberExperienceBizTypeEnum bizType, String bizId) { - if (experience == 0) { - return; - } - if (!bizType.isAdd() && experience > 0) { - experience = -experience; - } - - // 1. 创建经验记录 - MemberUserDO user = memberUserService.getUser(userId); - Integer userExperience = ObjUtil.defaultIfNull(user.getExperience(), 0); - userExperience = NumberUtil.max(userExperience + experience, 0); // 防止扣出负数 - MemberLevelRecordDO levelRecord = new MemberLevelRecordDO().setUserId(user.getId()) - .setExperience(experience).setUserExperience(userExperience).setLevelId(user.getLevelId()); - memberExperienceRecordService.createExperienceRecord(userId, experience, userExperience, - bizType, bizId); - - // 2.1 保存等级变更记录 - MemberLevelDO newLevel = calculateNewLevel(user, userExperience); - if (newLevel != null) { - MemberLevelRecordConvert.INSTANCE.copyTo(newLevel, levelRecord); - memberLevelRecordService.createLevelRecord(levelRecord); - - // 2.2 给会员发送等级变动消息 - notifyMemberLevelChange(userId, newLevel); - } - - // 3. 更新会员表上的等级编号、经验值 - memberUserService.updateUserLevel(user.getId(), levelRecord.getLevelId(), userExperience); - } - - /** - * 计算会员等级 - * - * @param user 会员 - * @param userExperience 会员当前的经验值 - * @return 会员新的等级,null表示无变化 - */ - private MemberLevelDO calculateNewLevel(MemberUserDO user, int userExperience) { - List list = getEnableLevelList(); - if (CollUtil.isEmpty(list)) { - log.warn("计算会员等级失败:会员等级配置不存在"); - return null; - } - - MemberLevelDO matchLevel = list.stream() - .filter(level -> userExperience >= level.getExperience()) - .max(Comparator.nullsFirst(Comparator.comparing(MemberLevelDO::getLevel))) - .orElse(null); - if (matchLevel == null) { - log.warn("计算会员等级失败:未找到会员{}经验{}对应的等级配置", user.getId(), userExperience); - return null; - } - - // 等级没有变化 - if (ObjectUtil.equal(matchLevel.getId(), user.getLevelId())) { - return null; - } - - return matchLevel; - } - - private void notifyMemberLevelChange(Long userId, MemberLevelDO level) { - //todo: 给会员发消息 - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java deleted file mode 100644 index 7e660d5d6..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.member.service.point; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; - -/** - * 用户积分记录 Service 接口 - * - * @author QingX - */ -public interface MemberPointRecordService { - - /** - * 【管理员】获得积分记录分页 - * - * @param pageReqVO 分页查询 - * @return 签到记录分页 - */ - PageResult getPointRecordPage(MemberPointRecordPageReqVO pageReqVO); - - /** - * 【会员】获得积分记录分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页查询 - * @return 签到记录分页 - */ - PageResult getPointRecordPage(Long userId, AppMemberPointRecordPageReqVO pageReqVO); - - /** - * 创建用户积分记录 - * - * @param userId 用户ID - * @param point 变动积分 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId); -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java deleted file mode 100644 index d21c7bfcf..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.member.service.point; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordPageReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.point.MemberPointRecordMapper; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.USER_POINT_NOT_ENOUGH; - - -/** - * 积分记录 Service 实现类 - * - * @author QingX - */ -@Slf4j -@Service -@Validated -public class MemberPointRecordServiceImpl implements MemberPointRecordService { - - @Resource - private MemberPointRecordMapper memberPointRecordMapper; - - @Resource - private MemberUserService memberUserService; - - @Override - public PageResult getPointRecordPage(MemberPointRecordPageReqVO pageReqVO) { - // 根据用户昵称查询出用户 ids - Set userIds = null; - if (StringUtils.isNotBlank(pageReqVO.getNickname())) { - List users = memberUserService.getUserListByNickname(pageReqVO.getNickname()); - // 如果查询用户结果为空直接返回无需继续查询 - if (CollectionUtils.isEmpty(users)) { - return PageResult.empty(); - } - userIds = convertSet(users, MemberUserDO::getId); - } - // 执行查询 - return memberPointRecordMapper.selectPage(pageReqVO, userIds); - } - - @Override - public PageResult getPointRecordPage(Long userId, AppMemberPointRecordPageReqVO pageReqVO) { - return memberPointRecordMapper.selectPage(userId, pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId) { - if (point == 0) { - return; - } - // 1. 校验用户积分余额 - MemberUserDO user = memberUserService.getUser(userId); - Integer userPoint = ObjectUtil.defaultIfNull(user.getPoint(), 0); - int totalPoint = userPoint + point; // 用户变动后的积分 - if (totalPoint < 0) { - throw exception(USER_POINT_NOT_ENOUGH); - } - - // 2. 更新用户积分 - boolean success = memberUserService.updateUserPoint(userId, point); - if (!success) { - throw exception(USER_POINT_NOT_ENOUGH); - } - - // 3. 增加积分记录 - MemberPointRecordDO record = new MemberPointRecordDO() - .setUserId(userId).setBizId(bizId).setBizType(bizType.getType()) - .setTitle(bizType.getName()).setDescription(StrUtil.format(bizType.getDescription(), point)) - .setPoint(point).setTotalPoint(totalPoint); - memberPointRecordMapper.insert(record); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java deleted file mode 100644 index b4a9c041c..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 签到规则 Service 接口 - * - * @author QingX - */ -public interface MemberSignInConfigService { - - /** - * 创建签到规则 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSignInConfig(@Valid MemberSignInConfigCreateReqVO createReqVO); - - /** - * 更新签到规则 - * - * @param updateReqVO 更新信息 - */ - void updateSignInConfig(@Valid MemberSignInConfigUpdateReqVO updateReqVO); - - /** - * 删除签到规则 - * - * @param id 编号 - */ - void deleteSignInConfig(Long id); - - /** - * 获得签到规则 - * - * @param id 编号 - * @return 签到规则 - */ - MemberSignInConfigDO getSignInConfig(Long id); - - /** - * 获得签到规则列表 - * - * @return 签到规则分页 - */ - List getSignInConfigList(); - - /** - * 获得签到规则列表 - * - * @param status 状态 - * @return 签到规则分页 - */ - List getSignInConfigList(Integer status); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java deleted file mode 100644 index 4e2b04c63..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.config.MemberSignInConfigUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_EXISTS; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS; - -/** - * 签到规则 Service 实现类 - * - * @author QingX - */ -@Service -@Validated -public class MemberSignInConfigServiceImpl implements MemberSignInConfigService { - - @Resource - private MemberSignInConfigMapper memberSignInConfigMapper; - - @Override - public Long createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) { - // 判断是否重复插入签到天数 - validateSignInConfigDayDuplicate(createReqVO.getDay(), null); - - // 插入 - MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO); - memberSignInConfigMapper.insert(signInConfig); - // 返回 - return signInConfig.getId(); - } - - @Override - public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) { - // 校验存在 - validateSignInConfigExists(updateReqVO.getId()); - // 判断是否重复插入签到天数 - validateSignInConfigDayDuplicate(updateReqVO.getDay(), updateReqVO.getId()); - - // 判断更新 - MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO); - memberSignInConfigMapper.updateById(updateObj); - } - - @Override - public void deleteSignInConfig(Long id) { - // 校验存在 - validateSignInConfigExists(id); - // 删除 - memberSignInConfigMapper.deleteById(id); - } - - private void validateSignInConfigExists(Long id) { - if (memberSignInConfigMapper.selectById(id) == null) { - throw exception(SIGN_IN_CONFIG_NOT_EXISTS); - } - } - - /** - * 校验 day 是否重复 - * - * @param day 天 - * @param id 编号,只有更新的时候会传递 - */ - private void validateSignInConfigDayDuplicate(Integer day, Long id) { - MemberSignInConfigDO config = memberSignInConfigMapper.selectByDay(day); - // 1. 新增时,config 非空,则说明重复 - if (id == null && config != null) { - throw exception(SIGN_IN_CONFIG_EXISTS); - } - // 2. 更新时,如果 config 非空,且 id 不相等,则说明重复 - if (id != null && config != null && !config.getId().equals(id)) { - throw exception(SIGN_IN_CONFIG_EXISTS); - } - } - - @Override - public MemberSignInConfigDO getSignInConfig(Long id) { - return memberSignInConfigMapper.selectById(id); - } - - @Override - public List getSignInConfigList() { - List list = memberSignInConfigMapper.selectList(); - list.sort(Comparator.comparing(MemberSignInConfigDO::getDay)); - return list; - } - - @Override - public List getSignInConfigList(Integer status) { - List list = memberSignInConfigMapper.selectListByStatus(status); - list.sort(Comparator.comparing(MemberSignInConfigDO::getDay)); - return list; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java deleted file mode 100644 index b22ceed1a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; - -/** - * 签到记录 Service 接口 - * - * @author 芋道源码 - */ -public interface MemberSignInRecordService { - - /** - * 【管理员】获得签到记录分页 - * - * @param pageReqVO 分页查询 - * @return 签到记录分页 - */ - PageResult getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO); - - /** - * 【会员】获得签到记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 签到记录分页 - */ - PageResult getSignRecordPage(Long userId, PageParam pageParam); - - /** - * 创建签到记录 - * - * @param userId 用户编号 - * @return 签到记录 - */ - MemberSignInRecordDO createSignRecord(Long userId); - - /** - * 根据用户编号,获得个人签到统计信息 - * - * @param userId 用户编号 - * @return 个人签到统计信息 - */ - AppMemberSignInRecordSummaryRespVO getSignInRecordSummary(Long userId); - - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java deleted file mode 100644 index 01bb1f429..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.member.service.signin; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; -import cn.iocoder.yudao.module.member.controller.app.signin.vo.record.AppMemberSignInRecordSummaryRespVO; -import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; -import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.member.service.level.MemberLevelService; -import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_RECORD_TODAY_EXISTS; - -/** - * 签到记录 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MemberSignInRecordServiceImpl implements MemberSignInRecordService { - - @Resource - private MemberSignInRecordMapper signInRecordMapper; - @Resource - private MemberSignInConfigService signInConfigService; - @Resource - private MemberPointRecordService pointRecordService; - @Resource - private MemberLevelService memberLevelService; - - @Resource - private MemberUserService memberUserService; - - @Override - public AppMemberSignInRecordSummaryRespVO getSignInRecordSummary(Long userId) { - // 1. 初始化默认返回信息 - AppMemberSignInRecordSummaryRespVO summary = new AppMemberSignInRecordSummaryRespVO(); - summary.setTotalDay(0); - summary.setContinuousDay(0); - summary.setTodaySignIn(false); - - // 2. 获取用户签到的记录数 - Long signCount = signInRecordMapper.selectCountByUserId(userId); - if (ObjUtil.equal(signCount, 0L)) { - return summary; - } - summary.setTotalDay(signCount.intValue()); // 设置总签到天数 - - // 3. 校验当天是否有签到 - MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserId(userId); - if (lastRecord == null) { - return summary; - } - summary.setTodaySignIn(DateUtils.isToday(lastRecord.getCreateTime())); - - // 4.1 校验今天是否签到,没有签到则直接返回 - if (!summary.getTodaySignIn()) { - return summary; - } - // 4.2 连续签到天数 - summary.setContinuousDay(lastRecord.getDay()); - return summary; - } - - @Override - public PageResult getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) { - // 根据用户昵称查询出用户ids - Set userIds = null; - if (StringUtils.isNotBlank(pageReqVO.getNickname())) { - List users = memberUserService.getUserListByNickname(pageReqVO.getNickname()); - // 如果查询用户结果为空直接返回无需继续查询 - if (CollUtil.isEmpty(users)) { - return PageResult.empty(); - } - userIds = convertSet(users, MemberUserDO::getId); - } - // 分页查询 - return signInRecordMapper.selectPage(pageReqVO, userIds); - } - - @Override - public PageResult getSignRecordPage(Long userId, PageParam pageParam) { - return signInRecordMapper.selectPage(userId, pageParam); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public MemberSignInRecordDO createSignRecord(Long userId) { - // 1. 获取当前用户最近的签到 - MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserId(userId); - // 1.1. 判断是否重复签到 - validateSigned(lastRecord); - - // 2.1. 获取所有的签到规则 - List signInConfigs = signInConfigService.getSignInConfigList(CommonStatusEnum.ENABLE.getStatus()); - // 2.2. 组合数据 - MemberSignInRecordDO record = MemberSignInRecordConvert.INSTANCE.convert(userId, lastRecord, signInConfigs); - - // 3. 插入签到记录 - signInRecordMapper.insert(record); - - // 4. 增加积分 - if (!ObjectUtils.equalsAny(record.getPoint(), null, 0)) { - pointRecordService.createPointRecord(userId, record.getPoint(), MemberPointBizTypeEnum.SIGN, String.valueOf(record.getId())); - } - // 5. 增加经验 - if (!ObjectUtils.equalsAny(record.getExperience(), null, 0)) { - memberLevelService.addExperience(userId, record.getExperience(), MemberExperienceBizTypeEnum.SIGN_IN, String.valueOf(record.getId())); - } - return record; - } - - private void validateSigned(MemberSignInRecordDO signInRecordDO) { - if (signInRecordDO == null) { - return; - } - if (DateUtils.isToday(signInRecordDO.getCreateTime())) { - throw exception(SIGN_IN_RECORD_TODAY_EXISTS); - } - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java deleted file mode 100644 index 5e3393394..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.member.service.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 会员标签 Service 接口 - * - * @author 芋道源码 - */ -public interface MemberTagService { - - /** - * 创建会员标签 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createTag(@Valid MemberTagCreateReqVO createReqVO); - - /** - * 更新会员标签 - * - * @param updateReqVO 更新信息 - */ - void updateTag(@Valid MemberTagUpdateReqVO updateReqVO); - - /** - * 删除会员标签 - * - * @param id 编号 - */ - void deleteTag(Long id); - - /** - * 获得会员标签 - * - * @param id 编号 - * @return 会员标签 - */ - MemberTagDO getTag(Long id); - - /** - * 获得会员标签列表 - * - * @param ids 编号 - * @return 会员标签列表 - */ - List getTagList(Collection ids); - - /** - * 获得会员标签分页 - * - * @param pageReqVO 分页查询 - * @return 会员标签分页 - */ - PageResult getTagPage(MemberTagPageReqVO pageReqVO); - - /** - * 获取标签列表 - * - * @return 标签列表 - */ - List getTagList(); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java deleted file mode 100644 index b267227d9..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.member.service.tag; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReqVO; -import cn.iocoder.yudao.module.member.convert.tag.MemberTagConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO; -import cn.iocoder.yudao.module.member.dal.mysql.tag.MemberTagMapper; -import cn.iocoder.yudao.module.member.service.user.MemberUserService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员标签 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MemberTagServiceImpl implements MemberTagService { - - @Resource - private MemberTagMapper memberTagMapper; - - @Resource - private MemberUserService memberUserService; - - @Override - public Long createTag(MemberTagCreateReqVO createReqVO) { - // 校验名称唯一 - validateTagNameUnique(null, createReqVO.getName()); - // 插入 - MemberTagDO tag = MemberTagConvert.INSTANCE.convert(createReqVO); - memberTagMapper.insert(tag); - // 返回 - return tag.getId(); - } - - @Override - public void updateTag(MemberTagUpdateReqVO updateReqVO) { - // 校验存在 - validateTagExists(updateReqVO.getId()); - // 校验名称唯一 - validateTagNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - MemberTagDO updateObj = MemberTagConvert.INSTANCE.convert(updateReqVO); - memberTagMapper.updateById(updateObj); - } - - @Override - public void deleteTag(Long id) { - // 校验存在 - validateTagExists(id); - // 校验标签下是否有用户 - validateTagHasUser(id); - // 删除 - memberTagMapper.deleteById(id); - } - - private void validateTagExists(Long id) { - if (memberTagMapper.selectById(id) == null) { - throw exception(TAG_NOT_EXISTS); - } - } - - private void validateTagNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - MemberTagDO tag = memberTagMapper.selelctByName(name); - if (tag == null) { - return; - } - - // 如果 id 为空,说明不用比较是否为相同 id 的标签 - if (id == null) { - throw exception(TAG_NAME_EXISTS); - } - if (!tag.getId().equals(id)) { - throw exception(TAG_NAME_EXISTS); - } - } - - void validateTagHasUser(Long id) { - Long count = memberUserService.getUserCountByTagId(id); - if (count > 0) { - throw exception(TAG_HAS_USER); - } - } - - @Override - public MemberTagDO getTag(Long id) { - return memberTagMapper.selectById(id); - } - - @Override - public List getTagList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return memberTagMapper.selectBatchIds(ids); - } - - @Override - public PageResult getTagPage(MemberTagPageReqVO pageReqVO) { - return memberTagMapper.selectPage(pageReqVO); - } - - @Override - public List getTagList() { - return memberTagMapper.selectList(); - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java deleted file mode 100644 index fb2e9cdbf..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.member.service.user; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.*; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 会员用户 Service 接口 - * - * @author 芋道源码 - */ -public interface MemberUserService { - - /** - * 通过手机查询用户 - * - * @param mobile 手机 - * @return 用户对象 - */ - MemberUserDO getUserByMobile(String mobile); - - /** - * 基于用户昵称,模糊匹配用户列表 - * - * @param nickname 用户昵称,模糊匹配 - * @return 用户信息的列表 - */ - List getUserListByNickname(String nickname); - - /** - * 基于手机号创建用户。 - * 如果用户已经存在,则直接进行返回 - * - * @param mobile 手机号 - * @param registerIp 注册 IP - * @param terminal 终端 {@link TerminalEnum} - * @return 用户对象 - */ - MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp, Integer terminal); - - /** - * 创建用户 - * 目的:三方登录时,如果未绑定用户时,自动创建对应用户 - * - * @param nickname 昵称 - * @param avtar 头像 - * @param registerIp 注册 IP - * @param terminal 终端 {@link TerminalEnum} - * @return 用户对象 - */ - MemberUserDO createUser(String nickname, String avtar, String registerIp, Integer terminal); - - /** - * 更新用户的最后登陆信息 - * - * @param id 用户编号 - * @param loginIp 登陆 IP - */ - void updateUserLogin(Long id, String loginIp); - - /** - * 通过用户 ID 查询用户 - * - * @param id 用户ID - * @return 用户对象信息 - */ - MemberUserDO getUser(Long id); - - /** - * 通过用户 ID 查询用户们 - * - * @param ids 用户 ID - * @return 用户对象信息数组 - */ - List getUserList(Collection ids); - - /** - * 【会员】修改基本信息 - * - * @param userId 用户编号 - * @param reqVO 基本信息 - */ - void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO); - - /** - * 【会员】修改手机,基于手机验证码 - * - * @param userId 用户编号 - * @param reqVO 请求信息 - */ - void updateUserMobile(Long userId, AppMemberUserUpdateMobileReqVO reqVO); - - /** - * 【会员】修改手机,基于微信小程序的授权码 - * - * @param userId 用户编号 - * @param reqVO 请求信息 - */ - void updateUserMobileByWeixin(Long userId, AppMemberUserUpdateMobileByWeixinReqVO reqVO); - - /** - * 【会员】修改密码 - * - * @param userId 用户编号 - * @param reqVO 请求信息 - */ - void updateUserPassword(Long userId, AppMemberUserUpdatePasswordReqVO reqVO); - - /** - * 【会员】忘记密码 - * - * @param reqVO 请求信息 - */ - void resetUserPassword(AppMemberUserResetPasswordReqVO reqVO); - - /** - * 判断密码是否匹配 - * - * @param rawPassword 未加密的密码 - * @param encodedPassword 加密后的密码 - * @return 是否匹配 - */ - boolean isPasswordMatch(String rawPassword, String encodedPassword); - - /** - * 【管理员】更新会员用户 - * - * @param updateReqVO 更新信息 - */ - void updateUser(@Valid MemberUserUpdateReqVO updateReqVO); - - /** - * 【管理员】获得会员用户分页 - * - * @param pageReqVO 分页查询 - * @return 会员用户分页 - */ - PageResult getUserPage(MemberUserPageReqVO pageReqVO); - - /** - * 更新用户的等级和经验 - * - * @param id 用户编号 - * @param levelId 用户等级 - * @param experience 用户经验 - */ - void updateUserLevel(Long id, Long levelId, Integer experience); - - /** - * 获得指定用户分组下的用户数量 - * - * @param groupId 用户分组编号 - * @return 用户数量 - */ - Long getUserCountByGroupId(Long groupId); - - /** - * 获得指定用户等级下的用户数量 - * - * @param levelId 用户等级编号 - * @return 用户数量 - */ - Long getUserCountByLevelId(Long levelId); - - /** - * 获得指定会员标签下的用户数量 - * - * @param tagId 用户标签编号 - * @return 用户数量 - */ - Long getUserCountByTagId(Long tagId); - - /** - * 更新用户的积分 - * - * @param userId 用户编号 - * @param point 积分数量 - * @return 更新结果 - */ - boolean updateUserPoint(Long userId, Integer point); - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java deleted file mode 100644 index 1aa95cac0..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ /dev/null @@ -1,317 +0,0 @@ -package cn.iocoder.yudao.module.member.service.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.*; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; -import cn.iocoder.yudao.module.member.controller.app.user.vo.*; -import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; -import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; -import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; -import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; -import cn.iocoder.yudao.module.member.mq.producer.user.MemberUserProducer; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; -import cn.iocoder.yudao.module.system.api.social.SocialClientApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; - -/** - * 会员 User Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Valid -@Slf4j -public class MemberUserServiceImpl implements MemberUserService { - - @Resource - private MemberUserMapper memberUserMapper; - - @Resource - private SmsCodeApi smsCodeApi; - - @Resource - private SocialClientApi socialClientApi; - - @Resource - private PasswordEncoder passwordEncoder; - - @Resource - private MemberUserProducer memberUserProducer; - - @Override - public MemberUserDO getUserByMobile(String mobile) { - return memberUserMapper.selectByMobile(mobile); - } - - @Override - public List getUserListByNickname(String nickname) { - return memberUserMapper.selectListByNicknameLike(nickname); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public MemberUserDO createUserIfAbsent(String mobile, String registerIp, Integer terminal) { - // 用户已经存在 - MemberUserDO user = memberUserMapper.selectByMobile(mobile); - if (user != null) { - return user; - } - // 用户不存在,则进行创建 - return createUser(mobile, null, null, registerIp, terminal); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public MemberUserDO createUser(String nickname, String avtar, String registerIp, Integer terminal) { - return createUser(null, nickname, avtar, registerIp, terminal); - } - - private MemberUserDO createUser(String mobile, String nickname, String avtar, - String registerIp, Integer terminal) { - // 生成密码 - String password = IdUtil.fastSimpleUUID(); - // 插入用户 - MemberUserDO user = new MemberUserDO(); - user.setMobile(mobile); - user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 - user.setPassword(encodePassword(password)); // 加密密码 - user.setRegisterIp(registerIp).setRegisterTerminal(terminal); - user.setNickname(nickname).setAvatar(avtar); // 基础信息 - if (StrUtil.isEmpty(nickname)) { - // 昵称为空时,随机一个名字,避免一些依赖 nickname 的逻辑报错,或者有点丑。例如说,短信发送有昵称时~ - user.setNickname("用户" + RandomUtil.randomNumbers(6)); - } - memberUserMapper.insert(user); - - // 发送 MQ 消息:用户创建 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - memberUserProducer.sendUserCreateMessage(user.getId()); - } - - }); - return user; - } - - @Override - public void updateUserLogin(Long id, String loginIp) { - memberUserMapper.updateById(new MemberUserDO().setId(id) - .setLoginIp(loginIp).setLoginDate(LocalDateTime.now())); - } - - @Override - public MemberUserDO getUser(Long id) { - return memberUserMapper.selectById(id); - } - - @Override - public List getUserList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return memberUserMapper.selectBatchIds(ids); - } - - @Override - public void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO) { - MemberUserDO updateObj = BeanUtils.toBean(reqVO, MemberUserDO.class).setId(userId); - memberUserMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateUserMobile(Long userId, AppMemberUserUpdateMobileReqVO reqVO) { - // 1.1 检测用户是否存在 - MemberUserDO user = validateUserExists(userId); - // 1.2 校验新手机是否已经被绑定 - validateMobileUnique(null, reqVO.getMobile()); - - // 2.1 校验旧手机和旧验证码 - // 补充说明:从安全性来说,老手机也校验 oldCode 验证码会更安全。但是由于 uni-app 商城界面暂时没做,所以这里不强制校验 - if (StrUtil.isNotEmpty(reqVO.getOldCode())) { - smsCodeApi.useSmsCode(new SmsCodeUseReqDTO().setMobile(user.getMobile()).setCode(reqVO.getOldCode()) - .setScene(SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene()).setUsedIp(getClientIP())).getCheckedData(); - } - // 2.2 使用新验证码 - smsCodeApi.useSmsCode(new SmsCodeUseReqDTO().setMobile(reqVO.getMobile()).setCode(reqVO.getCode()) - .setScene(SmsSceneEnum.MEMBER_UPDATE_MOBILE.getScene()).setUsedIp(getClientIP())).getCheckedData(); - - // 3. 更新用户手机 - memberUserMapper.updateById(MemberUserDO.builder().id(userId).mobile(reqVO.getMobile()).build()); - } - - @Override - public void updateUserMobileByWeixin(Long userId, AppMemberUserUpdateMobileByWeixinReqVO reqVO) { - // 1.1 获得对应的手机号信息 - SocialWxPhoneNumberInfoRespDTO phoneNumberInfo = socialClientApi.getWxMaPhoneNumberInfo( - UserTypeEnum.MEMBER.getValue(), reqVO.getCode()).getCheckedData(); - Assert.notNull(phoneNumberInfo, "获得手机信息失败,结果为空"); - // 1.2 校验新手机是否已经被绑定 - validateMobileUnique(userId, phoneNumberInfo.getPhoneNumber()); - - // 2. 更新用户手机 - memberUserMapper.updateById(MemberUserDO.builder().id(userId).mobile(phoneNumberInfo.getPhoneNumber()).build()); - } - - @Override - public void updateUserPassword(Long userId, AppMemberUserUpdatePasswordReqVO reqVO) { - // 检测用户是否存在 - MemberUserDO user = validateUserExists(userId); - // 校验验证码 - smsCodeApi.useSmsCode(new SmsCodeUseReqDTO().setMobile(user.getMobile()).setCode(reqVO.getCode()) - .setScene(SmsSceneEnum.MEMBER_UPDATE_PASSWORD.getScene()).setUsedIp(getClientIP())).getCheckedData(); - - // 更新用户密码 - memberUserMapper.updateById(MemberUserDO.builder().id(userId) - .password(passwordEncoder.encode(reqVO.getPassword())).build()); - } - - @Override - public void resetUserPassword(AppMemberUserResetPasswordReqVO reqVO) { - // 检验用户是否存在 - MemberUserDO user = validateUserExists(reqVO.getMobile()); - - // 使用验证码 - smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_RESET_PASSWORD, - getClientIP())).getCheckedData(); - - // 更新密码 - memberUserMapper.updateById(MemberUserDO.builder().id(user.getId()) - .password(passwordEncoder.encode(reqVO.getPassword())).build()); - } - - private MemberUserDO validateUserExists(String mobile) { - MemberUserDO user = memberUserMapper.selectByMobile(mobile); - if (user == null) { - throw exception(USER_MOBILE_NOT_EXISTS); - } - return user; - } - - @Override - public boolean isPasswordMatch(String rawPassword, String encodedPassword) { - return passwordEncoder.matches(rawPassword, encodedPassword); - } - - /** - * 对密码进行加密 - * - * @param password 密码 - * @return 加密后的密码 - */ - private String encodePassword(String password) { - return passwordEncoder.encode(password); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateUser(MemberUserUpdateReqVO updateReqVO) { - // 校验存在 - validateUserExists(updateReqVO.getId()); - // 校验手机唯一 - validateMobileUnique(updateReqVO.getId(), updateReqVO.getMobile()); - - // 更新 - MemberUserDO updateObj = MemberUserConvert.INSTANCE.convert(updateReqVO); - memberUserMapper.updateById(updateObj); - } - - @VisibleForTesting - MemberUserDO validateUserExists(Long id) { - if (id == null) { - return null; - } - MemberUserDO user = memberUserMapper.selectById(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - @VisibleForTesting - void validateMobileUnique(Long id, String mobile) { - if (StrUtil.isBlank(mobile)) { - return; - } - MemberUserDO user = memberUserMapper.selectByMobile(mobile); - if (user == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的用户 - if (id == null) { - throw exception(USER_MOBILE_USED, mobile); - } - if (!user.getId().equals(id)) { - throw exception(USER_MOBILE_USED, mobile); - } - } - - @Override - public PageResult getUserPage(MemberUserPageReqVO pageReqVO) { - return memberUserMapper.selectPage(pageReqVO); - } - - @Override - public void updateUserLevel(Long id, Long levelId, Integer experience) { - // 0 代表无等级:防止UpdateById时,会被过滤掉的问题 - levelId = ObjectUtil.defaultIfNull(levelId, 0L); - memberUserMapper.updateById(new MemberUserDO() - .setId(id) - .setLevelId(levelId).setExperience(experience) - ); - } - - @Override - public Long getUserCountByGroupId(Long groupId) { - return memberUserMapper.selectCountByGroupId(groupId); - } - - @Override - public Long getUserCountByLevelId(Long levelId) { - return memberUserMapper.selectCountByLevelId(levelId); - } - - @Override - public Long getUserCountByTagId(Long tagId) { - return memberUserMapper.selectCountByTagId(tagId); - } - - @Override - public boolean updateUserPoint(Long id, Integer point) { - if (point > 0) { - memberUserMapper.updatePointIncr(id, point); - } else if (point < 0) { - return memberUserMapper.updatePointDecr(id, point) > 0; - } - return true; - } - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/application.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/application.yaml deleted file mode 100644 index 691b32f1b..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.member - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/bootstrap.yaml b/yudao-module-member/yudao-module-member-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 32206295f..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: member-server - - profiles: - active: local - -server: - port: 48087 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/resources/logback-spring.xml b/yudao-module-member/yudao-module-member-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml b/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index c656a9fe4..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,47 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/logback.xml b/yudao-module-member/yudao-module-member-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index f972e048d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,5 +0,0 @@ -DELETE FROM "member_user"; -DELETE FROM "member_address"; -DELETE FROM "member_tag"; -DELETE FROM "member_level"; -DELETE FROM "member_group"; \ No newline at end of file diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 782a81810..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,113 +0,0 @@ -CREATE TABLE IF NOT EXISTS "member_user" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号', - "nickname" varchar(30) NOT NULL DEFAULT '' COMMENT '用户昵称', - "name" varchar(30) NULL COMMENT '真实名字', - sex tinyint null comment '性别', - birthday datetime null comment '出生日期', - area_id int null comment '所在地', - mark varchar(255) null comment '用户备注', - point int default 0 null comment '积分', - "avatar" varchar(255) NOT NULL DEFAULT '' COMMENT '头像', - "status" tinyint NOT NULL COMMENT '状态', - "mobile" varchar(11) NOT NULL COMMENT '手机号', - "password" varchar(100) NOT NULL DEFAULT '' COMMENT '密码', - "register_ip" varchar(32) NOT NULL COMMENT '注册 IP', - "login_ip" varchar(50) NULL DEFAULT '' COMMENT '最后登录IP', - "login_date" datetime NULL DEFAULT NULL COMMENT '最后登录时间', - "tag_ids" varchar(255) NULL DEFAULT NULL COMMENT '用户标签编号列表,以逗号分隔', - "level_id" bigint NULL DEFAULT NULL COMMENT '等级编号', - "experience" bigint NULL DEFAULT NULL COMMENT '经验', - "group_id" bigint NULL DEFAULT NULL COMMENT '用户分组编号', - "creator" varchar(64) NULL DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) NULL DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit(1) NOT NULL DEFAULT '0' COMMENT '是否删除', - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '会员表'; - -CREATE TABLE IF NOT EXISTS "member_address" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint(20) NOT NULL, - "name" varchar(10) NOT NULL, - "mobile" varchar(20) NOT NULL, - "area_id" bigint(20) NOT NULL, - "detail_address" varchar(250) NOT NULL, - "default_status" bit NOT NULL, - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "creator" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "updater" varchar(64) DEFAULT '', - PRIMARY KEY ("id") -) COMMENT '用户收件地址'; - -CREATE TABLE IF NOT EXISTS "member_tag" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL default '0', - PRIMARY KEY ("id") -) COMMENT '会员标签'; - -CREATE TABLE IF NOT EXISTS "member_level" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "experience" int NOT NULL, - "level" int NOT NULL, - "discount_percent" int NOT NULL, - "icon" varchar NOT NULL, - "background_url" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - "status" tinyint NOT NULL DEFAULT '0', - PRIMARY KEY ("id") -) COMMENT '会员等级'; - -CREATE TABLE IF NOT EXISTS "member_group" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "remark" varchar NOT NULL, - "status" tinyint NOT NULL DEFAULT '0', - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '用户分组'; -CREATE TABLE IF NOT EXISTS "member_brokerage_record" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "biz_id" varchar NOT NULL, - "biz_type" varchar NOT NULL, - "title" varchar NOT NULL, - "price" int NOT NULL, - "total_price" int NOT NULL, - "description" varchar NOT NULL, - "status" varchar NOT NULL, - "frozen_days" int NOT NULL, - "unfreeze_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金记录'; diff --git a/yudao-module-mp/pom.xml b/yudao-module-mp/pom.xml deleted file mode 100644 index 88735881d..000000000 --- a/yudao-module-mp/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - yudao - cn.iocoder.cloud - ${revision} - - 4.0.0 - - yudao-module-mp - pom - - - wechat 模块,主要实现微信平台的相关业务。 - 例如:微信公众号、企业微信 SCRM 等 - - - yudao-module-mp-api - yudao-module-mp-biz - - - diff --git a/yudao-module-mp/yudao-module-mp-api/pom.xml b/yudao-module-mp/yudao-module-mp-api/pom.xml deleted file mode 100644 index 9cad0d93f..000000000 --- a/yudao-module-mp/yudao-module-mp-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - yudao-module-mp - cn.iocoder.cloud - ${revision} - - 4.0.0 - yudao-module-mp-api - jar - - ${project.artifactId} - - mp 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java deleted file mode 100644 index 34c94fd00..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Mp 错误码枚举类 - * - * mp 系统,使用 1-006-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 公众号账号 1-006-000-000 ============ - ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_006_000_000, "公众号账号不存在"); - ErrorCode ACCOUNT_GENERATE_QR_CODE_FAIL = new ErrorCode(1_006_000_001, "生成公众号二维码失败,原因:{}"); - ErrorCode ACCOUNT_CLEAR_QUOTA_FAIL = new ErrorCode(1_006_000_002, "清空公众号的 API 配额失败,原因:{}"); - - // ========== 公众号统计 1-006-001-000 ============ - ErrorCode STATISTICS_GET_USER_SUMMARY_FAIL = new ErrorCode(1_006_001_000, "获取粉丝增减数据失败,原因:{}"); - ErrorCode STATISTICS_GET_USER_CUMULATE_FAIL = new ErrorCode(1_006_001_001, "获得粉丝累计数据失败,原因:{}"); - ErrorCode STATISTICS_GET_UPSTREAM_MESSAGE_FAIL = new ErrorCode(1_006_001_002, "获得消息发送概况数据失败,原因:{}"); - ErrorCode STATISTICS_GET_INTERFACE_SUMMARY_FAIL = new ErrorCode(1_006_001_003, "获得接口分析数据失败,原因:{}"); - - // ========== 公众号标签 1-006-002-000 ============ - ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_006_002_000, "标签不存在"); - ErrorCode TAG_CREATE_FAIL = new ErrorCode(1_006_002_001, "创建标签失败,原因:{}"); - ErrorCode TAG_UPDATE_FAIL = new ErrorCode(1_006_002_002, "更新标签失败,原因:{}"); - ErrorCode TAG_DELETE_FAIL = new ErrorCode(1_006_002_003, "删除标签失败,原因:{}"); - ErrorCode TAG_GET_FAIL = new ErrorCode(1_006_002_004, "获得标签失败,原因:{}"); - - // ========== 公众号粉丝 1-006-003-000 ============ - ErrorCode USER_NOT_EXISTS = new ErrorCode(1_006_003_000, "粉丝不存在"); - ErrorCode USER_UPDATE_TAG_FAIL = new ErrorCode(1_006_003_001, "更新粉丝标签失败,原因:{}"); - - // ========== 公众号素材 1-006-004-000 ============ - ErrorCode MATERIAL_NOT_EXISTS = new ErrorCode(1_006_004_000, "素材不存在"); - ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1_006_004_001, "上传素材失败,原因:{}"); - ErrorCode MATERIAL_IMAGE_UPLOAD_FAIL = new ErrorCode(1_006_004_002, "上传图片失败,原因:{}"); - ErrorCode MATERIAL_DELETE_FAIL = new ErrorCode(1_006_004_003, "删除素材失败,原因:{}"); - - // ========== 公众号消息 1-006-005-000 ============ - ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1_006_005_000, "发送消息失败,原因:{}"); - - // ========== 公众号发布能力 1-006-006-000 ============ - ErrorCode FREE_PUBLISH_LIST_FAIL = new ErrorCode(1_006_006_000, "获得已成功发布列表失败,原因:{}"); - ErrorCode FREE_PUBLISH_SUBMIT_FAIL = new ErrorCode(1_006_006_001, "提交发布失败,原因:{}"); - ErrorCode FREE_PUBLISH_DELETE_FAIL = new ErrorCode(1_006_006_002, "删除发布失败,原因:{}"); - - // ========== 公众号草稿 1-006-007-000 ============ - ErrorCode DRAFT_LIST_FAIL = new ErrorCode(1_006_007_000, "获得草稿列表失败,原因:{}"); - ErrorCode DRAFT_CREATE_FAIL = new ErrorCode(1_006_007_001, "创建草稿失败,原因:{}"); - ErrorCode DRAFT_UPDATE_FAIL = new ErrorCode(1_006_007_002, "更新草稿失败,原因:{}"); - ErrorCode DRAFT_DELETE_FAIL = new ErrorCode(1_006_007_003, "删除草稿失败,原因:{}"); - - // ========== 公众号菜单 1-006-008-000 ============ - ErrorCode MENU_SAVE_FAIL = new ErrorCode(1_006_008_000, "创建菜单失败,原因:{}"); - ErrorCode MENU_DELETE_FAIL = new ErrorCode(1_006_008_001, "删除菜单失败,原因:{}"); - - // ========== 公众号自动回复 1-006-009-000 ============ - ErrorCode AUTO_REPLY_NOT_EXISTS = new ErrorCode(1_006_009_000, "自动回复不存在"); - ErrorCode AUTO_REPLY_ADD_SUBSCRIBE_FAIL_EXISTS = new ErrorCode(1_006_009_001, "操作失败,原因:已存在关注时的回复"); - ErrorCode AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS = new ErrorCode(1_006_009_002, "操作失败,原因:已存在该消息类型的回复"); - ErrorCode AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS = new ErrorCode(1_006_009_003, "操作失败,原因:已关在该关键字的回复"); - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java deleted file mode 100644 index a5298dbf3..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 公众号消息自动回复的匹配模式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpAutoReplyMatchEnum { - - ALL(1, "完全匹配"), - LIKE(2, "半匹配"), - ; - - /** - * 匹配 - */ - private final Integer match; - /** - * 匹配的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java deleted file mode 100644 index 300f1f2ba..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 公众号消息自动回复的类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpAutoReplyTypeEnum { - - SUBSCRIBE(1, "关注时回复"), - MESSAGE(2, "收到消息回复"), - KEYWORD(3, "关键词回复"), - ; - - /** - * 来源 - */ - private final Integer type; - /** - * 类型的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java deleted file mode 100644 index a2af484a5..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 微信公众号消息的发送来源 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpMessageSendFromEnum { - - USER_TO_MP(1, "粉丝发送给公众号"), - MP_TO_USER(2, "公众号发给粉丝"), - ; - - /** - * 来源 - */ - private final Integer from; - /** - * 来源的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java deleted file mode 100644 index 598718088..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * mp 模块,我们放微信微信公众号。 - * 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - * - * 1. Controller URL:以 /mp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 mp_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.mp; diff --git a/yudao-module-mp/yudao-module-mp-biz/Dockerfile b/yudao-module-mp/yudao-module-mp-biz/Dockerfile deleted file mode 100644 index 99c228ab8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-mp-biz-1.8.0-snapshot -WORKDIR /yudao-module-mp-biz-1.8.0-snapshot -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-mp-biz-1.8.0-snapshot.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48086 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mp/yudao-module-mp-biz/pom.xml b/yudao-module-mp/yudao-module-mp-biz/pom.xml deleted file mode 100644 index 8c9db6e53..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/pom.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - yudao-module-mp - cn.iocoder.cloud - ${revision} - - 4.0.0 - yudao-module-mp-biz - jar - - ${project.artifactId} - - mp 模块,我们放微信微信公众号。 - 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - - cn.iocoder.cloud - yudao-module-mp-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - com.github.binarywang - wx-java-mp-spring-boot-starter - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/MpServerApplication.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/MpServerApplication.java deleted file mode 100644 index d4c36503a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/MpServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.mp; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class MpServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(MpServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java deleted file mode 100644 index 62be175ac..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.*; -import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号账号") -@RestController -@RequestMapping("/mp/account") -@Validated -public class MpAccountController { - - @Resource - private MpAccountService mpAccountService; - - @PostMapping("/create") - @Operation(summary = "创建公众号账号") - @PreAuthorize("@ss.hasPermission('mp:account:create')") - public CommonResult createAccount(@Valid @RequestBody MpAccountCreateReqVO createReqVO) { - return success(mpAccountService.createAccount(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号账号") - @PreAuthorize("@ss.hasPermission('mp:account:update')") - public CommonResult updateAccount(@Valid @RequestBody MpAccountUpdateReqVO updateReqVO) { - mpAccountService.updateAccount(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号账号") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:delete')") - public CommonResult deleteAccount(@RequestParam("id") Long id) { - mpAccountService.deleteAccount(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号账号") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult getAccount(@RequestParam("id") Long id) { - MpAccountDO wxAccount = mpAccountService.getAccount(id); - return success(MpAccountConvert.INSTANCE.convert(wxAccount)); - } - - @GetMapping("/page") - @Operation(summary = "获得公众号账号分页") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getAccountPage(@Valid MpAccountPageReqVO pageVO) { - PageResult pageResult = mpAccountService.getAccountPage(pageVO); - return success(MpAccountConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取公众号账号精简信息列表") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getSimpleAccounts() { - List list = mpAccountService.getAccountList(); - return success(MpAccountConvert.INSTANCE.convertList02(list)); - } - - @PutMapping("/generate-qr-code") - @Operation(summary = "生成公众号二维码") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:qr-code')") - public CommonResult generateAccountQrCode(@RequestParam("id") Long id) { - mpAccountService.generateAccountQrCode(id); - return success(true); - } - - @PutMapping("/clear-quota") - @Operation(summary = "清空公众号 API 配额") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:clear-quota')") - public CommonResult clearAccountQuota(@RequestParam("id") Long id) { - mpAccountService.clearAccountQuota(id); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java deleted file mode 100644 index 8f688309d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -/** - * 公众号账号 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author fengdan - */ -@Data -public class MpAccountBaseVO { - - @Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @NotEmpty(message = "公众号名称不能为空") - private String name; - - @Schema(description = "公众号微信号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma") - @NotEmpty(message = "公众号微信号不能为空") - private String account; - - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx5b23ba7a5589ecbb") - @NotEmpty(message = "公众号 appId 不能为空") - private String appId; - - @Schema(description = "公众号密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "3a7b3b20c537e52e74afd395eb85f61f") - @NotEmpty(message = "公众号密钥不能为空") - private String appSecret; - - @Schema(description = "公众号 token", requiredMode = Schema.RequiredMode.REQUIRED, example = "kangdayuzhen") - @NotEmpty(message = "公众号 token 不能为空") - private String token; - - @Schema(description = "加密密钥", example = "gjN+Ksei") - private String aesKey; - - @Schema(description = "备注", example = "请关注芋道源码,学习技术") - private String remark; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java deleted file mode 100644 index b864f16c5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 公众号账号创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountCreateReqVO extends MpAccountBaseVO { - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java deleted file mode 100644 index 93093dc19..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 公众号账号分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountPageReqVO extends PageParam { - - @Schema(name = "公众号名称", description = "模糊匹配") - private String name; - - @Schema(name = "公众号账号", description = "模糊匹配") - private String account; - - @Schema(name = "公众号 appid", description = "模糊匹配") - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java deleted file mode 100644 index 0f7ca7eba..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号账号 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountRespVO extends MpAccountBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "二维码图片URL", example = "https://www.iocoder.cn/1024.png") - private String qrCodeUrl; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java deleted file mode 100644 index db4594f6d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号账号精简信息 Response VO") -@Data -public class MpAccountSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java deleted file mode 100644 index e93123e6c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号账号更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountUpdateReqVO extends MpAccountBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http deleted file mode 100644 index 74b8f40b6..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http +++ /dev/null @@ -1,5 +0,0 @@ -### 请求 /mp/material/page 接口 => 成功 -GET {{baseUrl}}/mp/material/page?permanent=true&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java deleted file mode 100644 index ef175d2af..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.*; -import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.io.IOException; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号素材") -@RestController -@RequestMapping("/mp/material") -@Validated -public class MpMaterialController { - - @Resource - private MpMaterialService mpMaterialService; - - @Operation(summary = "上传临时素材") - @PostMapping("/upload-temporary") - @PreAuthorize("@ss.hasPermission('mp:material:upload-temporary')") - public CommonResult uploadTemporaryMaterial( - @Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException { - MpMaterialDO material = mpMaterialService.uploadTemporaryMaterial(reqVO); - return success(MpMaterialConvert.INSTANCE.convert(material)); - } - - @Operation(summary = "上传永久素材") - @PostMapping("/upload-permanent") - @PreAuthorize("@ss.hasPermission('mp:material:upload-permanent')") - public CommonResult uploadPermanentMaterial( - @Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException { - MpMaterialDO material = mpMaterialService.uploadPermanentMaterial(reqVO); - return success(MpMaterialConvert.INSTANCE.convert(material)); - } - - @Operation(summary = "删除素材") - @DeleteMapping("/delete-permanent") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:material:delete')") - public CommonResult deleteMaterial(@RequestParam("id") Long id) { - mpMaterialService.deleteMaterial(id); - return success(true); - } - - @Operation(summary = "上传图文内容中的图片") - @PostMapping("/upload-news-image") - @PreAuthorize("@ss.hasPermission('mp:material:upload-news-image')") - public CommonResult uploadNewsImage(@Valid MpMaterialUploadNewsImageReqVO reqVO) - throws IOException { - return success(mpMaterialService.uploadNewsImage(reqVO)); - } - - @Operation(summary = "获得素材分页") - @GetMapping("/page") - @PreAuthorize("@ss.hasPermission('mp:material:query')") - public CommonResult> getMaterialPage(@Valid MpMaterialPageReqVO pageReqVO) { - PageResult pageResult = mpMaterialService.getMaterialPage(pageReqVO); - return success(MpMaterialConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java deleted file mode 100644 index 8a2b60ff6..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMaterialPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "是否永久", example = "true") - private Boolean permanent; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", example = "image") - private String type; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java deleted file mode 100644 index 5aba24edd..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号素材 Response VO") -@Data -public class MpMaterialRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "素材的 media_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") - private String mediaId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - private String type; - - @Schema(description = "是否永久 true - 永久;false - 临时", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean permanent; - - @Schema(description = "素材的 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String url; - - - @Schema(description = "名字", example = "yunai.png") - private String name; - - @Schema(description = "公众号文件 URL 只有【永久素材】使用", example = "https://mmbiz.qpic.cn/xxx.mp3") - private String mpUrl; - - @Schema(description = "视频素材的标题 只有【永久素材】使用", example = "我是标题") - private String title; - @Schema(description = "视频素材的描述 只有【永久素材】使用", example = "我是介绍") - private String introduction; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java deleted file mode 100644 index 6ede4c5eb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传图文内容中的图片 Request VO") -@Data -public class MpMaterialUploadNewsImageReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java deleted file mode 100644 index 9ca8a4ad8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import cn.hutool.core.util.ObjectUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传永久 Request VO") -@Data -public class MpMaterialUploadPermanentReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - @NotEmpty(message = "文件类型不能为空") - private String type; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - - @Schema(description = "名字 如果 name 为空,则使用 file 文件名", example = "wechat.mp") - private String name; - - @Schema(description = "视频素材的标题 文件类型为 video 时,必填", example = "视频素材的标题") - private String title; - @Schema(description = "视频素材的描述 文件类型为 video 时,必填", example = "视频素材的描述") - private String introduction; - - @AssertTrue(message = "标题不能为空") - public boolean isTitleValid() { - // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 - return ObjectUtil.notEqual(type, WxConsts.MediaFileType.VIDEO) - || title != null; - } - - @AssertTrue(message = "描述不能为空") - public boolean isIntroductionValid() { - // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 - return ObjectUtil.notEqual(type, WxConsts.MediaFileType.VIDEO) - || introduction != null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java deleted file mode 100644 index 0174cbcc2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号素材上传结果 Response VO") -@Data -public class MpMaterialUploadRespVO { - - @Schema(description = "素材的 media_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") - private String mediaId; - - @Schema(description = "素材的 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String url; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java deleted file mode 100644 index abd6d06d1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传临时 Request VO") -@Data -public class MpMaterialUploadTemporaryReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - @NotEmpty(message = "文件类型不能为空") - private String type; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http deleted file mode 100644 index 2276b3b4f..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http +++ /dev/null @@ -1,50 +0,0 @@ -### 请求 /mp/menu/save 接口 => 成功 -POST {{baseUrl}}/mp/menu/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "menus": [ - { - "type":"click", - "name":"今日歌曲", - "menuKey":"V1001_TODAY_MUSIC" - }, - { - "name":"搜索", - "type":"view", - "url":"https://www.soso.com/" - }, - { - "name": "父按钮", - "children": [ - { - "type":"click", - "name":"归去来兮", - "menuKey":"MUSIC" - }, - { - "name":"不说", - "type":"view", - "url":"https://www.soso.com/" - }] - }] -} - -### 请求 /mp/menu/save 接口 => 成功(清空) -POST {{baseUrl}}/mp/menu/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "menus": [] -} - -### 请求 /mp/menu/list 接口 => 成功 -GET {{baseUrl}}/mp/menu/list?accountId=1 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java deleted file mode 100644 index b7c883519..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号菜单") -@RestController -@RequestMapping("/mp/menu") -@Validated -public class MpMenuController { - - @Resource - private MpMenuService mpMenuService; - - @PostMapping("/save") - @Operation(summary = "保存公众号菜单") - @PreAuthorize("@ss.hasPermission('mp:menu:save')") - public CommonResult saveMenu(@Valid @RequestBody MpMenuSaveReqVO createReqVO) { - mpMenuService.saveMenu(createReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号菜单") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "10") - @PreAuthorize("@ss.hasPermission('mp:menu:delete')") - public CommonResult deleteMenu(@RequestParam("accountId") Long accountId) { - mpMenuService.deleteMenuByAccountId(accountId); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获得公众号菜单列表") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "10") - @PreAuthorize("@ss.hasPermission('mp:menu:query')") - public CommonResult> getMenuList(@RequestParam("accountId") Long accountId) { - List list = mpMenuService.getMenuListByAccountId(accountId); - return success(MpMenuConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java deleted file mode 100644 index cd0e5b2e4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -import static cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; - -/** - * 公众号菜单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MpMenuBaseVO { - - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标识 - * - * 支持多 DB 类型时,无法直接使用 key + @TableField("menuKey") 来实现转换,原因是 "menuKey" AS key 而存在报错 - */ - private String menuKey; - /** - * 父菜单编号 - */ - private Long parentId; - - // ========== 按钮操作 ========== - - /** - * 按钮类型 - * - * 枚举 {@link WxConsts.MenuButtonType} - */ - private String type; - - @Schema(description = "网页链接", example = "https://www.iocoder.cn/") - @NotEmpty(message = "网页链接不能为空", groups = {ViewButtonGroup.class, MiniProgramButtonGroup.class}) - @URL(message = "网页链接必须是 URL 格式") - private String url; - - @Schema(description = "小程序的 appId", example = "wx1234567890") - @NotEmpty(message = "小程序的 appId 不能为空", groups = MiniProgramButtonGroup.class) - private String miniProgramAppId; - - @Schema(description = "小程序的页面路径", example = "pages/index/index") - @NotEmpty(message = "小程序的页面路径不能为空", groups = MiniProgramButtonGroup.class) - private String miniProgramPagePath; - - @Schema(description ="跳转图文的媒体编号", example = "jCQk93AIIgp8ixClWcW_NXXqBKInNWNmq2XnPeDZl7IMVqWiNeL4FfELtggRXd83") - @NotEmpty(message = "跳转图文的媒体编号不能为空", groups = ViewLimitedButtonGroup.class) - private String articleId; - - // ========== 消息内容 ========== - - @Schema(description = "回复的消息类型 枚举 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC", example = "text") - @NotEmpty(message = "回复的消息类型不能为空", groups = {ClickButtonGroup.class, ScanCodeWaitMsgButtonGroup.class}) - private String replyMessageType; - - @Schema(description = "回复的消息内容", example = "欢迎关注") - @NotEmpty(message = "回复的消息内容不能为空", groups = TextMessageGroup.class) - private String replyContent; - - @Schema(description = "回复的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String replyMediaId; - @Schema(description = "回复的媒体 URL", example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String replyMediaUrl; - - @Schema(description = "缩略图的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String replyThumbMediaId; - @Schema(description = "缩略图的媒体 URL",example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MusicMessageGroup.class}) - private String replyThumbMediaUrl; - - @Schema(description = "回复的标题", example = "视频标题") - @NotEmpty(message = "回复的消息标题不能为空", groups = VideoMessageGroup.class) - private String replyTitle; - @Schema(description = "回复的描述", example = "视频描述") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String replyDescription; - - /** - * 回复的图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @NotNull(message = "回复的图文消息不能为空", groups = {NewsMessageGroup.class, ViewLimitedButtonGroup.class}) - @Valid - private List replyArticles; - - @Schema(description = "回复的音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String replyMusicUrl; - @Schema(description = "高质量音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String replyHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java deleted file mode 100644 index 39c18ae20..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Date; - -@Schema(description = "管理后台 - 公众号菜单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMenuRespVO extends MpMenuBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long accountId; - - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890ox") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java deleted file mode 100644 index 580e62845..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号菜单保存 Request VO") -@Data -public class MpMenuSaveReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @NotEmpty(message = "菜单不能为空") - @Valid - private List

menus; - - @Schema(description = "管理后台 - 公众号菜单保存时的每个菜单") - @Data - public static class Menu extends MpMenuBaseVO { - - /** - * 子菜单数组 - */ - private List children; - - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http deleted file mode 100644 index dbb3a7b22..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http +++ /dev/null @@ -1,5 +0,0 @@ -### 请求 /mp/message/page 接口 => 成功 -GET {{baseUrl}}/mp/auto-reply/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java deleted file mode 100644 index f6a8b9b38..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpAutoReplyConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号自动回复") -@RestController -@RequestMapping("/mp/auto-reply") -@Validated -public class MpAutoReplyController { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @GetMapping("/page") - @Operation(summary = "获得公众号自动回复分页") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:query')") - public CommonResult> getAutoReplyPage(@Valid MpMessagePageReqVO pageVO) { - PageResult pageResult = mpAutoReplyService.getAutoReplyPage(pageVO); - return success(MpAutoReplyConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号自动回复") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:query')") - public CommonResult getAutoReply(@RequestParam("id") Long id) { - MpAutoReplyDO autoReply = mpAutoReplyService.getAutoReply(id); - return success(MpAutoReplyConvert.INSTANCE.convert(autoReply)); - } - - @PostMapping("/create") - @Operation(summary = "创建公众号自动回复") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:create')") - public CommonResult createAutoReply(@Valid @RequestBody MpAutoReplyCreateReqVO createReqVO) { - return success(mpAutoReplyService.createAutoReply(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号自动回复") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:update')") - public CommonResult updateAutoReply(@Valid @RequestBody MpAutoReplyUpdateReqVO updateReqVO) { - mpAutoReplyService.updateAutoReply(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号自动回复") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:auto-reply:delete')") - public CommonResult deleteAutoReply(@RequestParam("id") Long id) { - mpAutoReplyService.deleteAutoReply(id); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http deleted file mode 100644 index b9f9721c9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http +++ /dev/null @@ -1,33 +0,0 @@ -### 请求 /mp/message/page 接口 => 成功 -GET {{baseUrl}}/mp/message/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/message/send 接口 => 成功(文本) -POST {{baseUrl}}/mp/message/send -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 3, - "type": "text", - "content": "测试消息" -} - -### 请求 /mp/message/send 接口 => 成功(音乐) -POST {{baseUrl}}/mp/message/send -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 3, - "type": "music", - "title": "测试音乐标题", - "description": "测试音乐内容", - "musicUrl": "https://www.iocoder.cn/xx.mp3", - "hqMusicUrl": "https://www.iocoder.cn/xx_high.mp3", - "thumbMediaId": "s98Iveeg9vDVFwa9q0u8-zSfdKe3xIzAm7wCrFE4WKGPIo4d9qAhtC-n6qvnyWyH" -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java deleted file mode 100644 index 66befc65e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpMessageConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号消息") -@RestController -@RequestMapping("/mp/message") -@Validated -public class MpMessageController { - - @Resource - private MpMessageService mpMessageService; - - @GetMapping("/page") - @Operation(summary = "获得公众号消息分页") - @PreAuthorize("@ss.hasPermission('mp:message:query')") - public CommonResult> getMessagePage(@Valid MpMessagePageReqVO pageVO) { - PageResult pageResult = mpMessageService.getMessagePage(pageVO); - return success(MpMessageConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/send") - @Operation(summary = "给粉丝发送消息") - @PreAuthorize("@ss.hasPermission('mp:message:send')") - public CommonResult sendMessage(@Valid @RequestBody MpMessageSendReqVO reqVO) { - MpMessageDO message = mpMessageService.sendKefuMessage(reqVO); - return success(MpMessageConvert.INSTANCE.convert(message)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java deleted file mode 100644 index 4b84254fe..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 公众号自动回复 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MpAutoReplyBaseVO { - - @Schema(description = "回复类型 参见 MpAutoReplyTypeEnum 枚举", example = "1") - @NotNull(message = "回复类型不能为空") - private Integer type; - - // ==================== 请求消息 ==================== - - @Schema(description = "请求的关键字 当 type 为 MpAutoReplyTypeEnum#KEYWORD 时,必填", example = "关键字") - private String requestKeyword; - @Schema(description = "请求的匹配方式 当 type 为 MpAutoReplyTypeEnum#KEYWORD 时,必填", example = "1") - private Integer requestMatch; - - @Schema(description = "请求的消息类型 当 type 为 MpAutoReplyTypeEnum#MESSAGE 时,必填", example = "text") - private String requestMessageType; - - // ==================== 响应消息 ==================== - - @Schema(description = "回复的消息类型 枚举 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC", example = "text") - @NotEmpty(message = "回复的消息类型不能为空") - private String responseMessageType; - - @Schema(description = "回复的消息内容", example = "欢迎关注") - @NotEmpty(message = "回复的消息内容不能为空", groups = TextMessageGroup.class) - private String responseContent; - - @Schema(description = "回复的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String responseMediaId; - @Schema(description = "回复的媒体 URL", example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String responseMediaUrl; - - @Schema(description = "缩略图的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String responseThumbMediaId; - @Schema(description = "缩略图的媒体 URL",example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MusicMessageGroup.class}) - private String responseThumbMediaUrl; - - @Schema(description = "回复的标题", example = "视频标题") - @NotEmpty(message = "回复的消息标题不能为空", groups = VideoMessageGroup.class) - private String responseTitle; - @Schema(description = "回复的描述", example = "视频描述") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String responseDescription; - - /** - * 回复的图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @NotNull(message = "回复的图文消息不能为空", groups = {NewsMessageGroup.class, ViewLimitedButtonGroup.class}) - @Valid - private List responseArticles; - - @Schema(description = "回复的音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String responseMusicUrl; - @Schema(description = "高质量音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String responseHqMusicUrl; - - @AssertTrue(message = "请求的关键字不能为空") - public boolean isRequestKeywordValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.KEYWORD) - || requestKeyword != null; - } - - @AssertTrue(message = "请求的关键字的匹配不能为空") - public boolean isRequestMatchValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.KEYWORD) - || requestMatch != null; - } - - @AssertTrue(message = "请求的消息类型不能为空") - public boolean isRequestMessageTypeValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.MESSAGE) - || requestMessageType != null; - } - - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java deleted file mode 100644 index 5eafb3693..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyCreateReqVO extends MpAutoReplyBaseVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java deleted file mode 100644 index a68029e92..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java deleted file mode 100644 index 4efc97445..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Date; - -@Schema(description = "管理后台 - 公众号自动回复 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyRespVO extends MpAutoReplyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long accountId; - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java deleted file mode 100644 index 92095d773..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyUpdateReqVO extends MpAutoReplyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java deleted file mode 100644 index 3ca643ca6..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 公众号消息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMessagePageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "消息类型 参见 WxConsts.XmlMsgType 枚举", example = "text") - private String type; - - @Schema(description = "公众号粉丝标识", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java deleted file mode 100644 index 27c85be6b..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import com.baomidou.mybatisplus.annotation.TableField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@Schema(description = "管理后台 - 公众号消息 Response VO") -@Data -public class MpMessageRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "微信公众号消息 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23953173569869169") - private Long msgId; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appid", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "公众号粉丝编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - @Schema(description = "公众号粉丝标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "消息类型 参见 WxConsts.XmlMsgType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") - private String type; - @Schema(description = "消息来源 参见 MpMessageSendFromEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sendFrom; - - // ========= 普通消息内容 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html - - @Schema(description = "消息内容 消息类型为 text 时,才有值", example = "你好呀") - private String content; - - @Schema(description = "媒体素材的编号 消息类型为 image、voice、video 时,才有值", example = "1234567890") - private String mediaId; - @Schema(description = "媒体文件的 URL 消息类型为 image、voice、video 时,才有值", example = "https://www.iocoder.cn/xxx.png") - private String mediaUrl; - - @Schema(description = "语音识别后文本 消息类型为 voice 时,才有值", example = "语音识别后文本") - private String recognition; - @Schema(description = "语音格式 消息类型为 voice 时,才有值", example = "amr") - private String format; - - @Schema(description = "标题 消息类型为 video、music、link 时,才有值", example = "我是标题") - private String title; - - @Schema(description = "描述 消息类型为 video、music 时,才有值", example = "我是描述") - private String description; - - @Schema(description = "缩略图的媒体 id 消息类型为 video、music 时,才有值", example = "1234567890") - private String thumbMediaId; - @Schema(description = "缩略图的媒体 URL 消息类型为 video、music 时,才有值", example = "https://www.iocoder.cn/xxx.png") - private String thumbMediaUrl; - - @Schema(description = "点击图文消息跳转链接 消息类型为 link 时,才有值", example = "https://www.iocoder.cn") - private String url; - - @Schema(description = "地理位置维度 消息类型为 location 时,才有值", example = "23.137466") - private Double locationX; - - @Schema(description = "地理位置经度 消息类型为 location 时,才有值", example = "113.352425") - private Double locationY; - - @Schema(description = "地图缩放大小 消息类型为 location 时,才有值", example = "13") - private Double scale; - - @Schema(description = "详细地址 消息类型为 location 时,才有值", example = "杨浦区黄兴路 221-4 号临") - private String label; - - /** - * 图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List articles; - - @Schema(description = "音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") - private String musicUrl; - @Schema(description = "高质量音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") - private String hqMusicUrl; - - // ========= 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html - - @Schema(description = "事件类型 参见 WxConsts.EventType 枚举", example = "subscribe") - private String event; - @Schema(description = "事件 Key 参见 WxConsts.EventType 枚举", example = "qrscene_123456") - private String eventKey; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java deleted file mode 100644 index 8e833d443..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号消息发送 Request VO") -@Data -public class MpMessageSendReqVO { - - @Schema(description = "公众号粉丝的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号粉丝的编号不能为空") - private Long userId; - - // ========== 消息内容 ========== - - @Schema(description = "消息类型 TEXT/IMAGE/VOICE/VIDEO/NEWS", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") - @NotEmpty(message = "消息类型不能为空") - public String type; - - @Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好呀") - @NotEmpty(message = "消息内容不能为空", groups = TextMessageGroup.class) - private String content; - - @Schema(description = "媒体 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "qqc_2Fot30Jse-HDoZmo5RrUDijz2nGUkP") - @NotEmpty(message = "消息内容不能为空", groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String mediaId; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "没有标题") - @NotEmpty(message = "消息内容不能为空", groups = VideoMessageGroup.class) - private String title; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String description; - - @Schema(description = "缩略图的媒体 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "qqc_2Fot30Jse-HDoZmo5RrUDijz2nGUkP") - @NotEmpty(message = "缩略图的媒体 id 不能为空", groups = MusicMessageGroup.class) - private String thumbMediaId; - - @Schema(description = "图文消息", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - @NotNull(message = "图文消息不能为空", groups = NewsMessageGroup.class) - private List articles; - - @Schema(description = "音乐链接 消息类型为 MUSIC 时", example = "https://www.iocoder.cn/music.mp3") - private String musicUrl; - - @Schema(description = "高质量音乐链接 消息类型为 MUSIC 时", example = "https://www.iocoder.cn/music.mp3") - private String hqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http deleted file mode 100644 index 87f9d432a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http +++ /dev/null @@ -1,54 +0,0 @@ -### 请求 /mp/draft/page 接口 => 成功 -GET {{baseUrl}}/mp/draft/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/draft/create 接口 => 成功 -POST {{baseUrl}}/mp/draft/create?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "articles": [ - { - "title": "我是标题", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" - }, - { - "title": "我是标题 2", - "author": "我是作者 2", - "digest": "我是摘要 2", - "content": "我是内容 2", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" - } - ] -} - -### 请求 /mp/draft/create 接口 => 成功 -PUT {{baseUrl}}/mp/draft/update?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-q-G9pdsmZw0OYG4FzHQkKfpLfEwIH51wy2bxisx8PvW -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -[{ - "title": "我是标题(OOO)", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" -}, { - "title": "我是标题(XXX)", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" -}] diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java deleted file mode 100644 index c43d6c5d7..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpDraftPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.draft.*; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -@Tag(name = "管理后台 - 公众号草稿") -@RestController -@RequestMapping("/mp/draft") -@Validated -public class MpDraftController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpMaterialService mpMaterialService; - - @GetMapping("/page") - @Operation(summary = "获得草稿分页") - @PreAuthorize("@ss.hasPermission('mp:draft:query')") - public CommonResult> getDraftPage(MpDraftPageReqVO reqVO) { - // 从公众号查询草稿箱 - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - WxMpDraftList draftList; - try { - draftList = mpService.getDraftService().listDraft(PageUtils.getStart(reqVO), reqVO.getPageSize()); - } catch (WxErrorException e) { - throw exception(DRAFT_LIST_FAIL, e.getError().getErrorMsg()); - } - // 查询对应的图片地址。目的:解决公众号的图片链接无法在我们后台展示 - setDraftThumbUrl(draftList.getItems()); - - // 返回分页 - return success(new PageResult<>(draftList.getItems(), draftList.getTotalCount().longValue())); - } - - private void setDraftThumbUrl(List items) { - // 1.1 获得 mediaId 数组 - Set mediaIds = new HashSet<>(); - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> mediaIds.add(newsItem.getThumbMediaId()))); - if (CollUtil.isEmpty(mediaIds)) { - return; - } - // 1.2 批量查询对应的 Media 素材 - Map materials = CollectionUtils.convertMap(mpMaterialService.getMaterialListByMediaId(mediaIds), - MpMaterialDO::getMediaId); - - // 2. 设置回 WxMpDraftItem 记录 - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> - findAndThen(materials, newsItem.getThumbMediaId(), material -> newsItem.setThumbUrl(material.getUrl())))); - } - - @PostMapping("/create") - @Operation(summary = "创建草稿") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:draft:create')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestBody WxMpAddDraft draft) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - String mediaId = mpService.getDraftService().addDraft(draft); - return success(mediaId); - } catch (WxErrorException e) { - throw exception(DRAFT_CREATE_FAIL, e.getError().getErrorMsg()); - } - } - - @PutMapping("/update") - @Operation(summary = "更新草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "草稿素材的编号", required = true, example = "xxx") - }) - @PreAuthorize("@ss.hasPermission('mp:draft:update')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId, - @RequestBody List articles) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - for (int i = 0; i < articles.size(); i++) { - WxMpDraftArticles article = articles.get(i); - mpService.getDraftService().updateDraft(new WxMpUpdateDraft(mediaId, i, article)); - } - return success(true); - } catch (WxErrorException e) { - throw exception(DRAFT_UPDATE_FAIL, e.getError().getErrorMsg()); - } - } - - @DeleteMapping("/delete") - @Operation(summary = "删除草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "草稿素材的编号", required = true, example = "xxx") - }) - @PreAuthorize("@ss.hasPermission('mp:draft:delete')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - mpService.getDraftService().delDraft(mediaId); - return success(true); - } catch (WxErrorException e) { - throw exception(DRAFT_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http deleted file mode 100644 index 122413200..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http +++ /dev/null @@ -1,13 +0,0 @@ -### 请求 /mp/free-publish/page 接口 => 成功 -GET {{baseUrl}}/mp/free-publish/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/free-publish/submit 接口 => 成功 -POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-vilmd7iS51D8IPddxflWrau0hIQ2ovY8YanO5jlgUcM -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java deleted file mode 100644 index e36d7343c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpFreePublishPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishItem; -import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -@Tag(name = "管理后台 - 公众号发布能力") -@RestController -@RequestMapping("/mp/free-publish") -@Validated -public class MpFreePublishController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpMaterialService mpMaterialService; - - @GetMapping("/page") - @Operation(summary = "获得已发布的图文分页") - @PreAuthorize("@ss.hasPermission('mp:free-publish:query')") - public CommonResult> getFreePublishPage(MpFreePublishPageReqVO reqVO) { - // 从公众号查询已发布的图文列表 - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - WxMpFreePublishList publicationRecords; - try { - publicationRecords = mpService.getFreePublishService().getPublicationRecords( - PageUtils.getStart(reqVO), reqVO.getPageSize()); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg()); - } - // 查询对应的图片地址。目的:解决公众号的图片链接无法在我们后台展示 - setFreePublishThumbUrl(publicationRecords.getItems()); - - // 返回分页 - return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue())); - } - - private void setFreePublishThumbUrl(List items) { - // 1.1 获得 mediaId 数组 - Set mediaIds = new HashSet<>(); - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> mediaIds.add(newsItem.getThumbMediaId()))); - if (CollUtil.isEmpty(mediaIds)) { - return; - } - // 1.2 批量查询对应的 Media 素材 - Map materials = CollectionUtils.convertMap(mpMaterialService.getMaterialListByMediaId(mediaIds), - MpMaterialDO::getMediaId); - - // 2. 设置回 WxMpFreePublishItem 记录 - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> - findAndThen(materials, newsItem.getThumbMediaId(), material -> newsItem.setThumbUrl(material.getUrl())))); - } - - @PostMapping("/submit") - @Operation(summary = "发布草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "要发布的草稿的 media_id", required = true, example = "2048") - }) - @PreAuthorize("@ss.hasPermission('mp:free-publish:submit')") - public CommonResult submitFreePublish(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - String publishId = mpService.getFreePublishService().submit(mediaId); - return success(publishId); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_SUBMIT_FAIL, e.getError().getErrorMsg()); - } - } - - @DeleteMapping("/delete") - @Operation(summary = "删除草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "articleId", description = "发布记录的编号", required = true, example = "2048") - }) - @PreAuthorize("@ss.hasPermission('mp:free-publish:delete')") - public CommonResult deleteFreePublish(@RequestParam("accountId") Long accountId, - @RequestParam("articleId") String articleId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - mpService.getFreePublishService().deletePushAllArticle(articleId); - return success(true); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java deleted file mode 100644 index 62bc6f8e5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号草稿的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpDraftPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java deleted file mode 100644 index da36248f0..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号已发布列表的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpFreePublishPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java deleted file mode 100644 index 47e23923d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenCheckSignatureReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenHandleMessageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Objects; - -@Tag(name = "管理后台 - 公众号回调") -@RestController -@RequestMapping("/mp/open") -@Validated -@Slf4j -public class MpOpenController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpAccountService mpAccountService; - - /** - * 接收微信公众号的校验签名 - * - * 对应 文档 - */ - @Operation(summary = "校验签名") // 参见 - @GetMapping(value = "/{appId}", produces = "text/plain;charset=utf-8") - public String checkSignature(@PathVariable("appId") String appId, - MpOpenCheckSignatureReqVO reqVO) { - log.info("[checkSignature][appId({}) 接收到来自微信服务器的认证消息({})]", appId, reqVO); - // 校验请求签名 - WxMpService wxMpService = mpServiceFactory.getRequiredMpService(appId); - // 校验通过 - if (wxMpService.checkSignature(reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getSignature())) { - return reqVO.getEchostr(); - } - // 校验不通过 - return "非法请求"; - } - - /** - * 接收微信公众号的消息推送 - * - * 文档 - */ - @Operation(summary = "处理消息") - @PostMapping(value = "/{appId}", produces = "application/xml; charset=UTF-8") - public String handleMessage(@PathVariable("appId") String appId, - @RequestBody String content, - MpOpenHandleMessageReqVO reqVO) { - log.info("[handleMessage][appId({}) 推送消息,参数({}) 内容({})]", appId, reqVO, content); - - // 处理 appId + 多租户的上下文 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号 appId({}) 不存在", appId); - try { - MpContextHolder.setAppId(appId); - return TenantUtils.execute(account.getTenantId(), - () -> handleMessage0(appId, content, reqVO)); - } finally { - MpContextHolder.clear(); - } - } - - private String handleMessage0(String appId, String content, MpOpenHandleMessageReqVO reqVO) { - // 校验请求签名 - WxMpService mppService = mpServiceFactory.getRequiredMpService(appId); - Assert.isTrue(mppService.checkSignature(reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getSignature()), - "非法请求"); - - // 第一步,解析消息 - WxMpXmlMessage inMessage = null; - if (StrUtil.isBlank(reqVO.getEncrypt_type())) { // 明文模式 - inMessage = WxMpXmlMessage.fromXml(content); - } else if (Objects.equals(reqVO.getEncrypt_type(), MpOpenHandleMessageReqVO.ENCRYPT_TYPE_AES)) { // AES 加密模式 - inMessage = WxMpXmlMessage.fromEncryptedXml(content, mppService.getWxMpConfigStorage(), - reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getMsg_signature()); - } - Assert.notNull(inMessage, "消息解析失败,原因:消息为空"); - - // 第二步,处理消息 - WxMpMessageRouter mpMessageRouter = mpServiceFactory.getRequiredMpMessageRouter(appId); - WxMpXmlOutMessage outMessage = mpMessageRouter.route(inMessage); - if (outMessage == null) { - return ""; - } - - // 第三步,返回消息 - if (StrUtil.isBlank(reqVO.getEncrypt_type())) { // 明文模式 - return outMessage.toXml(); - } else if (Objects.equals(reqVO.getEncrypt_type(), MpOpenHandleMessageReqVO.ENCRYPT_TYPE_AES)) { // AES 加密模式 - return outMessage.toEncryptedXml(mppService.getWxMpConfigStorage()); - } - return ""; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java deleted file mode 100644 index c0c73a8ed..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号校验签名 Request VO") -@Data -public class MpOpenCheckSignatureReqVO { - - @Schema(description = "微信加密签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "490eb57f448b87bd5f20ccef58aa4de46aa1908e") - @NotEmpty(message = "微信加密签名不能为空") - private String signature; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1672587863") - @NotEmpty(message = "时间戳不能为空") - private String timestamp; - - @Schema(description = "随机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1827365808") - @NotEmpty(message = "随机数不能为空") - private String nonce; - - @Schema(description = "随机字符串", requiredMode = Schema.RequiredMode.REQUIRED, example = "2721154047828672511") - @NotEmpty(message = "随机字符串不能为空") - @SuppressWarnings("SpellCheckingInspection") - private String echostr; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java deleted file mode 100644 index cb8f9abf2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open.vo; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号处理消息 Request VO") -@Data -public class MpOpenHandleMessageReqVO { - - public static final String ENCRYPT_TYPE_AES = "aes"; - - @Schema(description = "微信加密签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "490eb57f448b87bd5f20ccef58aa4de46aa1908e") - @NotEmpty(message = "微信加密签名不能为空") - private String signature; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1672587863") - @NotEmpty(message = "时间戳不能为空") - private String timestamp; - - @Schema(description = "随机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1827365808") - @NotEmpty(message = "随机数不能为空") - private String nonce; - - @Schema(description = "粉丝 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "oz-Jdtyn-WGm4C4I5Z-nvBMO_ZfY") - @NotEmpty(message = "粉丝 openid 不能为空") - private String openid; - - @Schema(description = "消息加密类型", example = "aes") - private String encrypt_type; - - @Schema(description = "微信签名", example = "QW5kcm9pZCBUaGUgQmFzZTY0IGlzIGEgZ2VuZXJhdGVkIHN0cmluZw==") - private String msg_signature; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java deleted file mode 100644 index 8a9df53c3..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.*; -import cn.iocoder.yudao.module.mp.convert.statistics.MpStatisticsConvert; -import cn.iocoder.yudao.module.mp.service.statistics.MpStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号统计") -@RestController -@RequestMapping("/mp/statistics") -@Validated -public class MpStatisticsController { - - @Resource - private MpStatisticsService mpStatisticsService; - - @GetMapping("/user-summary") - @Operation(summary = "获得粉丝增减数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUserSummary(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUserSummary( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList01(list)); - } - - @GetMapping("/user-cumulate") - @Operation(summary = "获得粉丝累计数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUserCumulate(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUserCumulate( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList02(list)); - } - - @GetMapping("/upstream-message") - @Operation(summary = "获取消息发送概况数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUpstreamMessage(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUpstreamMessage( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList03(list)); - } - - @GetMapping("/interface-summary") - @Operation(summary = "获取消息发送概况数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getInterfaceSummary(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getInterfaceSummary( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList04(list)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java deleted file mode 100644 index f228f7259..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 获得统计数据 Request VO") -@Data -public class MpStatisticsGetReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "查询时间范围", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotNull(message = "查询时间范围不能为空") - private LocalDateTime[] date; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java deleted file mode 100644 index c7952f42d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的接口分析数据 Response VO") -@Data -public class MpStatisticsInterfaceSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "通过服务器配置地址获得消息后,被动回复粉丝消息的次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer callbackCount; - - @Schema(description = "上述动作的失败次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer failCount; - - @Schema(description = "总耗时,除以 callback_count 即为平均耗时", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer totalTimeCost; - - @Schema(description = "最大耗时", requiredMode = Schema.RequiredMode.REQUIRED, example = "40") - private Integer maxTimeCost; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java deleted file mode 100644 index f9bba2ce2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的粉丝增减数据 Response VO") -@Data -public class MpStatisticsUpstreamMessageRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "上行发送了(向公众号发送了)消息的粉丝数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer messageUser; - - @Schema(description = "上行发送了消息的消息总数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer messageCount; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java deleted file mode 100644 index 6503c0780..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的消息发送概况数据 Response VO") -@Data -public class MpStatisticsUserCumulateRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "累计粉丝量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer cumulateUser; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java deleted file mode 100644 index f7feb5171..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Date; - -@Schema(description = "管理后台 - 某一天的粉丝增减数据 Response VO") -@Data -public class MpStatisticsUserSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "粉丝来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer userSource; - - @Schema(description = "新关注的粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer newUser; - - @Schema(description = "取消关注的粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer cancelUser; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http deleted file mode 100644 index fe79105ba..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http +++ /dev/null @@ -1,39 +0,0 @@ -### 请求 /mp/tag/create 接口 => 成功 -POST {{baseUrl}}/mp/tag/create -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "name": "测试" -} - -### 请求 /mp/tag/update 接口 => 成功 -PUT {{baseUrl}}/mp/tag/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": "3", - "name": "测试标签啦" -} - -### 请求 /mp/tag/delete 接口 => 成功 -DELETE {{baseUrl}}/mp/tag/delete?id=3 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/tag/page 接口 => 成功 -GET {{baseUrl}}/mp/tag/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/tag/sync 接口 => 成功 -POST {{baseUrl}}/mp/tag/sync?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java deleted file mode 100644 index 96af036dc..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.*; -import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import cn.iocoder.yudao.module.mp.service.tag.MpTagService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号标签") -@RestController -@RequestMapping("/mp/tag") -@Validated -public class MpTagController { - - @Resource - private MpTagService mpTagService; - - @PostMapping("/create") - @Operation(summary = "创建公众号标签") - @PreAuthorize("@ss.hasPermission('mp:tag:create')") - public CommonResult createTag(@Valid @RequestBody MpTagCreateReqVO createReqVO) { - return success(mpTagService.createTag(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号标签") - @PreAuthorize("@ss.hasPermission('mp:tag:update')") - public CommonResult updateTag(@Valid @RequestBody MpTagUpdateReqVO updateReqVO) { - mpTagService.updateTag(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号标签") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:tag:delete')") - public CommonResult deleteTag(@RequestParam("id") Long id) { - mpTagService.deleteTag(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获取公众号标签详情") - @PreAuthorize("@ss.hasPermission('mp:tag:query')") - public CommonResult get(@RequestParam("id") Long id) { - MpTagDO mpTagDO = mpTagService.get(id); - return success(MpTagConvert.INSTANCE.convert(mpTagDO)); - } - - @GetMapping("/page") - @Operation(summary = "获取公众号标签分页") - @PreAuthorize("@ss.hasPermission('mp:tag:query')") - public CommonResult> getTagPage(MpTagPageReqVO pageReqVO) { - PageResult pageResult = mpTagService.getTagPage(pageReqVO); - return success(MpTagConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取公众号账号精简信息列表") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getSimpleTags() { - List list = mpTagService.getTagList(); - return success(MpTagConvert.INSTANCE.convertList02(list)); - } - - @PostMapping("/sync") - @Operation(summary = "同步公众号标签") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:tag:sync')") - public CommonResult syncTag(@RequestParam("accountId") Long accountId) { - mpTagService.syncTag(accountId); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java deleted file mode 100644 index dc034e3e8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -/** - * 公众号标签 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author fengdan - */ -@Data -public class MpTagBaseVO { - - @Schema(description = "标签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - @NotEmpty(message = "标签名不能为空") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java deleted file mode 100644 index ba56a0271..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号标签创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagCreateReqVO extends MpTagBaseVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java deleted file mode 100644 index 0666b340a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号标签分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotEmpty(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "标签名,模糊匹配", example = "哈哈") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java deleted file mode 100644 index 0da562dee..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号标签 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagRespVO extends MpTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "此标签下粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer count; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java deleted file mode 100644 index ca23be1c8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号标签精简信息 Response VO") -@Data -public class MpTagSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号的标签编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long tagId; - - @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "快乐") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java deleted file mode 100644 index cb61f1afb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号标签更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagUpdateReqVO extends MpTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http deleted file mode 100644 index 7c615810f..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http +++ /dev/null @@ -1,18 +0,0 @@ -### 请求 /mp/user/sync 接口 => 成功 -POST {{baseUrl}}/mp/user/sync?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/user/update 接口 => 成功 -PUT {{baseUrl}}/mp/user/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": "3", - "nickname": "test", - "remark": "测试备注", - "tagIds": [103, 104] -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java deleted file mode 100644 index 7098bc57e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号粉丝") -@RestController -@RequestMapping("/mp/user") -@Validated -public class MpUserController { - - @Resource - private MpUserService mpUserService; - - @GetMapping("/page") - @Operation(summary = "获得公众号粉丝分页") - @PreAuthorize("@ss.hasPermission('mp:user:query')") - public CommonResult> getUserPage(@Valid MpUserPageReqVO pageVO) { - PageResult pageResult = mpUserService.getUserPage(pageVO); - return success(MpUserConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号粉丝") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:user:query')") - public CommonResult getUser(@RequestParam("id") Long id) { - return success(MpUserConvert.INSTANCE.convert(mpUserService.getUser(id))); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号粉丝") - @PreAuthorize("@ss.hasPermission('mp:user:update')") - public CommonResult updateUser(@Valid @RequestBody MpUserUpdateReqVO updateReqVO) { - mpUserService.updateUser(updateReqVO); - return success(true); - } - - @PostMapping("/sync") - @Operation(summary = "同步公众号粉丝") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:user:sync')") - public CommonResult syncUser(@RequestParam("accountId") Long accountId) { - mpUserService.syncUser(accountId); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java deleted file mode 100644 index 93b5ba92c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号粉丝分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpUserPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "公众号粉丝标识,模糊匹配", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "微信生态唯一标识,模糊匹配", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String unionId; - - @Schema(description = "公众号粉丝昵称,模糊匹配", example = "芋艿") - private String nickname; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java deleted file mode 100644 index 95f919a1b..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 公众号粉丝 Response VO") -@Data -public class MpUserRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号粉丝标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "微信生态唯一标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String unionId; - - @Schema(description = "关注状态 参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer subscribeStatus; - @Schema(description = "关注时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime subscribeTime; - @Schema(description = "取消关注时间") - private LocalDateTime unsubscribeTime; - - @Schema(description = "昵称", example = "芋道") - private String nickname; - @Schema(description = "头像地址", example = "https://www.iocoder.cn/1.png") - private String headImageUrl; - @Schema(description = "语言", example = "zh_CN") - private String language; - @Schema(description = "国家", example = "中国") - private String country; - @Schema(description = "省份", example = "广东省") - private String province; - @Schema(description = "城市", example = "广州市") - private String city; - @Schema(description = "备注", example = "你是一个芋头嘛") - private String remark; - - @Schema(description = "标签编号数组", example = "1,2,3") - private List tagIds; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java deleted file mode 100644 index 3089ed3d3..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号粉丝更新 Request VO") -@Data -public class MpUserUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "昵称", example = "芋道") - private String nickname; - - @Schema(description = "备注", example = "你是一个芋头嘛") - private String remark; - - @Schema(description = "标签编号数组", example = "1,2,3") - private List tagIds; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java deleted file mode 100644 index 31a057767..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.mp.controller; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java deleted file mode 100644 index 5f8fde36a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountSimpleRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpAccountConvert { - - MpAccountConvert INSTANCE = Mappers.getMapper(MpAccountConvert.class); - - MpAccountDO convert(MpAccountCreateReqVO bean); - - MpAccountDO convert(MpAccountUpdateReqVO bean); - - MpAccountRespVO convert(MpAccountDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java deleted file mode 100644 index ca4f69c3d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadRespVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import me.chanjar.weixin.mp.bean.material.WxMpMaterial; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.io.File; - -@Mapper -public interface MpMaterialConvert { - - MpMaterialConvert INSTANCE = Mappers.getMapper(MpMaterialConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - @Mapping(source = "name", target = "name") - }) - MpMaterialDO convert(String mediaId, String type, String url, MpAccountDO account, - String name); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - @Mapping(source = "name", target = "name") - }) - MpMaterialDO convert(String mediaId, String type, String url, MpAccountDO account, - String name, String title, String introduction, String mpUrl); - - MpMaterialUploadRespVO convert(MpMaterialDO bean); - - default WxMpMaterial convert(String name, File file, String title, String introduction) { - return new WxMpMaterial(name, file, title, introduction); - } - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java deleted file mode 100644 index a5ae32a44..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.menu; - -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.bean.menu.WxMenuButton; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpMenuConvert { - - MpMenuConvert INSTANCE = Mappers.getMapper(MpMenuConvert.class); - - MpMenuRespVO convert(MpMenuDO bean); - - List convertList(List list); - - @Mappings({ - @Mapping(source = "menu.appId", target = "appId"), - @Mapping(source = "menu.replyMessageType", target = "type"), - @Mapping(source = "menu.replyContent", target = "content"), - @Mapping(source = "menu.replyMediaId", target = "mediaId"), - @Mapping(source = "menu.replyThumbMediaId", target = "thumbMediaId"), - @Mapping(source = "menu.replyTitle", target = "title"), - @Mapping(source = "menu.replyDescription", target = "description"), - @Mapping(source = "menu.replyArticles", target = "articles"), - @Mapping(source = "menu.replyMusicUrl", target = "musicUrl"), - @Mapping(source = "menu.replyHqMusicUrl", target = "hqMusicUrl"), - }) - MpMessageSendOutReqBO convert(String openid, MpMenuDO menu); - - List convert(List list); - - @Mappings({ - @Mapping(source = "menuKey", target = "key"), - @Mapping(source = "children", target = "subButtons"), - @Mapping(source = "miniProgramAppId", target = "appId"), - @Mapping(source = "miniProgramPagePath", target = "pagePath"), - }) - WxMenuButton convert(MpMenuSaveReqVO.Menu bean); - - MpMenuDO convert02(MpMenuSaveReqVO.Menu menu); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java deleted file mode 100644 index c7cf8902e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface MpAutoReplyConvert { - - MpAutoReplyConvert INSTANCE = Mappers.getMapper(MpAutoReplyConvert.class); - - @Mappings({ - @Mapping(source = "reply.appId", target = "appId"), - @Mapping(source = "reply.responseMessageType", target = "type"), - @Mapping(source = "reply.responseContent", target = "content"), - @Mapping(source = "reply.responseMediaId", target = "mediaId"), - @Mapping(source = "reply.responseTitle", target = "title"), - @Mapping(source = "reply.responseDescription", target = "description"), - @Mapping(source = "reply.responseArticles", target = "articles"), - }) - MpMessageSendOutReqBO convert(String openid, MpAutoReplyDO reply); - - PageResult convertPage(PageResult page); - - MpAutoReplyRespVO convert(MpAutoReplyDO bean); - - MpAutoReplyDO convert(MpAutoReplyCreateReqVO bean); - - MpAutoReplyDO convert(MpAutoReplyUpdateReqVO bean); -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java deleted file mode 100644 index 8f31a683a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage; -import me.chanjar.weixin.mp.builder.outxml.BaseBuilder; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpMessageConvert { - - MpMessageConvert INSTANCE = Mappers.getMapper(MpMessageConvert.class); - - MpMessageRespVO convert(MpMessageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default MpMessageDO convert(WxMpXmlMessage wxMessage, MpAccountDO account, MpUserDO user) { - MpMessageDO message = convert(wxMessage); - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - @Mappings(value = { - @Mapping(source = "msgType", target = "type"), - @Mapping(target = "createTime", ignore = true), - }) - MpMessageDO convert(WxMpXmlMessage bean); - - default MpMessageDO convert(MpMessageSendOutReqBO sendReqBO, MpAccountDO account, MpUserDO user) { - // 构建消息 - MpMessageDO message = new MpMessageDO(); - message.setType(sendReqBO.getType()); - switch (sendReqBO.getType()) { - case WxConsts.XmlMsgType.TEXT: // 1. 文本 - message.setContent(sendReqBO.getContent()); - break; - case WxConsts.XmlMsgType.IMAGE: // 2. 图片 - case WxConsts.XmlMsgType.VOICE: // 3. 语音 - message.setMediaId(sendReqBO.getMediaId()); - break; - case WxConsts.XmlMsgType.VIDEO: // 4. 视频 - message.setMediaId(sendReqBO.getMediaId()) - .setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()); - break; - case WxConsts.XmlMsgType.NEWS: // 5. 图文 - message.setArticles(sendReqBO.getArticles()); - case WxConsts.XmlMsgType.MUSIC: // 6. 音乐 - message.setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()) - .setMusicUrl(sendReqBO.getMusicUrl()).setHqMusicUrl(sendReqBO.getHqMusicUrl()) - .setThumbMediaId(sendReqBO.getThumbMediaId()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); - } - - // 其它字段 - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - - default WxMpXmlOutMessage convert02(MpMessageDO message, MpAccountDO account) { - BaseBuilder builder; - // 个性化字段 - switch (message.getType()) { - case WxConsts.XmlMsgType.TEXT: - builder = WxMpXmlOutMessage.TEXT().content(message.getContent()); - break; - case WxConsts.XmlMsgType.IMAGE: - builder = WxMpXmlOutMessage.IMAGE().mediaId(message.getMediaId()); - break; - case WxConsts.XmlMsgType.VOICE: - builder = WxMpXmlOutMessage.VOICE().mediaId(message.getMediaId()); - break; - case WxConsts.XmlMsgType.VIDEO: - builder = WxMpXmlOutMessage.VIDEO().mediaId(message.getMediaId()) - .title(message.getTitle()).description(message.getDescription()); - break; - case WxConsts.XmlMsgType.NEWS: - builder = WxMpXmlOutMessage.NEWS().articles(convertList02(message.getArticles())); - break; - case WxConsts.XmlMsgType.MUSIC: - builder = WxMpXmlOutMessage.MUSIC().title(message.getTitle()).description(message.getDescription()) - .musicUrl(message.getMusicUrl()).hqMusicUrl(message.getHqMusicUrl()) - .thumbMediaId(message.getThumbMediaId()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); - } - // 通用字段 - builder.fromUser(account.getAccount()); - builder.toUser(message.getOpenid()); - return builder.build(); - } - List convertList02(List list); - - default WxMpKefuMessage convert(MpMessageSendReqVO sendReqVO, MpUserDO user) { - me.chanjar.weixin.mp.builder.kefu.BaseBuilder builder; - // 个性化字段 - switch (sendReqVO.getType()) { - case WxConsts.KefuMsgType.TEXT: - builder = WxMpKefuMessage.TEXT().content(sendReqVO.getContent()); - break; - case WxConsts.KefuMsgType.IMAGE: - builder = WxMpKefuMessage.IMAGE().mediaId(sendReqVO.getMediaId()); - break; - case WxConsts.KefuMsgType.VOICE: - builder = WxMpKefuMessage.VOICE().mediaId(sendReqVO.getMediaId()); - break; - case WxConsts.KefuMsgType.VIDEO: - builder = WxMpKefuMessage.VIDEO().mediaId(sendReqVO.getMediaId()) - .title(sendReqVO.getTitle()).description(sendReqVO.getDescription()); - break; - case WxConsts.KefuMsgType.NEWS: - builder = WxMpKefuMessage.NEWS().articles(convertList03(sendReqVO.getArticles())); - break; - case WxConsts.KefuMsgType.MUSIC: - builder = WxMpKefuMessage.MUSIC().title(sendReqVO.getTitle()).description(sendReqVO.getDescription()) - .thumbMediaId(sendReqVO.getThumbMediaId()) - .musicUrl(sendReqVO.getMusicUrl()).hqMusicUrl(sendReqVO.getHqMusicUrl()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + sendReqVO.getType()); - } - // 通用字段 - builder.toUser(user.getOpenid()); - return builder.build(); - } - List convertList03(List list); - - default MpMessageDO convert(WxMpKefuMessage wxMessage, MpAccountDO account, MpUserDO user) { - MpMessageDO message = convert(wxMessage); - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - @Mappings(value = { - @Mapping(source = "msgType", target = "type"), - @Mapping(target = "createTime", ignore = true), - }) - MpMessageDO convert(WxMpKefuMessage bean); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java deleted file mode 100644 index 9d4d7e3de..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.statistics; - -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsInterfaceSummaryRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Mapper -public interface MpStatisticsConvert { - - MpStatisticsConvert INSTANCE = Mappers.getMapper(MpStatisticsConvert.class); - - List convertList01(List list); - - List convertList02(List list); - - List convertList03(List list); - - @Mappings({ - @Mapping(target = "refDate", expression = "java(dateFormat0(bean.getRefDate()))"), - @Mapping(source = "msgUser", target = "messageUser"), - @Mapping(source = "msgCount", target = "messageCount"), - }) - MpStatisticsUpstreamMessageRespVO convert(WxDataCubeMsgResult bean); - - List convertList04(List list); - - @Mapping(target = "refDate", expression = "java(dateFormat0(bean.getRefDate()))") - MpStatisticsInterfaceSummaryRespVO convert(WxDataCubeInterfaceResult bean); - - @Named("dateFormat0") - default LocalDateTime dateFormat0(String date) { - return LocalDate.parse(date, DateTimeFormatter.ofPattern(FORMAT_YEAR_MONTH_DAY)).atStartOfDay(); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java deleted file mode 100644 index 727ccd314..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagSimpleRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpTagConvert { - - MpTagConvert INSTANCE = Mappers.getMapper(MpTagConvert.class); - - WxUserTag convert(MpTagUpdateReqVO bean); - - MpTagRespVO convert(WxUserTag bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "tag.id", target = "tagId"), - @Mapping(source = "tag.name", target = "name"), - @Mapping(source = "tag.count", target = "count"), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - }) - MpTagDO convert(WxUserTag tag, MpAccountDO account); - - MpTagRespVO convert(MpTagDO mpTagDO); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java deleted file mode 100644 index 13ed0b34a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.user; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpUserConvert { - - MpUserConvert INSTANCE = Mappers.getMapper(MpUserConvert.class); - - MpUserRespVO convert(MpUserDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings(value = { - @Mapping(source = "openId", target = "openid"), - @Mapping(source = "unionId", target = "unionId"), - @Mapping(source = "headImgUrl", target = "headImageUrl"), - @Mapping(target = "subscribeTime", ignore = true), // 单独转换 - }) - MpUserDO convert(WxMpUser wxMpUser); - - default MpUserDO convert(MpAccountDO account, WxMpUser wxMpUser) { - MpUserDO user = convert(wxMpUser); - user.setSubscribeStatus(wxMpUser.getSubscribe() ? CommonStatusEnum.ENABLE.getStatus() - : CommonStatusEnum.DISABLE.getStatus()); - user.setSubscribeTime(LocalDateTimeUtil.of(wxMpUser.getSubscribeTime() * 1000L)); - if (account != null) { - user.setAccountId(account.getId()); - user.setAppId(account.getAppId()); - } - return user; - } - - default List convertList(MpAccountDO account, List wxUsers) { - return CollectionUtils.convertList(wxUsers, wxUser -> convert(account, wxUser)); - } - - MpUserDO convert(MpUserUpdateReqVO bean); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java deleted file mode 100644 index eddf87ba0..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.account; - -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 公众号账号 DO - * - * @author 芋道源码 - */ -@TableName("mp_account") -@KeySequence("mp_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpAccountDO extends TenantBaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 公众号名称 - */ - private String name; - /** - * 公众号账号 - */ - private String account; - /** - * 公众号 appid - */ - private String appId; - /** - * 公众号密钥 - */ - private String appSecret; - /** - * 公众号token - */ - private String token; - /** - * 消息加解密密钥 - */ - private String aesKey; - /** - * 二维码图片 URL - */ - private String qrCodeUrl; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java deleted file mode 100644 index 735235e31..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.material; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; -import me.chanjar.weixin.common.api.WxConsts; - -/** - * 公众号素材 DO - * - * 1. 临时素材 - * 2. 永久素材 - * - * @author 芋道源码 - */ -@TableName("mp_material") -@KeySequence("mp_material_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpMaterialDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 公众号素材 id - */ - private String mediaId; - /** - * 文件类型 - * - * 枚举 {@link WxConsts.MediaFileType} - */ - private String type; - /** - * 是否永久 - * - * true - 永久素材 - * false - 临时素材 - */ - private Boolean permanent; - /** - * 文件服务器的 URL - */ - private String url; - - /** - * 名字 - * - * 永久素材:非空 - * 临时素材:可能为空。 - * 1. 为空的情况:粉丝主动发送的图片、语音等 - * 2. 非空的情况:主动发送给粉丝的图片、语音等 - */ - private String name; - - /** - * 公众号文件 URL - * - * 只有【永久素材】使用 - */ - private String mpUrl; - - /** - * 视频素材的标题 - * - * 只有【永久素材】使用 - */ - private String title; - /** - * 视频素材的描述 - * - * 只有【永久素材】使用 - */ - private String introduction; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java deleted file mode 100644 index 2e6aa73ce..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.menu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxConsts.MenuButtonType; - -import java.util.List; - -/** - * 公众号菜单 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_menu", autoResultMap = true) -@KeySequence("mp_menu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMenuDO extends BaseDO { - - /** - * 编号 - 顶级菜单 - */ - public static final Long ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标识 - * - * 支持多 DB 类型时,无法直接使用 key + @TableField("menuKey") 来实现转换,原因是 "menuKey" AS key 而存在报错 - */ - private String menuKey; - /** - * 父菜单编号 - */ - private Long parentId; - - // ========== 按钮操作 ========== - - /** - * 按钮类型 - * - * 枚举 {@link MenuButtonType} - */ - private String type; - - /** - * 网页链接 - * - * 粉丝点击菜单可打开链接,不超过 1024 字节 - * - * 类型为 {@link WxConsts.XmlMsgType} 的 VIEW、MINIPROGRAM - */ - private String url; - - /** - * 小程序的 appId - * - * 类型为 {@link MenuButtonType} 的 MINIPROGRAM - */ - private String miniProgramAppId; - /** - * 小程序的页面路径 - * - * 类型为 {@link MenuButtonType} 的 MINIPROGRAM - */ - private String miniProgramPagePath; - - /** - * 跳转图文的媒体编号 - */ - private String articleId; - - // ========== 消息内容 ========== - - /** - * 消息类型 - * - * 当 {@link #type} 为 CLICK、SCANCODE_WAITMSG - * - * 枚举 {@link WxConsts.XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC - */ - private String replyMessageType; - - /** - * 回复的消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String replyContent; - - /** - * 回复的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String replyMediaId; - /** - * 回复的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String replyMediaUrl; - - /** - * 回复的标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String replyTitle; - /** - * 回复的描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String replyDescription; - - /** - * 回复的缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String replyThumbMediaId; - /** - * 回复的缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String replyThumbMediaUrl; - - /** - * 回复的图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List replyArticles; - - /** - * 回复的音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String replyMusicUrl; - /** - * 回复的高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String replyHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java deleted file mode 100644 index 52f4539a4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.message; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxConsts.XmlMsgType; - -import java.util.List; -import java.util.Set; - -/** - * 公众号消息自动回复 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_auto_reply", autoResultMap = true) -@KeySequence("mp_auto_reply_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyDO extends BaseDO { - - public static Set REQUEST_MESSAGE_TYPE = SetUtils.asSet(WxConsts.XmlMsgType.TEXT, WxConsts.XmlMsgType.IMAGE, - WxConsts.XmlMsgType.VOICE, WxConsts.XmlMsgType.VIDEO, WxConsts.XmlMsgType.SHORTVIDEO, - WxConsts.XmlMsgType.LOCATION, WxConsts.XmlMsgType.LINK); - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 回复类型 - * - * 枚举 {@link MpAutoReplyTypeEnum} - */ - private Integer type; - - // ==================== 请求消息 ==================== - - /** - * 请求的关键字 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#KEYWORD} - */ - private String requestKeyword; - /** - * 请求的关键字的匹配 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#KEYWORD} - * - * 枚举 {@link MpAutoReplyMatchEnum} - */ - private Integer requestMatch; - - /** - * 请求的消息类型 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#MESSAGE} - * - * 枚举 {@link XmlMsgType} 中的 {@link #REQUEST_MESSAGE_TYPE} - */ - private String requestMessageType; - - // ==================== 响应消息 ==================== - - /** - * 回复的消息类型 - * - * 枚举 {@link XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS - */ - private String responseMessageType; - - /** - * 回复的消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String responseContent; - - /** - * 回复的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String responseMediaId; - /** - * 回复的媒体 URL - */ - private String responseMediaUrl; - - /** - * 回复的标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String responseTitle; - /** - * 回复的描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String responseDescription; - - /** - * 回复的缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String responseThumbMediaId; - /** - * 回复的缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String responseThumbMediaUrl; - - /** - * 回复的图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List responseArticles; - - /** - * 回复的音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String responseMusicUrl; - /** - * 回复的高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String responseHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java deleted file mode 100644 index cb1401091..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java +++ /dev/null @@ -1,255 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.message; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.enums.message.MpMessageSendFromEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.builder.kefu.NewsBuilder; - -import javax.validation.constraints.NotEmpty; -import java.io.Serializable; -import java.util.List; - -/** - * 公众号消息 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_message", autoResultMap = true) -@KeySequence("mp_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMessageDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 微信公众号消息 id - */ - private Long msgId; - /** - * 公众号账号的 ID - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appid - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - /** - * 公众号粉丝的编号 - * - * 关联 {@link MpUserDO#getId()} - */ - private Long userId; - /** - * 公众号粉丝标志 - * - * 冗余 {@link MpUserDO#getOpenid()} - */ - private String openid; - - /** - * 消息类型 - * - * 枚举 {@link WxConsts.XmlMsgType} - */ - private String type; - /** - * 消息来源 - * - * 枚举 {@link MpMessageSendFromEnum} - */ - private Integer sendFrom; - - // ========= 普通消息内容 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html - - /** - * 消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String content; - - /** - * 媒体文件的编号 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String mediaId; - /** - * 媒体文件的 URL - */ - private String mediaUrl; - /** - * 语音识别后文本 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VOICE - */ - private String recognition; - /** - * 语音格式,如 amr,speex 等 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VOICE - */ - private String format; - /** - * 标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC、LINK - */ - private String title; - /** - * 描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC - */ - private String description; - - /** - * 缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String thumbMediaId; - /** - * 缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String thumbMediaUrl; - - /** - * 点击图文消息跳转链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LINK - */ - private String url; - - /** - * 地理位置维度 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double locationX; - /** - * 地理位置经度 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double locationY; - /** - * 地图缩放大小 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double scale; - /** - * 详细地址 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - * - * 例如说杨浦区黄兴路 221-4 号临 - */ - private String label; - - /** - * 图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = ArticleTypeHandler.class) - private List
articles; - - /** - * 音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String musicUrl; - /** - * 高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String hqMusicUrl; - - // ========= 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html - - /** - * 事件类型 - * - * 枚举 {@link WxConsts.EventType} - */ - private String event; - /** - * 事件 Key - * - * 1. {@link WxConsts.EventType} 的 SCAN:qrscene_ 为前缀,后面为二维码的参数值 - * 2. {@link WxConsts.EventType} 的 CLICK:与自定义菜单接口中 KEY 值对应 - */ - private String eventKey; - - /** - * 文章 - */ - @Data - public static class Article implements Serializable { - - /** - * 图文消息标题 - */ - @NotEmpty(message = "图文消息标题不能为空", groups = NewsBuilder.class) - private String title; - /** - * 图文消息描述 - */ - @NotEmpty(message = "图文消息描述不能为空", groups = NewsBuilder.class) - private String description; - /** - * 图片链接 - * - * 支持 JPG、PNG 格式,较好的效果为大图 360*200,小图 200*200 - */ - @NotEmpty(message = "图片链接不能为空", groups = NewsBuilder.class) - private String picUrl; - /** - * 点击图文消息跳转链接 - */ - @NotEmpty(message = "点击图文消息跳转链接不能为空", groups = NewsBuilder.class) - private String url; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class ArticleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List
parse(String json) { - return JsonUtils.parseArray(json, Article.class); - } - - @Override - protected String toJson(List
obj) { - return JsonUtils.toJsonString(obj); - } - - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java deleted file mode 100644 index 8a5b9f6eb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.tag; - -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import lombok.*; - -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; - -/** - * 公众号标签 DO - * - * @author 芋道源码 - */ -@TableName("mp_tag") -@KeySequence("mp_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpTagDO extends BaseDO { - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Long id; - /** - * 公众号标签 id - */ - private Long tagId; - /** - * 标签名 - */ - private String name; - /** - * 此标签下粉丝数 - * - * 冗余:{@link WxUserTag#getCount()} 字段,需要管理员点击【同步】后,更新该字段 - */ - private Integer count; - - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java deleted file mode 100644 index 0eb6a19bc..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.user; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 微信公众号粉丝 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_user", autoResultMap = true) -@KeySequence("mp_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpUserDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 粉丝标识 - */ - private String openid; - - /** - * 微信生态唯一标识 - */ - private String unionid; - /** - * 微信生态唯一标识 - */ - private String unionId; - /** - * 关注状态 - * - * 枚举 {@link CommonStatusEnum} - * 1. 开启 - 已关注 - * 2. 禁用 - 取消关注 - */ - private Integer subscribeStatus; - /** - * 关注时间 - */ - private LocalDateTime subscribeTime; - /** - * 取消关注时间 - */ - private LocalDateTime unsubscribeTime; - /** - * 昵称 - * - * 注意,2021-12-27 公众号接口不再返回头像和昵称,只能通过微信公众号的网页登录获取 - */ - private String nickname; - /** - * 头像地址 - * - * 注意,2021-12-27 公众号接口不再返回头像和昵称,只能通过微信公众号的网页登录获取 - */ - private String headImageUrl; - /** - * 语言 - */ - private String language; - /** - * 国家 - */ - private String country; - /** - * 省份 - */ - private String province; - /** - * 城市 - */ - private String city; - /** - * 备注 - */ - private String remark; - /** - * 标签编号数组 - * - * 注意,对应的是 {@link MpTagDO#getTagId()} 字段 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List tagIds; - - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java deleted file mode 100644 index 30c54fd51..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; - -@Mapper -public interface MpAccountMapper extends BaseMapperX { - - default PageResult selectPage(MpAccountPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MpAccountDO::getName, reqVO.getName()) - .likeIfPresent(MpAccountDO::getAccount, reqVO.getAccount()) - .likeIfPresent(MpAccountDO::getAppId, reqVO.getAppId()) - .orderByDesc(MpAccountDO::getId)); - } - - default MpAccountDO selectByAppId(String appId) { - return selectOne(MpAccountDO::getAppId, appId); - } - - @Select("SELECT COUNT(*) FROM mp_account WHERE update_time > #{maxUpdateTime}") - Long selectCountByUpdateTimeGt(LocalDateTime maxUpdateTime); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java deleted file mode 100644 index ca3c6b3a9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface MpMaterialMapper extends BaseMapperX { - - default MpMaterialDO selectByAccountIdAndMediaId(Long accountId, String mediaId) { - return selectOne(MpMaterialDO::getAccountId, accountId, - MpMaterialDO::getMediaId, mediaId); - } - - default PageResult selectPage(MpMaterialPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(MpMaterialDO::getAccountId, pageReqVO.getAccountId()) - .eqIfPresent(MpMaterialDO::getPermanent, pageReqVO.getPermanent()) - .eqIfPresent(MpMaterialDO::getType, pageReqVO.getType()) - .orderByDesc(MpMaterialDO::getId)); - } - - default List selectListByMediaId(Collection mediaIds) { - return selectList(MpMaterialDO::getMediaId, mediaIds); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java deleted file mode 100644 index fccd7f2d9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.menu; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpMenuMapper extends BaseMapperX { - - default MpMenuDO selectByAppIdAndMenuKey(String appId, String menuKey) { - return selectOne(MpMenuDO::getAppId, appId, - MpMenuDO::getMenuKey, menuKey); - } - - default List selectListByAccountId(Long accountId) { - return selectList(MpMenuDO::getAccountId, accountId); - } - - default void deleteByAccountId(Long accountId) { - delete(new LambdaQueryWrapperX().eq(MpMenuDO::getAccountId, accountId)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java deleted file mode 100644 index c8260e8c7..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpAutoReplyMapper extends BaseMapperX { - - default PageResult selectPage(MpMessagePageReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, pageVO.getAccountId()) - .eqIfPresent(MpAutoReplyDO::getType, pageVO.getType())); - } - - default List selectListByAppIdAndKeywordAll(String appId, String requestKeyword) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.ALL.getMatch()) - .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } - - default List selectListByAppIdAndKeywordLike(String appId, String requestKeyword) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.LIKE.getMatch()) - .like(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } - - default List selectListByAppIdAndMessage(String appId, String requestMessageType) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) - .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); - } - - default List selectListByAppIdAndSubscribe(String appId) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.SUBSCRIBE.getType())); - } - - default MpAutoReplyDO selectByAccountIdAndSubscribe(Long accountId) { - return selectOne(MpAutoReplyDO::getAccountId, accountId, - MpAutoReplyDO::getType, MpAutoReplyTypeEnum.SUBSCRIBE.getType()); - } - - default MpAutoReplyDO selectByAccountIdAndMessage(Long accountId, String requestMessageType) { - return selectOne(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, accountId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) - .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); - } - - default MpAutoReplyDO selectByAccountIdAndKeyword(Long accountId, String requestKeyword) { - return selectOne(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, accountId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java deleted file mode 100644 index 72ba56627..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface MpMessageMapper extends BaseMapperX { - - default PageResult selectPage(MpMessagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MpMessageDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(MpMessageDO::getType, reqVO.getType()) - .eqIfPresent(MpMessageDO::getOpenid, reqVO.getOpenid()) - .betweenIfPresent(MpMessageDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MpMessageDO::getId)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java deleted file mode 100644 index 760f53aa1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpTagMapper extends BaseMapperX { - - default PageResult selectPage(MpTagPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MpTagDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(MpTagDO::getName, reqVO.getName()) - .orderByDesc(MpTagDO::getId)); - } - - default List selectListByAccountId(Long accountId) { - return selectList(MpTagDO::getAccountId, accountId); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java deleted file mode 100644 index bd13f925a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpUserMapper extends BaseMapperX { - - default PageResult selectPage(MpUserPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MpUserDO::getOpenid, reqVO.getOpenid()) - .likeIfPresent(MpUserDO::getNickname, reqVO.getNickname()) - .eqIfPresent(MpUserDO::getAccountId, reqVO.getAccountId()) - .orderByDesc(MpUserDO::getId)); - } - - default MpUserDO selectByAppIdAndOpenid(String appId, String openid) { - return selectOne(MpUserDO::getAppId, appId, - MpUserDO::getOpenid, openid); - } - - default List selectListByAppIdAndOpenid(String appId, List openids) { - return selectList(new LambdaQueryWrapperX() - .eq(MpUserDO::getAppId, appId) - .in(MpUserDO::getOpenid, openids)); - - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java deleted file mode 100644 index c90866066..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.config; - -import cn.iocoder.yudao.module.mp.framework.mp.core.DefaultMpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.handler.menu.MenuHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageReceiveHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageAutoReplyHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.KfSessionHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.NullHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.ScanHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.StoreCheckNotifyHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.LocationHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.SubscribeHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.UnsubscribeHandler; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.core.StringRedisTemplate; - -/** - * 微信公众号的配置类 - * - * @author 芋道源码 - */ -@Configuration -public class MpConfiguration { - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public RedisTemplateWxRedisOps redisTemplateWxRedisOps(StringRedisTemplate stringRedisTemplate) { - return new RedisTemplateWxRedisOps(stringRedisTemplate); - } - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public MpServiceFactory mpServiceFactory(RedisTemplateWxRedisOps redisTemplateWxRedisOps, - WxMpProperties wxMpProperties, - MessageReceiveHandler messageReceiveHandler, - KfSessionHandler kfSessionHandler, - StoreCheckNotifyHandler storeCheckNotifyHandler, - MenuHandler menuHandler, - NullHandler nullHandler, - SubscribeHandler subscribeHandler, - UnsubscribeHandler unsubscribeHandler, - LocationHandler locationHandler, - ScanHandler scanHandler, - MessageAutoReplyHandler messageAutoReplyHandler) { - return new DefaultMpServiceFactory(redisTemplateWxRedisOps, wxMpProperties, - messageReceiveHandler, kfSessionHandler, storeCheckNotifyHandler, menuHandler, - nullHandler, subscribeHandler, unsubscribeHandler, locationHandler, scanHandler, messageAutoReplyHandler); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java deleted file mode 100644 index 414f73aa8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core; - -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.handler.menu.MenuHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageReceiveHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageAutoReplyHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.KfSessionHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.NullHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.ScanHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.StoreCheckNotifyHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.LocationHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.SubscribeHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.UnsubscribeHandler; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import com.google.common.collect.Maps; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; -import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; -import me.chanjar.weixin.mp.constant.WxMpEventConstants; - -import java.util.List; -import java.util.Map; - -/** - * 默认的 {@link MpServiceFactory} 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@RequiredArgsConstructor -public class DefaultMpServiceFactory implements MpServiceFactory { - - /** - * 微信 appId 与 WxMpService 的映射 - */ - private volatile Map appId2MpServices; - /** - * 公众号账号 id 与 WxMpService 的映射 - */ - private volatile Map id2MpServices; - /** - * 微信 appId 与 WxMpMessageRouter 的映射 - */ - private volatile Map mpMessageRouters; - - private final RedisTemplateWxRedisOps redisTemplateWxRedisOps; - private final WxMpProperties mpProperties; - - // ========== 各种 Handler ========== - - private final MessageReceiveHandler messageReceiveHandler; - private final KfSessionHandler kfSessionHandler; - private final StoreCheckNotifyHandler storeCheckNotifyHandler; - private final MenuHandler menuHandler; - private final NullHandler nullHandler; - private final SubscribeHandler subscribeHandler; - private final UnsubscribeHandler unsubscribeHandler; - private final LocationHandler locationHandler; - private final ScanHandler scanHandler; - private final MessageAutoReplyHandler messageAutoReplyHandler; - - @Override - public void init(List list) { - Map appId2MpServices = Maps.newHashMap(); - Map id2MpServices = Maps.newHashMap(); - Map mpMessageRouters = Maps.newHashMap(); - // 处理 list - list.forEach(account -> { - // 构建 WxMpService 对象 - WxMpService mpService = buildMpService(account); - appId2MpServices.put(account.getAppId(), mpService); - id2MpServices.put(account.getId(), mpService); - // 构建 WxMpMessageRouter 对象 - WxMpMessageRouter mpMessageRouter = buildMpMessageRouter(mpService); - mpMessageRouters.put(account.getAppId(), mpMessageRouter); - }); - - // 设置到缓存 - this.appId2MpServices = appId2MpServices; - this.id2MpServices = id2MpServices; - this.mpMessageRouters = mpMessageRouters; - } - - @Override - public WxMpService getMpService(Long id) { - return id2MpServices.get(id); - } - - @Override - public WxMpService getMpService(String appId) { - return appId2MpServices.get(appId); - } - - @Override - public WxMpMessageRouter getMpMessageRouter(String appId) { - return mpMessageRouters.get(appId); - } - - private WxMpService buildMpService(MpAccountDO account) { - // 第一步,创建 WxMpRedisConfigImpl 对象 - WxMpRedisConfigImpl configStorage = new WxMpRedisConfigImpl( - redisTemplateWxRedisOps, mpProperties.getConfigStorage().getKeyPrefix()); - configStorage.setAppId(account.getAppId()); - configStorage.setSecret(account.getAppSecret()); - configStorage.setToken(account.getToken()); - configStorage.setAesKey(account.getAesKey()); - - // 第二步,创建 WxMpService 对象 - WxMpService service = new WxMpServiceImpl(); - service.setWxMpConfigStorage(configStorage); - return service; - } - - private WxMpMessageRouter buildMpMessageRouter(WxMpService mpService) { - WxMpMessageRouter router = new WxMpMessageRouter(mpService); - // 记录所有事件的日志(异步执行) - router.rule().handler(messageReceiveHandler).next(); - - // 接收客服会话管理事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION) - .handler(kfSessionHandler).end(); - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION) - .handler(kfSessionHandler) - .end(); - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION) - .handler(kfSessionHandler).end(); - - // 门店审核事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.POI_CHECK_NOTIFY) - .handler(storeCheckNotifyHandler).end(); - - // 自定义菜单事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.MenuButtonType.CLICK).handler(menuHandler).end(); - - // 点击菜单连接事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.MenuButtonType.VIEW).handler(nullHandler).end(); - - // 关注事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.SUBSCRIBE).handler(subscribeHandler) - .end(); - - // 取消关注事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.UNSUBSCRIBE) - .handler(unsubscribeHandler).end(); - - // 上报地理位置事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.LOCATION).handler(locationHandler) - .end(); - - // 接收地理位置消息 - router.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION) - .handler(locationHandler).end(); - - // 扫码事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.SCAN).handler(scanHandler).end(); - - // 默认 - router.rule().async(false).handler(messageAutoReplyHandler).end(); - return router; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java deleted file mode 100644 index ce017ff64..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; - -import java.util.List; - -/** - * {@link WxMpService} 工厂接口 - * - * @author 芋道源码 - */ -public interface MpServiceFactory { - - /** - * 基于微信公众号的账号,初始化对应的 WxMpService 与 WxMpMessageRouter 实例 - * - * @param list 公众号的账号列表 - */ - void init(List list); - - /** - * 获得 id 对应的 WxMpService 实例 - * - * @param id 微信公众号的编号 - * @return WxMpService 实例 - */ - WxMpService getMpService(Long id); - - default WxMpService getRequiredMpService(Long id) { - WxMpService wxMpService = getMpService(id); - Assert.notNull(wxMpService, "找到对应 id({}) 的 WxMpService,请核实!", id); - return wxMpService; - } - - /** - * 获得 appId 对应的 WxMpService 实例 - * - * @param appId 微信公众号 appId - * @return WxMpService 实例 - */ - WxMpService getMpService(String appId); - - default WxMpService getRequiredMpService(String appId) { - WxMpService wxMpService = getMpService(appId); - Assert.notNull(wxMpService, "找到对应 appId({}) 的 WxMpService,请核实!", appId); - return wxMpService; - } - - /** - * 获得 appId 对应的 WxMpMessageRouter 实例 - * - * @param appId 微信公众号 appId - * @return WxMpMessageRouter 实例 - */ - WxMpMessageRouter getMpMessageRouter(String appId); - - default WxMpMessageRouter getRequiredMpMessageRouter(String appId) { - WxMpMessageRouter wxMpMessageRouter = getMpMessageRouter(appId); - Assert.notNull(wxMpMessageRouter, "找到对应 appId({}) 的 WxMpMessageRouter,请核实!", appId); - return wxMpMessageRouter; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java deleted file mode 100644 index e5c45c531..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package cn.iocoder.yudao.module.mp.framework.mp.core.context; - -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenHandleMessageReqVO; -import com.alibaba.ttl.TransmittableThreadLocal; -import lombok.experimental.UtilityClass; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; - -/** - * 微信上下文 Context - * - * 目的:解决微信多公众号的问题,在 {@link WxMpMessageHandler} 实现类中,可以通过 {@link #getAppId()} 获取到当前的 appId - * - * @see cn.iocoder.yudao.module.mp.controller.admin.open.MpOpenController#handleMessage(String, String, MpOpenHandleMessageReqVO) - * - * @author 芋道源码 - */ -public class MpContextHolder { - - /** - * 微信公众号的 appId 上下文 - */ - private static final ThreadLocal APPID = new TransmittableThreadLocal<>(); - - public static void setAppId(String appId) { - APPID.set(appId); - } - - public static String getAppId() { - return APPID.get(); - } - - public static void clear() { - APPID.remove(); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java deleted file mode 100644 index 880d8c8f5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core.util; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; - -import javax.validation.Validator; - -/** - * 公众号工具类 - * - * @author 芋道源码 - */ -@Slf4j -public class MpUtils { - - /** - * 校验消息的格式是否符合要求 - * - * @param type 类型 - * @param message 消息 - */ - public static void validateMessage(Validator validator, String type, Object message) { - // 获得对应的校验 group - Class group; - switch (type) { - case WxConsts.XmlMsgType.TEXT: - group = TextMessageGroup.class; - break; - case WxConsts.XmlMsgType.IMAGE: - group = ImageMessageGroup.class; - break; - case WxConsts.XmlMsgType.VOICE: - group = VoiceMessageGroup.class; - break; - case WxConsts.XmlMsgType.VIDEO: - group = VideoMessageGroup.class; - break; - case WxConsts.XmlMsgType.NEWS: - group = NewsMessageGroup.class; - break; - case WxConsts.XmlMsgType.MUSIC: - group = MusicMessageGroup.class; - break; - default: - log.error("[validateMessage][未知的消息类型({})]", message); - throw new IllegalArgumentException("不支持的消息类型:" + type); - } - // 执行校验 - ValidationUtils.validate(validator, message, group); - } - - public static void validateButton(Validator validator, String type, String messageType, Object button) { - if (StrUtil.isBlank(type)) { - return; - } - // 获得对应的校验 group - Class group; - switch (type) { - case WxConsts.MenuButtonType.CLICK: - group = ClickButtonGroup.class; - validateMessage(validator, messageType, button); // 需要额外校验回复的消息格式 - break; - case WxConsts.MenuButtonType.VIEW: - group = ViewButtonGroup.class; - break; - case WxConsts.MenuButtonType.MINIPROGRAM: - group = MiniProgramButtonGroup.class; - break; - case WxConsts.MenuButtonType.SCANCODE_WAITMSG: - group = ScanCodeWaitMsgButtonGroup.class; - validateMessage(validator, messageType, button); // 需要额外校验回复的消息格式 - break; - case "article_" + WxConsts.MenuButtonType.VIEW_LIMITED: - group = ViewLimitedButtonGroup.class; - break; - case WxConsts.MenuButtonType.SCANCODE_PUSH: // 不用校验,直接 return 即可 - case WxConsts.MenuButtonType.PIC_SYSPHOTO: - case WxConsts.MenuButtonType.PIC_PHOTO_OR_ALBUM: - case WxConsts.MenuButtonType.PIC_WEIXIN: - case WxConsts.MenuButtonType.LOCATION_SELECT: - return; - default: - log.error("[validateButton][未知的按钮({})]", button); - throw new IllegalArgumentException("不支持的按钮类型:" + type); - } - // 执行校验 - ValidationUtils.validate(validator, button, group); - } - - /** - * 根据消息类型,获得对应的媒体文件类型 - * - * 注意,不会返回 WxConsts.MediaFileType.THUMB,因为该类型会有明确标注 - * - * @param messageType 消息类型 {@link WxConsts.XmlMsgType} - * @return 媒体文件类型 {@link WxConsts.MediaFileType} - */ - public static String getMediaFileType(String messageType) { - switch (messageType) { - case WxConsts.XmlMsgType.IMAGE: - return WxConsts.MediaFileType.IMAGE; - case WxConsts.XmlMsgType.VOICE: - return WxConsts.MediaFileType.VOICE; - case WxConsts.XmlMsgType.VIDEO: - return WxConsts.MediaFileType.VIDEO; - default: - return WxConsts.MediaFileType.FILE; - } - } - - /** - * Text 类型的消息,参数校验 Group - */ - public interface TextMessageGroup {} - - /** - * Image 类型的消息,参数校验 Group - */ - public interface ImageMessageGroup {} - - /** - * Voice 类型的消息,参数校验 Group - */ - public interface VoiceMessageGroup {} - - /** - * Video 类型的消息,参数校验 Group - */ - public interface VideoMessageGroup {} - - /** - * News 类型的消息,参数校验 Group - */ - public interface NewsMessageGroup {} - - /** - * Music 类型的消息,参数校验 Group - */ - public interface MusicMessageGroup {} - - /** - * Click 类型的按钮,参数校验 Group - */ - public interface ClickButtonGroup {} - - /** - * View 类型的按钮,参数校验 Group - */ - public interface ViewButtonGroup {} - - /** - * MiniProgram 类型的按钮,参数校验 Group - */ - public interface MiniProgramButtonGroup {} - - /** - * SCANCODE_WAITMSG 类型的按钮,参数校验 Group - */ - public interface ScanCodeWaitMsgButtonGroup {} - - /** - * VIEW_LIMITED 类型的按钮,参数校验 Group - */ - public interface ViewLimitedButtonGroup {} -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java deleted file mode 100644 index 112ecdd26..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 mp 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.mp.framework; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/config/RpcConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index d4e85a278..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.rpc.config; - -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = FileApi.class) -public class RpcConfiguration { -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/package-info.java deleted file mode 100644 index 147223f74..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.mp.framework.rpc; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/config/SecurityConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 016c2ffd5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.system.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * System 模块的 Security 配置 - */ -@Configuration(proxyBeanMethods = false, value = "systemSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("systemAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案 - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/core/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/core/package-info.java deleted file mode 100644 index dad146082..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.mp.framework.security.core; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java deleted file mode 100644 index 598718088..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * mp 模块,我们放微信微信公众号。 - * 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - * - * 1. Controller URL:以 /mp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 mp_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.mp; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java deleted file mode 100644 index e122c6a98..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; - -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.ACCOUNT_NOT_EXISTS; - -/** - * 公众号账号 Service 接口 - * - * @author 芋道源码 - */ -public interface MpAccountService { - - /** - * 初始化缓存 - */ - void initLocalCache(); - - /** - * 创建公众号账号 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAccount(@Valid MpAccountCreateReqVO createReqVO); - - /** - * 更新公众号账号 - * - * @param updateReqVO 更新信息 - */ - void updateAccount(@Valid MpAccountUpdateReqVO updateReqVO); - - /** - * 删除公众号账号 - * - * @param id 编号 - */ - void deleteAccount(Long id); - - /** - * 获得公众号账号 - * - * @param id 编号 - * @return 公众号账号 - */ - MpAccountDO getAccount(Long id); - - /** - * 获得公众号账号。若不存在,则抛出业务异常 - * - * @param id 编号 - * @return 公众号账号 - */ - default MpAccountDO getRequiredAccount(Long id) { - MpAccountDO account = getAccount(id); - if (account == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - return account; - } - - /** - * 从缓存中,获得公众号账号 - * - * @param appId 微信公众号 appId - * @return 公众号账号 - */ - MpAccountDO getAccountFromCache(String appId); - - /** - * 获得公众号账号分页 - * - * @param pageReqVO 分页查询 - * @return 公众号账号分页 - */ - PageResult getAccountPage(MpAccountPageReqVO pageReqVO); - - /** - * 获得公众号账号列表 - * - * @return 公众号账号列表 - */ - List getAccountList(); - - /** - * 生成公众号账号的二维码 - * - * @param id 编号 - */ - void generateAccountQrCode(Long id); - - /** - * 清空公众号账号的 API 配额 - * - * 参考文档:接口调用频次限制说明 - * - * @param id 编号 - */ - void clearAccountQuota(Long id); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java deleted file mode 100644 index a8f9b78d1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.account; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.mysql.account.MpAccountMapper; -import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import com.google.common.annotations.VisibleForTesting; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS; - -/** - * 公众号账号 Service 实现类 - * - * @author fengdan - */ -@Slf4j -@Service -@Validated -public class MpAccountServiceImpl implements MpAccountService { - - /** - * 账号缓存 - * key:账号编号 {@link MpAccountDO#getAppId()} - * - * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 - */ - @Getter - private volatile Map accountCache; - - @Resource - private MpAccountMapper mpAccountMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - @PostConstruct - public void initLocalCache() { - // 注意:忽略自动多租户,因为要全局初始化缓存 - TenantUtils.executeIgnore(() -> { - // 第一步:查询数据 - List accounts = Collections.emptyList(); - try { - accounts = mpAccountMapper.selectList(); - } catch (Throwable ex) { - if (!ex.getMessage().contains("doesn't exist")) { - throw ex; - } - log.error("[微信公众号 yudao-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]"); - } - log.info("[initLocalCacheIfUpdate][缓存公众号账号,数量为:{}]", accounts.size()); - - // 第二步:构建缓存。创建或更新支付 Client - mpServiceFactory.init(accounts); - accountCache = convertMap(accounts, MpAccountDO::getAppId); - }); - } - - /** - * 通过定时任务轮询,刷新缓存 - * - * 目的:多节点部署时,通过轮询”通知“所有节点,进行刷新 - */ - @Scheduled(initialDelay = 60, fixedRate = 60, timeUnit = TimeUnit.SECONDS) - public void refreshLocalCache() { - // 注意:忽略自动多租户,因为要全局初始化缓存 - TenantUtils.executeIgnore(() -> { - // 情况一:如果缓存里没有数据,则直接刷新缓存 - if (CollUtil.isEmpty(accountCache)) { - initLocalCache(); - return; - } - - // 情况二,如果缓存里数据,则通过 updateTime 判断是否有数据变更,有变更则刷新缓存 - LocalDateTime maxTime = getMaxValue(accountCache.values(), MpAccountDO::getUpdateTime); - if (mpAccountMapper.selectCountByUpdateTimeGt(maxTime) > 0) { - initLocalCache(); - } - }); - } - - @Override - public Long createAccount(MpAccountCreateReqVO createReqVO) { - // 校验 appId 唯一 - validateAppIdUnique(null, createReqVO.getAppId()); - - // 插入 - MpAccountDO account = MpAccountConvert.INSTANCE.convert(createReqVO); - mpAccountMapper.insert(account); - - // 刷新缓存 - initLocalCache(); - return account.getId(); - } - - @Override - public void updateAccount(MpAccountUpdateReqVO updateReqVO) { - // 校验存在 - validateAccountExists(updateReqVO.getId()); - // 校验 appId 唯一 - validateAppIdUnique(updateReqVO.getId(), updateReqVO.getAppId()); - - // 更新 - MpAccountDO updateObj = MpAccountConvert.INSTANCE.convert(updateReqVO); - mpAccountMapper.updateById(updateObj); - - // 刷新缓存 - initLocalCache(); - } - - @Override - public void deleteAccount(Long id) { - // 校验存在 - validateAccountExists(id); - // 删除 - mpAccountMapper.deleteById(id); - - // 刷新缓存 - initLocalCache(); - } - - private MpAccountDO validateAccountExists(Long id) { - MpAccountDO account = mpAccountMapper.selectById(id); - if (account == null) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ACCOUNT_NOT_EXISTS); - } - return account; - } - - @VisibleForTesting - public void validateAppIdUnique(Long id, String appId) { - // 多个租户,appId 是不能重复,否则公众号回调会无法识别 - TenantUtils.executeIgnore(() -> { - MpAccountDO account = mpAccountMapper.selectByAppId(appId); - if (account == null) { - return; - } - // 存在 account 记录的情况下 - if (id == null // 新增时,说明重复 - || ObjUtil.notEqual(id, account.getId())) { // 更新时,如果 id 不一致,说明重复 - throw exception(USER_USERNAME_EXISTS); - } - }); - } - - @Override - public MpAccountDO getAccount(Long id) { - return mpAccountMapper.selectById(id); - } - - @Override - public MpAccountDO getAccountFromCache(String appId) { - return accountCache.get(appId); - } - - @Override - public PageResult getAccountPage(MpAccountPageReqVO pageReqVO) { - return mpAccountMapper.selectPage(pageReqVO); - } - - @Override - public List getAccountList() { - return mpAccountMapper.selectList(); - } - - @Override - public void generateAccountQrCode(Long id) { - // 校验存在 - MpAccountDO account = validateAccountExists(id); - - // 生成二维码 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId()); - String qrCodeUrl; - try { - WxMpQrCodeTicket qrCodeTicket = mpService.getQrcodeService().qrCodeCreateLastTicket("default"); - qrCodeUrl = mpService.getQrcodeService().qrCodePictureUrl(qrCodeTicket.getTicket()); - } catch (WxErrorException e) { - throw exception(ErrorCodeConstants.ACCOUNT_GENERATE_QR_CODE_FAIL, e.getError().getErrorMsg()); - } - - // 保存二维码 - mpAccountMapper.updateById(new MpAccountDO().setId(id).setQrCodeUrl(qrCodeUrl)); - } - - @Override - public void clearAccountQuota(Long id) { - // 校验存在 - MpAccountDO account = validateAccountExists(id); - - // 生成二维码 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId()); - try { - mpService.clearQuota(account.getAppId()); - } catch (WxErrorException e) { - throw exception(ErrorCodeConstants.ACCOUNT_CLEAR_QUOTA_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java deleted file mode 100644 index 039712514..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.menu; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMenuService; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType; - -/** - * 自定义菜单的事件处理器 - * - * 逻辑:粉丝点击菜单时,触发对应的回复 - * - * @author 芋道源码 - */ -@Component -public class MenuHandler implements WxMpMessageHandler { - - @Resource - private MpMenuService mpMenuService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) { - return mpMenuService.reply(MpContextHolder.getAppId(), wxMessage.getEventKey(), wxMessage.getFromUser()); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java deleted file mode 100644 index 30d94a97c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 自动回复消息的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class MessageAutoReplyHandler implements WxMpMessageHandler { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) { - // 只处理指定类型的消息 - if (!MpAutoReplyDO.REQUEST_MESSAGE_TYPE.contains(wxMessage.getMsgType())) { - return null; - } - - // 自动回复 - return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java deleted file mode 100644 index 4e4a4ebf4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.message; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 保存微信消息的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class MessageReceiveHandler implements WxMpMessageHandler { - - @Resource - private MpMessageService mpMessageService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - log.info("[handle][接收到请求消息,内容:{}]", wxMessage); - mpMessageService.receiveMessage(MpContextHolder.getAppId(), wxMessage); - return null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java deleted file mode 100644 index fca7fab9a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 接收客服会话管理的事件处理器 - * - * @author 芋道源码 - */ -@Component -public class KfSessionHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java deleted file mode 100644 index 09b3efbf2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 点击菜单连接的事件处理器 - */ -@Component -public class NullHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java deleted file mode 100644 index 54a6bbc32..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 扫码的事件处理器 - */ -@Component -public class ScanHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map context, - WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java deleted file mode 100644 index 475b8ee97..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 门店审核事件的事件处理器 - */ -@Component -public class StoreCheckNotifyHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java deleted file mode 100644 index 7fd662260..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 本包内的 handler 都是一些不重要的,所以放在 other 其它里 - */ -package cn.iocoder.yudao.module.mp.service.handler.other; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java deleted file mode 100644 index 598ebb91a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 上报地理位置的事件处理器 - * - * 触发操作:打开微信公众号 -> 点击 + 号 -> 选择「语音」 - * - * 逻辑:粉丝上传地理位置时,也可以触发自动回复 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class LocationHandler implements WxMpMessageHandler { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - // 防御性编程:必须是 LOCATION 消息 - if (ObjectUtil.notEqual(wxMessage.getMsgType(), WxConsts.XmlMsgType.LOCATION)) { - return null; - } - log.info("[handle][上报地理位置,纬度({})、经度({})、精度({})", wxMessage.getLatitude(), - wxMessage.getLongitude(), wxMessage.getPrecision()); - - // 自动回复 - return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java deleted file mode 100644 index 5f3c3eacd..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 关注的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class SubscribeHandler implements WxMpMessageHandler { - - @Resource - private MpUserService mpUserService; - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) throws WxErrorException { - // 第一步,从公众号平台,获取粉丝信息 - log.info("[handle][粉丝({}) 关注]", wxMessage.getFromUser()); - WxMpUser wxMpUser = null; - try { - wxMpUser = weixinService.getUserService().userInfo(wxMessage.getFromUser()); - } catch (WxErrorException e) { - log.error("[handle][粉丝({})] 获取粉丝信息失败!", wxMessage.getFromUser(), e); - } - - // 第二步,保存粉丝信息 - mpUserService.saveUser(MpContextHolder.getAppId(), wxMpUser); - - // 第三步,回复关注的欢迎语 - return mpAutoReplyService.replyForSubscribe(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java deleted file mode 100644 index 3bf363506..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 取消关注的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class UnsubscribeHandler implements WxMpMessageHandler { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpUserService mpUserService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, - Map context, WxMpService wxMpService, - WxSessionManager sessionManager) { - log.info("[handle][粉丝({}) 取消关注]", wxMessage.getFromUser()); - mpUserService.updateUserUnsubscribe(MpContextHolder.getAppId(), wxMessage.getFromUser()); - return null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java deleted file mode 100644 index 60e4c07b4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadNewsImageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadPermanentReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadTemporaryReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import me.chanjar.weixin.common.api.WxConsts; - -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -/** - * 公众号素材 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMaterialService { - - /** - * 获得素材的 URL - * - * 该 URL 来自我们自己的文件服务器存储的 URL,不是公众号存储的 URL - * - * @param accountId 公众号账号编号 - * @param mediaId 公众号素材 id - * @param type 文件类型 {@link WxConsts.MediaFileType} - * @return 素材的 URL - */ - String downloadMaterialUrl(Long accountId, String mediaId, String type); - - /** - * 上传临时素材 - * - * @param reqVO 请求 - * @return 素材 - * @throws IOException 文件操作发生异常 - */ - MpMaterialDO uploadTemporaryMaterial(@Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException; - - /** - * 上传永久素材 - * - * @param reqVO 请求 - * @return 素材 - * @throws IOException 文件操作发生异常 - */ - MpMaterialDO uploadPermanentMaterial(@Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException; - - /** - * 上传图文内容中的图片 - * - * @param reqVO 上传请求 - * @return 图片地址 - */ - String uploadNewsImage(MpMaterialUploadNewsImageReqVO reqVO) throws IOException; - - /** - * 获得素材分页 - * - * @param pageReqVO 分页请求 - * @return 素材分页 - */ - PageResult getMaterialPage(MpMaterialPageReqVO pageReqVO); - - /** - * 获得素材列表 - * - * @param mediaIds 素材 mediaId 列表 - * @return 素材列表 - */ - List getMaterialListByMediaId(Collection mediaIds); - - /** - * 删除素材 - * - * @param id 编号 - */ - void deleteMaterial(Long id); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java deleted file mode 100644 index 9e48a8f97..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java +++ /dev/null @@ -1,224 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.material; - -import cn.hutool.core.io.FileTypeUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadNewsImageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadPermanentReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadTemporaryReqVO; -import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.dal.mysql.material.MpMaterialMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号素材 Service 接口 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMaterialServiceImpl implements MpMaterialService { - - @Resource - private MpMaterialMapper mpMaterialMapper; - - @Resource - private FileApi fileApi; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - public String downloadMaterialUrl(Long accountId, String mediaId, String type) { - // 第一步,直接从数据库查询。如果已经下载,直接返回 - MpMaterialDO material = mpMaterialMapper.selectByAccountIdAndMediaId(accountId, mediaId); - if (material != null) { - return material.getUrl(); - } - - // 第二步,尝试从临时素材中下载 - String url = downloadMedia(accountId, mediaId); - if (url == null) { - return null; - } - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - material = MpMaterialConvert.INSTANCE.convert(mediaId, type, url, account, null) - .setPermanent(false); - mpMaterialMapper.insert(material); - - // 不考虑下载永久素材,因为上传的时候已经保存 - return url; - } - - @Override - public MpMaterialDO uploadTemporaryMaterial(MpMaterialUploadTemporaryReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - // 第一步,上传到公众号 - File file = null; - WxMediaUploadResult result; - String mediaId; - String url; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - result = mpService.getMaterialService().mediaUpload(reqVO.getType(), file); - // 上传到文件服务 - mediaId = ObjUtil.defaultIfNull(result.getMediaId(), result.getThumbMediaId()); - url = uploadFile(mediaId, file); - } catch (WxErrorException e) { - throw exception(MATERIAL_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - - // 第二步,存储到数据库 - MpAccountDO account = mpAccountService.getRequiredAccount(reqVO.getAccountId()); - MpMaterialDO material = MpMaterialConvert.INSTANCE.convert(mediaId, reqVO.getType(), url, account, - reqVO.getFile().getName()).setPermanent(false); - mpMaterialMapper.insert(material); - return material; - } - - @Override - public MpMaterialDO uploadPermanentMaterial(MpMaterialUploadPermanentReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - // 第一步,上传到公众号 - String name = StrUtil.blankToDefault(reqVO.getName(), reqVO.getFile().getName()); - File file = null; - WxMpMaterialUploadResult result; - String mediaId; - String url; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - result = mpService.getMaterialService().materialFileUpload(reqVO.getType(), - MpMaterialConvert.INSTANCE.convert(name, file, reqVO.getTitle(), reqVO.getIntroduction())); - // 上传到文件服务 - mediaId = ObjUtil.defaultIfNull(result.getMediaId(), result.getMediaId()); - url = uploadFile(mediaId, file); - } catch (WxErrorException e) { - throw exception(MATERIAL_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - - // 第二步,存储到数据库 - MpAccountDO account = mpAccountService.getRequiredAccount(reqVO.getAccountId()); - MpMaterialDO material = MpMaterialConvert.INSTANCE.convert(mediaId, reqVO.getType(), url, account, - name, reqVO.getTitle(), reqVO.getIntroduction(), result.getUrl()).setPermanent(true); - mpMaterialMapper.insert(material); - return material; - } - - @Override - public String uploadNewsImage(MpMaterialUploadNewsImageReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - File file = null; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - return mpService.getMaterialService().mediaImgUpload(file).getUrl(); - } catch (WxErrorException e) { - throw exception(MATERIAL_IMAGE_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - } - - @Override - public PageResult getMaterialPage(MpMaterialPageReqVO pageReqVO) { - return mpMaterialMapper.selectPage(pageReqVO); - } - - @Override - public List getMaterialListByMediaId(Collection mediaIds) { - return mpMaterialMapper.selectListByMediaId(mediaIds); - } - - @Override - public void deleteMaterial(Long id) { - MpMaterialDO material = mpMaterialMapper.selectById(id); - if (material == null) { - throw exception(MATERIAL_NOT_EXISTS); - } - - // 第一步,从公众号删除 - if (material.getPermanent()) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(material.getAppId()); - try { - mpService.getMaterialService().materialDelete(material.getMediaId()); - } catch (WxErrorException e) { - throw exception(MATERIAL_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - - // 第二步,从数据库中删除 - mpMaterialMapper.deleteById(id); - } - - /** - * 下载微信媒体文件的内容,并上传到文件服务 - * - * 为什么要下载?媒体文件在微信后台保存时间为 3 天,即 3 天后 media_id 失效。 - * - * @param accountId 公众号账号的编号 - * @param mediaId 媒体文件编号 - * @return 上传后的 URL - */ - public String downloadMedia(Long accountId, String mediaId) { - WxMpService mpService = mpServiceFactory.getMpService(accountId); - for (int i = 0; i < 3; i++) { - try { - // 第一步,从公众号下载媒体文件 - File file = mpService.getMaterialService().mediaDownload(mediaId); - // 第二步,上传到文件服务 - return uploadFile(mediaId, file); - } catch (WxErrorException e) { - log.error("[mediaDownload][media({}) 第 ({}) 次下载失败]", mediaId, i); - } - } - return null; - } - - private String uploadFile(String mediaId, File file) { - String path = mediaId + "." + FileTypeUtil.getType(file); - return fileApi.createFile(path, FileUtil.readBytes(file)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java deleted file mode 100644 index 19f3b1458..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.menu; - -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -import javax.validation.Valid; -import java.util.List; - -/** - * 公众号菜单 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMenuService { - - /** - * 保存公众号菜单 - * - * @param createReqVO 创建信息 - */ - void saveMenu(@Valid MpMenuSaveReqVO createReqVO); - - /** - * 删除公众号菜单 - * - * @param accountId 公众号账号的编号 - */ - void deleteMenuByAccountId(Long accountId); - - /** - * 粉丝点击菜单按钮时,回复对应的消息 - * - * @param appId 公众号 AppId - * @param key 菜单按钮的标识 - * @param openid 粉丝的 openid - * @return 消息 - */ - WxMpXmlOutMessage reply(String appId, String key, String openid); - - /** - * 获得公众号菜单列表 - * - * @param accountId 公众号账号的编号 - * @return 公众号菜单列表 - */ - List getMenuListByAccountId(Long accountId); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java deleted file mode 100644 index eb9ceba89..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.menu; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.dal.mysql.menu.MpMenuMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.bean.menu.WxMenu; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MENU_DELETE_FAIL; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MENU_SAVE_FAIL; - -/** - * 公众号菜单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMenuServiceImpl implements MpMenuService { - - @Resource - private MpMessageService mpMessageService; - @Resource - @Lazy // 延迟加载,避免循环引用报错 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,避免循环引用报错 - private MpServiceFactory mpServiceFactory; - - @Resource - private Validator validator; - - @Resource - private MpMenuMapper mpMenuMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public void saveMenu(MpMenuSaveReqVO createReqVO) { - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - WxMpService mpService = mpServiceFactory.getRequiredMpService(createReqVO.getAccountId()); - - // 参数校验 - createReqVO.getMenus().forEach(this::validateMenu); - - // 第一步,同步公众号 - WxMenu wxMenu = new WxMenu(); - wxMenu.setButtons(MpMenuConvert.INSTANCE.convert(createReqVO.getMenus())); - try { - mpService.getMenuService().menuCreate(wxMenu); - } catch (WxErrorException e) { - throw exception(MENU_SAVE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,存储到数据库 - mpMenuMapper.deleteByAccountId(createReqVO.getAccountId()); - createReqVO.getMenus().forEach(menu -> { - // 先保存顶级菜单 - MpMenuDO menuDO = createMenu(menu, null, account); - // 再保存子菜单 - if (CollUtil.isEmpty(menu.getChildren())) { - return; - } - menu.getChildren().forEach(childMenu -> createMenu(childMenu, menuDO, account)); - }); - } - - /** - * 校验菜单的格式是否正确 - * - * @param menu 菜单 - */ - private void validateMenu(MpMenuSaveReqVO.Menu menu) { - MpUtils.validateButton(validator, menu.getType(), menu.getReplyMessageType(), menu); - // 子菜单 - if (CollUtil.isEmpty(menu.getChildren())) { - return; - } - menu.getChildren().forEach(this::validateMenu); - } - - /** - * 创建菜单,并存储到数据库 - * - * @param wxMenu 菜单信息 - * @param parentMenu 父菜单 - * @param account 公众号账号 - * @return 创建后的菜单 - */ - private MpMenuDO createMenu(MpMenuSaveReqVO.Menu wxMenu, MpMenuDO parentMenu, MpAccountDO account) { - // 创建菜单 - MpMenuDO menu = CollUtil.isNotEmpty(wxMenu.getChildren()) - ? new MpMenuDO().setName(wxMenu.getName()) - : MpMenuConvert.INSTANCE.convert02(wxMenu); - // 设置菜单的公众号账号信息 - if (account != null) { - menu.setAccountId(account.getId()).setAppId(account.getAppId()); - } - // 设置父编号 - if (parentMenu != null) { - menu.setParentId(parentMenu.getId()); - } else { - menu.setParentId(MpMenuDO.ID_ROOT); - } - - // 插入到数据库 - mpMenuMapper.insert(menu); - return menu; - } - - @Override - public void deleteMenuByAccountId(Long accountId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - // 第一步,同步公众号 - try { - mpService.getMenuService().menuDelete(); - } catch (WxErrorException e) { - throw exception(MENU_DELETE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,存储到数据库 - mpMenuMapper.deleteByAccountId(accountId); - } - - @Override - public WxMpXmlOutMessage reply(String appId, String key, String openid) { - // 第一步,获得菜单 - MpMenuDO menu = mpMenuMapper.selectByAppIdAndMenuKey(appId, key); - if (menu == null) { - log.error("[reply][appId({}) key({}) 找不到对应的菜单]", appId, key); - return null; - } - // 按钮必须要有消息类型,不然后续无法回复消息 - if (StrUtil.isEmpty(menu.getReplyMessageType())) { - log.error("[reply][menu({}) 不存在对应的消息类型]", menu); - return null; - } - - // 第二步,回复消息 - MpMessageSendOutReqBO sendReqBO = MpMenuConvert.INSTANCE.convert(openid, menu); - return mpMessageService.sendOutMessage(sendReqBO); - } - - @Override - public List getMenuListByAccountId(Long accountId) { - return mpMenuMapper.selectListByAccountId(accountId); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java deleted file mode 100644 index fc125d06d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -/** - * 公众号的自动回复 Service 接口 - * - * @author 芋道源码 - */ -public interface MpAutoReplyService { - - /** - * 获得公众号自动回复分页 - * - * @param pageVO 分页请求 - * @return 自动回复分页结果 - */ - PageResult getAutoReplyPage(MpMessagePageReqVO pageVO); - - /** - * 获得公众号自动回复 - * - * @param id 编号 - * @return 自动回复 - */ - MpAutoReplyDO getAutoReply(Long id); - - - /** - * 创建公众号自动回复 - * - * @param createReqVO 创建请求 - * @return 自动回复的编号 - */ - Long createAutoReply(MpAutoReplyCreateReqVO createReqVO); - - /** - * 更新公众号自动回复 - * - * @param updateReqVO 更新请求 - */ - void updateAutoReply(MpAutoReplyUpdateReqVO updateReqVO); - - /** - * 删除公众号自动回复 - * - * @param id 自动回复的编号 - */ - void deleteAutoReply(Long id); - - /** - * 当收到消息时,自动回复 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - * @return 回复的消息 - */ - WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage); - - /** - * 当粉丝关注时,自动回复 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - * @return 回复的消息 - */ - WxMpXmlOutMessage replyForSubscribe(String appId, WxMpXmlMessage wxMessage); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java deleted file mode 100644 index b90b82e96..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpAutoReplyConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.dal.mysql.message.MpAutoReplyMapper; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号的自动回复 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MpAutoReplyServiceImpl implements MpAutoReplyService { - - @Resource - private MpMessageService mpMessageService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private MpAccountService mpAccountService; - - @Resource - private Validator validator; - - @Resource - private MpAutoReplyMapper mpAutoReplyMapper; - - @Override - public PageResult getAutoReplyPage(MpMessagePageReqVO pageVO) { - return mpAutoReplyMapper.selectPage(pageVO); - } - - @Override - public MpAutoReplyDO getAutoReply(Long id) { - return mpAutoReplyMapper.selectById(id); - } - - @Override - public Long createAutoReply(MpAutoReplyCreateReqVO createReqVO) { - // 第一步,校验数据 - if (createReqVO.getResponseMessageType() != null) { - MpUtils.validateMessage(validator, createReqVO.getResponseMessageType(), createReqVO); - } - validateAutoReplyConflict(null, createReqVO.getAccountId(), createReqVO.getType(), - createReqVO.getRequestKeyword(), createReqVO.getRequestMessageType()); - - // 第二步,插入数据 - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - MpAutoReplyDO autoReply = MpAutoReplyConvert.INSTANCE.convert(createReqVO) - .setAppId(account.getAppId()); - mpAutoReplyMapper.insert(autoReply); - return autoReply.getId(); - } - - @Override - public void updateAutoReply(MpAutoReplyUpdateReqVO updateReqVO) { - // 第一步,校验数据 - if (updateReqVO.getResponseMessageType() != null) { - MpUtils.validateMessage(validator, updateReqVO.getResponseMessageType(), updateReqVO); - } - MpAutoReplyDO autoReply = validateAutoReplyExists(updateReqVO.getId()); - validateAutoReplyConflict(updateReqVO.getId(), autoReply.getAccountId(), updateReqVO.getType(), - updateReqVO.getRequestKeyword(), updateReqVO.getRequestMessageType()); - - // 第二步,更新数据 - MpAutoReplyDO updateObj = MpAutoReplyConvert.INSTANCE.convert(updateReqVO) - .setAccountId(null).setAppId(null); // 避免前端传递,更新着两个字段 - mpAutoReplyMapper.updateById(updateObj); - } - - /** - * 校验自动回复是否冲突 - * - * 不同的 type,会有不同的逻辑: - * 1. type = SUBSCRIBE 时,不允许有其他的自动回复 - * 2. type = MESSAGE 时,校验 requestMessageType 已经存在自动回复 - * 3. type = KEYWORD 时,校验 keyword 已经存在自动回复 - * - * @param id 自动回复编号 - * @param accountId 公众号账号的编号 - * @param type 类型 - * @param requestKeyword 请求关键词 - * @param requestMessageType 请求消息类型 - */ - private void validateAutoReplyConflict(Long id, Long accountId, Integer type, - String requestKeyword, String requestMessageType) { - // 获得已经存在的自动回复 - MpAutoReplyDO autoReply = null; - ErrorCode errorCode = null; - if (MpAutoReplyTypeEnum.SUBSCRIBE.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndSubscribe(accountId); - errorCode = AUTO_REPLY_ADD_SUBSCRIBE_FAIL_EXISTS; - } else if (MpAutoReplyTypeEnum.MESSAGE.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndMessage(accountId, requestMessageType); - errorCode = AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS; - } else if (MpAutoReplyTypeEnum.KEYWORD.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndKeyword(accountId, requestKeyword); - errorCode = AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS; - } - if (autoReply == null) { - return; - } - - // 存在冲突,抛出业务异常 - if (id == null // 情况一,新增(id == null),存在记录,说明冲突 - || ObjUtil.notEqual(id, autoReply.getId())) { // 情况二,修改(id != null),id 不匹配,说明冲突 - throw exception(errorCode); - } - } - - @Override - public void deleteAutoReply(Long id) { - // 校验粉丝存在 - validateAutoReplyExists(id); - - // 删除自动回复 - mpAutoReplyMapper.deleteById(id); - } - - private MpAutoReplyDO validateAutoReplyExists(Long id) { - MpAutoReplyDO autoReply = mpAutoReplyMapper.selectById(id); - if (autoReply == null) { - throw exception(AUTO_REPLY_NOT_EXISTS); - } - return autoReply; - } - - @Override - public WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage) { - // 第一步,匹配自动回复 - List replies = null; - // 1.1 关键字 - if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) { - // 完全匹配 - replies = mpAutoReplyMapper.selectListByAppIdAndKeywordAll(appId, wxMessage.getContent()); - if (CollUtil.isEmpty(replies)) { - // 模糊匹配 - replies = mpAutoReplyMapper.selectListByAppIdAndKeywordLike(appId, wxMessage.getContent()); - } - } - // 1.2 消息类型 - if (CollUtil.isEmpty(replies)) { - replies = mpAutoReplyMapper.selectListByAppIdAndMessage(appId, wxMessage.getMsgType()); - } - if (CollUtil.isEmpty(replies)) { - return null; - } - MpAutoReplyDO reply = CollUtil.getFirst(replies); - - // 第二步,基于自动回复,创建消息 - MpMessageSendOutReqBO sendReqBO = MpAutoReplyConvert.INSTANCE.convert(wxMessage.getFromUser(), reply); - return mpMessageService.sendOutMessage(sendReqBO); - } - - @Override - public WxMpXmlOutMessage replyForSubscribe(String appId, WxMpXmlMessage wxMessage) { - // 第一步,匹配自动回复 - List replies = mpAutoReplyMapper.selectListByAppIdAndSubscribe(appId); - MpAutoReplyDO reply = CollUtil.isNotEmpty(replies) ? CollUtil.getFirst(replies) - : buildDefaultSubscribeAutoReply(appId); // 如果不存在,提供一个默认末班 - - // 第二步,基于自动回复,创建消息 - MpMessageSendOutReqBO sendReqBO = MpAutoReplyConvert.INSTANCE.convert(wxMessage.getFromUser(), reply); - return mpMessageService.sendOutMessage(sendReqBO); - } - - private MpAutoReplyDO buildDefaultSubscribeAutoReply(String appId) { - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号账号({}) 不存在", appId); - // 构建默认的【关注】自动回复 - return new MpAutoReplyDO().setAppId(appId).setAccountId(account.getId()) - .setType(MpAutoReplyTypeEnum.SUBSCRIBE.getType()) - .setResponseMessageType(WxConsts.XmlMsgType.TEXT).setResponseContent("感谢关注"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java deleted file mode 100644 index 01c691a34..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -import javax.validation.Valid; - -/** - * 公众号消息 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMessageService { - - /** - * 获得公众号消息分页 - * - * @param pageReqVO 分页查询 - * @return 公众号消息分页 - */ - PageResult getMessagePage(MpMessagePageReqVO pageReqVO); - - /** - * 从公众号,接收到粉丝消息 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - */ - void receiveMessage(String appId, WxMpXmlMessage wxMessage); - - /** - * 使用公众号,给粉丝回复消息 - * - * 例如说:自动回复、客服消息、菜单回复消息等场景 - * - * 注意,该方法只是返回 WxMpXmlOutMessage 对象,不会真的发送消息 - * - * @param sendReqBO 消息内容 - * @return 微信回复消息 XML - */ - WxMpXmlOutMessage sendOutMessage(@Valid MpMessageSendOutReqBO sendReqBO); - - /** - * 使用公众号,给粉丝发送【客服】消息 - * - * 注意,该方法会真实发送消息 - * - * @param sendReqVO 消息内容 - * @return 消息 - */ - MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java deleted file mode 100644 index 07553c764..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpMessageConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.dal.mysql.message.MpMessageMapper; -import cn.iocoder.yudao.module.mp.enums.message.MpMessageSendFromEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL; - -/** - * 粉丝消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMessageServiceImpl implements MpMessageService { - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private MpAccountService mpAccountService; - @Resource - private MpUserService mpUserService; - @Resource - private MpMaterialService mpMaterialService; - - @Resource - private MpMessageMapper mpMessageMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Resource - private Validator validator; - - @Override - public PageResult getMessagePage(MpMessagePageReqVO pageReqVO) { - return mpMessageMapper.selectPage(pageReqVO); - } - - @Override - public void receiveMessage(String appId, WxMpXmlMessage wxMessage) { - // 获得关联信息 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号账号({}) 不存在", appId); - - // 订阅事件不记录,因为此时公众号粉丝表中还没有此粉丝的数据 - // TODO @芋艿:这个修复,后续看看还有啥问题 - if (ObjUtil.equal(wxMessage.getEvent(), WxConsts.EventType.SUBSCRIBE)) { - return; - } - - MpUserDO user = mpUserService.getUser(appId, wxMessage.getFromUser()); - Assert.notNull(user, "公众号粉丝({}/{}) 不存在", appId, wxMessage.getFromUser()); - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user) - .setSendFrom(MpMessageSendFromEnum.USER_TO_MP.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - } - - @Override - public WxMpXmlOutMessage sendOutMessage(MpMessageSendOutReqBO sendReqBO) { - // 校验消息格式 - MpUtils.validateMessage(validator, sendReqBO.getType(), sendReqBO); - - // 获得关联信息 - MpAccountDO account = mpAccountService.getAccountFromCache(sendReqBO.getAppId()); - Assert.notNull(account, "公众号账号({}) 不存在", sendReqBO.getAppId()); - MpUserDO user = mpUserService.getUser(sendReqBO.getAppId(), sendReqBO.getOpenid()); - Assert.notNull(user, "公众号粉丝({}/{}) 不存在", sendReqBO.getAppId(), sendReqBO.getOpenid()); - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(sendReqBO, account, user). - setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - - // 转换返回 WxMpXmlOutMessage 对象 - return MpMessageConvert.INSTANCE.convert02(message, account); - } - - @Override - public MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO) { - // 校验消息格式 - MpUtils.validateMessage(validator, sendReqVO.getType(), sendReqVO); - - // 获得关联信息 - MpUserDO user = mpUserService.getRequiredUser(sendReqVO.getUserId()); - MpAccountDO account = mpAccountService.getRequiredAccount(user.getAccountId()); - - // 发送客服消息 - WxMpKefuMessage wxMessage = MpMessageConvert.INSTANCE.convert(sendReqVO, user); - WxMpService mpService = mpServiceFactory.getRequiredMpService(user.getAppId()); - try { - mpService.getKefuService().sendKefuMessageWithResponse(wxMessage); - } catch (WxErrorException e) { - throw exception(MESSAGE_SEND_FAIL, e.getError().getErrorMsg()); - } - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user) - .setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - return message; - } - - /** - * 下载消息使用到的媒体文件,并上传到文件服务 - * - * @param message 消息 - */ - private void downloadMessageMedia(MpMessageDO message) { - if (StrUtil.isNotEmpty(message.getMediaId())) { - message.setMediaUrl(mpMaterialService.downloadMaterialUrl(message.getAccountId(), - message.getMediaId(), MpUtils.getMediaFileType(message.getType()))); - } - if (StrUtil.isNotEmpty(message.getThumbMediaId())) { - message.setThumbMediaUrl(mpMaterialService.downloadMaterialUrl(message.getAccountId(), - message.getThumbMediaId(), WxConsts.MediaFileType.THUMB)); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java deleted file mode 100644 index 9da709050..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message.bo; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 公众号消息发送 Request BO - * - * 为什么要有该 BO 呢?在自动回复、客服消息、菜单回复消息等场景,都涉及到 MP 给粉丝发送消息,所以使用该 BO 统一承接 - * - * @author 芋道源码 - */ -@Data -public class MpMessageSendOutReqBO { - - /** - * 公众号 appId - */ - @NotEmpty(message = "公众号 appId 不能为空") - private String appId; - /** - * 公众号粉丝 openid - */ - @NotEmpty(message = "公众号粉丝 openid 不能为空") - private String openid; - - // ========== 消息内容 ========== - /** - * 消息类型 - * - * 枚举 {@link WxConsts.XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC - */ - @NotEmpty(message = "消息类型不能为空") - public String type; - - /** - * 消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - @NotEmpty(message = "消息内容不能为空", groups = TextMessageGroup.class) - private String content; - - /** - * 媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - @NotEmpty(message = "消息 mediaId 不能为空", groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String mediaId; - - /** - * 缩略图的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC - */ - @NotEmpty(message = "消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String thumbMediaId; - - /** - * 标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - @NotEmpty(message = "消息标题不能为空", groups = VideoMessageGroup.class) - private String title; - /** - * 描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String description; - - /** - * 图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @Valid - @NotNull(message = "图文消息不能为空", groups = NewsMessageGroup.class) - private List articles; - - /** - * 音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - @NotEmpty(message = "音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String musicUrl; - - /** - * 高质量音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - @NotEmpty(message = "高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String hqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java deleted file mode 100644 index 08e5c35bb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.statistics; - -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 公众号统计 Service 接口 - * - * @author 芋道源码 - */ -public interface MpStatisticsService { - - /** - * 获取粉丝增减数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 粉丝增减数据 - */ - List getUserSummary(Long accountId, LocalDateTime[] date); - - /** - * 获取粉丝累计数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 粉丝累计数据 - */ - List getUserCumulate(Long accountId, LocalDateTime[] date); - - /** - * 获取消息发送概况数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 消息发送概况数据 - */ - List getUpstreamMessage(Long accountId, LocalDateTime[] date); - - /** - * 获取接口分析数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 接口分析数据 - */ - List getInterfaceSummary(Long accountId, LocalDateTime[] date); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java deleted file mode 100644 index 4c3b37413..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.statistics; - -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class MpStatisticsServiceImpl implements MpStatisticsService { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - public List getUserSummary(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUserSummary( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_USER_SUMMARY_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getUserCumulate(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUserCumulate( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_USER_CUMULATE_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getUpstreamMessage(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUpstreamMsg( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_UPSTREAM_MESSAGE_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getInterfaceSummary(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getInterfaceSummary( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_INTERFACE_SUMMARY_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java deleted file mode 100644 index 77dbf338f..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 公众号标签 Service 接口 - * - * @author fengdan - */ -public interface MpTagService { - - /** - * 创建公众号标签 - * - * @param createReqVO 创建标签信息 - * @return 标签编号 - */ - Long createTag(@Valid MpTagCreateReqVO createReqVO); - - /** - * 更新公众号标签 - * - * @param updateReqVO 更新标签信息 - */ - void updateTag(@Valid MpTagUpdateReqVO updateReqVO); - - /** - * 删除公众号标签 - * - * @param id 编号 - */ - void deleteTag(Long id); - - /** - * 获得公众号标签分页 - * - * @param pageReqVO 分页查询 - * @return 公众号标签分页 - */ - PageResult getTagPage(MpTagPageReqVO pageReqVO); - - /** - * 获得公众号标签详情 - * @param id id查询 - * @return 公众号标签详情 - */ - MpTagDO get(Long id); - - List getTagList(); - - /** - * 同步公众号标签 - * - * @param accountId 公众号账号的编号 - */ - void syncTag(Long accountId); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java deleted file mode 100644 index a4fa50923..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.tag; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import cn.iocoder.yudao.module.mp.dal.mysql.tag.MpTagMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号标签 Service 实现类 - * - * @author fengdan - */ -@Slf4j -@Service -@Validated -public class MpTagServiceImpl implements MpTagService { - - @Resource - private MpTagMapper mpTagMapper; - - @Resource - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private MpServiceFactory mpServiceFactory; - - @Override - public Long createTag(MpTagCreateReqVO createReqVO) { - // 获得公众号账号 - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - - // 第一步,新增标签到公众号平台。标签名的唯一,交给公众号平台 - WxMpService mpService = mpServiceFactory.getRequiredMpService(createReqVO.getAccountId()); - WxUserTag wxTag; - try { - wxTag = mpService.getUserTagService().tagCreate(createReqVO.getName()); - } catch (WxErrorException e) { - throw exception(TAG_CREATE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,新增标签到数据库 - MpTagDO tag = MpTagConvert.INSTANCE.convert(wxTag, account); - mpTagMapper.insert(tag); - return tag.getId(); - } - - @Override - public void updateTag(MpTagUpdateReqVO updateReqVO) { - // 校验标签存在 - MpTagDO tag = validateTagExists(updateReqVO.getId()); - - // 第一步,更新标签到公众号平台。标签名的唯一,交给公众号平台 - WxMpService mpService = mpServiceFactory.getRequiredMpService(tag.getAccountId()); - try { - mpService.getUserTagService().tagUpdate(tag.getTagId(), updateReqVO.getName()); - } catch (WxErrorException e) { - throw exception(TAG_UPDATE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,更新标签到数据库 - mpTagMapper.updateById(new MpTagDO().setId(tag.getId()).setName(updateReqVO.getName())); - } - - @Override - public void deleteTag(Long id) { - // 校验标签存在 - MpTagDO tag = validateTagExists(id); - - // 第一步,删除标签到公众号平台。 - WxMpService mpService = mpServiceFactory.getRequiredMpService(tag.getAccountId()); - try { - mpService.getUserTagService().tagDelete(tag.getTagId()); - } catch (WxErrorException e) { - throw exception(TAG_DELETE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,删除标签到数据库 - mpTagMapper.deleteById(tag.getId()); - } - - private MpTagDO validateTagExists(Long id) { - MpTagDO tag = mpTagMapper.selectById(id); - if (tag == null) { - throw exception(TAG_NOT_EXISTS); - } - return tag; - } - - @Override - public PageResult getTagPage(MpTagPageReqVO pageReqVO) { - return mpTagMapper.selectPage(pageReqVO); - } - - @Override - public MpTagDO get(Long id) { - return mpTagMapper.selectById(id); - } - - @Override - public List getTagList() { - return mpTagMapper.selectList(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void syncTag(Long accountId) { - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - - // 第一步,从公众号平台获取最新的标签列表 - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - List wxTags; - try { - wxTags = mpService.getUserTagService().tagGet(); - } catch (WxErrorException e) { - throw exception(TAG_GET_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,合并更新回自己的数据库;由于标签只有 100 个,所以直接 for 循环操作 - Map tagMap = convertMap(mpTagMapper.selectListByAccountId(accountId), - MpTagDO::getTagId); - wxTags.forEach(wxTag -> { - MpTagDO tag = tagMap.remove(wxTag.getId()); - // 情况一,不存在,新增 - if (tag == null) { - tag = MpTagConvert.INSTANCE.convert(wxTag, account); - mpTagMapper.insert(tag); - return; - } - // 情况二,存在,则更新 - mpTagMapper.updateById(new MpTagDO().setId(tag.getId()) - .setName(wxTag.getName()).setCount(wxTag.getCount())); - }); - // 情况三,部分标签已经不存在了,删除 - if (CollUtil.isNotEmpty(tagMap)) { - mpTagMapper.deleteBatchIds(convertList(tagMap.values(), MpTagDO::getId)); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java deleted file mode 100644 index bdefc0e60..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import me.chanjar.weixin.mp.bean.result.WxMpUser; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS; - -/** - * 公众号粉丝 Service 接口 - * - * @author 芋道源码 - */ -public interface MpUserService { - - /** - * 获得公众号粉丝 - * - * @param id 编号 - * @return 公众号粉丝 - */ - MpUserDO getUser(Long id); - - /** - * 使用 appId + openId,获得公众号粉丝 - * - * @param appId 公众号 appId - * @param openId 公众号 openId - * @return 公众号粉丝 - */ - MpUserDO getUser(String appId, String openId); - - /** - * 获得公众号粉丝 - * - * @param id 编号 - * @return 公众号粉丝 - */ - default MpUserDO getRequiredUser(Long id) { - MpUserDO user = getUser(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - /** - * 获得公众号粉丝列表 - * - * @param ids 编号 - * @return 公众号粉丝列表 - */ - List getUserList(Collection ids); - - /** - * 获得公众号粉丝分页 - * - * @param pageReqVO 分页查询 - * @return 公众号粉丝分页 - */ - PageResult getUserPage(MpUserPageReqVO pageReqVO); - - /** - * 保存公众号粉丝 - * - * 新增或更新,根据是否存在数据库中 - * - * @param appId 公众号 appId - * @param wxMpUser 公众号粉丝的信息 - * @return 公众号粉丝 - */ - MpUserDO saveUser(String appId, WxMpUser wxMpUser); - - /** - * 同步一个公众号粉丝 - * - * @param accountId 公众号账号的编号 - */ - void syncUser(Long accountId); - - /** - * 更新公众号粉丝,取消关注 - * - * @param appId 公众号 appId - * @param openId 公众号粉丝的 openid - */ - void updateUserUnsubscribe(String appId, String openId); - - /** - * 更新公众号粉丝 - * - * @param updateReqVO 更新信息 - */ - void updateUser(MpUserUpdateReqVO updateReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java deleted file mode 100644 index 0cef919d9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.dal.mysql.user.MpUserMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import me.chanjar.weixin.mp.bean.result.WxMpUserList; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_UPDATE_TAG_FAIL; - -/** - * 微信公众号粉丝 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpUserServiceImpl implements MpUserService { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Resource - private MpUserMapper mpUserMapper; - - @Override - public MpUserDO getUser(Long id) { - return mpUserMapper.selectById(id); - } - - @Override - public MpUserDO getUser(String appId, String openId) { - return mpUserMapper.selectByAppIdAndOpenid(appId, openId); - } - - @Override - public List getUserList(Collection ids) { - return mpUserMapper.selectBatchIds(ids); - } - - @Override - public PageResult getUserPage(MpUserPageReqVO pageReqVO) { - return mpUserMapper.selectPage(pageReqVO); - } - - @Override - public MpUserDO saveUser(String appId, WxMpUser wxMpUser) { - // 构建保存的 MpUserDO 对象 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - MpUserDO user = MpUserConvert.INSTANCE.convert(account, wxMpUser); - - // 根据情况,插入或更新 - MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, wxMpUser.getOpenId()); - if (dbUser == null) { - mpUserMapper.insert(user); - } else { - user.setId(dbUser.getId()); - mpUserMapper.updateById(user); - } - return user; - } - - @Override - @Async - public void syncUser(Long accountId) { - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - // for 循环,避免递归出意外问题,导致死循环 - String nextOpenid = null; - for (int i = 0; i < Short.MAX_VALUE; i++) { - log.info("[syncUser][第({}) 次加载公众号粉丝列表,nextOpenid({})]", i, nextOpenid); - try { - nextOpenid = syncUser0(account, nextOpenid); - } catch (WxErrorException e) { - log.error("[syncUser][第({}) 次同步粉丝异常]", i, e); - break; - } - // 如果 nextOpenid 为空,表示已经同步完毕 - if (StrUtil.isEmpty(nextOpenid)) { - break; - } - } - } - - private String syncUser0(MpAccountDO account, String nextOpenid) throws WxErrorException { - // 第一步,从公众号流式加载粉丝 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getId()); - WxMpUserList wxUserList = mpService.getUserService().userList(nextOpenid); - if (CollUtil.isEmpty(wxUserList.getOpenids())) { - return null; - } - - // 第二步,分批加载粉丝信息 - List> openidsList = CollUtil.split(wxUserList.getOpenids(), 100); - for (List openids : openidsList) { - log.info("[syncUser][批量加载粉丝信息,openids({})]", openids); - List wxUsers = mpService.getUserService().userInfoList(openids); - batchSaveUser(account, wxUsers); - } - - // 返回下一次的 nextOpenId - return wxUserList.getNextOpenid(); - } - - private void batchSaveUser(MpAccountDO account, List wxUsers) { - if (CollUtil.isEmpty(wxUsers)) { - return; - } - // 1. 获得数据库已保存的粉丝列表 - List dbUsers = mpUserMapper.selectListByAppIdAndOpenid(account.getAppId(), - CollectionUtils.convertList(wxUsers, WxMpUser::getOpenId)); - Map openId2Users = CollectionUtils.convertMap(dbUsers, MpUserDO::getOpenid); - - // 2.1 根据情况,插入或更新 - List users = MpUserConvert.INSTANCE.convertList(account, wxUsers); - List newUsers = new ArrayList<>(); - for (MpUserDO user : users) { - MpUserDO dbUser = openId2Users.get(user.getOpenid()); - if (dbUser == null) { // 新增:稍后批量插入 - newUsers.add(user); - } else { // 更新:直接执行更新 - user.setId(dbUser.getId()); - mpUserMapper.updateById(user); - } - } - // 2.2 批量插入 - if (CollUtil.isNotEmpty(newUsers)) { - mpUserMapper.insertBatch(newUsers); - } - } - - @Override - public void updateUserUnsubscribe(String appId, String openid) { - MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, openid); - if (dbUser == null) { - log.error("[updateUserUnsubscribe][微信公众号粉丝 appId({}) openid({}) 不存在]", appId, openid); - return; - } - mpUserMapper.updateById(new MpUserDO().setId(dbUser.getId()).setSubscribeStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUnsubscribeTime(LocalDateTime.now())); - } - - @Override - public void updateUser(MpUserUpdateReqVO updateReqVO) { - // 校验存在 - MpUserDO user = validateUserExists(updateReqVO.getId()); - - // 第一步,更新标签到公众号 - updateUserTag(user.getAppId(), user.getOpenid(), updateReqVO.getTagIds()); - - // 第二步,更新基本信息到数据库 - MpUserDO updateObj = MpUserConvert.INSTANCE.convert(updateReqVO).setId(user.getId()); - mpUserMapper.updateById(updateObj); - } - - private MpUserDO validateUserExists(Long id) { - MpUserDO user = mpUserMapper.selectById(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - private void updateUserTag(String appId, String openid, List tagIds) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(appId); - try { - // 第一步,先取消原来的标签 - List oldTagIds = mpService.getUserTagService().userTagList(openid); - for (Long tagId : oldTagIds) { - mpService.getUserTagService().batchUntagging(tagId, new String[]{openid}); - } - // 第二步,再设置新的标签 - if (CollUtil.isEmpty(tagIds)) { - return; - } - for (Long tagId: tagIds) { - mpService.getUserTagService().batchTagging(tagId, new String[]{openid}); - } - } catch (WxErrorException e) { - throw exception(USER_UPDATE_TAG_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-dev.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 0a3975f46..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,99 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-local.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-local.yaml deleted file mode 100644 index d4dabc22c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,119 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.mp.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml deleted file mode 100644 index 509722ed5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,114 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 微信公众号相关配置 #################### -wx: - mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 - # 存储配置,解决 AccessToken 的跨节点的共享 - config-storage: - type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 - key-prefix: wx # Redis Key 的前缀 - http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 - app-id: null # 避免 weixin-java-mp starter 报错 - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.mp - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - permit-all_urls: - - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 - -debug: false diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index a4f9d0821..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: mp-server - - profiles: - active: local - -server: - port: 48086 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/logback-spring.xml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-pay/pom.xml b/yudao-module-pay/pom.xml deleted file mode 100644 index 3a735b8bd..000000000 --- a/yudao-module-pay/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - yudao-module-pay - pom - - yudao-module-pay-api - yudao-module-pay-biz - yudao-spring-boot-starter-biz-pay - - - ${project.artifactId} - - pay 模块,我们放支付业务,提供业务的支付能力。 - 例如说:商户、应用、支付、退款等等 - - - - diff --git a/yudao-module-pay/yudao-module-pay-api/pom.xml b/yudao-module-pay/yudao-module-pay-api/pom.xml deleted file mode 100644 index d517fa95c..000000000 --- a/yudao-module-pay/yudao-module-pay-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - yudao-module-pay - cn.iocoder.cloud - ${revision} - - 4.0.0 - yudao-module-pay-api - jar - - ${project.artifactId} - - pay 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java deleted file mode 100644 index 291b364d9..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "RPC 服务 - 支付单的通知 Request DTO") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderNotifyReqDTO { - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") - @NotEmpty(message = "商户订单号不能为空") - private String merchantOrderId; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "P202") - @NotNull(message = "支付订单编号不能为空") - private Long payOrderId; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java deleted file mode 100644 index d92ad994f..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "RPC 服务 - 退款单的通知 Request DTO") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayRefundNotifyReqDTO { - - @Schema(description = "商户退款单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "MR101") - @NotEmpty(message = "商户退款单编号不能为空") - private String merchantOrderId; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "R303") - @NotNull(message = "支付退款编号不能为空") - private Long payRefundId; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java deleted file mode 100644 index 60c4ca883..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无特殊作用 - */ -package cn.iocoder.yudao.module.pay.api.notify; diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java deleted file mode 100644 index 8e5bf3776..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.security.PermitAll; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 支付单") -public interface PayOrderApi { - - String PREFIX = ApiConstants.PREFIX + "/order"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建支付单") - CommonResult createOrder(@Valid @RequestBody PayOrderCreateReqDTO reqDTO); - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得支付单") - @Parameter(name = "id", description = "支付单编号", example = "1", required = true) - @PermitAll - CommonResult getOrder(@RequestParam("id") Long id); - - @PutMapping(PREFIX + "/update-price") - @Operation(summary = "更新支付订单价格") - @Parameters({ - @Parameter(name = "id", description = "支付单编号", example = "1", required = true), - @Parameter(name = "payPrice", description = "支付单价格", example = "100", required = true) - }) - CommonResult updatePayOrderPrice(@RequestParam("id") Long id, - @RequestParam("payPrice") Integer payPrice); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java deleted file mode 100644 index c862e338d..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -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.time.LocalDateTime; - -@Schema(description = "RPC 服务 - 支付单创建 Request DTO") -@Data -public class PayOrderCreateReqDTO implements Serializable { - - public static final int SUBJECT_MAX_LENGTH = 32; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是标题") - @NotEmpty(message = "商品标题不能为空") - @Length(max = 32, message = "商品标题不能超过 32") - private String subject; - - @Schema(description = "商品描述", example = "我是描述") - @Length(max = 128, message = "商品描述信息长度不能超过128") - private String body; - - // ========== 订单相关字段 ========== - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "80") - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer price; - - @Schema(description = "支付过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "支付过期时间不能为空") - private LocalDateTime expireTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java deleted file mode 100644 index 7bf9e6167..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 支付单信息 Response DTO") -@Data -public class PayOrderRespDTO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub") // PayChannelEnum 枚举 - private String channelCode; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - private String merchantOrderId; - - // ========== 订单相关字段 ========== - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "101") - private Integer price; - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // PayOrderStatusEnum 枚举 - private Integer status; - - // ========== 渠道相关字段 ========== - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java deleted file mode 100644 index 9bdb25af8..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 退款单") -public interface PayRefundApi { - - String PREFIX = ApiConstants.PREFIX + "/refund"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建退款单") - CommonResult createRefund(@Valid @RequestBody PayRefundCreateReqDTO reqDTO); - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得退款单") - @Parameter(name = "id", description = "退款单编号", example = "1", required = true) - CommonResult getRefund(@RequestParam("id") Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java deleted file mode 100644 index c03bc5368..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "RPC 服务 - 退款单创建 Request DTO") -@Data -public class PayRefundCreateReqDTO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商户退款编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "MR101") - @NotEmpty(message = "商户退款编号不能为空") - private String merchantRefundId; - - @Schema(description = "退款描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是退款描述") - @NotEmpty(message = "退款描述不能为空") - @Length(max = 128, message = "退款描述长度不能超过 128") - private String reason; - - // ========== 订单相关字段 ========== - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "60") - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于零") - private Integer price; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java deleted file mode 100644 index a562f581e..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "RPC 服务 - 退款单信息 Response DTO") -@Data -public class PayRefundRespDTO { - - @Schema(description = "退款单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - // ========== 退款相关字段 ========== - - @Schema(description = "退款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // PayRefundStatusEnum 枚举 - private Integer status; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "101") - private Integer refundPrice; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - private String merchantOrderId; - - @Schema(description = "退款成功时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime successTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java deleted file mode 100644 index 3661fdc39..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 转账单") -public interface PayTransferApi { - - String PREFIX = ApiConstants.PREFIX + "/transfer"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建转账单") - CommonResult createTransfer(@Valid @RequestBody PayTransferCreateReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java deleted file mode 100644 index 17a611172..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer.dto; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "RPC 服务 - 转账单创建 Request DTO") -@Data -public class PayTransferCreateReqDTO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "转账金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "80") - @Min(value = 1, message = "转账金额必须大于零") - @NotNull(message = "转账金额不能为空") - private Integer price; - - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是标题") - @NotEmpty(message = "转账标题不能为空") - private String title; - - @Schema(description = "收款方信息", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "收款方信息不能为空") - private Map payeeInfo; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ApiConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ApiConstants.java deleted file mode 100644 index 72b040248..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "pay-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/pay"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java deleted file mode 100644 index 8f0d9b718..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -/** - * Pay 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String CHANNEL_CODE = "pay_channel_code"; // 支付渠道编码 - - String ORDER_STATUS = "pay_order_status"; // 支付渠道 - - String REFUND_STATUS = "pay_order_status"; // 退款状态 - - String NOTIFY_STATUS = "pay_notify_status"; // 回调状态 - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java deleted file mode 100644 index 476d7417b..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Pay 错误码 Core 枚举类 - * - * pay 系统,使用 1-007-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== APP 模块 1-007-000-000 ========== - ErrorCode APP_NOT_FOUND = new ErrorCode(1_007_000_000, "App 不存在"); - ErrorCode APP_IS_DISABLE = new ErrorCode(1_007_000_002, "App 已经被禁用"); - ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除"); - ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除"); - - // ========== CHANNEL 模块 1-007-001-000 ========== - ErrorCode CHANNEL_NOT_FOUND = new ErrorCode(1_007_001_000, "支付渠道的配置不存在"); - ErrorCode CHANNEL_IS_DISABLE = new ErrorCode(1_007_001_001, "支付渠道已经禁用"); - ErrorCode CHANNEL_EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1_007_001_004, "已存在相同的渠道"); - - // ========== ORDER 模块 1-007-002-000 ========== - ErrorCode PAY_ORDER_NOT_FOUND = new ErrorCode(1_007_002_000, "支付订单不存在"); - ErrorCode PAY_ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_002_001, "支付订单不处于待支付"); - ErrorCode PAY_ORDER_STATUS_IS_SUCCESS = new ErrorCode(1_007_002_002, "订单已支付,请刷新页面"); - ErrorCode PAY_ORDER_IS_EXPIRED = new ErrorCode(1_007_002_003, "支付订单已经过期"); - ErrorCode PAY_ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_002_004, "发起支付报错,错误码:{},错误提示:{}"); - ErrorCode PAY_ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1_007_002_005, "支付订单退款失败,原因:状态不是已支付或已退款"); - - // ========== ORDER 模块(拓展单) 1-007-003-000 ========== - ErrorCode PAY_ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_003_000, "支付交易拓展单不存在"); - ErrorCode PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_003_001, "支付交易拓展单不处于待支付"); - ErrorCode PAY_ORDER_EXTENSION_IS_PAID = new ErrorCode(1_007_003_002, "订单已支付,请等待支付结果"); - - // ========== 支付模块(退款) 1-007-006-000 ========== - ErrorCode REFUND_PRICE_EXCEED = new ErrorCode(1_007_006_000, "退款金额超过订单可退款金额"); - ErrorCode REFUND_HAS_REFUNDING = new ErrorCode(1_007_006_002, "已经有退款在处理中"); - ErrorCode REFUND_EXISTS = new ErrorCode(1_007_006_003, "已经存在退款单"); - ErrorCode REFUND_NOT_FOUND = new ErrorCode(1_007_006_004, "支付退款单不存在"); - ErrorCode REFUND_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_006_005, "支付退款单不处于待退款"); - - // ========== 钱包模块 1-007-007-000 ========== - ErrorCode WALLET_NOT_FOUND = new ErrorCode(1_007_007_000, "用户钱包不存在"); - ErrorCode WALLET_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_007_001, "钱包余额不足"); - ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1_007_007_002, "未找到对应的钱包交易"); - ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款"); - ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足"); - - // ========== 钱包充值模块 1-007-008-000 ========== - ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_008_002, "钱包充值更新支付状态失败,支付单编号不匹配"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_008_003, "钱包充值更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_008_004, "钱包充值更新支付状态失败,支付单金额不匹配"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_008_005, "钱包发起退款失败,钱包充值订单未支付"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_008_006, "钱包发起退款失败,钱包充值订单已退款"); - ErrorCode WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_008_007, "钱包发起退款失败,钱包余额不足"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_008_008, "钱包退款更新失败,钱包退款单编号不匹配"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_008_009, "钱包退款更新失败,退款订单不存在"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_008_010, "钱包退款更新失败,退款单金额不匹配"); - ErrorCode WALLET_RECHARGE_PACKAGE_AND_PRICE_IS_EMPTY = new ErrorCode(1_007_008_011, "充值金额和充钱套餐不能同时为空"); - ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_012, "钱包充值套餐不存在"); - ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_013, "钱包充值套餐已禁用"); - ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_014, "钱包充值套餐名称已存在"); - - // ========== 转账模块 1-007-009-000 ========== - ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}"); - ErrorCode PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY = new ErrorCode(1_007_009_001, "支付宝登录 ID 不能为空"); - ErrorCode PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY = new ErrorCode(1_007_009_002, "支付宝账号名称不能为空"); - ErrorCode PAY_TRANSFER_NOT_FOUND = new ErrorCode(1_007_009_003, "转账交易单不存在"); - ErrorCode PAY_TRANSFER_STATUS_IS_SUCCESS = new ErrorCode(1_007_009_004, "转账单已成功转账"); - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_005, "转账单不处于待转账"); - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_006, "转账单不处于待转账或转账中"); - ErrorCode PAY_TRANSFER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_009_007, "转账交易拓展单不存在"); - ErrorCode PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH = new ErrorCode(1_007_009_008, "转账类型和转账渠道不匹配"); - ErrorCode PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_009, "转账拓展单不处于待转账或转账中"); - - // ========== 示例订单 1-007-900-000 ========== - ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在"); - ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_900_001, "示例订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_900_002, "示例订单更新支付状态失败,支付单编号不匹配"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_900_003, "示例订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_900_004, "示例订单更新支付状态失败,支付单金额不匹配"); - ErrorCode DEMO_ORDER_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_900_005, "发起退款失败,示例订单未支付"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_900_006, "发起退款失败,示例订单已退款"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_900_007, "发起退款失败,退款订单不存在"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS = new ErrorCode(1_007_900_008, "发起退款失败,退款订单未退款成功"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_900_009, "发起退款失败,退款单编号不匹配"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_900_010, "发起退款失败,退款单金额不匹配"); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java deleted file mode 100644 index b735598d5..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.notify; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付通知状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayNotifyStatusEnum { - - WAITING(0, "等待通知"), - SUCCESS(10, "通知成功"), - FAILURE(20, "通知失败"), // 多次尝试,彻底失败 - REQUEST_SUCCESS(21, "请求成功,但是结果失败"), - REQUEST_FAILURE(22, "请求失败"), - - ; - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java deleted file mode 100644 index 8c259d93c..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.notify; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付通知类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayNotifyTypeEnum { - - ORDER(1, "支付单"), - REFUND(2, "退款单"), - ; - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java deleted file mode 100644 index 86a9e1704..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 支付订单的状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderStatusEnum implements IntArrayValuable { - - WAITING(0, "未支付"), - SUCCESS(10, "支付成功"), - REFUND(20, "已退款"), - CLOSED(30, "支付关闭"), // 注意:全部退款后,还是 REFUND 状态 - ; - - private final Integer status; - private final String name; - - @Override - public int[] array() { - return new int[0]; - } - - /** - * 判断是否支付成功 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - /** - * 判断是否支付成功或者已退款 - * - * @param status 状态 - * @return 是否支付成功或者已退款 - */ - public static boolean isSuccessOrRefund(Integer status) { - return ObjectUtils.equalsAny(status, - SUCCESS.getStatus(), REFUND.getStatus()); - } - - /** - * 判断是否支付关闭 - * - * @param status 状态 - * @return 是否支付关闭 - */ - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java deleted file mode 100644 index 4ae14cc67..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.refund; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的退款状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayRefundStatusEnum { - - WAITING(0, "未退款"), - SUCCESS(10, "退款成功"), - FAILURE(20, "退款失败"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isFailure(Integer status) { - return Objects.equals(status, FAILURE.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java deleted file mode 100644 index f3eff1495..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.transfer; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayTransferStatusEnum { - - WAITING(0, "待转账"), - /** - * TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现 - */ - IN_PROGRESS(10, "转账进行中"), - - SUCCESS(20, "转账成功"), - /** - * 转账关闭 (失败,或者其它情况) - */ - CLOSED(30, "转账关闭"); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - public static boolean isWaiting(Integer status) { - return Objects.equals(status, WAITING.getStatus()); - } - - /** - * 是否处于待转账或者转账中的状态 - * @param status 状态 - */ - public static boolean isPendingStatus(Integer status) { - return Objects.equals(status, WAITING.getStatus()) || Objects.equals(status, IN_PROGRESS.status); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java deleted file mode 100644 index b86b37384..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.transfer; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 转账类型枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayTransferTypeEnum implements IntArrayValuable { - - ALIPAY_BALANCE(1, "支付宝余额"), - WX_BALANCE(2, "微信余额"), - BANK_CARD(3, "银行卡"), - WALLET_BALANCE(4, "钱包余额"); - - public static final String ALIPAY_LOGON_ID = "ALIPAY_LOGON_ID"; - public static final String ALIPAY_ACCOUNT_NAME = "ALIPAY_ACCOUNT_NAME"; - - private final Integer type; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - - public static PayTransferTypeEnum typeOf(Integer type) { - return ArrayUtil.firstMatch(item -> item.getType().equals(type), values()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java deleted file mode 100644 index 20e0a8b09..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.wallet; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 钱包交易业务分类 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayWalletBizTypeEnum implements IntArrayValuable { - - RECHARGE(1, "充值"), - RECHARGE_REFUND(2, "充值退款"), - PAYMENT(3, "支付"), - PAYMENT_REFUND(4, "支付退款"); - - // TODO 后续增加 - - /** - * 业务分类 - */ - private final Integer type; - /** - * 说明 - */ - private final String description; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayWalletBizTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/Dockerfile b/yudao-module-pay/yudao-module-pay-biz/Dockerfile deleted file mode 100644 index e49321f39..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-pay-biz-1.8.0-snapshot -WORKDIR /yudao-module-pay-biz-1.8.0-snapshot -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-pay-biz-1.8.0-snapshot.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48085 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-pay/yudao-module-pay-biz/pom.xml b/yudao-module-pay/yudao-module-pay-biz/pom.xml deleted file mode 100644 index bcd5d1ea4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-pay - ${revision} - - 4.0.0 - yudao-module-pay-biz - jar - - ${project.artifactId} - - pay 模块,我们放支付业务,提供业务的支付能力。 - 例如说:商户、应用、支付、退款等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - - cn.iocoder.cloud - yudao-module-pay-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-pay - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/PayServerApplication.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/PayServerApplication.java deleted file mode 100644 index dc67f2da3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/PayServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class PayServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(PayServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java deleted file mode 100644 index a0c0042e3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class PayOrderApiImpl implements PayOrderApi { - - @Resource - private PayOrderService payOrderService; - - @Override - public CommonResult createOrder(PayOrderCreateReqDTO reqDTO) { - return success(payOrderService.createOrder(reqDTO)); - } - - @Override - public CommonResult getOrder(Long id) { - PayOrderDO order = payOrderService.getOrder(id); - return success(PayOrderConvert.INSTANCE.convert2(order)); - } - - @Override - public CommonResult updatePayOrderPrice(Long id, Integer payPrice) { - payOrderService.updatePayOrderPrice(id, payPrice); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java deleted file mode 100644 index d88fb8dd1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class PayRefundApiImpl implements PayRefundApi { - - @Resource - private PayRefundService payRefundService; - - @Override - public CommonResult createRefund(PayRefundCreateReqDTO reqDTO) { - return success(payRefundService.createPayRefund(reqDTO)); - } - - @Override - public CommonResult getRefund(Long id) { - return success(PayRefundConvert.INSTANCE.convert02(payRefundService.getRefund(id))); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java deleted file mode 100644 index 592a213b3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 转账单 API 实现类 - * - * @author jason - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class PayTransferApiImpl implements PayTransferApi { - - @Resource - private PayTransferService payTransferService; - - @Override - public CommonResult createTransfer(PayTransferCreateReqDTO reqDTO) { - return success(payTransferService.createTransfer(reqDTO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java deleted file mode 100644 index b0d80eac3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.*; -import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Slf4j -@Tag(name = "管理后台 - 支付应用信息") -@RestController -@RequestMapping("/pay/app") -@Validated -public class PayAppController { - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @PostMapping("/create") - @Operation(summary = "创建支付应用信息") - @PreAuthorize("@ss.hasPermission('pay:app:create')") - public CommonResult createApp(@Valid @RequestBody PayAppCreateReqVO createReqVO) { - return success(appService.createApp(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付应用信息") - @PreAuthorize("@ss.hasPermission('pay:app:update')") - public CommonResult updateApp(@Valid @RequestBody PayAppUpdateReqVO updateReqVO) { - appService.updateApp(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新支付应用状态") - @PreAuthorize("@ss.hasPermission('pay:app:update')") - public CommonResult updateAppStatus(@Valid @RequestBody PayAppUpdateStatusReqVO updateReqVO) { - appService.updateAppStatus(updateReqVO.getId(), updateReqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付应用信息") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:app:delete')") - public CommonResult deleteApp(@RequestParam("id") Long id) { - appService.deleteApp(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付应用信息") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:app:query')") - public CommonResult getApp(@RequestParam("id") Long id) { - PayAppDO app = appService.getApp(id); - return success(PayAppConvert.INSTANCE.convert(app)); - } - - @GetMapping("/page") - @Operation(summary = "获得支付应用信息分页") - @PreAuthorize("@ss.hasPermission('pay:app:query')") - public CommonResult> getAppPage(@Valid PayAppPageReqVO pageVO) { - // 得到应用分页列表 - PageResult pageResult = appService.getAppPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 得到所有的应用编号,查出所有的渠道 - Collection appIds = convertList(pageResult.getList(), PayAppDO::getId); - List channels = channelService.getChannelListByAppIds(appIds); - - // 拼接后返回 - return success(PayAppConvert.INSTANCE.convertPage(pageResult, channels)); - } - - @GetMapping("/list") - @Operation(summary = "获得应用列表") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getAppList() { - List appListDO = appService.getAppList(); - return success(PayAppConvert.INSTANCE.convertList(appListDO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java deleted file mode 100644 index 45f29360f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.*; - -/** -* 支付应用信息 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayAppBaseVO { - - @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小豆") - @NotNull(message = "应用名不能为空") - private String name; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注", example = "我是一个测试应用") - private String remark; - - @Schema(description = "支付结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/pay-callback") - @NotNull(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的回调地址必须为 URL 格式") - private String orderNotifyUrl; - - @Schema(description = "退款结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/refund-callback") - @NotNull(message = "退款结果的回调地址不能为空") - @URL(message = "退款结果的回调地址必须为 URL 格式") - private String refundNotifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java deleted file mode 100644 index 03cab7d3e..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 支付应用信息创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppCreateReqVO extends PayAppBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java deleted file mode 100644 index 76b62003c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - 支付应用信息分页查询 Response VO,相比于支付信息,还会多出应用渠道的开关信息") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppPageItemRespVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "已配置的支付渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "[alipay_pc, alipay_wap]") - private Set channelCodes; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java deleted file mode 100644 index 94ade7ce6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付应用信息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppPageReqVO extends PageParam { - - @Schema(description = "应用名", example = "小豆") - private String name; - - @Schema(description = "开启状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java deleted file mode 100644 index 9471a2f01..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付应用信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppRespVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java deleted file mode 100644 index 5edf2290a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 支付应用信息更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppUpdateReqVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java deleted file mode 100644 index 9b8dad6e1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 应用更新状态 Request VO") -@Data -public class PayAppUpdateStatusReqVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long id; - - @Schema(description = "状态,见 SysCommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java deleted file mode 100644 index 37927a799..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 支付渠道") -@RestController -@RequestMapping("/pay/channel") -@Validated -public class PayChannelController { - - @Resource - private PayChannelService channelService; - - @PostMapping("/create") - @Operation(summary = "创建支付渠道 ") - @PreAuthorize("@ss.hasPermission('pay:channel:create')") - public CommonResult createChannel(@Valid @RequestBody PayChannelCreateReqVO createReqVO) { - return success(channelService.createChannel(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付渠道 ") - @PreAuthorize("@ss.hasPermission('pay:channel:update')") - public CommonResult updateChannel(@Valid @RequestBody PayChannelUpdateReqVO updateReqVO) { - channelService.updateChannel(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付渠道 ") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:channel:delete')") - public CommonResult deleteChannel(@RequestParam("id") Long id) { - channelService.deleteChannel(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付渠道") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:channel:query')") - public CommonResult getChannel(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "appId", required = false) Long appId, - @RequestParam(value = "code", required = false) String code) { - PayChannelDO channel = null; - if (id != null) { - channel = channelService.getChannel(id); - } else if (appId != null && code != null) { - channel = channelService.getChannelByAppIdAndCode(appId, code); - } - return success(PayChannelConvert.INSTANCE.convert(channel)); - } - - @GetMapping("/get-enable-code-list") - @Operation(summary = "获得指定应用的开启的支付渠道编码列表") - @Parameter(name = "appId", description = "应用编号", required = true, example = "1") - public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { - List channels = channelService.getEnableChannelList(appId); - return success(convertSet(channels, PayChannelDO::getCode)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java deleted file mode 100644 index 1416c9790..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -/** -* 支付渠道 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayChannelBaseVO { - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注", example = "我是小备注") - private String remark; - - @Schema(description = "渠道费率,单位:百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "渠道费率,单位:百分比不能为空") - private Double feeRate; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java deleted file mode 100644 index 08073827a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 支付渠道 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelCreateReqVO extends PayChannelBaseVO { - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - @NotNull(message = "渠道编码不能为空") - private String code; - - @Schema(description = "渠道配置的 json 字符串") - @NotBlank(message = "渠道配置不能为空") - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java deleted file mode 100644 index dafd29ec9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付渠道 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelRespVO extends PayChannelBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDateTime createTime; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - private String code; - - @Schema(description = "配置", requiredMode = Schema.RequiredMode.REQUIRED) - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java deleted file mode 100644 index 39bf83eb0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 支付渠道 更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelUpdateReqVO extends PayChannelBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long id; - - @Schema(description = "渠道配置的json字符串") - @NotBlank(message = "渠道配置不能为空") - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java deleted file mode 100644 index 59edf04e6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderRespVO; -import cn.iocoder.yudao.module.pay.convert.demo.PayDemoOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import cn.iocoder.yudao.module.pay.service.demo.PayDemoOrderService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 示例订单") -@RestController -@RequestMapping("/pay/demo-order") -@Validated -public class PayDemoOrderController { - - @Resource - private PayDemoOrderService payDemoOrderService; - - @PostMapping("/create") - @Operation(summary = "创建示例订单") - public CommonResult createDemoOrder(@Valid @RequestBody PayDemoOrderCreateReqVO createReqVO) { - return success(payDemoOrderService.createDemoOrder(getLoginUserId(), createReqVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得示例订单分页") - public CommonResult> getDemoOrderPage(@Valid PageParam pageVO) { - PageResult pageResult = payDemoOrderService.getDemoOrderPage(pageVO); - return success(PayDemoOrderConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新示例订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - public CommonResult updateDemoOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - payDemoOrderService.updateDemoOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @PutMapping("/refund") - @Operation(summary = "发起示例订单的退款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult refundDemoOrder(@RequestParam("id") Long id) { - payDemoOrderService.refundDemoOrder(id, getClientIP()); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新示例订单为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - public CommonResult updateDemoOrderRefunded(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - payDemoOrderService.updateDemoOrderRefunded(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayRefundId()); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java deleted file mode 100644 index e3411d40c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.service.demo.PayDemoTransferService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 示例转账单") -@RestController -@RequestMapping("/pay/demo-transfer") -@Validated -public class PayDemoTransferController { - @Resource - private PayDemoTransferService demoTransferService; - - @PostMapping("/create") - @Operation(summary = "创建示例转账订单") - public CommonResult createDemoOrder(@Valid @RequestBody PayDemoTransferCreateReqVO createReqVO) { - return success(demoTransferService.createDemoTransfer(getLoginUserId(), createReqVO)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderCreateReqVO.java deleted file mode 100644 index 9960ada48..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderCreateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 示例订单创建 Request VO") -@Data -public class PayDemoOrderCreateReqVO { - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17682") - @NotNull(message = "商品编号不能为空") - private Long spuId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderRespVO.java deleted file mode 100644 index 3404844dc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -/** -* 示例订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayDemoOrderRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23199") - private Long userId; - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17682") - private Long spuId; - - @Schema(description = "商家备注", example = "李四") - private String spuName; - - @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30381") - private Integer price; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "16863") - private Long payOrderId; - - @Schema(description = "订单支付时间") - private LocalDateTime payTime; - - @Schema(description = "支付渠道", example = "alipay_qr") - private String payChannelCode; - - @Schema(description = "支付退款编号", example = "23366") - private Long payRefundId; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "14039") - private Integer refundPrice; - - @Schema(description = "退款时间") - private LocalDateTime refundTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java deleted file mode 100644 index 41bafe676..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -/** - * @author jason - */ -@Schema(description = "管理后台 - 示例转账单创建 Request VO") -@Data -public class PayDemoTransferCreateReqVO { - - @Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - @NotNull(message = "转账金额不能为空") - @Min(value = 1, message = "转账金额必须大于零") - private Integer price; - - // TODO @jason:感觉这个动态字段,晚点改;可能要讨论下怎么搞好; - @Schema(description = "收款方信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "{'ALIPAY_LOGON_ID':'xxxx'}") - @NotEmpty(message = "收款方信息不能为空") - private Map payeeInfo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java deleted file mode 100644 index f74daa5fc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; -import cn.iocoder.yudao.module.pay.convert.notify.PayNotifyTaskConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.CHANNEL_NOT_FOUND; - -@Tag(name = "管理后台 - 回调通知") -@RestController -@RequestMapping("/pay/notify") -@Validated -@Slf4j -public class PayNotifyController { - - @Resource - private PayOrderService orderService; - @Resource - private PayRefundService refundService; - @Resource - private PayNotifyService notifyService; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @PostMapping(value = "/order/{channelId}") - @Operation(summary = "支付渠道的统一【支付】回调") - @PermitAll - public String notifyOrder(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { - log.info("[notifyOrder][channelId({}) 回调数据({}/{})]", channelId, params, body); - // 1. 校验支付渠道是否存在 - PayClient payClient = channelService.getPayClient(channelId); - if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); - throw exception(CHANNEL_NOT_FOUND); - } - - // 2. 解析通知数据 - PayOrderRespDTO notify = payClient.parseOrderNotify(params, body); - orderService.notifyOrder(channelId, notify); - return "success"; - } - - @PostMapping(value = "/refund/{channelId}") - @Operation(summary = "支付渠道的统一【退款】回调") - @PermitAll - public String notifyRefund(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { - log.info("[notifyRefund][channelId({}) 回调数据({}/{})]", channelId, params, body); - // 1. 校验支付渠道是否存在 - PayClient payClient = channelService.getPayClient(channelId); - if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); - throw exception(CHANNEL_NOT_FOUND); - } - - // 2. 解析通知数据 - PayRefundRespDTO notify = payClient.parseRefundNotify(params, body); - refundService.notifyRefund(channelId, notify); - return "success"; - } - - @GetMapping("/get-detail") - @Operation(summary = "获得回调通知的明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:notify:query')") - public CommonResult getNotifyTaskDetail(@RequestParam("id") Long id) { - PayNotifyTaskDO task = notifyService.getNotifyTask(id); - if (task == null) { - return success(null); - } - // 拼接返回 - PayAppDO app = appService.getApp(task.getAppId()); - List logs = notifyService.getNotifyLogList(id); - return success(PayNotifyTaskConvert.INSTANCE.convert(task, app, logs)); - } - - @GetMapping("/page") - @Operation(summary = "获得回调通知分页") - @PreAuthorize("@ss.hasPermission('pay:notify:query')") - public CommonResult> getNotifyTaskPage(@Valid PayNotifyTaskPageReqVO pageVO) { - PageResult pageResult = notifyService.getNotifyTaskPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 拼接返回 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayNotifyTaskDO::getAppId)); - return success(PayNotifyTaskConvert.INSTANCE.convertPage(pageResult, appMap)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java deleted file mode 100644 index 1e623751b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 回调通知 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayNotifyTaskBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10636") - private Long appId; - - @Schema(description = "通知类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Byte type; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6722") - private Long dataId; - - @Schema(description = "通知状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Byte status; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26697") - private String merchantOrderId; - - @Schema(description = "下一次通知时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime nextNotifyTime; - - @Schema(description = "最后一次执行时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime lastExecuteTime; - - @Schema(description = "当前通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte notifyTimes; - - @Schema(description = "最大可通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte maxNotifyTimes; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java deleted file mode 100644 index 7c75613e2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ - -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 回调通知的明细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskDetailRespVO extends PayNotifyTaskBaseVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - - @Schema(description = "回调日志列表") - private List logs; - - @Schema(description = "管理后台 - 回调日志") - @Data - public static class Log { - - @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8848") - private Long id; - - @Schema(description = "通知状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Byte status; - - @Schema(description = "当前通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte notifyTimes; - - @Schema(description = "HTTP 响应结果", requiredMode = Schema.RequiredMode.REQUIRED) - private String response; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java deleted file mode 100644 index 003d2fb33..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 回调通知分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "10636") - private Long appId; - - @Schema(description = "通知类型", example = "2") - private Integer type; - - @Schema(description = "数据编号", example = "6722") - private Long dataId; - - @Schema(description = "通知状态", example = "1") - private Integer status; - - @Schema(description = "商户订单编号", example = "26697") - private String merchantOrderId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java deleted file mode 100644 index d7f7fe6fb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 回调通知 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskRespVO extends PayNotifyTaskBaseVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java deleted file mode 100755 index 55e08ce1d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "管理后台 - 支付订单") -@RestController -@RequestMapping("/pay/order") -@Validated -public class PayOrderController { - - @Resource - private PayOrderService orderService; - @Resource - private PayAppService appService; - - @GetMapping("/get") - @Operation(summary = "获得支付订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult getOrder(@RequestParam("id") Long id) { - return success(PayOrderConvert.INSTANCE.convert(orderService.getOrder(id))); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得支付订单详情") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - PayOrderDO order = orderService.getOrder(id); - if (order == null) { - return success(null); - } - - // 拼接返回 - PayAppDO app = appService.getApp(order.getAppId()); - PayOrderExtensionDO orderExtension = orderService.getOrderExtension(order.getExtensionId()); - return success(PayOrderConvert.INSTANCE.convert(order, orderExtension, app)); - } - - @PostMapping("/submit") - @Operation(summary = "提交支付订单") - public CommonResult submitPayOrder(@RequestBody PayOrderSubmitReqVO reqVO) { - // 1. 钱包支付事,需要额外传 user_id 和 user_type - if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { - Map channelExtras = reqVO.getChannelExtras() == null ? - Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); - channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); - channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); - reqVO.setChannelExtras(channelExtras); - } - - // 2. 提交支付 - PayOrderSubmitRespVO respVO = orderService.submitOrder(reqVO, getClientIP()); - return success(respVO); - } - - @GetMapping("/page") - @Operation(summary = "获得支付订单分页") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult> getOrderPage(@Valid PayOrderPageReqVO pageVO) { - PageResult pageResult = orderService.getOrderPage(pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayOrderDO::getAppId)); - return success(PayOrderConvert.INSTANCE.convertPage(pageResult, appMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出支付订单 Excel") - @PreAuthorize("@ss.hasPermission('pay:order:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportOrderExcel(@Valid PayOrderExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = orderService.getOrderList(exportReqVO); - if (CollectionUtil.isEmpty(list)) { - ExcelUtils.write(response, "支付订单.xls", "数据", - PayOrderExcelVO.class, new ArrayList<>()); - return; - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(list, PayOrderDO::getAppId)); - List excelList = PayOrderConvert.INSTANCE.convertList(list, appMap); - // 导出 Excel - ExcelUtils.write(response, "支付订单.xls", "数据", PayOrderExcelVO.class, excelList); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java deleted file mode 100755 index 568f84459..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 支付订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author aquan - */ -@Data -public class PayOrderBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "渠道编号", example = "2048") - private Long channelId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - @NotNull(message = "商品标题不能为空") - private String subject; - - @Schema(description = "商品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是土豆") - @NotNull(message = "商品描述不能为空") - private String body; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/pay/notify") - @NotNull(message = "异步通知地址不能为空") - private String notifyUrl; - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "支付金额,单位:分不能为空") - private Long price; - - @Schema(description = "渠道手续费,单位:百分比", example = "10") - private Double channelFeeRate; - - @Schema(description = "渠道手续金额,单位:分", example = "100") - private Integer channelFeePrice; - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "支付状态不能为空") - private Integer status; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotNull(message = "用户 IP不能为空") - private String userIp; - - @Schema(description = "订单失效时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "订单失效时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime expireTime; - - @Schema(description = "订单支付成功时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime successTime; - - @Schema(description = "支付成功的订单拓展单编号", example = "50") - private Long extensionId; - - @Schema(description = "支付订单号", example = "2048888") - private String no; - - @Schema(description = "退款总金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "退款总金额,单位:分不能为空") - private Long refundPrice; - - @Schema(description = "渠道用户编号", example = "2048") - private String channelUserId; - - @Schema(description = "渠道订单号", example = "4096") - private String channelOrderNo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java deleted file mode 100644 index a4fe4632f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单详细信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderDetailsRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String appName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - /** - * 支付订单扩展 - */ - private PayOrderExtension extension; - - @Data - @Schema(description = "支付订单扩展") - public static class PayOrderExtension { - - @Schema(description = "支付订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String no; - - @Schema(description = "支付异步通知的内容") - private String channelNotifyData; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java deleted file mode 100755 index 5dc17a0f0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 支付订单 Excel VO - * - * @author aquan - */ -@Data -public class PayOrderExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty(value = "支付金额", converter = MoneyConvert.class) - private Integer price; - - @ExcelProperty(value = "退款金额", converter = MoneyConvert.class) - private Integer refundPrice; - - @ExcelProperty(value = "手续金额", converter = MoneyConvert.class) - private Integer channelFeePrice; - - @ExcelProperty("商户单号") - private String merchantOrderId; - - @ExcelProperty(value = "支付单号") - private String no; - - @ExcelProperty("渠道单号") - private String channelOrderNo; - - @ExcelProperty(value = "支付状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.ORDER_STATUS) - private Integer status; - - @ExcelProperty(value = "渠道编号名称", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CHANNEL_CODE) - private String channelCode; - - @ExcelProperty("订单支付成功时间") - private LocalDateTime successTime; - - @ExcelProperty("订单失效时间") - private LocalDateTime expireTime; - - @ExcelProperty(value = "应用名称") - private String appName; - - @ExcelProperty("商品标题") - private String subject; - - @ExcelProperty("商品描述") - private String body; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java deleted file mode 100755 index 9e4d20b91..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付订单 Excel 导出 Request VO,参数和 PayOrderPageReqVO 是一致的") -@Data -public class PayOrderExportReqVO { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", example = "4096") - private String merchantOrderId; - - @Schema(description = "渠道编号", example = "1888") - private String channelOrderNo; - - @Schema(description = "支付单号", example = "2014888") - private String no; - - @Schema(description = "支付状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java deleted file mode 100755 index 05411c913..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderPageItemRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java deleted file mode 100755 index f7ff801cb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", example = "4096") - private String merchantOrderId; - - @Schema(description = "渠道编号", example = "1888") - private String channelOrderNo; - - @Schema(description = "支付单号", example = "2014888") - private String no; - - @Schema(description = "支付状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java deleted file mode 100644 index d48a4db08..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java deleted file mode 100644 index ffda105b7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "管理后台 - 支付订单提交 Request VO") -@Data -public class PayOrderSubmitReqVO { - - @Schema(description = "支付单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "支付单编号不能为空") - private Long id; - - @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub") - @NotEmpty(message = "支付渠道不能为空") - private String channelCode; - - @Schema(description = "支付渠道的额外参数,例如说,微信公众号需要传递 openid 参数") - private Map channelExtras; - - @Schema(description = "展示模式", example = "url") // 参见 {@link PayDisplayModeEnum} 枚举。如果不传递,则每个支付渠道使用默认的方式 - private String displayMode; - - @Schema(description = "回跳地址") - @URL(message = "回跳地址的格式必须是 URL") - private String returnUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java deleted file mode 100644 index 8dcd9df2f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 支付订单提交 Response VO") -@Data -public class PayOrderSubmitRespVO { - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // 参见 PayOrderStatusEnum 枚举 - private Integer status; - - @Schema(description = "展示模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "url") // 参见 PayDisplayModeEnum 枚举 - private String displayMode; - @Schema(description = "展示内容", requiredMode = Schema.RequiredMode.REQUIRED) - private String displayContent; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java deleted file mode 100755 index 7dbef49be..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.*; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 退款订单") -@RestController -@RequestMapping("/pay/refund") -@Validated -public class PayRefundController { - - @Resource - private PayRefundService refundService; - @Resource - private PayAppService appService; - - @GetMapping("/get") - @Operation(summary = "获得退款订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:refund:query')") - public CommonResult getRefund(@RequestParam("id") Long id) { - PayRefundDO refund = refundService.getRefund(id); - if (refund == null) { - return success(new PayRefundDetailsRespVO()); - } - - // 拼接数据 - PayAppDO app = appService.getApp(refund.getAppId()); - return success(PayRefundConvert.INSTANCE.convert(refund, app)); - } - - @GetMapping("/page") - @Operation(summary = "获得退款订单分页") - @PreAuthorize("@ss.hasPermission('pay:refund:query')") - public CommonResult> getRefundPage(@Valid PayRefundPageReqVO pageVO) { - PageResult pageResult = refundService.getRefundPage(pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 处理应用ID数据 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayRefundDO::getAppId)); - return success(PayRefundConvert.INSTANCE.convertPage(pageResult, appMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出退款订单 Excel") - @PreAuthorize("@ss.hasPermission('pay:refund:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportRefundExcel(@Valid PayRefundExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = refundService.getRefundList(exportReqVO); - if (CollectionUtil.isEmpty(list)) { - ExcelUtils.write(response, "退款订单.xls", "数据", - PayRefundExcelVO.class, new ArrayList<>()); - return; - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(list, PayRefundDO::getAppId)); - List excelList = PayRefundConvert.INSTANCE.convertList(list, appMap); - // 导出 Excel - ExcelUtils.write(response, "退款订单.xls", "数据", PayRefundExcelVO.class, excelList); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java deleted file mode 100755 index 25cadf478..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** -* 退款订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayRefundBaseVO { - - @Schema(description = "外部退款号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110") - private String no; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long appId; - - @Schema(description = "渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long channelId; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_app") - private String channelCode; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "225") - private String merchantOrderId; - - @Schema(description = "商户退款订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private String merchantRefundId; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED) - private String notifyUrl; - - // ========== 退款相关字段 ========== - - @Schema(description = "退款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long payPrice; - - @Schema(description = "退款金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Long refundPrice; - - @Schema(description = "退款原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "我要退了") - private String reason; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - // ========== 渠道相关字段 ========== - - @Schema(description = "渠道订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "233") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "2022") - private String channelRefundNo; - - @Schema(description = "退款成功时间") - private LocalDateTime successTime; - - @Schema(description = "调用渠道的错误码") - private String channelErrorCode; - - @Schema(description = "调用渠道的错误提示") - private String channelErrorMsg; - - @Schema(description = "支付渠道的额外参数") - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java deleted file mode 100755 index 8f50a3a13..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 退款订单详情 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundDetailsRespVO extends PayRefundBaseVO { - - @Schema(description = "支付退款编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是芋艿") - private String appName; - - @Schema(description = "支付订单", requiredMode = Schema.RequiredMode.REQUIRED) - private Order order; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间") - private LocalDateTime updateTime; - - @Schema(description = "管理后台 - 支付订单") - @Data - public static class Order { - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - private String subject; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java deleted file mode 100755 index 758b6b6b0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 退款订单 Excel VO - * - * @author aquan - */ -@Data -public class PayRefundExcelVO { - - @ExcelProperty("支付退款编号") - private Long id; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty(value = "支付金额", converter = MoneyConvert.class) - private Integer payPrice; - - @ExcelProperty(value = "退款金额", converter = MoneyConvert.class) - private Integer refundPrice; - - @ExcelProperty("商户退款单号") - private String merchantRefundId; - @ExcelProperty("退款单号") - private String no; - @ExcelProperty("渠道退款单号") - private String channelRefundNo; - - @ExcelProperty("商户支付单号") - private String merchantOrderId; - @ExcelProperty("渠道支付单号") - private String channelOrderNo; - - @ExcelProperty(value = "退款状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.REFUND_STATUS) - private Integer status; - - @ExcelProperty(value = "退款渠道", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CHANNEL_CODE) - private String channelCode; - - @ExcelProperty("成功时间") - private LocalDateTime successTime; - - @ExcelProperty(value = "支付应用") - private String appName; - - @ExcelProperty("退款原因") - private String reason; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java deleted file mode 100755 index 645816ee2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 退款订单 Excel 导出 Request VO,参数和 PayRefundPageReqVO 是一致的") -@Data -public class PayRefundExportReqVO { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户支付单号", example = "10") - private String merchantOrderId; - - @Schema(description = "商户退款单号", example = "20") - private String merchantRefundId; - - @Schema(description = "渠道支付单号", example = "30") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "40") - private String channelRefundNo; - - @Schema(description = "退款状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java deleted file mode 100755 index 27c1285cc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 退款订单分页查询 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundPageItemRespVO extends PayRefundBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是芋艿") - private String appName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java deleted file mode 100755 index 7ff1530f0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 退款订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户支付单号", example = "10") - private String merchantOrderId; - - @Schema(description = "商户退款单号", example = "20") - private String merchantRefundId; - - @Schema(description = "渠道支付单号", example = "30") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "40") - private String channelRefundNo; - - @Schema(description = "退款状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java deleted file mode 100644 index 6d8592058..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitRespVO; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; - -@Tag(name = "管理后台 - 转账单") -@RestController -@RequestMapping("/pay/transfer") -@Validated -public class PayTransferController { - - @Resource - private PayTransferService payTransferService; - - @PostMapping("/submit") - @Operation(summary = "提交转账订单") - // TODO @jason:权限的设置, 管理后台页面加的时候加一下 - public CommonResult submitPayTransfer(@Valid @RequestBody PayTransferSubmitReqVO reqVO) { - PayTransferSubmitRespVO respVO = payTransferService.submitTransfer(reqVO, getClientIP()); - return success(respVO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitReqVO.java deleted file mode 100644 index 36e67ce01..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "管理后台 - 转账单提交 Request VO") -@Data -public class PayTransferSubmitReqVO { - - @Schema(description = "转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账单编号不能为空") - private Long id; - - @Schema(description = "转账渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_transfer") - @NotEmpty(message = "转账渠道不能为空") - private String channelCode; - - @Schema(description = "转账渠道的额外参数") - private Map channelExtras; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitRespVO.java deleted file mode 100644 index fef296f09..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitRespVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 转账单提交 Response VO") -@Data -public class PayTransferSubmitRespVO { - - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 PayTransferStatusEnum 枚举 - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java deleted file mode 100644 index 8fcb668ac..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - 用户钱包") -@RestController -@RequestMapping("/pay/wallet") -@Validated -@Slf4j -public class PayWalletController { - - @Resource - private PayWalletService payWalletService; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - @Operation(summary = "获得用户钱包明细") - public CommonResult getWallet(PayWalletUserReqVO reqVO) { - PayWalletDO wallet = payWalletService.getOrCreateWallet(reqVO.getUserId(), MEMBER.getValue()); - // TODO jason:如果为空,返回给前端只要 null 就可以了 - MemberUserRespDTO memberUser = memberUserApi.getUser(reqVO.getUserId()).getCheckedData(); - String nickname = memberUser == null ? "" : memberUser.getNickname(); - String avatar = memberUser == null ? "" : memberUser.getAvatar(); - return success(PayWalletConvert.INSTANCE.convert02(nickname, avatar, wallet)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员钱包分页") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - public CommonResult> getWalletPage(@Valid PayWalletPageReqVO pageVO) { - if (StrUtil.isNotEmpty(pageVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageVO.getNickname()).getCheckedData(); - pageVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // TODO @jason:管理员也可以先查询下。。 - // 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景 - PageResult pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - List users = memberUserApi.getUserList(convertList(pageResult.getList(), PayWalletDO::getUserId)).getCheckedData(); - Map userMap = convertMap(users, MemberUserRespDTO::getId); - return success(PayWalletConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java deleted file mode 100644 index 97942c319..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; - -@Tag(name = "管理后台 - 钱包充值") -@RestController -@RequestMapping("/pay/wallet-recharge") -@Validated -@Slf4j -public class PayWalletRechargeController { - - @Resource - private PayWalletRechargeService walletRechargeService; - - @PostMapping("/update-paid") - @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录, 内部校验实现 - public CommonResult updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - // TODO @jason:发起退款,要 post 操作哈; - @GetMapping("/refund") - @Operation(summary = "发起钱包充值退款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult refundWalletRecharge(@RequestParam("id") Long id) { - walletRechargeService.refundWalletRecharge(id, getClientIP()); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新钱包充值为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录, 内部校验实现 - public CommonResult updateWalletRechargeRefunded(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - walletRechargeService.updateWalletRechargeRefunded( - Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayRefundId()); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java deleted file mode 100644 index c60127fe7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargePackageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - 钱包充值套餐") -@RestController -@RequestMapping("/pay/wallet-recharge-package") -@Validated -public class PayWalletRechargePackageController { - - @Resource - private PayWalletRechargePackageService walletRechargePackageService; - - @PostMapping("/create") - @Operation(summary = "创建钱包充值套餐") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:create')") - public CommonResult createWalletRechargePackage(@Valid @RequestBody WalletRechargePackageCreateReqVO createReqVO) { - return success(walletRechargePackageService.createWalletRechargePackage(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新钱包充值套餐") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:update')") - public CommonResult updateWalletRechargePackage(@Valid @RequestBody WalletRechargePackageUpdateReqVO updateReqVO) { - walletRechargePackageService.updateWalletRechargePackage(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除钱包充值套餐") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:delete')") - public CommonResult deleteWalletRechargePackage(@RequestParam("id") Long id) { - walletRechargePackageService.deleteWalletRechargePackage(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得钱包充值套餐") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") - public CommonResult getWalletRechargePackage(@RequestParam("id") Long id) { - PayWalletRechargePackageDO walletRechargePackage = walletRechargePackageService.getWalletRechargePackage(id); - return success(WalletRechargePackageConvert.INSTANCE.convert(walletRechargePackage)); - } - - @GetMapping("/page") - @Operation(summary = "获得钱包充值套餐分页") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") - public CommonResult> getWalletRechargePackagePage(@Valid WalletRechargePackagePageReqVO pageVO) { - PageResult pageResult = walletRechargePackageService.getWalletRechargePackagePage(pageVO); - return success(WalletRechargePackageConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java deleted file mode 100644 index 37dd51642..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 钱包余额明细") -@RestController -@RequestMapping("/pay/wallet-transaction") -@Validated -@Slf4j -public class PayWalletTransactionController { - - @Resource - private PayWalletTransactionService payWalletTransactionService; - - @GetMapping("/page") - @Operation(summary = "获得钱包流水分页") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - public CommonResult> getWalletTransactionPage( - @Valid PayWalletTransactionPageReqVO pageReqVO) { - PageResult result = payWalletTransactionService.getWalletTransactionPage(pageReqVO); - return success(PayWalletTransactionConvert.INSTANCE.convertPage2(result)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java deleted file mode 100644 index c3f58e1da..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 充值套餐 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class WalletRechargePackageBaseVO { - - @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "套餐名不能为空") - private String name; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "16454") - @NotNull(message = "支付金额不能为空") - private Integer payPrice; - - @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20887") - @NotNull(message = "赠送金额不能为空") - private Integer bonusPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Byte status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java deleted file mode 100644 index 4232a9983..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 充值套餐创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageCreateReqVO extends WalletRechargePackageBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java deleted file mode 100644 index 346e85902..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 充值套餐分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackagePageReqVO extends PageParam { - - @Schema(description = "套餐名", example = "李四") - private String name; - - @Schema(description = "状态", example = "2") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java deleted file mode 100644 index e709cfdd3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 充值套餐 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageRespVO extends WalletRechargePackageBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9032") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java deleted file mode 100644 index 37170cb8b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 充值套餐更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageUpdateReqVO extends WalletRechargePackageBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9032") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java deleted file mode 100644 index 678649ce0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 钱包流水分页 Request VO") -@Data -public class PayWalletTransactionPageReqVO extends PageParam { - - @Schema(description = "钱包编号", example = "1") - private Long walletId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java deleted file mode 100644 index 6203b78d5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 钱包流水分页 Response VO") -@Data -public class PayWalletTransactionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Long walletId; - - @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long price; - - @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") - private String title; - - @Schema(description = "交易后的余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long balance; - - @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // TODO @jason:merchantOrderId 字段,需要在 PayWalletTransaction 存储下;然后,前端也返回下这个字段,界面也展示下商户名 - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java deleted file mode 100644 index a45ea8b90..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 用户钱包 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayWalletBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20020") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户类型不能为空") - private Integer userType; - - @Schema(description = "余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "余额,单位分不能为空") - private Integer balance; - - @Schema(description = "累计支出,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "累计支出,单位分不能为空") - private Integer totalExpense; - - @Schema(description = "累计充值,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "累计充值,单位分不能为空") - private Integer totalRecharge; - - @Schema(description = "冻结金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "20737") - @NotNull(message = "冻结金额,单位分不能为空") - private Integer freezePrice; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java deleted file mode 100644 index d74bd44b1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员钱包分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayWalletPageReqVO extends PageParam { - - @Schema(description = "用户昵称", example = "李四") - private String nickname; - - @Schema(description = "用户编号", example = "[1,2]") - private Collection userIds; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java deleted file mode 100644 index a9eedbdfd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户钱包 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayWalletRespVO extends PayWalletBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29528") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java deleted file mode 100644 index dfa335166..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户钱包明细 Request VO") -@Data -public class PayWalletUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java deleted file mode 100644 index 12323a7d5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.channel; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "用户 App - 支付渠道") -@RestController -@RequestMapping("/pay/channel") -@Validated -public class AppPayChannelController { - - @Resource - private PayChannelService channelService; - - @GetMapping("/get-enable-code-list") - @Operation(summary = "获得指定应用的开启的支付渠道编码列表") - @Parameter(name = "appId", description = "应用编号", required = true, example = "1") - public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { - List channels = channelService.getEnableChannelList(appId); - return success(convertSet(channels, PayChannelDO::getCode)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http deleted file mode 100644 index 14ce54ef9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http +++ /dev/null @@ -1,63 +0,0 @@ -### /pay/create 提交支付订单【alipay_pc】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 174, - "channelCode": "alipay_pc" -} - -### /pay/create 提交支付订单【wx_bar】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_bar", - "channelExtras": { - "authCode": "134042110834344848" - } -} - -### /pay/create 提交支付订单【wx_pub】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_pub", - "channelExtras": { - "openid": "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" - } -} - -### /pay/create 提交支付订单【wx_lite】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_lite", - "channelExtras": { - "openid": "oLefc4g5GjKWHJjLjMSXB3wX0fD0" - } -} - -### /pay/create 提交支付订单【wx_native】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_native" -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java deleted file mode 100644 index 8033b26b0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "用户 APP - 支付订单") -@RestController -@RequestMapping("/pay/order") -@Validated -@Slf4j -public class AppPayOrderController { - - @Resource - private PayOrderService payOrderService; - - // TODO 芋艿:临时 demo,技术打样。 - @GetMapping("/get") - @Operation(summary = "获得支付订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getOrder(@RequestParam("id") Long id) { - return success(PayOrderConvert.INSTANCE.convert(payOrderService.getOrder(id))); - } - - @PostMapping("/submit") - @Operation(summary = "提交支付订单") - public CommonResult submitPayOrder(@RequestBody AppPayOrderSubmitReqVO reqVO) { - // 1. 钱包支付事,需要额外传 user_id 和 user_type - if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { - Map channelExtras = reqVO.getChannelExtras() == null ? - Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); - channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); - channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); - reqVO.setChannelExtras(channelExtras); - } - - // 2. 提交支付 - PayOrderSubmitRespVO respVO = payOrderService.submitOrder(reqVO, getClientIP()); - return success(PayOrderConvert.INSTANCE.convert3(respVO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java deleted file mode 100644 index 8f18c6cec..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order.vo; - -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "用户 APP - 支付订单提交 Request VO") -@Data -public class AppPayOrderSubmitReqVO extends PayOrderSubmitReqVO { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java deleted file mode 100644 index 106535efd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order.vo; - -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Schema(description = "用户 APP - 支付订单提交 Response VO") -@Data -public class AppPayOrderSubmitRespVO extends PayOrderSubmitRespVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java deleted file mode 100644 index ee2004e1a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占个位置,没啥用 - */ -package cn.iocoder.yudao.module.pay.controller.app.refund; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java deleted file mode 100644 index 95c085cbc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * @author jason - */ -@Tag(name = "用户 APP - 钱包") -@RestController -@RequestMapping("/pay/wallet") -@Validated -@Slf4j -public class AppPayWalletController { - - @Resource - private PayWalletService payWalletService; - - @GetMapping("/get") - @Operation(summary = "获取钱包") - @PreAuthenticated - public CommonResult getPayWallet() { - PayWalletDO wallet = payWalletService.getOrCreateWallet(getLoginUserId(), UserTypeEnum.MEMBER.getValue()); - return success(PayWalletConvert.INSTANCE.convert(wallet)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java deleted file mode 100644 index 5f0a64286..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "用户 APP - 钱包充值") -@RestController -@RequestMapping("/pay/wallet-recharge") -@Validated -@Slf4j -public class AppPayWalletRechargeController { - - @Resource - private PayWalletRechargeService walletRechargeService; - - @PostMapping("/create") - @Operation(summary = "创建钱包充值记录(发起充值)") - public CommonResult createWalletRecharge( - @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { - PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge( - getLoginUserId(), getLoginUserType(), getClientIP(), reqVO); - return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java deleted file mode 100644 index 9b2aac188..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 钱包充值套餐") -@RestController -@RequestMapping("/pay/wallet-recharge-package") -@Validated -@Slf4j -public class AppPayWalletRechargePackageController { - - @GetMapping("/list") - @Operation(summary = "获得钱包充值套餐列表") - public CommonResult> getWalletRechargePackageList() { - // 只查询开启;需要按照 payPrice 排序; - List list = new ArrayList<>(); - list.add(new AppPayWalletPackageRespVO().setId(1L).setName("土豆").setPayPrice(10).setBonusPrice(2)); - list.add(new AppPayWalletPackageRespVO().setId(2L).setName("番茄").setPayPrice(20).setBonusPrice(5)); - return success(list); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java deleted file mode 100644 index db0c7844d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 钱包余额明细") -@RestController -@RequestMapping("/pay/wallet-transaction") -@Validated -@Slf4j -public class AppPayWalletTransactionController { - - @Resource - private PayWalletTransactionService payWalletTransactionService; - - @GetMapping("/page") - @Operation(summary = "获得钱包流水分页") - public CommonResult> getWalletTransactionPage( - @Valid AppPayWalletTransactionPageReqVO pageReqVO) { - if (true) { - PageResult result = new PageResult<>(10L); - result.getList().add(new AppPayWalletTransactionRespVO().setPrice(1L) - .setTitle("测试").setCreateTime(LocalDateTime.now())); - result.getList().add(new AppPayWalletTransactionRespVO().setPrice(-1L) - .setTitle("测试2").setCreateTime(LocalDateTime.now())); - return success(result); - } - PageResult result = payWalletTransactionService.getWalletTransactionPage(getLoginUserId(), - UserTypeEnum.MEMBER.getValue(), pageReqVO); - return success(PayWalletTransactionConvert.INSTANCE.convertPage(result)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java deleted file mode 100644 index c12db9889..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 用户充值套餐 Response VO") -@Data -public class AppPayWalletPackageRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小套餐") - private String name; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer payPrice; - @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer bonusPrice; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java deleted file mode 100644 index 1421fb0b5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import java.util.Objects; - -@Schema(description = "用户 APP - 创建钱包充值 Request VO") -@Data -public class AppPayWalletRechargeCreateReqVO { - - @Schema(description = "支付金额", example = "1000") - @Min(value = 1, message = "支付金额必须大于零") - private Integer payPrice; - - @Schema(description = "充值套餐编号", example = "1024") - private Long packageId; - - @AssertTrue(message = "充值金额和充钱套餐不能同时为空") - public boolean validatePayPriceAndPackageId() { - return Objects.nonNull(payPrice) || Objects.nonNull(packageId); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java deleted file mode 100644 index 2c4a96f62..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 创建钱包充值 Resp VO") -@Data -public class AppPayWalletRechargeCreateRespVO { - - @Schema(description = "钱包充值编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long payOrderId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java deleted file mode 100644 index 942ab5b6d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 钱包流水分页 Request VO") -@Data -public class AppPayWalletTransactionPageReqVO extends PageParam { - - /** - * 类型 - 收入 - */ - public static final Integer TYPE_INCOME = 1; - /** - * 类型 - 支出 - */ - public static final Integer TYPE_EXPENSE = 2; - - @Schema(description = "类型", example = "1") - private Integer type; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java deleted file mode 100644 index 5c20188eb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 钱包流水分页 Response VO") -@Data -public class AppPayWalletTransactionRespVO { - - @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long price; - - @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") - private String title; - - @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java deleted file mode 100644 index f0c78e405..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 用户钱包 Response VO") -@Data -public class AppPayWalletRespVO { - - @Schema(description = "钱包余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer balance; - - @Schema(description = "累计支出, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalExpense; - - @Schema(description = "累计充值, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer totalRecharge; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java deleted file mode 100644 index 652122752..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.pay.controller; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java deleted file mode 100644 index 4853d07f7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.app; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageItemRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -/** - * 支付应用信息 Convert - * - * @author 芋艿 - */ -@Mapper -public interface PayAppConvert { - - PayAppConvert INSTANCE = Mappers.getMapper(PayAppConvert.class); - - PayAppPageItemRespVO pageConvert (PayAppDO bean); - - PayAppDO convert(PayAppCreateReqVO bean); - - PayAppDO convert(PayAppUpdateReqVO bean); - - PayAppRespVO convert(PayAppDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, List channels) { - PageResult voPageResult = convertPage(pageResult); - // 处理 channel 关系 - Map> appIdChannelMap = CollectionUtils.convertMultiMap2(channels, PayChannelDO::getAppId, PayChannelDO::getCode); - voPageResult.getList().forEach(app -> app.setChannelCodes(appIdChannelMap.get(app.getId()))); - return voPageResult; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java deleted file mode 100644 index 5baf598fd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.channel; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayChannelConvert { - - PayChannelConvert INSTANCE = Mappers.getMapper(PayChannelConvert.class); - - @Mapping(target = "config",ignore = true) - PayChannelDO convert(PayChannelCreateReqVO bean); - - @Mapping(target = "config",ignore = true) - PayChannelDO convert(PayChannelUpdateReqVO bean); - - @Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))") - PayChannelRespVO convert(PayChannelDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java deleted file mode 100644 index 313e5d266..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 示例订单 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PayDemoOrderConvert { - - PayDemoOrderConvert INSTANCE = Mappers.getMapper(PayDemoOrderConvert.class); - - PayDemoOrderDO convert(PayDemoOrderCreateReqVO bean); - - PayDemoOrderRespVO convert(PayDemoOrderDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java deleted file mode 100644 index d0b8e36ff..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 支付通知 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PayNotifyTaskConvert { - - PayNotifyTaskConvert INSTANCE = Mappers.getMapper(PayNotifyTaskConvert.class); - - PayNotifyTaskRespVO convert(PayNotifyTaskDO bean); - - default PageResult convertPage(PageResult page, Map appMap){ - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - default PayNotifyTaskDetailRespVO convert(PayNotifyTaskDO task, PayAppDO app, List logs) { - PayNotifyTaskDetailRespVO respVO = convert(task, logs); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayNotifyTaskDetailRespVO convert(PayNotifyTaskDO task, List logs); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java deleted file mode 100755 index 682006041..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 支付订单 Convert - * - * @author aquan - */ -@Mapper -public interface PayOrderConvert { - - PayOrderConvert INSTANCE = Mappers.getMapper(PayOrderConvert.class); - - PayOrderRespVO convert(PayOrderDO bean); - - PayOrderRespDTO convert2(PayOrderDO order); - - default PayOrderDetailsRespVO convert(PayOrderDO order, PayOrderExtensionDO orderExtension, PayAppDO app) { - PayOrderDetailsRespVO respVO = convertDetail(order); - respVO.setExtension(convert(orderExtension)); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayOrderDetailsRespVO convertDetail(PayOrderDO bean); - PayOrderDetailsRespVO.PayOrderExtension convert(PayOrderExtensionDO bean); - - default PageResult convertPage(PageResult page, Map appMap) { - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - default List convertList(List list, Map appMap) { - return CollectionUtils.convertList(list, order -> { - PayOrderExcelVO excelVO = convertExcel(order); - MapUtils.findAndThen(appMap, order.getAppId(), app -> excelVO.setAppName(app.getName())); - return excelVO; - }); - } - PayOrderExcelVO convertExcel(PayOrderDO bean); - - PayOrderDO convert(PayOrderCreateReqDTO bean); - - @Mapping(target = "id", ignore = true) - PayOrderExtensionDO convert(PayOrderSubmitReqVO bean, String userIp); - - PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO, String userIp); - - @Mapping(source = "order.status", target = "status") - PayOrderSubmitRespVO convert(PayOrderDO order, cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO respDTO); - - AppPayOrderSubmitRespVO convert3(PayOrderSubmitRespVO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java deleted file mode 100644 index df43d5ac3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.pay.convert; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java deleted file mode 100755 index 9f087f702..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundDetailsRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExcelVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageItemRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface PayRefundConvert { - - PayRefundConvert INSTANCE = Mappers.getMapper(PayRefundConvert.class); - - - default PayRefundDetailsRespVO convert(PayRefundDO refund, PayAppDO app) { - PayRefundDetailsRespVO respVO = convert(refund); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayRefundDetailsRespVO convert(PayRefundDO bean); - PayRefundDetailsRespVO.Order convert(PayOrderDO bean); - - default PageResult convertPage(PageResult page, Map appMap) { - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - PayRefundDO convert(PayRefundCreateReqDTO bean); - - PayRefundRespDTO convert02(PayRefundDO bean); - - default List convertList(List list, Map appMap) { - return CollectionUtils.convertList(list, order -> { - PayRefundExcelVO excelVO = convertExcel(order); - MapUtils.findAndThen(appMap, order.getAppId(), app -> excelVO.setAppName(app.getName())); - return excelVO; - }); - } - PayRefundExcelVO convertExcel(PayRefundDO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java deleted file mode 100644 index 440f0103b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.transfer; - -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayTransferConvert { - - PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class); - - @Mapping(source = "title", target = "subject") // TODO @jason:是不是都改成 subject 完事呀? - PayTransferDO convert(PayTransferCreateReqDTO dto); - - PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java deleted file mode 100644 index e162b88bc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Map; - -@Mapper -public interface PayWalletConvert { - - PayWalletConvert INSTANCE = Mappers.getMapper(PayWalletConvert.class); - - AppPayWalletRespVO convert(PayWalletDO bean); - - PayWalletRespVO convert02(String nickname,String avatar, PayWalletDO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, Map userMap){ - PageResult pageResult = convertPage(page); - pageResult.getList().forEach( wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(), - user -> { - // TODO @jason:可以链式调用哈; - wallet.setNickname(user.getNickname()); - wallet.setAvatar(user.getAvatar()); - })); - return pageResult; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java deleted file mode 100644 index eda8bcf95..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayWalletRechargeConvert { - - PayWalletRechargeConvert INSTANCE = Mappers.getMapper(PayWalletRechargeConvert.class); - - @Mapping(target = "totalPrice", expression = "java( payPrice + bonusPrice)") - PayWalletRechargeDO convert(Long walletId, Integer payPrice, Integer bonusPrice, Long packageId); - - AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java deleted file mode 100644 index f956f8d56..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayWalletTransactionConvert { - - PayWalletTransactionConvert INSTANCE = Mappers.getMapper(PayWalletTransactionConvert.class); - - PageResult convertPage(PageResult page); - - PageResult convertPage2(PageResult page); - - PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java deleted file mode 100644 index 8784adda7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface WalletRechargePackageConvert { - - WalletRechargePackageConvert INSTANCE = Mappers.getMapper(WalletRechargePackageConvert.class); - - PayWalletRechargePackageDO convert(WalletRechargePackageCreateReqVO bean); - - PayWalletRechargePackageDO convert(WalletRechargePackageUpdateReqVO bean); - - WalletRechargePackageRespVO convert(PayWalletRechargePackageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git "a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" "b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" deleted file mode 100644 index 8153487b7..000000000 --- "a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/\343\200\212\350\212\213\351\201\223 Spring Boot \345\257\271\350\261\241\350\275\254\346\215\242 MapStruct \345\205\245\351\227\250\343\200\213.md" +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java deleted file mode 100644 index 977eff93a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.app; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 支付应用 DO - * 一个商户下,可能会有多个支付应用。例如说,京东有京东商城、京东到家等等 - * 不过一般来说,一个商户,只有一个应用哈~ - * - * 即 PayMerchantDO : PayAppDO = 1 : n - * - * @author 芋道源码 - */ -@TableName("pay_app") -@KeySequence("pay_app_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayAppDO extends BaseDO { - - /** - * 应用编号,数据库自增 - */ - @TableId - private Long id; - /** - * 应用名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 支付结果的回调地址 - */ - private String orderNotifyUrl; - /** - * 退款结果的回调地址 - */ - private String refundNotifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java deleted file mode 100644 index 72387eb1c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.channel; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -/** - * 支付渠道 DO - * 一个应用下,会有多种支付渠道,例如说微信支付、支付宝支付等等 - * - * 即 PayAppDO : PayChannelDO = 1 : n - * - * @author 芋道源码 - */ -@TableName(value = "pay_channel", autoResultMap = true) -@KeySequence("pay_channel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayChannelDO extends TenantBaseDO { - - /** - * 渠道编号,数据库自增 - */ - private Long id; - /** - * 渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String code; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 渠道费率,单位:百分比 - */ - private Double feeRate; - /** - * 备注 - */ - private String remark; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 支付渠道配置 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private PayClientConfig config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java deleted file mode 100644 index a22f7c1b8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.demo; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 示例订单 - * - * 演示业务系统的订单,如何接入 pay 系统的支付与退款 - * - * @author 芋道源码 - */ -@TableName("pay_demo_order") -@KeySequence("pay_demo_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayDemoOrderDO extends BaseDO { - - /** - * 订单编号,自增 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 商品编号 - */ - private Long spuId; - /** - * 商品名称 - */ - private String spuName; - /** - * 价格,单位:分 - */ - private Integer price; - - // ========== 支付相关字段 ========== - - /** - * 是否支付 - */ - private Boolean payStatus; - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - // ========== 退款相关字段 ========== - /** - * 支付退款单号 - */ - private Long payRefundId; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - /** - * 退款完成时间 - */ - private LocalDateTime refundTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java deleted file mode 100644 index b036c30a2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.demo; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 示例转账订单 - * - * 演示业务系统的转账业务 - */ -@TableName(value ="pay_demo_transfer", autoResultMap = true) -@KeySequence("pay_demo_transfer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayDemoTransferDO extends BaseDO { - - /** - * 订单编号 - */ - @TableId - private Long id; - - /** - * 用户编号 - */ - private Long userId; - - /** - * 转账金额,单位:分 - */ - private Integer price; - - /** - * 转账类型 - */ - private Integer type; - - // TODO @jason:要不字段还是弄成正确的平铺开? - /** - * 收款人信息,不同类型和渠道不同 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map payeeInfo; - - /** - * 转账状态 - */ - private Integer transferStatus; - - /** - * 转账订单编号 - */ - private Long payTransferId; - - /** - * 转账支付成功渠道 - */ - private String payChannelCode; - - /** - * 转账支付时间 - */ - private LocalDateTime transferTime; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java deleted file mode 100644 index a482605d5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.notify; - -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商户支付、退款等的通知 Log - * 每次通知时,都会在该表中,记录一次 Log,方便排查问题 - * - * @author 芋道源码 - */ -@TableName("pay_notify_log") -@KeySequence("pay_notify_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayNotifyLogDO extends BaseDO { - - /** - * 日志编号,自增 - */ - private Long id; - /** - * 通知任务编号 - * - * 关联 {@link PayNotifyTaskDO#getId()} - */ - private Long taskId; - /** - * 第几次被通知 - * - * 对应到 {@link PayNotifyTaskDO#getNotifyTimes()} - */ - private Integer notifyTimes; - /** - * HTTP 响应结果 - */ - private String response; - /** - * 支付通知状态 - * - * 外键 {@link PayNotifyStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java deleted file mode 100644 index 181a32802..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.notify; - -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; - -/** - * 支付通知 - * 在支付系统收到支付渠道的支付、退款的结果后,需要不断的通知到业务系统,直到成功。 - * - * @author 芋道源码 - */ -@TableName("pay_notify_task") -@KeySequence("pay_notify_task_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class PayNotifyTaskDO extends TenantBaseDO { - - /** - * 通知频率,单位为秒。 - * - * 算上首次的通知,实际是一共 1 + 8 = 9 次。 - */ - public static final Integer[] NOTIFY_FREQUENCY = new Integer[]{ - 15, 15, 30, 180, - 1800, 1800, 1800, 3600 - }; - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 通知类型 - * - * 外键 {@link PayNotifyTypeEnum} - */ - private Integer type; - /** - * 数据编号,根据不同 type 进行关联: - * - * 1. {@link PayNotifyTypeEnum#ORDER} 时,关联 {@link PayOrderDO#getId()} - * 2. {@link PayNotifyTypeEnum#REFUND} 时,关联 {@link PayRefundDO#getId()} - */ - private Long dataId; - /** - * 商户订单编号 - */ - private String merchantOrderId; - /** - * 通知状态 - * - * 外键 {@link PayNotifyStatusEnum} - */ - private Integer status; - /** - * 下一次通知时间 - */ - private LocalDateTime nextNotifyTime; - /** - * 最后一次执行时间 - */ - private LocalDateTime lastExecuteTime; - /** - * 当前通知次数 - */ - private Integer notifyTimes; - /** - * 最大可通知次数 - */ - private Integer maxNotifyTimes; - /** - * 通知地址 - */ - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java deleted file mode 100644 index a51b875fd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.order; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 支付订单 DO - * - * @author 芋道源码 - */ -@TableName("pay_order") -@KeySequence("pay_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderDO extends BaseDO { - - /** - * 订单编号,数据库自增 - */ - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - - // ========== 商户相关字段 ========== - - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - /** - * 商品标题 - */ - private String subject; - /** - * 商品描述信息 - */ - private String body; - /** - * 异步通知地址 - */ - private String notifyUrl; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - private Integer price; - /** - * 渠道手续费,单位:百分比 - * - * 冗余 {@link PayChannelDO#getFeeRate()} - */ - private Double channelFeeRate; - /** - * 渠道手续金额,单位:分 - */ - private Integer channelFeePrice; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - /** - * 用户 IP - */ - private String userIp; - /** - * 订单失效时间 - */ - private LocalDateTime expireTime; - /** - * 订单支付成功时间 - */ - private LocalDateTime successTime; - /** - * 支付成功的订单拓展单编号 - * - * 关联 {@link PayOrderExtensionDO#getId()} - */ - private Long extensionId; - /** - * 支付成功的外部订单号 - * - * 关联 {@link PayOrderExtensionDO#getNo()} - */ - private String no; - - // ========== 退款相关字段 ========== - /** - * 退款总金额,单位:分 - */ - private Integer refundPrice; - - // ========== 渠道相关字段 ========== - /** - * 渠道用户编号 - * - * 例如说,微信 openid、支付宝账号 - */ - private String channelUserId; - /** - * 渠道订单号 - */ - private String channelOrderNo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java deleted file mode 100644 index 9466243e1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.order; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.Map; - -/** - * 支付订单拓展 DO - * - * 每次调用支付渠道,都会生成一条对应记录 - * - * @author 芋道源码 - */ -@TableName(value = "pay_order_extension",autoResultMap = true) -@KeySequence("pay_order_extension_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderExtensionDO extends BaseDO { - - /** - * 订单拓展编号,数据库自增 - */ - private Long id; - /** - * 外部订单号,根据规则生成 - * - * 调用支付渠道时,使用该字段作为对接的订单号: - * 1. 微信支付:对应 JSAPI 支付 的 out_trade_no 字段 - * 2. 支付宝支付:对应 电脑网站支付 的 out_trade_no 字段 - * - * 例如说,P202110132239124200055 - */ - private String no; - /** - * 订单号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long orderId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 渠道编码 - */ - private String channelCode; - /** - * 用户 IP - */ - private String userIp; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - /** - * 支付渠道的额外参数 - * - * 参见 参数说明 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map channelExtras; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - /** - * 支付渠道的同步/异步通知的内容 - * - * 对应 {@link PayOrderRespDTO#getRawData()} - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java deleted file mode 100644 index 5d9c612a3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.refund; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 支付退款单 DO - * 一个支付订单,可以拥有多个支付退款单 - * - * 即 PayOrderDO : PayRefundDO = 1 : n - * - * @author 芋道源码 - */ -@TableName("pay_refund") -@KeySequence("pay_refund_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayRefundDO extends BaseDO { - - /** - * 退款单编号,数据库自增 - */ - @TableId - private Long id; - /** - * 外部退款号,根据规则生成 - * - * 调用支付渠道时,使用该字段作为对接的退款号: - * 1. 微信退款:对应 申请退款 的 out_refund_no 字段 - * 2. 支付宝退款:对应 的 out_request_no 字段 - */ - private String no; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 商户编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - /** - * 订单编号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long orderId; - /** - * 支付订单编号 - * - * 冗余 {@link PayOrderDO#getNo()} - */ - private String orderNo; - - // ========== 商户相关字段 ========== - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - /** - * 商户退款订单号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantRefundId; - /** - * 异步通知地址 - */ - private String notifyUrl; - - // ========== 退款相关字段 ========== - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer status; - - /** - * 支付金额,单位:分 - */ - private Integer payPrice; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - - /** - * 退款原因 - */ - private String reason; - - /** - * 用户 IP - */ - private String userIp; - - // ========== 渠道相关字段 ========== - /** - * 渠道订单号 - * - * 冗余 {@link PayOrderDO#getChannelOrderNo()} - */ - private String channelOrderNo; - /** - * 渠道退款单号 - * - * 1. 微信退款:对应 申请退款 的 refund_id 字段 - * 2. 支付宝退款:没有字段 - */ - private String channelRefundNo; - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道的错误提示 - */ - private String channelErrorMsg; - - /** - * 支付渠道的同步/异步通知的内容 - * - * 对应 {@link PayRefundRespDTO#getRawData()} - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java deleted file mode 100644 index 507157a7a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 转账单 DO - * - * @author jason - */ -@TableName(value ="pay_transfer", autoResultMap = true) -@KeySequence("pay_transfer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayTransferDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 转账渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 转账渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - /** - * 类型 - * - * 枚举 {@link PayTransferTypeEnum} - */ - private Integer type; - - // ========== 商户相关字段 ========== - - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - - /** - * 转账标题 - */ - private String subject; - - // ========== 转账相关字段 ========== - /** - * 转账金额,单位:分 - */ - private Integer price; - /** - * 转账状态 - * - * 枚举 {@link PayTransferStatusRespEnum} - */ - private Integer status; - /** - * 订单转账成功时间 - */ - private LocalDateTime successTime; - /** - * 转账成功的转账拓展单编号 - * - * 关联 {@link PayTransferExtensionDO#getId()} - */ - private Long extensionId; - /** - * 转账成功的转账拓展单号 - * - * 关联 {@link PayTransferExtensionDO#getNo()} - */ - private String no; - /** - * 收款人信息,不同类型和渠道不同 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map payeeInfo; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java deleted file mode 100644 index c3d4253e8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.util.Map; - -// TODO @jason:转账是不是类似 refund,不用拓展单呀?支付做拓展单的原因,是因为它存在不确定性,可以切换多种;转账和退款,都是明确方式的; -// @芋艿 转账是不是也存在多种方式。 例如转账到银行卡。 可以使用微信,也可以使用支付宝。 支付宝账号余额不够,可以切换到微信; -// TODO @jason:发起了,就不允许调整了,类似退款哈; -/** - * 转账拓展单 DO - * - * @author jason - */ -@TableName(value ="pay_transfer_extension",autoResultMap = true) -@KeySequence("pay_transfer_extension_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayTransferExtensionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 转账单号 - */ - private String no; - - /** - * 转账单编号 - */ - private Long transferId; - - /** - * 转账渠道编号 - */ - private Long channelId; - - /** - * 转账渠道编码 - */ - private String channelCode; - - /** - * 支付渠道的额外参数 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map channelExtras; - - /** - * 转账状态 - */ - private Integer status; - - /** - * 支付渠道异步通知的内容 - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java deleted file mode 100644 index a3c54c969..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包 DO - * - * @author jason - */ -@TableName(value ="pay_wallet") -@KeySequence("pay_wallet_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 用户 id - * - * 关联 MemberUserDO 的 id 编号 - * 关联 AdminUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户类型, 预留 多商户转帐可能需要用到 - * - * 关联 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 余额,单位分 - */ - private Integer balance; - - /** - * 冻结金额,单位分 - */ - private Integer freezePrice; - - /** - * 累计支出,单位分 - */ - private Integer totalExpense; - /** - * 累计充值,单位分 - */ - private Integer totalRecharge; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java deleted file mode 100644 index a842c95e6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 会员钱包充值 - */ -@TableName(value ="pay_wallet_recharge") -@KeySequence("pay_wallet_recharge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletRechargeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 钱包编号 - * - * 关联 {@link PayWalletDO#getId()} - */ - private Long walletId; - - /** - * 用户实际到账余额 - * - * 例如充 100 送 20,则该值是 120 - */ - private Integer totalPrice; - /** - * 实际支付金额 - */ - private Integer payPrice; - /** - * 钱包赠送金额 - */ - private Integer bonusPrice; - - /** - * 充值套餐编号 - * - * 关联 {@link PayWalletRechargeDO#getPackageId()} 字段 - */ - private Long packageId; - - /** - * 是否已支付 - * - * true - 已支付 - * false - 未支付 - */ - private Boolean payStatus; - - /** - * 支付订单编号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long payOrderId; - - /** - * 支付成功的支付渠道 - * - * 冗余 {@link PayOrderDO#getChannelCode()} - */ - private String payChannelCode; - /** - * 订单支付时间 - */ - private LocalDateTime payTime; - - /** - * 支付退款单编号 - * - * 关联 {@link PayRefundDO#getId()} - */ - private Long payRefundId; - - /** - * 退款金额,包含赠送金额 - */ - private Integer refundTotalPrice; - /** - * 退款支付金额 - */ - private Integer refundPayPrice; - - /** - * 退款钱包赠送金额 - */ - private Integer refundBonusPrice; - - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer refundStatus; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java deleted file mode 100644 index 72fc43d96..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包充值套餐 DO - * - * 通过充值套餐时,可以赠送一定金额; - * - * @author 芋道源码 - */ -@TableName(value ="pay_wallet_recharge_package") -@KeySequence("pay_wallet_recharge_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletRechargePackageDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 套餐名 - */ - private String name; - - /** - * 支付金额 - */ - private Integer payPrice; - /** - * 赠送金额 - */ - private Integer bonusPrice; - - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java deleted file mode 100644 index 654e51157..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包流水 DO - * - * @author jason - */ -@TableName(value ="pay_wallet_transaction") -@KeySequence("pay_wallet_transaction_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletTransactionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 流水号 - */ - private String no; - - /** - * 钱包编号 - * - * 关联 {@link PayWalletDO#getId()} - */ - private Long walletId; - - /** - * 关联业务分类 - * - * 枚举 {@link PayWalletBizTypeEnum#getType()} - */ - private Integer bizType; - - /** - * 关联业务编号 - */ - private String bizId; - - /** - * 流水说明 - */ - private String title; - - /** - * 交易金额,单位分 - * - * 正值表示余额增加,负值表示余额减少 - */ - private Integer price; - - /** - * 交易后余额,单位分 - */ - private Integer balance; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java deleted file mode 100644 index c31dba551..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.app; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayAppMapper extends BaseMapperX { - - default PageResult selectPage(PayAppPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PayAppDO::getName, reqVO.getName()) - .eqIfPresent(PayAppDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayAppDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayAppDO::getId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java deleted file mode 100644 index c7e6ad0f8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.channel; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface PayChannelMapper extends BaseMapperX { - - default PayChannelDO selectByAppIdAndCode(Long appId, String code) { - return selectOne(PayChannelDO::getAppId, appId, PayChannelDO::getCode, code); - } - - default List selectListByAppIds(Collection appIds){ - return selectList(PayChannelDO::getAppId, appIds); - } - - default List selectListByAppId(Long appId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(PayChannelDO::getAppId, appId) - .eq(PayChannelDO::getStatus, status)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java deleted file mode 100644 index 0a92c6b76..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 示例订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface PayDemoOrderMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(PayDemoOrderDO::getId)); - } - - default int updateByIdAndPayed(Long id, boolean wherePayed, PayDemoOrderDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayDemoOrderDO::getId, id).eq(PayDemoOrderDO::getPayStatus, wherePayed)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java deleted file mode 100644 index a2a600660..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.demo; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayDemoTransferMapper extends BaseMapperX { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java deleted file mode 100644 index 8b586dff2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.notify; - -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayNotifyLogMapper extends BaseMapperX { - - default List selectListByTaskId(Long taskId) { - return selectList(PayNotifyLogDO::getTaskId, taskId); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java deleted file mode 100644 index cc7701271..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayNotifyTaskMapper extends BaseMapperX { - - /** - * 获得需要通知的 PayNotifyTaskDO 记录。需要满足如下条件: - * - * 1. status 非成功 - * 2. nextNotifyTime 小于当前时间 - * - * @return PayTransactionNotifyTaskDO 数组 - */ - default List selectListByNotify() { - return selectList(new LambdaQueryWrapper() - .in(PayNotifyTaskDO::getStatus, PayNotifyStatusEnum.WAITING.getStatus(), - PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()) - .le(PayNotifyTaskDO::getNextNotifyTime, LocalDateTime.now())); - } - - default PageResult selectPage(PayNotifyTaskPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayNotifyTaskDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayNotifyTaskDO::getType, reqVO.getType()) - .eqIfPresent(PayNotifyTaskDO::getDataId, reqVO.getDataId()) - .eqIfPresent(PayNotifyTaskDO::getStatus, reqVO.getStatus()) - .eqIfPresent(PayNotifyTaskDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .betweenIfPresent(PayNotifyTaskDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayNotifyTaskDO::getId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java deleted file mode 100755 index 8513c4b31..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayOrderExtensionMapper extends BaseMapperX { - - default PayOrderExtensionDO selectByNo(String no) { - return selectOne(PayOrderExtensionDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayOrderExtensionDO::getId, id).eq(PayOrderExtensionDO::getStatus, status)); - } - - default List selectListByOrderId(Long orderId) { - return selectList(PayOrderExtensionDO::getOrderId, orderId); - } - - default List selectListByStatusAndCreateTimeGe(Integer status, LocalDateTime minCreateTime) { - return selectList(new LambdaQueryWrapper() - .eq(PayOrderExtensionDO::getStatus, status) - .ge(PayOrderExtensionDO::getCreateTime, minCreateTime)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java deleted file mode 100755 index 95510d5f7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayOrderMapper extends BaseMapperX { - - default PageResult selectPage(PayOrderPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(PayOrderDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayOrderDO::getId)); - } - - default List selectList(PayOrderExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(PayOrderDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayOrderDO::getId)); - } - - default Long selectCountByAppId(Long appId) { - return selectCount(PayOrderDO::getAppId, appId); - } - - default PayOrderDO selectByAppIdAndMerchantOrderId(Long appId, String merchantOrderId) { - return selectOne(PayOrderDO::getAppId, appId, - PayOrderDO::getMerchantOrderId, merchantOrderId); - } - - default int updateByIdAndStatus(Long id, Integer status, PayOrderDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayOrderDO::getId, id).eq(PayOrderDO::getStatus, status)); - } - - default List selectListByStatusAndExpireTimeLt(Integer status, LocalDateTime expireTime) { - return selectList(new LambdaQueryWrapper() - .eq(PayOrderDO::getStatus, status) - .lt(PayOrderDO::getExpireTime, expireTime)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java deleted file mode 100755 index 0b620eaed..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayRefundMapper extends BaseMapperX { - - default Long selectCountByAppId(Long appId) { - return selectCount(PayRefundDO::getAppId, appId); - } - - default PayRefundDO selectByAppIdAndMerchantRefundId(Long appId, String merchantRefundId) { - return selectOne(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getMerchantRefundId, merchantRefundId)); - } - - default Long selectCountByAppIdAndOrderId(Long appId, Long orderId, Integer status) { - return selectCount(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getOrderId, orderId) - .eq(PayRefundDO::getStatus, status)); - } - - default PayRefundDO selectByAppIdAndNo(Long appId, String no) { - return selectOne(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getNo, no)); - } - - default PayRefundDO selectByNo(String no) { - return selectOne(PayRefundDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, Integer status, PayRefundDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayRefundDO::getId, id).eq(PayRefundDO::getStatus, status)); - } - - default PageResult selectPage(PayRefundPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayRefundDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayRefundDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayRefundDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayRefundDO::getMerchantRefundId, reqVO.getMerchantRefundId()) - .likeIfPresent(PayRefundDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayRefundDO::getChannelRefundNo, reqVO.getChannelRefundNo()) - .eqIfPresent(PayRefundDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayRefundDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayRefundDO::getId)); - } - - default List selectList(PayRefundExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(PayRefundDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayRefundDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayRefundDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayRefundDO::getMerchantRefundId, reqVO.getMerchantRefundId()) - .likeIfPresent(PayRefundDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayRefundDO::getChannelRefundNo, reqVO.getChannelRefundNo()) - .eqIfPresent(PayRefundDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayRefundDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayRefundDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(PayRefundDO::getStatus, status); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferExtensionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferExtensionMapper.java deleted file mode 100644 index 8e808f24d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferExtensionMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferExtensionDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayTransferExtensionMapper extends BaseMapperX { - - default PayTransferExtensionDO selectByNo(String no){ - return selectOne(PayTransferExtensionDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, List whereStatuses, PayTransferExtensionDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(PayTransferExtensionDO::getId, id).in(PayTransferExtensionDO::getStatus, whereStatuses)); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java deleted file mode 100644 index 3bd25d4b5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayTransferMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, List status, PayTransferDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(PayTransferDO::getId, id).in(PayTransferDO::getStatus, status)); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java deleted file mode 100644 index ce672255a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletMapper extends BaseMapperX { - - default PayWalletDO selectByUserIdAndType(Long userId, Integer userType) { - return selectOne(PayWalletDO::getUserId, userId, - PayWalletDO::getUserType, userType); - } - - default PageResult selectPage(Integer userType, PayWalletPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(PayWalletDO::getUserId, reqVO.getUserIds()) - .eqIfPresent(PayWalletDO::getUserType, userType) - .betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayWalletDO::getId)); - } - - /** - * 当消费退款时候, 更新钱包 - * - * @param id 钱包 id - * @param price 消费金额 - */ - default int updateWhenConsumptionRefund(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", total_expense = total_expense - " + price) - .eq(PayWalletDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 当消费时候, 更新钱包 - * - * @param price 消费金额 - * @param id 钱包 id - */ - default int updateWhenConsumption(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance - " + price - + ", total_expense = total_expense + " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getBalance, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 当充值的时候,更新钱包 - * - * @param id 钱包 id - * @param price 钱包金额 - */ - default int updateWhenRecharge(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", total_recharge = total_recharge + " + price) - .eq(PayWalletDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 冻结钱包部分余额 - * - * @param id 钱包 id - * @param price 冻结金额 - */ - default int freezePrice(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance - " + price - + ", freeze_price = freeze_price + " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getBalance, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 解冻钱包余额 - * - * @param id 钱包 id - * @param price 解冻金额 - */ - default int unFreezePrice(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", freeze_price = freeze_price - " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getFreezePrice, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 当充值退款时, 更新钱包 - * - * @param id 钱包 id - * @param price 退款金额 - */ - default int updateWhenRechargeRefund(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" freeze_price = freeze_price - " + price - + ", total_recharge = total_recharge - " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getFreezePrice, price) - .ge(PayWalletDO::getTotalRecharge, price);// cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java deleted file mode 100644 index 4cb77f020..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletRechargeMapper extends BaseMapperX { - - default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus)); - } - - default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); - } - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java deleted file mode 100644 index b68b4c893..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletRechargePackageMapper extends BaseMapperX { - - default PageResult selectPage(WalletRechargePackagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PayWalletRechargePackageDO::getName, reqVO.getName()) - .eqIfPresent(PayWalletRechargePackageDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayWalletRechargePackageDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayWalletRechargePackageDO::getPayPrice)); - } - - // TODO @jason:这里要有空格哈;String name) { - default PayWalletRechargePackageDO selectByName(String name){ - return selectOne(PayWalletRechargePackageDO::getName, name); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java deleted file mode 100644 index 41d7dbeb4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -@Mapper -public interface PayWalletTransactionMapper extends BaseMapperX { - - default PageResult selectPage(Long walletId, Integer type, - PageParam pageParam) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - .eqIfPresent(PayWalletTransactionDO::getWalletId, walletId); - if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_INCOME)) { - query.gt(PayWalletTransactionDO::getPrice, 0); - } else if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) { - query.lt(PayWalletTransactionDO::getPrice, 0); - } - query.orderByDesc(PayWalletTransactionDO::getId); - return selectPage(pageParam, query); - } - - default PayWalletTransactionDO selectByNo(String no) { - return selectOne(PayWalletTransactionDO::getNo, no); - } - - default PayWalletTransactionDO selectByBiz(String bizId, Integer bizType) { - return selectOne(PayWalletTransactionDO::getBizId, bizId, - PayWalletTransactionDO::getBizType, bizType); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java deleted file mode 100644 index 30081c6e8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis; - -/** - * 支付 Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 通知任务的分布式锁 - * - * KEY 格式:pay_notify:lock:%d // 参数来自 DefaultLockKeyBuilder 类 - * VALUE 数据格式:HASH // RLock.class:Redisson 的 Lock 锁,使用 Hash 数据结构 - * 过期时间:不固定 - */ - String PAY_NOTIFY_LOCK = "pay_notify:lock:%d"; - - /** - * 支付序号的缓存 - * - * KEY 格式:pay_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String PAY_NO = "pay_no:"; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java deleted file mode 100644 index f6be6f92a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis.no; - -import cn.hutool.core.date.DatePattern;import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 支付序号的 Redis DAO - * - * @author 芋道源码 - */ -@Repository -public class PayNoRedisDAO { - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号 - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN); - String key = RedisKeyConstants.PAY_NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofMinutes(1L)); - return noPrefix + no; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java deleted file mode 100644 index 69fab20dc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis.notify; - -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants.PAY_NOTIFY_LOCK; - -/** - * 支付通知的锁 Redis DAO - * - * @author 芋道源码 - */ -@Repository -public class PayNotifyLockRedisDAO { - - @Resource - private RedissonClient redissonClient; - - public void lock(Long id, Long timeoutMillis, Runnable runnable) { - String lockKey = formatKey(id); - RLock lock = redissonClient.getLock(lockKey); - try { - lock.lock(timeoutMillis, TimeUnit.MILLISECONDS); - // 执行逻辑 - runnable.run(); - } finally { - lock.unlock(); - } - } - - private static String formatKey(Long id) { - return String.format(PAY_NOTIFY_LOCK, id); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java deleted file mode 100644 index cd6bd0bb7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.job.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.ThreadPoolExecutor; - -@Configuration(proxyBeanMethods = false) -public class PayJobConfiguration { - - public static final String NOTIFY_THREAD_POOL_TASK_EXECUTOR = "NOTIFY_THREAD_POOL_TASK_EXECUTOR"; - - @Bean(NOTIFY_THREAD_POOL_TASK_EXECUTOR) - public ThreadPoolTaskExecutor notifyThreadPoolTaskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(8); // 设置核心线程数 - executor.setMaxPoolSize(16); // 设置最大线程数 - executor.setKeepAliveSeconds(60); // 设置空闲时间 - executor.setQueueCapacity(100); // 设置队列大小 - executor.setThreadNamePrefix("notify-task-"); // 配置线程池的前缀 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - // 进行加载 - executor.initialize(); - return executor; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java deleted file mode 100644 index 5a5a689f8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.job.core; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java deleted file mode 100644 index a1286828e..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 pay 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.pay.framework; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java deleted file mode 100644 index 376cd0acb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(PayProperties.class) -public class PayConfiguration { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java deleted file mode 100644 index d422b3528..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.config; - -import lombok.Data; -import org.hibernate.validator.constraints.URL; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotEmpty; - -@ConfigurationProperties(prefix = "yudao.pay") -@Validated -@Data -public class PayProperties { - - private static final String ORDER_NO_PREFIX = "P"; - private static final String REFUND_NO_PREFIX = "R"; - - /** - * 支付回调地址 - * - * 实际上,对应的 PayNotifyController 的 notifyOrder 方法的 URL - * - * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 orderNotifyUrl 地址 => 业务的 PayAppDO.orderNotifyUrl 地址 - */ - @NotEmpty(message = "支付回调地址不能为空") - @URL(message = "支付回调地址的格式必须是 URL") - private String orderNotifyUrl; - - /** - * 退款回调地址 - * - * 实际上,对应的 PayNotifyController 的 notifyRefund 方法的 URL - * - * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 refundNotifyUrl 地址 => 业务的 PayAppDO.notifyRefundUrl 地址 - */ - @NotEmpty(message = "支付回调地址不能为空") - @URL(message = "支付回调地址的格式必须是 URL") - private String refundNotifyUrl; - - /** - * 支付订单 no 的前缀 - */ - @NotEmpty(message = "支付订单 no 的前缀不能为空") - private String orderNoPrefix = ORDER_NO_PREFIX; - - /** - * 退款订单 no 的前缀 - */ - @NotEmpty(message = "退款订单 no 的前缀不能为空") - private String refundNoPrefix = REFUND_NO_PREFIX; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java deleted file mode 100644 index 212551f4d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.core; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_EXTENSION_NOT_FOUND; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.REFUND_NOT_FOUND; - -/** - * 钱包支付的 PayClient 实现类 - * - * @author jason - */ -@Slf4j -public class WalletPayClient extends AbstractPayClient { - - public static final String USER_ID_KEY = "user_id"; - public static final String USER_TYPE_KEY = "user_type"; - - private PayWalletService wallService; - private PayWalletTransactionService walletTransactionService; - private PayOrderService orderService; - private PayRefundService refundService; - - public WalletPayClient(Long channelId, NonePayClientConfig config) { - super(channelId, PayChannelEnum.WALLET.getCode(), config); - } - - @Override - protected void doInit() { - if (wallService == null) { - wallService = SpringUtil.getBean(PayWalletService.class); - } - if (walletTransactionService == null) { - walletTransactionService = SpringUtil.getBean(PayWalletTransactionService.class); - } - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - try { - Long userId = MapUtil.getLong(reqDTO.getChannelExtras(), USER_ID_KEY); - Integer userType = MapUtil.getInt(reqDTO.getChannelExtras(), USER_TYPE_KEY); - Assert.notNull(userId, "用户 id 不能为空"); - Assert.notNull(userType, "用户类型不能为空"); - PayWalletTransactionDO transaction = wallService.orderPay(userId, userType, reqDTO.getOutTradeNo(), - reqDTO.getPrice()); - return PayOrderRespDTO.successOf(transaction.getNo(), transaction.getCreator(), - transaction.getCreateTime(), - reqDTO.getOutTradeNo(), transaction); - } catch (Throwable ex) { - log.error("[doUnifiedOrder] 失败", ex); - Integer errorCode = INTERNAL_SERVER_ERROR.getCode(); - String errorMsg = INTERNAL_SERVER_ERROR.getMsg(); - if (ex instanceof ServiceException) { - ServiceException serviceException = (ServiceException) ex; - errorCode = serviceException.getCode(); - errorMsg = serviceException.getMessage(); - } - return PayOrderRespDTO.closedOf(String.valueOf(errorCode), errorMsg, - reqDTO.getOutTradeNo(), ""); - } - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - throw new UnsupportedOperationException("钱包支付无支付回调"); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - if (orderService == null) { - orderService = SpringUtil.getBean(PayOrderService.class); - } - PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo); - // 支付交易拓展单不存在, 返回关闭状态 - if (orderExtension == null) { - return PayOrderRespDTO.closedOf(String.valueOf(PAY_ORDER_EXTENSION_NOT_FOUND.getCode()), - PAY_ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, ""); - } - // 关闭状态 - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { - return PayOrderRespDTO.closedOf(orderExtension.getChannelErrorCode(), - orderExtension.getChannelErrorMsg(), outTradeNo, ""); - } - // 成功状态 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(orderExtension.getOrderId()), PayWalletBizTypeEnum.PAYMENT); - Assert.notNull(walletTransaction, "支付单 {} 钱包流水不能为空", outTradeNo); - return PayOrderRespDTO.successOf(walletTransaction.getNo(), walletTransaction.getCreator(), - walletTransaction.getCreateTime(), outTradeNo, walletTransaction); - } - // 其它状态为无效状态 - log.error("[doGetOrder] 支付单 {} 的状态不正确", outTradeNo); - throw new IllegalStateException(String.format("支付单[%s] 状态不正确", outTradeNo)); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - try { - PayWalletTransactionDO payWalletTransaction = wallService.orderRefund(reqDTO.getOutRefundNo(), - reqDTO.getRefundPrice(), reqDTO.getReason()); - return PayRefundRespDTO.successOf(payWalletTransaction.getNo(), payWalletTransaction.getCreateTime(), - reqDTO.getOutRefundNo(), payWalletTransaction); - } catch (Throwable ex) { - log.error("[doUnifiedRefund] 失败", ex); - Integer errorCode = INTERNAL_SERVER_ERROR.getCode(); - String errorMsg = INTERNAL_SERVER_ERROR.getMsg(); - if (ex instanceof ServiceException) { - ServiceException serviceException = (ServiceException) ex; - errorCode = serviceException.getCode(); - errorMsg = serviceException.getMessage(); - } - return PayRefundRespDTO.failureOf(String.valueOf(errorCode), errorMsg, - reqDTO.getOutRefundNo(), ""); - } - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - throw new UnsupportedOperationException("钱包支付无退款回调"); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - if (refundService == null) { - refundService = SpringUtil.getBean(PayRefundService.class); - } - PayRefundDO payRefund = refundService.getRefundByNo(outRefundNo); - // 支付退款单不存在, 返回退款失败状态 - if (payRefund == null) { - return PayRefundRespDTO.failureOf(String.valueOf(REFUND_NOT_FOUND), REFUND_NOT_FOUND.getMsg(), - outRefundNo, ""); - } - // 退款失败 - if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) { - return PayRefundRespDTO.failureOf(payRefund.getChannelErrorCode(), payRefund.getChannelErrorMsg(), - outRefundNo, ""); - } - // 退款成功 - if (PayRefundStatusRespEnum.isSuccess(payRefund.getStatus())) { - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(payRefund.getId()), PayWalletBizTypeEnum.PAYMENT_REFUND); - Assert.notNull(walletTransaction, "支付退款单 {} 钱包流水不能为空", outRefundNo); - return PayRefundRespDTO.successOf(walletTransaction.getNo(), walletTransaction.getCreateTime(), - outRefundNo, walletTransaction); - } - // 其它状态为无效状态 - log.error("[doGetRefund] 支付退款单 {} 的状态不正确", outRefundNo); - throw new IllegalStateException(String.format("支付退款单[%s] 状态不正确", outRefundNo)); - } - - @Override - public PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/config/RpcConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 92317f04b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = MemberUserApi.class) -public class RpcConfiguration { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/package-info.java deleted file mode 100644 index 98523d98b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.rpc; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/config/SecurityConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 70a3a239f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Pay 模块的 Security 配置 - */ -@Configuration("paySecurityConfiguration") -public class SecurityConfiguration { - - @Bean("payAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/core/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/core/package-info.java deleted file mode 100644 index 12c1c533d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.security.core; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java deleted file mode 100644 index b2c14a9bd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.notify; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 支付通知 Job - * 通过不断扫描待通知的 PayNotifyTaskDO 记录,回调业务线的回调接口 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayNotifyJob { - - @Resource - private PayNotifyService payNotifyService; - - @XxlJob("payNotifyJob") - @TenantJob // 多租户 - public void execute() throws Exception { - int notifyCount = payNotifyService.executeNotify(); - log.info("[execute][执行支付通知 ({}) 个]", notifyCount); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java deleted file mode 100644 index 93dfe4548..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 支付订单的过期 Job - * - * 支付超过过期时间时,支付渠道是不会通知进行过期,所以需要定时进行过期关闭。 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayOrderExpireJob { - - @Resource - private PayOrderService orderService; - - @XxlJob("payOrderExpireJob") - @TenantJob // 多租户 - public void execute(String param) { - int count = orderService.expireOrder(); - log.info("[execute][支付过期 ({}) 个]", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java deleted file mode 100644 index 15de61cdd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 支付订单的同步 Job - * - * 由于支付订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayOrderSyncJob { - - /** - * 同步创建时间在 N 分钟之前的订单 - * - * 为什么同步 10 分钟之前的订单? - * 因为一个订单发起支付,到支付成功,大多数在 10 分钟内,需要保证轮询到。 - * 如果设置为 30、60 或者更大时间范围,会导致轮询的订单太多,影响性能。当然,你也可以根据自己的业务情况来处理。 - */ - private static final Duration CREATE_TIME_DURATION_BEFORE = Duration.ofMinutes(10); - - @Resource - private PayOrderService orderService; - - @XxlJob("payOrderSyncJob") - @TenantJob // 多租户 - public void execute() { - LocalDateTime minCreateTime = LocalDateTime.now().minus(CREATE_TIME_DURATION_BEFORE); - int count = orderService.syncOrder(minCreateTime); - log.info("[execute][同步支付订单 ({}) 个]", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java deleted file mode 100644 index 25f239dc7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.refund; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 退款订单的同步 Job - * - * 由于退款订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayRefundSyncJob { - - @Resource - private PayRefundService refundService; - - @XxlJob("payRefundSyncJob") - @TenantJob // 多租户 - public void execute() { - int count = refundService.syncRefund(); - log.info("[execute][同步退款订单 ({}) 个]", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java deleted file mode 100644 index 40ab66da0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * pay 模块,我们放支付业务,提供业务的支付能力。 - * 例如说:商户、应用、支付、退款等等 - * - * 1. Controller URL:以 /pay/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 pay_ 开头,方便在数据库中区分 - * - * 注意,由于 Pay 模块和 Trade 模块,容易重名,所以类名都加载 Pay 的前缀~ - */ -package cn.iocoder.yudao.module.pay; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java deleted file mode 100644 index 4f9e289d6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 支付应用 Service 接口 - * - * @author 芋艿 - */ -public interface PayAppService { - - /** - * 创建支付应用 - * - * @param createReqVO 创建 - * @return 编号 - */ - Long createApp(@Valid PayAppCreateReqVO createReqVO); - - /** - * 更新支付应用 - * - * @param updateReqVO 更新 - */ - void updateApp(@Valid PayAppUpdateReqVO updateReqVO); - - /** - * 修改应用状态 - * - * @param id 应用编号 - * @param status 状态 - */ - void updateAppStatus(Long id, Integer status); - - /** - * 删除支付应用 - * - * @param id 编号 - */ - void deleteApp(Long id); - - /** - * 获得支付应用 - * - * @param id 编号 - * @return 支付应用 - */ - PayAppDO getApp(Long id); - - /** - * 获得支付应用列表 - * - * @param ids 编号 - * @return 支付应用列表 - */ - List getAppList(Collection ids); - - /** - * 获得支付应用列表 - * - * @return 支付应用列表 - */ - List getAppList(); - - /** - * 获得支付应用分页 - * - * @param pageReqVO 分页查询 - * @return 支付应用分页 - */ - PageResult getAppPage(PayAppPageReqVO pageReqVO); - - /** - * 获得指定编号的商户 Map - * - * @param ids 应用编号集合 - * @return 商户 Map - */ - default Map getAppMap(Collection ids) { - List list = getAppList(ids); - return CollectionUtils.convertMap(list, PayAppDO::getId); - } - - /** - * 支付应用的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param id 应用编号 - * @return 应用 - */ - PayAppDO validPayApp(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java deleted file mode 100644 index 56087ef13..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付应用 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -public class PayAppServiceImpl implements PayAppService { - - @Resource - private PayAppMapper appMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖报错 - private PayOrderService orderService; - @Resource - @Lazy // 延迟加载,避免循环依赖报错 - private PayRefundService refundService; - - @Override - public Long createApp(PayAppCreateReqVO createReqVO) { - // 插入 - PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO); - appMapper.insert(app); - // 返回 - return app.getId(); - } - - @Override - public void updateApp(PayAppUpdateReqVO updateReqVO) { - // 校验存在 - validateAppExists(updateReqVO.getId()); - // 更新 - PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO); - appMapper.updateById(updateObj); - } - - @Override - public void updateAppStatus(Long id, Integer status) { - // 校验商户存在 - validateAppExists(id); - // 更新状态 - appMapper.updateById(new PayAppDO().setId(id).setStatus(status)); - } - - @Override - public void deleteApp(Long id) { - // 校验存在 - validateAppExists(id); - // 校验关联数据是否存在 - if (orderService.getOrderCountByAppId(id) > 0) { - throw exception(APP_EXIST_ORDER_CANT_DELETE); - } - if (refundService.getRefundCountByAppId(id) > 0) { - throw exception(APP_EXIST_REFUND_CANT_DELETE); - } - - // 删除 - appMapper.deleteById(id); - } - - private void validateAppExists(Long id) { - if (appMapper.selectById(id) == null) { - throw exception(APP_NOT_FOUND); - } - } - - @Override - public PayAppDO getApp(Long id) { - return appMapper.selectById(id); - } - - @Override - public List getAppList(Collection ids) { - return appMapper.selectBatchIds(ids); - } - - @Override - public List getAppList() { - return appMapper.selectList(); - } - - @Override - public PageResult getAppPage(PayAppPageReqVO pageReqVO) { - return appMapper.selectPage(pageReqVO); - } - - @Override - public PayAppDO validPayApp(Long id) { - PayAppDO app = appMapper.selectById(id); - // 校验是否存在 - if (app == null) { - throw exception(ErrorCodeConstants.APP_NOT_FOUND); - } - // 校验是否禁用 - if (CommonStatusEnum.DISABLE.getStatus().equals(app.getStatus())) { - throw exception(ErrorCodeConstants.APP_IS_DISABLE); - } - return app; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java deleted file mode 100644 index 281496602..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 支付渠道 Service 接口 - * - * @author aquan - */ -public interface PayChannelService { - - /** - * 创建支付渠道 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createChannel(@Valid PayChannelCreateReqVO createReqVO); - - /** - * 更新支付渠道 - * - * @param updateReqVO 更新信息 - */ - void updateChannel(@Valid PayChannelUpdateReqVO updateReqVO); - - /** - * 删除支付渠道 - * - * @param id 编号 - */ - void deleteChannel(Long id); - - /** - * 获得支付渠道 - * - * @param id 编号 - * @return 支付渠道 - */ - PayChannelDO getChannel(Long id); - - /** - * 根据支付应用 ID 集合,获得支付渠道列表 - * - * @param appIds 应用编号集合 - * @return 支付渠道列表 - */ - List getChannelListByAppIds(Collection appIds); - - /** - * 根据条件获取渠道 - * - * @param appId 应用编号 - * @param code 渠道编码 - * @return 数量 - */ - PayChannelDO getChannelByAppIdAndCode(Long appId, String code); - - /** - * 支付渠道的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param id 渠道编号 - * @return 渠道信息 - */ - PayChannelDO validPayChannel(Long id); - - /** - * 支付渠道的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param appId 应用编号 - * @param code 支付渠道 - * @return 渠道信息 - */ - PayChannelDO validPayChannel(Long appId, String code); - - /** - * 获得指定应用的开启的渠道列表 - * - * @param appId 应用编号 - * @return 渠道列表 - */ - List getEnableChannelList(Long appId); - - /** - * 获得指定编号的支付客户端 - * - * @param id 编号 - * @return 支付客户端 - */ - PayClient getPayClient(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java deleted file mode 100644 index 2fe495a5f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.validation.Validator; -import java.time.Duration; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付渠道 Service 实现类 - * - * @author aquan - */ -@Service -@Slf4j -@Validated -public class PayChannelServiceImpl implements PayChannelService { - - /** - * {@link PayClient} 缓存,通过它异步清空 smsClientFactory - */ - @Getter - private final LoadingCache clientCache = buildAsyncReloadingCache(Duration.ofSeconds(10L), - new CacheLoader() { - - @Override - public PayClient load(Long id) { - // 查询,然后尝试清空 - PayChannelDO channel = payChannelMapper.selectById(id); - if (channel != null) { - payClientFactory.createOrUpdatePayClient(channel.getId(), channel.getCode(), channel.getConfig()); - } - return payClientFactory.getPayClient(id); - } - - }); - - @Resource - private PayClientFactory payClientFactory; - - @Resource - private PayChannelMapper payChannelMapper; - - @Resource - private Validator validator; - - /** - * 初始化,为了注册钱包 - */ - @PostConstruct - public void init() { - payClientFactory.registerPayClientClass(PayChannelEnum.WALLET, WalletPayClient.class); - } - - @Override - public Long createChannel(PayChannelCreateReqVO reqVO) { - // 断言是否有重复的 - PayChannelDO dbChannel = getChannelByAppIdAndCode(reqVO.getAppId(), reqVO.getCode()); - if (dbChannel != null) { - throw exception(CHANNEL_EXIST_SAME_CHANNEL_ERROR); - } - - // 新增渠道 - PayChannelDO channel = PayChannelConvert.INSTANCE.convert(reqVO) - .setConfig(parseConfig(reqVO.getCode(), reqVO.getConfig())); - payChannelMapper.insert(channel); - return channel.getId(); - } - - @Override - public void updateChannel(PayChannelUpdateReqVO updateReqVO) { - // 校验存在 - PayChannelDO dbChannel = validateChannelExists(updateReqVO.getId()); - - // 更新 - PayChannelDO channel = PayChannelConvert.INSTANCE.convert(updateReqVO) - .setConfig(parseConfig(dbChannel.getCode(), updateReqVO.getConfig())); - payChannelMapper.updateById(channel); - - // 清空缓存 - clearCache(channel.getId()); - } - - /** - * 解析并校验配置 - * - * @param code 渠道编码 - * @param configStr 配置 - * @return 支付配置 - */ - private PayClientConfig parseConfig(String code, String configStr) { - // 解析配置 - Class payClass = PayChannelEnum.getByCode(code).getConfigClass(); - if (ObjectUtil.isNull(payClass)) { - throw exception(CHANNEL_NOT_FOUND); - } - PayClientConfig config = JsonUtils.parseObject2(configStr, payClass); - Assert.notNull(config); - - // 验证参数 - config.validate(validator); - return config; - } - - @Override - public void deleteChannel(Long id) { - // 校验存在 - validateChannelExists(id); - - // 删除 - payChannelMapper.deleteById(id); - - // 清空缓存 - clearCache(id); - } - - /** - * 删除缓存 - * - * @param id 渠道编号 - */ - private void clearCache(Long id) { - clientCache.invalidate(id); - } - - private PayChannelDO validateChannelExists(Long id) { - PayChannelDO channel = payChannelMapper.selectById(id); - if (channel == null) { - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - @Override - public PayChannelDO getChannel(Long id) { - return payChannelMapper.selectById(id); - } - - @Override - public List getChannelListByAppIds(Collection appIds) { - return payChannelMapper.selectListByAppIds(appIds); - } - - @Override - public PayChannelDO getChannelByAppIdAndCode(Long appId, String code) { - return payChannelMapper.selectByAppIdAndCode(appId, code); - } - - @Override - public PayChannelDO validPayChannel(Long id) { - PayChannelDO channel = payChannelMapper.selectById(id); - validPayChannel(channel); - return channel; - } - - @Override - public PayChannelDO validPayChannel(Long appId, String code) { - PayChannelDO channel = payChannelMapper.selectByAppIdAndCode(appId, code); - validPayChannel(channel); - return channel; - } - - private void validPayChannel(PayChannelDO channel) { - if (channel == null) { - throw exception(CHANNEL_NOT_FOUND); - } - if (CommonStatusEnum.DISABLE.getStatus().equals(channel.getStatus())) { - throw exception(CHANNEL_IS_DISABLE); - } - } - - @Override - public List getEnableChannelList(Long appId) { - return payChannelMapper.selectListByAppId(appId, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public PayClient getPayClient(Long id) { - return clientCache.getUnchecked(id); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java deleted file mode 100644 index e6822e626..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; - -import javax.validation.Valid; - -/** - * 示例订单 Service 接口 - * - * @author 芋道源码 - */ -public interface PayDemoOrderService { - - /** - * 创建示例订单 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemoOrder(Long userId, @Valid PayDemoOrderCreateReqVO createReqVO); - - /** - * 获得示例订单 - * - * @param id 编号 - * @return 示例订单 - */ - PayDemoOrderDO getDemoOrder(Long id); - - /** - * 获得示例订单分页 - * - * @param pageReqVO 分页查询 - * @return 示例订单分页 - */ - PageResult getDemoOrderPage(PageParam pageReqVO); - - /** - * 更新示例订单为已支付 - * - * @param id 编号 - * @param payOrderId 支付订单号 - */ - void updateDemoOrderPaid(Long id, Long payOrderId); - - /** - * 发起示例订单的退款 - * - * @param id 编号 - * @param userIp 用户编号 - */ - void refundDemoOrder(Long id, String userIp); - - /** - * 更新示例订单为已退款 - * - * @param id 编号 - * @param payRefundId 退款订单号 - */ - void updateDemoOrderRefunded(Long id, Long payRefundId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java deleted file mode 100644 index c19b9dfd8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java +++ /dev/null @@ -1,265 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoOrderMapper; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static cn.hutool.core.util.ObjectUtil.notEqual; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 示例订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class PayDemoOrderServiceImpl implements PayDemoOrderService { - - /** - * 接入的实力应用编号 - * - * 从 [支付管理 -> 应用信息] 里添加 - */ - private static final Long PAY_APP_ID = 7L; - - /** - * 商品信息 Map - * - * key:商品编号 - * value:[商品名、商品价格] - */ - private final Map spuNames = new HashMap<>(); - - @Resource - private PayOrderApi payOrderApi; - @Resource - private PayRefundApi payRefundApi; - - @Resource - private PayDemoOrderMapper payDemoOrderMapper; - - public PayDemoOrderServiceImpl() { - spuNames.put(1L, new Object[]{"华为手机", 1}); - spuNames.put(2L, new Object[]{"小米电视", 10}); - spuNames.put(3L, new Object[]{"苹果手表", 100}); - spuNames.put(4L, new Object[]{"华硕笔记本", 1000}); - spuNames.put(5L, new Object[]{"蔚来汽车", 200000}); - } - - @Override - public Long createDemoOrder(Long userId, PayDemoOrderCreateReqVO createReqVO) { - // 1.1 获得商品 - Object[] spu = spuNames.get(createReqVO.getSpuId()); - Assert.notNull(spu, "商品({}) 不存在", createReqVO.getSpuId()); - String spuName = (String) spu[0]; - Integer price = (Integer) spu[1]; - // 1.2 插入 demo 订单 - PayDemoOrderDO demoOrder = new PayDemoOrderDO().setUserId(userId) - .setSpuId(createReqVO.getSpuId()).setSpuName(spuName) - .setPrice(price).setPayStatus(false).setRefundPrice(0); - payDemoOrderMapper.insert(demoOrder); - - // 2.1 创建支付单 - Long payOrderId = payOrderApi.createOrder(new PayOrderCreateReqDTO() - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 - .setMerchantOrderId(demoOrder.getId().toString()) // 业务的订单编号 - .setSubject(spuName).setBody("").setPrice(price) // 价格信息 - .setExpireTime(addTime(Duration.ofHours(2L)))).getCheckedData(); // 支付的过期时间 - // 2.2 更新支付单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(demoOrder.getId()) - .setPayOrderId(payOrderId)); - // 返回 - return demoOrder.getId(); - } - - @Override - public PayDemoOrderDO getDemoOrder(Long id) { - return payDemoOrderMapper.selectById(id); - } - - @Override - public PageResult getDemoOrderPage(PageParam pageReqVO) { - return payDemoOrderMapper.selectPage(pageReqVO); - } - - @Override - public void updateDemoOrderPaid(Long id, Long payOrderId) { - // 校验并获得支付订单(可支付) - PayOrderRespDTO payOrder = validateDemoOrderCanPaid(id, payOrderId); - - // 更新 PayDemoOrderDO 状态为已支付 - int updateCount = payDemoOrderMapper.updateByIdAndPayed(id, false, - new PayDemoOrderDO().setPayStatus(true).setPayTime(LocalDateTime.now()) - .setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - } - - /** - * 校验交易订单满足被支付的条件 - * - * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private PayOrderRespDTO validateDemoOrderCanPaid(Long id, Long payOrderId) { - // 1.1 校验订单是否存在 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 1.2 校验订单未支付 - if (order.getPayStatus()) { - log.error("[validateDemoOrderCanPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, toJsonString(order)); - throw exception(DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 1.3 校验支付订单匹配 - if (notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateDemoOrderCanPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, toJsonString(order)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 2.1 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId).getCheckedData(); - if (payOrder == null) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 2.2 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 2.3 校验支付金额一致 - if (notEqual(payOrder.getPrice(), order.getPrice())) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, toJsonString(order), toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 2.4 校验支付订单匹配(二次) - if (notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateDemoOrderCanPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return payOrder; - } - - @Override - public void refundDemoOrder(Long id, String userIp) { - // 1. 校验订单是否可以退款 - PayDemoOrderDO order = validateDemoOrderCanRefund(id); - - // 2.1 生成退款单号 - // 一般来说,用户发起退款的时候,都会单独插入一个售后维权表,然后使用该表的 id 作为 refundId - // 这里我们是个简单的 demo,所以没有售后维权表,直接使用订单 id + "-refund" 来演示 - String refundId = order.getId() + "-refund"; - // 2.2 创建退款单 - Long payRefundId = payRefundApi.createRefund(new PayRefundCreateReqDTO() - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 - .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号 - .setMerchantRefundId(refundId) - .setReason("想退钱").setPrice(order.getPrice())).getCheckedData();// 价格信息 - // 2.3 更新退款单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(id) - .setPayRefundId(payRefundId).setRefundPrice(order.getPrice())); - } - - private PayDemoOrderDO validateDemoOrderCanRefund(Long id) { - // 校验订单是否存在 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 校验订单是否支付 - if (!order.getPayStatus()) { - throw exception(DEMO_ORDER_REFUND_FAIL_NOT_PAID); - } - // 校验订单是否已退款 - if (order.getPayRefundId() != null) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUNDED); - } - return order; - } - - @Override - public void updateDemoOrderRefunded(Long id, Long payRefundId) { - // 1. 校验并获得退款订单(可退款) - PayRefundRespDTO payRefund = validateDemoOrderCanRefunded(id, payRefundId); - // 2.2 更新退款单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(id) - .setRefundTime(payRefund.getSuccessTime())); - } - - private PayRefundRespDTO validateDemoOrderCanRefunded(Long id, Long payRefundId) { - // 1.1 校验示例订单 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 1.2 校验退款订单匹配 - if (Objects.equals(order.getPayOrderId(), payRefundId)) { - log.error("[validateDemoOrderCanRefunded][order({}) 退款单不匹配({}),请进行处理!order 数据是:{}]", - id, payRefundId, toJsonString(order)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - - // 2.1 校验退款订单 - PayRefundRespDTO payRefund = payRefundApi.getRefund(payRefundId).getCheckedData(); - if (payRefund == null) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND); - } - // 2.2 - if (!PayRefundStatusEnum.isSuccess(payRefund.getStatus())) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS); - } - // 2.3 校验退款金额一致 - if (notEqual(payRefund.getRefundPrice(), order.getPrice())) { - log.error("[validateDemoOrderCanRefunded][order({}) payRefund({}) 退款金额不匹配,请进行处理!order 数据是:{},payRefund 数据是:{}]", - id, payRefundId, toJsonString(order), toJsonString(payRefund)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH); - } - // 2.4 校验退款订单匹配(二次) - if (notEqual(payRefund.getMerchantOrderId(), id.toString())) { - log.error("[validateDemoOrderCanRefunded][order({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]", - id, payRefundId, toJsonString(payRefund)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - return payRefund; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java deleted file mode 100644 index f775a838f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; - -import javax.validation.Valid; - -/** - * 示例转账业务 Service 接口 - * - * @author jason - */ -public interface PayDemoTransferService { - - /** - * 创建转账单 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemoTransfer(Long userId, @Valid PayDemoTransferCreateReqVO createReqVO); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java deleted file mode 100644 index d4da016ac..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoTransferMapper; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.WAITING; - -/** - * 示例转账业务 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class PayDemoTransferServiceImpl implements PayDemoTransferService { - - /** - * 接入的实力应用编号 - - * 从 [支付管理 -> 应用信息] 里添加 - */ - private static final Long TRANSFER_APP_ID = 8L; - @Resource - private PayDemoTransferMapper demoTransferMapper; - @Resource - private PayTransferService transferService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDemoTransfer(Long userId, @Valid PayDemoTransferCreateReqVO vo) { - // 1 校验收款账号 - validatePayeeInfo(vo.getType(), vo.getPayeeInfo()); - - // 2 保存示例转账业务表 - PayDemoTransferDO demoTransfer = new PayDemoTransferDO().setUserId(userId).setType(vo.getType()) - .setPrice(vo.getPrice()).setPayeeInfo(vo.getPayeeInfo()) - .setTransferStatus(WAITING.getStatus()); - demoTransferMapper.insert(demoTransfer); - - // 3.1 创建转账单 - Long transferId = transferService.createTransfer(PayTransferConvert.INSTANCE.convert(vo) - .setAppId(TRANSFER_APP_ID).setTitle("示例转账") - .setMerchantOrderId(String.valueOf(demoTransfer.getId()))); - // 3.2 更新转账单编号 - demoTransferMapper.updateById(new PayDemoTransferDO().setId(demoTransfer.getId()) - .setPayTransferId(transferId)); - return demoTransfer.getId(); - } - - // TODO @jason:可以参考 AppBrokerageWithdrawCreateReqVO 搞下字段哈,进行校验 - // @jason payeeinfo 字段确定改一下 - private void validatePayeeInfo(Integer transferType, Map payeeInfo) { - PayTransferTypeEnum transferTypeEnum = typeOf(transferType); - switch (transferTypeEnum) { - case ALIPAY_BALANCE: { - if (StrUtil.isEmpty(MapUtil.getStr(payeeInfo, ALIPAY_LOGON_ID))) { - throw exception(PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY); - } - if (StrUtil.isEmpty(MapUtil.getStr(payeeInfo, ALIPAY_ACCOUNT_NAME))) { - throw exception(PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY); - } - break; - } - case WX_BALANCE: - case BANK_CARD: - case WALLET_BALANCE: { - throw new UnsupportedOperationException("待实现"); - } - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java deleted file mode 100644 index ed9399772..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; - -import java.util.List; - -/** - * 回调通知 Service 接口 - * - * @author 芋道源码 - */ -public interface PayNotifyService { - - /** - * 创建回调通知任务 - * - * @param type 类型 - * @param dataId 数据编号 - */ - void createPayNotifyTask(Integer type, Long dataId); - - /** - * 执行回调通知 - * - * 注意,该方法提供给定时任务调用。目前是 yudao-server 进行调用 - * @return 通知数量 - */ - int executeNotify() throws InterruptedException; - - /** - * 获得回调通知 - * - * @param id 编号 - * @return 回调通知 - */ - PayNotifyTaskDO getNotifyTask(Long id); - - /** - * 获得回调通知分页 - * - * @param pageReqVO 分页查询 - * @return 回调通知分页 - */ - PageResult getNotifyTaskPage(PayNotifyTaskPageReqVO pageReqVO); - - /** - * 获得回调日志列表 - * - * @param taskId 任务编号 - * @return 日志列表 - */ - List getNotifyLogList(Long taskId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java deleted file mode 100644 index c85876ee7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java +++ /dev/null @@ -1,294 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.exceptions.ExceptionUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.hutool.http.HttpResponse; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyLogMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper; -import cn.iocoder.yudao.module.pay.dal.redis.notify.PayNotifyLockRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.module.pay.framework.job.config.PayJobConfiguration.NOTIFY_THREAD_POOL_TASK_EXECUTOR; - -/** - * 支付通知 Core Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Valid -@Slf4j -public class PayNotifyServiceImpl implements PayNotifyService { - - /** - * 通知超时时间,单位:秒 - */ - public static final int NOTIFY_TIMEOUT = 120; - /** - * {@link #NOTIFY_TIMEOUT} 的毫秒 - */ - public static final long NOTIFY_TIMEOUT_MILLIS = 120 * DateUtils.SECOND_MILLIS; - - @Resource - @Lazy // 循环依赖,避免报错 - private PayOrderService orderService; - @Resource - @Lazy // 循环依赖,避免报错 - private PayRefundService refundService; - - @Resource - private PayNotifyTaskMapper notifyTaskMapper; - @Resource - private PayNotifyLogMapper notifyLogMapper; - - @Resource(name = NOTIFY_THREAD_POOL_TASK_EXECUTOR) - private ThreadPoolTaskExecutor threadPoolTaskExecutor; - - @Resource - private PayNotifyLockRedisDAO notifyLockCoreRedisDAO; - - @Override - @Transactional(rollbackFor = Exception.class) - public void createPayNotifyTask(Integer type, Long dataId) { - PayNotifyTaskDO task = new PayNotifyTaskDO().setType(type).setDataId(dataId); - task.setStatus(PayNotifyStatusEnum.WAITING.getStatus()).setNextNotifyTime(LocalDateTime.now()) - .setNotifyTimes(0).setMaxNotifyTimes(PayNotifyTaskDO.NOTIFY_FREQUENCY.length + 1); - // 补充 appId + notifyUrl 字段 - if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { - PayOrderDO order = orderService.getOrder(task.getDataId()); // 不进行非空判断,有问题直接异常 - task.setAppId(order.getAppId()). - setMerchantOrderId(order.getMerchantOrderId()).setNotifyUrl(order.getNotifyUrl()); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { - PayRefundDO refundDO = refundService.getRefund(task.getDataId()); - task.setAppId(refundDO.getAppId()) - .setMerchantOrderId(refundDO.getMerchantOrderId()).setNotifyUrl(refundDO.getNotifyUrl()); - } - - // 执行插入 - notifyTaskMapper.insert(task); - - // 必须在事务提交后,在发起任务,否则 PayNotifyTaskDO 还没入库,就提前回调接入的业务 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - executeNotify(task); - } - }); - } - - @Override - public int executeNotify() throws InterruptedException { - // 获得需要通知的任务 - List tasks = notifyTaskMapper.selectListByNotify(); - if (CollUtil.isEmpty(tasks)) { - return 0; - } - - // 遍历,逐个通知 - CountDownLatch latch = new CountDownLatch(tasks.size()); - tasks.forEach(task -> threadPoolTaskExecutor.execute(() -> { - try { - executeNotify(task); - } finally { - latch.countDown(); - } - })); - // 等待完成 - awaitExecuteNotify(latch); - // 返回执行完成的任务数(成功 + 失败) - return tasks.size(); - } - - /** - * 等待全部支付通知的完成 - * 每 1 秒会打印一次剩余任务数量 - * - * @param latch Latch - * @throws InterruptedException 如果被打断 - */ - private void awaitExecuteNotify(CountDownLatch latch) throws InterruptedException { - long size = latch.getCount(); - for (int i = 0; i < NOTIFY_TIMEOUT; i++) { - if (latch.await(1L, TimeUnit.SECONDS)) { - return; - } - log.info("[awaitExecuteNotify][任务处理中, 总任务数({}) 剩余任务数({})]", size, latch.getCount()); - } - log.error("[awaitExecuteNotify][任务未处理完,总任务数({}) 剩余任务数({})]", size, latch.getCount()); - } - - /** - * 同步执行单个支付通知 - * - * @param task 通知任务 - */ - public void executeNotify(PayNotifyTaskDO task) { - // 分布式锁,避免并发问题 - notifyLockCoreRedisDAO.lock(task.getId(), NOTIFY_TIMEOUT_MILLIS, () -> { - // 校验,当前任务是否已经被通知过 - // 虽然已经通过分布式加锁,但是可能同时满足通知的条件,然后都去获得锁。此时,第一个执行完后,第二个还是能拿到锁,然后会再执行一次。 - // 因此,此处我们通过第 notifyTimes 通知次数是否匹配来判断 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - if (ObjectUtil.notEqual(task.getNotifyTimes(), dbTask.getNotifyTimes())) { - log.warn("[executeNotifySync][task({}) 任务被忽略,原因是它的通知不是第 ({}) 次,可能是因为并发执行了]", - JsonUtils.toJsonString(task), dbTask.getNotifyTimes()); - return; - } - - // 执行通知 - getSelf().executeNotify0(dbTask); - }); - } - - @Transactional(rollbackFor = Exception.class) - public void executeNotify0(PayNotifyTaskDO task) { - // 发起回调 - CommonResult invokeResult = null; - Throwable invokeException = null; - try { - invokeResult = executeNotifyInvoke(task); - } catch (Throwable e) { - invokeException = e; - } - - // 处理结果 - Integer newStatus = processNotifyResult(task, invokeResult, invokeException); - - // 记录 PayNotifyLog 日志 - String response = invokeException != null ? ExceptionUtil.getRootCauseMessage(invokeException) : - JsonUtils.toJsonString(invokeResult); - notifyLogMapper.insert(PayNotifyLogDO.builder().taskId(task.getId()) - .notifyTimes(task.getNotifyTimes() + 1).status(newStatus).response(response).build()); - } - - /** - * 执行单个支付任务的 HTTP 调用 - * - * @param task 通知任务 - * @return HTTP 响应 - */ - private CommonResult executeNotifyInvoke(PayNotifyTaskDO task) { - // 拼接 body 参数 - Object request; - if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { - request = PayOrderNotifyReqDTO.builder().merchantOrderId(task.getMerchantOrderId()) - .payOrderId(task.getDataId()).build(); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { - request = PayRefundNotifyReqDTO.builder().merchantOrderId(task.getMerchantOrderId()) - .payRefundId(task.getDataId()).build(); - } else { - throw new RuntimeException("未知的通知任务类型:" + JsonUtils.toJsonString(task)); - } - // 拼接 header 参数 - Map headers = new HashMap<>(); - TenantUtils.addTenantHeader(headers, task.getTenantId()); - - // 发起请求 - try (HttpResponse response = HttpUtil.createPost(task.getNotifyUrl()) - .body(JsonUtils.toJsonString(request)).addHeaders(headers) - .timeout((int) NOTIFY_TIMEOUT_MILLIS).execute()) { - // 解析结果 - return JsonUtils.parseObject(response.body(), CommonResult.class); - } - } - - /** - * 处理并更新通知结果 - * - * @param task 通知任务 - * @param invokeResult 通知结果 - * @param invokeException 通知异常 - * @return 最终任务的状态 - */ - @VisibleForTesting - Integer processNotifyResult(PayNotifyTaskDO task, CommonResult invokeResult, Throwable invokeException) { - // 设置通用的更新 PayNotifyTaskDO 的字段 - PayNotifyTaskDO updateTask = new PayNotifyTaskDO() - .setId(task.getId()) - .setLastExecuteTime(LocalDateTime.now()) - .setNotifyTimes(task.getNotifyTimes() + 1); - - // 情况一:调用成功 - if (invokeResult != null && invokeResult.isSuccess()) { - updateTask.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - // 情况二:调用失败、调用异常 - // 2.1 超过最大回调次数 - if (updateTask.getNotifyTimes() >= PayNotifyTaskDO.NOTIFY_FREQUENCY.length) { - updateTask.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - // 2.2 未超过最大回调次数 - updateTask.setNextNotifyTime(addTime(Duration.ofSeconds(PayNotifyTaskDO.NOTIFY_FREQUENCY[updateTask.getNotifyTimes()]))); - updateTask.setStatus(invokeException != null ? PayNotifyStatusEnum.REQUEST_FAILURE.getStatus() - : PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - - @Override - public PayNotifyTaskDO getNotifyTask(Long id) { - return notifyTaskMapper.selectById(id); - } - - @Override - public PageResult getNotifyTaskPage(PayNotifyTaskPageReqVO pageReqVO) { - return notifyTaskMapper.selectPage(pageReqVO); - } - - @Override - public List getNotifyLogList(Long taskId) { - return notifyLogMapper.selectListByTaskId(taskId); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayNotifyServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java deleted file mode 100755 index 978a7950c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 支付订单 Service 接口 - * - * @author aquan - */ -public interface PayOrderService { - - /** - * 获得支付订单 - * - * @param id 编号 - * @return 支付订单 - */ - PayOrderDO getOrder(Long id); - - /** - * 获得支付订单 - * - * @param appId 应用编号 - * @param merchantOrderId 商户订单编号 - * @return 支付订单 - */ - PayOrderDO getOrder(Long appId, String merchantOrderId); - - /** - * 获得指定应用的订单数量 - * - * @param appId 应用编号 - * @return 订单数量 - */ - Long getOrderCountByAppId(Long appId); - - /** - * 获得支付订单分页 - * - * @param pageReqVO 分页查询 - * @return 支付订单分页 - */ - PageResult getOrderPage(PayOrderPageReqVO pageReqVO); - - /** - * 获得支付订单列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 支付订单列表 - */ - List getOrderList(PayOrderExportReqVO exportReqVO); - - /** - * 创建支付单 - * - * @param reqDTO 创建请求 - * @return 支付单编号 - */ - Long createOrder(@Valid PayOrderCreateReqDTO reqDTO); - - /** - * 提交支付 - * 此时,会发起支付渠道的调用 - * - * @param reqVO 提交请求 - * @param userIp 提交 IP - * @return 提交结果 - */ - PayOrderSubmitRespVO submitOrder(@Valid PayOrderSubmitReqVO reqVO, - @NotEmpty(message = "提交 IP 不能为空") String userIp); - - /** - * 通知支付单成功 - * - * @param channelId 渠道编号 - * @param notify 通知 - */ - void notifyOrder(Long channelId, PayOrderRespDTO notify); - - /** - * 更新支付订单的退款金额 - * - * @param id 编号 - * @param incrRefundPrice 增加的退款金额 - */ - void updateOrderRefundPrice(Long id, Integer incrRefundPrice); - - /** - * 更新支付订单价格 - * - * @param id 支付单编号 - * @param payPrice 支付单价格 - */ - void updatePayOrderPrice(Long id, Integer payPrice); - - /** - * 获得支付订单 - * - * @param id 编号 - * @return 支付订单 - */ - PayOrderExtensionDO getOrderExtension(Long id); - - /** - * 获得支付订单 - * - * @param no 支付订单 no - * @return 支付订单 - */ - PayOrderExtensionDO getOrderExtensionByNo(String no); - - /** - * 同步订单的支付状态 - * - * @param minCreateTime 最小创建时间 - * @return 同步到已支付的订单数量 - */ - int syncOrder(LocalDateTime minCreateTime); - - /** - * 将已过期的订单,状态修改为已关闭 - * - * @return 过期的订单数量 - */ - int expireOrder(); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java deleted file mode 100755 index 16977c630..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ /dev/null @@ -1,570 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付订单 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -@Slf4j -public class PayOrderServiceImpl implements PayOrderService { - - @Resource - private PayProperties payProperties; - - @Resource - private PayOrderMapper orderMapper; - @Resource - private PayOrderExtensionMapper orderExtensionMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - - @Override - public PayOrderDO getOrder(Long id) { - return orderMapper.selectById(id); - } - - @Override - public PayOrderDO getOrder(Long appId, String merchantOrderId) { - return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId); - } - - @Override - public Long getOrderCountByAppId(Long appId) { - return orderMapper.selectCountByAppId(appId); - } - - @Override - public PageResult getOrderPage(PayOrderPageReqVO pageReqVO) { - return orderMapper.selectPage(pageReqVO); - } - - @Override - public List getOrderList(PayOrderExportReqVO exportReqVO) { - return orderMapper.selectList(exportReqVO); - } - - @Override - public Long createOrder(PayOrderCreateReqDTO reqDTO) { - // 校验 App - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); - - // 查询对应的支付交易单是否已经存在。如果是,则直接返回 - PayOrderDO order = orderMapper.selectByAppIdAndMerchantOrderId( - reqDTO.getAppId(), reqDTO.getMerchantOrderId()); - if (order != null) { - log.warn("[createOrder][appId({}) merchantOrderId({}) 已经存在对应的支付单({})]", order.getAppId(), - order.getMerchantOrderId(), toJsonString(order)); // 理论来说,不会出现这个情况 - return order.getId(); - } - - // 创建支付交易单 - order = PayOrderConvert.INSTANCE.convert(reqDTO).setAppId(app.getId()) - // 商户相关字段 - .setNotifyUrl(app.getOrderNotifyUrl()) - // 订单相关字段 - .setStatus(PayOrderStatusEnum.WAITING.getStatus()) - // 退款相关字段 - .setRefundPrice(0); - orderMapper.insert(order); - return order.getId(); - } - - @Override // 注意,这里不能添加事务注解,避免调用支付渠道失败时,将 PayOrderExtensionDO 回滚了 - public PayOrderSubmitRespVO submitOrder(PayOrderSubmitReqVO reqVO, String userIp) { - // 1.1 获得 PayOrderDO ,并校验其是否存在 - PayOrderDO order = validateOrderCanSubmit(reqVO.getId()); - // 1.32 校验支付渠道是否有效 - PayChannelDO channel = validateChannelCanSubmit(order.getAppId(), reqVO.getChannelCode()); - PayClient client = channelService.getPayClient(channel.getId()); - - // 2. 插入 PayOrderExtensionDO - String no = noRedisDAO.generate(payProperties.getOrderNoPrefix()); - PayOrderExtensionDO orderExtension = PayOrderConvert.INSTANCE.convert(reqVO, userIp) - .setOrderId(order.getId()).setNo(no) - .setChannelId(channel.getId()).setChannelCode(channel.getCode()) - .setStatus(PayOrderStatusEnum.WAITING.getStatus()); - orderExtensionMapper.insert(orderExtension); - - // 3. 调用三方接口 - PayOrderUnifiedReqDTO unifiedOrderReqDTO = PayOrderConvert.INSTANCE.convert2(reqVO, userIp) - // 商户相关的字段 - .setOutTradeNo(orderExtension.getNo()) // 注意,此处使用的是 PayOrderExtensionDO.no 属性! - .setSubject(order.getSubject()).setBody(order.getBody()) - .setNotifyUrl(genChannelOrderNotifyUrl(channel)) - .setReturnUrl(reqVO.getReturnUrl()) - // 订单相关字段 - .setPrice(order.getPrice()).setExpireTime(order.getExpireTime()); - PayOrderRespDTO unifiedOrderResp = client.unifiedOrder(unifiedOrderReqDTO); - - // 4. 如果调用直接支付成功,则直接更新支付单状态为成功。例如说:付款码支付,免密支付时,就直接验证支付成功 - if (unifiedOrderResp != null) { - getSelf().notifyOrder(channel, unifiedOrderResp); - // 如有渠道错误码,则抛出业务异常,提示用户 - if (StrUtil.isNotEmpty(unifiedOrderResp.getChannelErrorCode())) { - throw exception(PAY_ORDER_SUBMIT_CHANNEL_ERROR, unifiedOrderResp.getChannelErrorCode(), - unifiedOrderResp.getChannelErrorMsg()); - } - // 此处需要读取最新的状态 - order = orderMapper.selectById(order.getId()); - } - return PayOrderConvert.INSTANCE.convert(order, unifiedOrderResp); - } - - private PayOrderDO validateOrderCanSubmit(Long id) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { // 是否存在 - throw exception(PAY_ORDER_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(order.getStatus())) { // 校验状态,发现已支付 - throw exception(PAY_ORDER_STATUS_IS_SUCCESS); - } - if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - if (LocalDateTimeUtils.beforeNow(order.getExpireTime())) { // 校验是否过期 - throw exception(PAY_ORDER_IS_EXPIRED); - } - - // 【重要】校验是否支付拓展单已支付,只是没有回调、或者数据不正常 - validateOrderActuallyPaid(id); - return order; - } - - /** - * 校验支付订单实际已支付 - * - * @param id 支付编号 - */ - @VisibleForTesting - void validateOrderActuallyPaid(Long id) { - List orderExtensions = orderExtensionMapper.selectListByOrderId(id); - orderExtensions.forEach(orderExtension -> { - // 情况一:校验数据库中的 orderExtension 是不是已支付 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.warn("[validateOrderCanSubmit][order({}) 的 extension({}) 已支付,可能是数据不一致]", - id, orderExtension.getId()); - throw exception(PAY_ORDER_EXTENSION_IS_PAID); - } - // 情况二:调用三方接口,查询支付单状态,是不是已支付 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[validateOrderCanSubmit][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - if (respDTO != null && PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) { - log.warn("[validateOrderCanSubmit][order({}) 的 PayOrderRespDTO({}) 已支付,可能是回调延迟]", - id, toJsonString(respDTO)); - throw exception(PAY_ORDER_EXTENSION_IS_PAID); - } - }); - } - - private PayChannelDO validateChannelCanSubmit(Long appId, String channelCode) { - // 校验 App - appService.validPayApp(appId); - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(appId, channelCode); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[validatePayChannelCanSubmit][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - /** - * 根据支付渠道的编码,生成支付渠道的回调地址 - * - * @param channel 支付渠道 - * @return 支付渠道的回调地址 配置地址 + "/" + channel id - */ - private String genChannelOrderNotifyUrl(PayChannelDO channel) { - return payProperties.getOrderNotifyUrl() + "/" + channel.getId(); - } - - @Override - public void notifyOrder(Long channelId, PayOrderRespDTO notify) { - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 更新支付订单为已支付 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyOrder(channel, notify)); - } - - /** - * 通知并更新订单的支付结果 - * - * @param channel 支付渠道 - * @param notify 通知 - */ - @Transactional(rollbackFor = Exception.class) - // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效 - public void notifyOrder(PayChannelDO channel, PayOrderRespDTO notify) { - // 情况一:支付成功的回调 - if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) { - notifyOrderSuccess(channel, notify); - return; - } - // 情况二:支付失败的回调 - if (PayOrderStatusRespEnum.isClosed(notify.getStatus())) { - notifyOrderClosed(channel, notify); - } - // 情况三:WAITING:无需处理 - // 情况四:REFUND:通过退款回调处理 - } - - private void notifyOrderSuccess(PayChannelDO channel, PayOrderRespDTO notify) { - // 1. 更新 PayOrderExtensionDO 支付成功 - PayOrderExtensionDO orderExtension = updateOrderSuccess(notify); - // 2. 更新 PayOrderDO 支付成功 - Boolean paid = updateOrderSuccess(channel, orderExtension, notify); - if (paid) { // 如果之前已经成功回调,则直接返回,不用重复记录支付通知记录;例如说:支付平台重复回调 - return; - } - - // 3. 插入支付通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.ORDER.getType(), - orderExtension.getOrderId()); - } - - /** - * 更新 PayOrderExtensionDO 支付成功 - * - * @param notify 通知 - * @return PayOrderExtensionDO 对象 - */ - private PayOrderExtensionDO updateOrderSuccess(PayOrderRespDTO notify) { - // 1. 查询 PayOrderExtensionDO - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[updateOrderExtensionSuccess][orderExtension({}) 已经是已支付,无需更新]", orderExtension.getId()); - return orderExtension; - } - if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderExtensionDO - int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(), - PayOrderExtensionDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()).channelNotifyData(toJsonString(notify)).build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionSuccess][orderExtension({}) 更新为已支付]", orderExtension.getId()); - return orderExtension; - } - - /** - * 更新 PayOrderDO 支付成功 - * - * @param channel 支付渠道 - * @param orderExtension 支付拓展单 - * @param notify 通知回调 - * @return 是否之前已经成功回调 - */ - private Boolean updateOrderSuccess(PayChannelDO channel, PayOrderExtensionDO orderExtension, - PayOrderRespDTO notify) { - // 1. 判断 PayOrderDO 是否处于待支付 - PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId()); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(order.getStatus()) // 如果已经是成功,直接返回,不用重复更新 - && Objects.equals(order.getExtensionId(), orderExtension.getId())) { - log.info("[updateOrderExtensionSuccess][order({}) 已经是已支付,无需更新]", order.getId()); - return true; - } - if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderDO - int updateCounts = orderMapper.updateByIdAndStatus(order.getId(), PayOrderStatusEnum.WAITING.getStatus(), - PayOrderDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()) - .channelId(channel.getId()).channelCode(channel.getCode()) - .successTime(notify.getSuccessTime()).extensionId(orderExtension.getId()).no(orderExtension.getNo()) - .channelOrderNo(notify.getChannelOrderNo()).channelUserId(notify.getChannelUserId()) - .channelFeeRate(channel.getFeeRate()) - .channelFeePrice(MoneyUtils.calculateRatePrice(order.getPrice(), channel.getFeeRate())) - .build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionSuccess][order({}) 更新为已支付]", order.getId()); - return false; - } - - private void notifyOrderClosed(PayChannelDO channel, PayOrderRespDTO notify) { - updateOrderExtensionClosed(channel, notify); - } - - private void updateOrderExtensionClosed(PayChannelDO channel, PayOrderRespDTO notify) { - // 1. 查询 PayOrderExtensionDO - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { // 如果已经是关闭,直接返回,不用重复更新 - log.info("[updateOrderExtensionClosed][orderExtension({}) 已经是支付关闭,无需更新]", orderExtension.getId()); - return; - } - // 一般出现先是支付成功,然后支付关闭,都是全部退款导致关闭的场景。这个情况,我们不更新支付拓展单,只通过退款流程,更新支付单 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.info("[updateOrderExtensionClosed][orderExtension({}) 是已支付,无需更新为支付关闭]", orderExtension.getId()); - return; - } - if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderExtensionDO - int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(), - PayOrderExtensionDO.builder().status(PayOrderStatusEnum.CLOSED.getStatus()).channelNotifyData(toJsonString(notify)) - .channelErrorCode(notify.getChannelErrorCode()).channelErrorMsg(notify.getChannelErrorMsg()).build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionClosed][orderExtension({}) 更新为支付关闭]", orderExtension.getId()); - } - - @Override - public void updateOrderRefundPrice(Long id, Integer incrRefundPrice) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - if (order.getRefundPrice() + incrRefundPrice > order.getPrice()) { - throw exception(REFUND_PRICE_EXCEED); - } - - // 更新订单 - PayOrderDO updateObj = new PayOrderDO() - .setRefundPrice(order.getRefundPrice() + incrRefundPrice) - .setStatus(PayOrderStatusEnum.REFUND.getStatus()); - int updateCount = orderMapper.updateByIdAndStatus(id, order.getStatus(), updateObj); - if (updateCount == 0) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - } - - @Override - public void updatePayOrderPrice(Long id, Integer payPrice) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (ObjectUtil.notEqual(PayOrderStatusEnum.WAITING.getStatus(), order.getStatus())) { - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - if (ObjectUtil.equal(order.getPrice(), payPrice)) { - return; - } - - // TODO 芋艿:应该 new 出来更新 - order.setPrice(payPrice); - orderMapper.updateById(order); - } - - @Override - public PayOrderExtensionDO getOrderExtension(Long id) { - return orderExtensionMapper.selectById(id); - } - - @Override - public PayOrderExtensionDO getOrderExtensionByNo(String no) { - return orderExtensionMapper.selectByNo(no); - } - - @Override - public int syncOrder(LocalDateTime minCreateTime) { - // 1. 查询指定创建时间内的待支付订单 - List orderExtensions = orderExtensionMapper.selectListByStatusAndCreateTimeGe( - PayOrderStatusEnum.WAITING.getStatus(), minCreateTime); - if (CollUtil.isEmpty(orderExtensions)) { - return 0; - } - // 2. 遍历执行 - int count = 0; - for (PayOrderExtensionDO orderExtension : orderExtensions) { - count += syncOrder(orderExtension) ? 1 : 0; - } - return count; - } - - /** - * 同步单个支付拓展单 - * - * @param orderExtension 支付拓展单 - * @return 是否已支付 - */ - private boolean syncOrder(PayOrderExtensionDO orderExtension) { - try { - // 1.1 查询支付订单信息 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[syncOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return false; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - // 1.2 回调支付结果 - notifyOrder(orderExtension.getChannelId(), respDTO); - - // 2. 如果是已支付,则返回 true - return PayOrderStatusRespEnum.isSuccess(respDTO.getStatus()); - } catch (Throwable e) { - log.error("[syncOrder][orderExtension({}) 同步支付状态异常]", orderExtension.getId(), e); - return false; - } - } - - @Override - public int expireOrder() { - // 1. 查询过期的待支付订单 - List orders = orderMapper.selectListByStatusAndExpireTimeLt( - PayOrderStatusEnum.WAITING.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (PayOrderDO order : orders) { - count += expireOrder(order) ? 1 : 0; - } - return count; - } - - /** - * 同步单个支付单 - * - * @param order 支付单 - * @return 是否已过期 - */ - private boolean expireOrder(PayOrderDO order) { - try { - // 1. 需要先处理关联的支付拓展单,避免错误的过期已支付 or 已退款的订单 - List orderExtensions = orderExtensionMapper.selectListByOrderId(order.getId()); - for (PayOrderExtensionDO orderExtension : orderExtensions) { - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { - continue; - } - // 情况一:校验数据库中的 orderExtension 是不是已支付 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.error("[expireOrder][order({}) 的 extension({}) 已支付,可能是数据不一致]", - order.getId(), orderExtension.getId()); - return false; - } - // 情况二:调用三方接口,查询支付单状态,是不是已支付/已退款 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[expireOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return false; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - if (PayOrderStatusRespEnum.isRefund(respDTO.getStatus())) { - // 补充说明:按道理,应该是 WAITING => SUCCESS => REFUND 状态,如果直接 WAITING => REFUND 状态,说明中间丢了过程 - // 此时,需要人工介入,手工补齐数据,保持 WAITING => SUCCESS => REFUND 的过程 - log.error("[expireOrder][extension({}) 的 PayOrderRespDTO({}) 已退款,可能是回调延迟]", - orderExtension.getId(), toJsonString(respDTO)); - return false; - } - if (PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) { - notifyOrder(orderExtension.getChannelId(), respDTO); - return false; - } - // 兜底逻辑:将支付拓展单更新为已关闭 - PayOrderExtensionDO updateObj = new PayOrderExtensionDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setChannelNotifyData(toJsonString(respDTO)); - if (orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), PayOrderStatusEnum.WAITING.getStatus(), - updateObj) == 0) { - log.error("[expireOrder][extension({}) 更新为支付关闭失败]", orderExtension.getId()); - return false; - } - log.info("[expireOrder][extension({}) 更新为支付关闭成功]", orderExtension.getId()); - } - - // 2. 都没有上述情况,可以安心更新为已关闭 - PayOrderDO updateObj = new PayOrderDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - if (orderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateObj) == 0) { - log.error("[expireOrder][order({}) 更新为支付关闭失败]", order.getId()); - return false; - } - log.info("[expireOrder][order({}) 更新为支付关闭失败]", order.getId()); - return true; - } catch (Throwable e) { - log.error("[expireOrder][order({}) 过期订单异常]", order.getId(), e); - return false; - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayOrderServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java deleted file mode 100755 index 258cea964..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; - -import java.util.List; - -/** - * 退款订单 Service 接口 - * - * @author aquan - */ -public interface PayRefundService { - - /** - * 获得退款订单 - * - * @param id 编号 - * @return 退款订单 - */ - PayRefundDO getRefund(Long id); - - /** - * 获得退款订单 - * - * @param no 外部退款单号 - * @return 退款订单 - */ - PayRefundDO getRefundByNo(String no); - - /** - * 获得指定应用的退款数量 - * - * @param appId 应用编号 - * @return 退款数量 - */ - Long getRefundCountByAppId(Long appId); - - /** - * 获得退款订单分页 - * - * @param pageReqVO 分页查询 - * @return 退款订单分页 - */ - PageResult getRefundPage(PayRefundPageReqVO pageReqVO); - - /** - * 获得退款订单列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 退款订单列表 - */ - List getRefundList(PayRefundExportReqVO exportReqVO); - - /** - * 创建退款申请 - * - * @param reqDTO 退款申请信息 - * @return 退款单号 - */ - Long createPayRefund(PayRefundCreateReqDTO reqDTO); - - /** - * 渠道的退款通知 - * - * @param channelId 渠道编号 - * @param notify 通知 - */ - void notifyRefund(Long channelId, PayRefundRespDTO notify); - - /** - * 同步渠道退款的退款状态 - * - * @return 同步到状态的退款数量,包括退款成功、退款失败 - */ - int syncRefund(); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java deleted file mode 100755 index 20855826d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java +++ /dev/null @@ -1,331 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 退款订单 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -@Validated -public class PayRefundServiceImpl implements PayRefundService { - - @Resource - private PayProperties payProperties; - - @Resource - private PayRefundMapper refundMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Resource - private PayOrderService orderService; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - - @Override - public PayRefundDO getRefund(Long id) { - return refundMapper.selectById(id); - } - - @Override - public PayRefundDO getRefundByNo(String no) { - return refundMapper.selectByNo(no); - } - - @Override - public Long getRefundCountByAppId(Long appId) { - return refundMapper.selectCountByAppId(appId); - } - - @Override - public PageResult getRefundPage(PayRefundPageReqVO pageReqVO) { - return refundMapper.selectPage(pageReqVO); - } - - @Override - public List getRefundList(PayRefundExportReqVO exportReqVO) { - return refundMapper.selectList(exportReqVO); - } - - @Override - public Long createPayRefund(PayRefundCreateReqDTO reqDTO) { - // 1.1 校验 App - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); - // 1.2 校验支付订单 - PayOrderDO order = validatePayOrderCanRefund(reqDTO); - // 1.3 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(order.getChannelId()); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[refund][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - // 1.4 校验退款订单是否已经存在 - PayRefundDO refund = refundMapper.selectByAppIdAndMerchantRefundId( - app.getId(), reqDTO.getMerchantRefundId()); - if (refund != null) { - throw exception(REFUND_EXISTS); - } - - // 2.1 插入退款单 - String no = noRedisDAO.generate(payProperties.getRefundNoPrefix()); - refund = PayRefundConvert.INSTANCE.convert(reqDTO) - .setNo(no).setOrderId(order.getId()).setOrderNo(order.getNo()) - .setChannelId(order.getChannelId()).setChannelCode(order.getChannelCode()) - // 商户相关的字段 - .setNotifyUrl(app.getRefundNotifyUrl()) - // 渠道相关字段 - .setChannelOrderNo(order.getChannelOrderNo()) - // 退款相关字段 - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setPayPrice(order.getPrice()).setRefundPrice(reqDTO.getPrice()); - refundMapper.insert(refund); - try { - // 2.2 向渠道发起退款申请 - PayRefundUnifiedReqDTO unifiedReqDTO = new PayRefundUnifiedReqDTO() - .setPayPrice(order.getPrice()) - .setRefundPrice(reqDTO.getPrice()) - .setOutTradeNo(order.getNo()) - .setOutRefundNo(refund.getNo()) - .setNotifyUrl(genChannelRefundNotifyUrl(channel)) - .setReason(reqDTO.getReason()); - PayRefundRespDTO refundRespDTO = client.unifiedRefund(unifiedReqDTO); - // 2.3 处理退款返回 - getSelf().notifyRefund(channel, refundRespDTO); - } catch (Throwable e) { - // 注意:这里仅打印异常,不进行抛出。 - // 原因是:虽然调用支付渠道进行退款发生异常(网络请求超时),实际退款成功。这个结果,后续通过退款回调、或者退款轮询补偿可以拿到。 - // 最终,在异常的情况下,支付中心会异步回调业务的退款回调接口,提供退款结果 - log.error("[createPayRefund][退款 id({}) requestDTO({}) 发生异常]", - refund.getId(), reqDTO, e); - } - - // 返回退款编号 - return refund.getId(); - } - - /** - * 校验支付订单是否可以退款 - * - * @param reqDTO 退款申请信息 - * @return 支付订单 - */ - private PayOrderDO validatePayOrderCanRefund(PayRefundCreateReqDTO reqDTO) { - PayOrderDO order = orderService.getOrder(reqDTO.getAppId(), reqDTO.getMerchantOrderId()); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - // 校验状态,必须是已支付、或者已退款 - if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - // 校验金额,退款金额不能大于原定的金额 - if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()){ - throw exception(REFUND_PRICE_EXCEED); - } - // 是否有退款中的订单 - if (refundMapper.selectCountByAppIdAndOrderId(reqDTO.getAppId(), order.getId(), - PayRefundStatusEnum.WAITING.getStatus()) > 0) { - throw exception(REFUND_HAS_REFUNDING); - } - return order; - } - - /** - * 根据支付渠道的编码,生成支付渠道的回调地址 - * - * @param channel 支付渠道 - * @return 支付渠道的回调地址 配置地址 + "/" + channel id - */ - private String genChannelRefundNotifyUrl(PayChannelDO channel) { - return payProperties.getRefundNotifyUrl() + "/" + channel.getId(); - } - - @Override - public void notifyRefund(Long channelId, PayRefundRespDTO notify) { - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 更新退款订单 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyRefund(channel, notify)); - } - - /** - * 通知并更新订单的退款结果 - * - * @param channel 支付渠道 - * @param notify 通知 - */ - @Transactional(rollbackFor = Exception.class) // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效 - public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) { - // 情况一:退款成功 - if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) { - notifyRefundSuccess(channel, notify); - return; - } - // 情况二:退款失败 - if (PayRefundStatusRespEnum.isFailure(notify.getStatus())) { - notifyRefundFailure(channel, notify); - } - } - - private void notifyRefundSuccess(PayChannelDO channel, PayRefundRespDTO notify) { - // 1.1 查询 PayRefundDO - PayRefundDO refund = refundMapper.selectByAppIdAndNo( - channel.getAppId(), notify.getOutRefundNo()); - if (refund == null) { - throw exception(REFUND_NOT_FOUND); - } - if (PayRefundStatusEnum.isSuccess(refund.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[notifyRefundSuccess][退款订单({}) 已经是退款成功,无需更新]", refund.getId()); - return; - } - if (!PayRefundStatusEnum.WAITING.getStatus().equals(refund.getStatus())) { - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - // 1.2 更新 PayRefundDO - PayRefundDO updateRefundObj = new PayRefundDO() - .setSuccessTime(notify.getSuccessTime()) - .setChannelRefundNo(notify.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(notify)); - int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj); - if (updateCounts == 0) { // 校验状态,必须是等待状态 - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - log.info("[notifyRefundSuccess][退款订单({}) 更新为退款成功]", refund.getId()); - - // 2. 更新订单 - orderService.updateOrderRefundPrice(refund.getOrderId(), refund.getRefundPrice()); - - // 3. 插入退款通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(), - refund.getId()); - } - - private void notifyRefundFailure(PayChannelDO channel, PayRefundRespDTO notify) { - // 1.1 查询 PayRefundDO - PayRefundDO refund = refundMapper.selectByAppIdAndNo( - channel.getAppId(), notify.getOutRefundNo()); - if (refund == null) { - throw exception(REFUND_NOT_FOUND); - } - if (PayRefundStatusEnum.isFailure(refund.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[notifyRefundSuccess][退款订单({}) 已经是退款关闭,无需更新]", refund.getId()); - return; - } - if (!PayRefundStatusEnum.WAITING.getStatus().equals(refund.getStatus())) { - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - // 1.2 更新 PayRefundDO - PayRefundDO updateRefundObj = new PayRefundDO() - .setChannelRefundNo(notify.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.FAILURE.getStatus()) - .setChannelNotifyData(toJsonString(notify)) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()); - int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj); - if (updateCounts == 0) { // 校验状态,必须是等待状态 - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - log.info("[notifyRefundFailure][退款订单({}) 更新为退款失败]", refund.getId()); - - // 2. 插入退款通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(), - refund.getId()); - } - - @Override - public int syncRefund() { - // 1. 查询指定创建时间内的待退款订单 - List refunds = refundMapper.selectListByStatus(PayRefundStatusEnum.WAITING.getStatus()); - if (CollUtil.isEmpty(refunds)) { - return 0; - } - // 2. 遍历执行 - int count = 0; - for (PayRefundDO refund : refunds) { - count += syncRefund(refund) ? 1 : 0; - } - return count; - } - - /** - * 同步单个退款订单 - * - * @param refund 退款订单 - * @return 是否同步到 - */ - private boolean syncRefund(PayRefundDO refund) { - try { - // 1.1 查询退款订单信息 - PayClient payClient = channelService.getPayClient(refund.getChannelId()); - if (payClient == null) { - log.error("[syncRefund][渠道编号({}) 找不到对应的支付客户端]", refund.getChannelId()); - return false; - } - PayRefundRespDTO respDTO = payClient.getRefund(refund.getOrderNo(), refund.getNo()); - // 1.2 回调退款结果 - notifyRefund(refund.getChannelId(), respDTO); - - // 2. 如果同步到,则返回 true - return PayRefundStatusEnum.isSuccess(respDTO.getStatus()) - || PayRefundStatusEnum.isFailure(respDTO.getStatus()); - } catch (Throwable e) { - log.error("[syncRefund][refund({}) 同步退款状态异常]", refund.getId(), e); - return false; - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayRefundServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java deleted file mode 100644 index 0da38c640..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.transfer; - -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitRespVO; - -import javax.validation.Valid; - -/** - * 转账 Service 接口 - * - * @author jason - */ -public interface PayTransferService { - - /** - * 提交转账单 - * - * 此时,会发起支付渠道的调用 - * - * @param reqVO 请求 - * @param userIp 用户 ip - * @return 渠道的返回结果 - */ - PayTransferSubmitRespVO submitTransfer(@Valid PayTransferSubmitReqVO reqVO, String userIp); - - /** - * 创建转账单 - * - * @param reqDTO 创建请求 - * @return 转账单编号 - */ - Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java deleted file mode 100644 index cbe5b739c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java +++ /dev/null @@ -1,271 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.transfer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.transfer.PayTransferExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.transfer.PayTransferMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.*; - -// TODO @jason:等彻底实现完,单测写写; -/** - * 转账 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayTransferServiceImpl implements PayTransferService { - - private static final String TRANSFER_NO_PREFIX = "T"; - - @Resource - private PayTransferMapper transferMapper; - @Resource - private PayTransferExtensionMapper transferExtensionMapper; - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @Resource - private PayNoRedisDAO noRedisDAO; - - @Override - public PayTransferSubmitRespVO submitTransfer(PayTransferSubmitReqVO reqVO, String userIp) { - // 1.1 校验转账单是否可以提交 - PayTransferDO transfer = validateTransferCanSubmit(reqVO.getId()); - // 1.2 校验转账类型和渠道是否匹配 - validateChannelCodeAndTypeMatch(reqVO.getChannelCode(), transfer.getType()); - // 1.3 校验支付渠道是否有效 - PayChannelDO channel = validateChannelCanSubmit(transfer.getAppId(), reqVO.getChannelCode()); - PayClient client = channelService.getPayClient(channel.getId()); - - // 2. 新增转账拓展单 - String no = noRedisDAO.generate(TRANSFER_NO_PREFIX); - PayTransferExtensionDO transferExtension = new PayTransferExtensionDO().setNo(no) - .setTransferId(transfer.getId()).setChannelId(channel.getId()) - .setChannelCode(channel.getCode()).setStatus(WAITING.getStatus()); - transferExtensionMapper.insert(transferExtension); - - // 3. 调用三方渠道发起转账 - PayTransferUnifiedReqDTO transferUnifiedReq = new PayTransferUnifiedReqDTO() - .setOutTransferNo(transferExtension.getNo()).setPrice(transfer.getPrice()) - .setType(transfer.getType()).setTitle(transfer.getSubject()) - .setPayeeInfo(transfer.getPayeeInfo()).setUserIp(userIp) - .setChannelExtras(reqVO.getChannelExtras()); - PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); - - // 4. 通知转账结果 - getSelf().notifyTransfer(channel, unifiedTransferResp); - // 如有渠道错误码,则抛出业务异常,提示用户 - if (StrUtil.isNotEmpty(unifiedTransferResp.getChannelErrorCode())) { - throw exception(PAY_TRANSFER_SUBMIT_CHANNEL_ERROR, unifiedTransferResp.getChannelErrorCode(), - unifiedTransferResp.getChannelErrorMsg()); - } - return new PayTransferSubmitRespVO().setStatus(unifiedTransferResp.getStatus()); - } - - @Override - public Long createTransfer(PayTransferCreateReqDTO reqDTO) { - // 校验 App - appService.validPayApp(reqDTO.getAppId()); - // 创建转账单 - PayTransferDO transfer = PayTransferConvert.INSTANCE.convert(reqDTO) - .setStatus(WAITING.getStatus()); - transferMapper.insert(transfer); - return transfer.getId(); - } - - @Transactional(rollbackFor = Exception.class) - // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyTransfer(channel, notify) 调用,否则事务不生效 - public void notifyTransfer(PayChannelDO channel, PayTransferRespDTO notify) { - // 转账成功的回调 - if (PayTransferStatusRespEnum.isSuccess(notify.getStatus())) { - notifyTransferSuccess(channel, notify); - } - // 转账关闭的回调 - if (PayTransferStatusRespEnum.isClosed(notify.getStatus())) { - notifyTransferClosed(channel, notify); - } - // WAITING 状态无需处理 - // TODO IN_PROGRESS 待处理 - } - - private void notifyTransferSuccess(PayChannelDO channel, PayTransferRespDTO notify) { - // 1. 更新 PayTransferExtensionDO 转账成功 - PayTransferExtensionDO transferExtension = updateTransferExtensionSuccess(notify); - - // 2. 更新 PayTransferDO 转账成功 - Boolean transferred = updateTransferSuccess(channel,transferExtension, notify); - if (transferred) { - return; - } - // 3. TODO 插入转账通知记录 - } - - private Boolean updateTransferSuccess(PayChannelDO channel, PayTransferExtensionDO transferExtension, - PayTransferRespDTO notify) { - // 1.校验 - PayTransferDO transfer = transferMapper.selectById(transferExtension.getTransferId()); - if (transfer == null) { - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (isSuccess(transfer.getStatus()) && Objects.equals(transfer.getExtensionId(), transferExtension.getId())) { - log.info("[updateTransferSuccess][transfer({}) 已经是已转账,无需更新]", transfer.getId()); - return true; - } - if (!isPendingStatus(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - // 2.更新 - int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferDO().setStatus(SUCCESS.getStatus()).setSuccessTime(notify.getSuccessTime()) - .setChannelId(channel.getId()).setChannelCode(channel.getCode()) - .setExtensionId(transferExtension.getId()).setNo(transferExtension.getNo())); - if (updateCounts == 0) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferSuccess][transfer({}) 更新为已转账]", transfer.getId()); - return false; - } - - private PayTransferExtensionDO updateTransferExtensionSuccess(PayTransferRespDTO notify) { - // 1 校验 - PayTransferExtensionDO transferExtension = transferExtensionMapper.selectByNo(notify.getOutTransferNo()); - if (transferExtension == null) { - throw exception(PAY_TRANSFER_EXTENSION_NOT_FOUND); - } - if (isSuccess(transferExtension.getStatus())) { // 如果已成功,直接返回,不用重复更新 - log.info("[updateTransferExtensionSuccess][transferExtension({}) 已经是成功状态,无需更新]", transferExtension.getId()); - return transferExtension; - } - if (!isPendingStatus(transferExtension.getStatus())) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - // 2. 更新 PayTransferExtensionDO - int updateCount = transferExtensionMapper.updateByIdAndStatus(transferExtension.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferExtensionDO().setStatus(SUCCESS.getStatus()) - .setChannelNotifyData(JsonUtils.toJsonString(notify))); - if (updateCount == 0) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferExtensionSuccess][transferExtension({}) 更新为已转账]", transferExtension.getId()); - return transferExtension; - } - - private void notifyTransferClosed(PayChannelDO channel, PayTransferRespDTO notify) { - // 更新 PayTransferExtensionDO 转账关闭 - updateTransferExtensionClosed(notify); - } - - private void updateTransferExtensionClosed(PayTransferRespDTO notify) { - // 1 校验 - PayTransferExtensionDO transferExtension = transferExtensionMapper.selectByNo(notify.getOutTransferNo()); - if (transferExtension == null) { - throw exception(PAY_TRANSFER_EXTENSION_NOT_FOUND); - } - if (isClosed(transferExtension.getStatus())) { // 如果已是关闭状态,直接返回,不用重复更新 - log.info("[updateTransferExtensionSuccess][transferExtension({}) 已经是关闭状态,无需更新]", transferExtension.getId()); - return; - } - if (!isPendingStatus(transferExtension.getStatus())) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - // 2. 更新 PayTransferExtensionDO - int updateCount = transferExtensionMapper.updateByIdAndStatus(transferExtension.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferExtensionDO().setStatus(CLOSED.getStatus()) - .setChannelNotifyData(JsonUtils.toJsonString(notify))); - if (updateCount == 0) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferExtensionSuccess][transferExtension({}) 更新为关闭状态]", transferExtension.getId()); - } - - private void validateChannelCodeAndTypeMatch(String channelCode, Integer type) { - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(type); - PayChannelEnum payChannel = PayChannelEnum.getByCode(channelCode); - switch (transferType) { - case ALIPAY_BALANCE: { - // TODO @jason:可以抽到 PayChannelEnum 里,isAlipay? 类似这种哈 - if (!payChannel.getCode().startsWith("alipay")) { - throw exception(PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH); - } - break; - } - case WX_BALANCE: - case BANK_CARD: - case WALLET_BALANCE: { - throw new UnsupportedOperationException("待实现"); - } - } - } - - private PayChannelDO validateChannelCanSubmit(Long appId, String channelCode) { - // 校验 App - appService.validPayApp(appId); - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(appId, channelCode); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[validateChannelCanSubmit][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - private PayTransferDO validateTransferCanSubmit(Long id) { - PayTransferDO transfer = transferMapper.selectById(id); - if (transfer == null) { // 是否存在 - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (PayTransferStatusEnum.isSuccess(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_SUCCESS); - } - if (!PayTransferStatusEnum.isWaiting(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_WAITING); - } - // TODO 查询拓展单是否未已转账和转账中 - return transfer; - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayTransferServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java deleted file mode 100644 index 235d2a908..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; - -import javax.validation.Valid; - -/** - * 钱包充值套餐 Service 接口 - * - * @author jason - */ -public interface PayWalletRechargePackageService { - - /** - * 获取钱包充值套餐 - * @param packageId 充值套餐编号 - */ - PayWalletRechargePackageDO getWalletRechargePackage(Long packageId); - - /** - * 校验钱包充值套餐的有效性, 无效的话抛出 ServiceException 异常 - * - * @param packageId 充值套餐编号 - */ - PayWalletRechargePackageDO validWalletRechargePackage(Long packageId); - - /** - * 创建充值套餐 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createWalletRechargePackage(@Valid WalletRechargePackageCreateReqVO createReqVO); - - /** - * 更新充值套餐 - * - * @param updateReqVO 更新信息 - */ - void updateWalletRechargePackage(@Valid WalletRechargePackageUpdateReqVO updateReqVO); - - /** - * 删除充值套餐 - * - * @param id 编号 - */ - void deleteWalletRechargePackage(Long id); - - /** - * 获得充值套餐分页 - * - * @param pageReqVO 分页查询 - * @return 充值套餐分页 - */ - PageResult getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java deleted file mode 100644 index 12224ed4c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargePackageMapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 钱包充值套餐 Service 实现类 - * - * @author jason - */ -@Service -public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePackageService { - - @Resource - private PayWalletRechargePackageMapper walletRechargePackageMapper; - - @Override - public PayWalletRechargePackageDO getWalletRechargePackage(Long packageId) { - return walletRechargePackageMapper.selectById(packageId); - } - - @Override - public PayWalletRechargePackageDO validWalletRechargePackage(Long packageId) { - PayWalletRechargePackageDO rechargePackageDO = walletRechargePackageMapper.selectById(packageId); - if (rechargePackageDO == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND); - } - if (CommonStatusEnum.DISABLE.getStatus().equals(rechargePackageDO.getStatus())) { - throw exception(WALLET_RECHARGE_PACKAGE_IS_DISABLE); - } - return rechargePackageDO; - } - - @Override - public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) { - // 校验套餐名是否唯一 - validateRechargePackageNameUnique(null, createReqVO.getName()); - - // 插入 - PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO); - walletRechargePackageMapper.insert(walletRechargePackage); - // 返回 - return walletRechargePackage.getId(); - } - - @Override - public void updateWalletRechargePackage(WalletRechargePackageUpdateReqVO updateReqVO) { - // 校验存在 - validateWalletRechargePackageExists(updateReqVO.getId()); - // 校验套餐名是否唯一 - validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName()); - - // 更新 - PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO); - walletRechargePackageMapper.updateById(updateObj); - } - - private void validateRechargePackageNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - PayWalletRechargePackageDO rechargePackage = walletRechargePackageMapper.selectByName(name); - if (rechargePackage == null) { - return ; - } - if (id == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS); - } - if (!id.equals(rechargePackage.getId())) { - throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS); - } - } - - @Override - public void deleteWalletRechargePackage(Long id) { - // 校验存在 - validateWalletRechargePackageExists(id); - // 删除 - walletRechargePackageMapper.deleteById(id); - } - - private void validateWalletRechargePackageExists(Long id) { - if (walletRechargePackageMapper.selectById(id) == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND); - } - } - - @Override - public PageResult getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO) { - return walletRechargePackageMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java deleted file mode 100644 index 752ce89af..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; - -/** - * 钱包充值 Service 接口 - * - * @author jason - */ -public interface PayWalletRechargeService { - - /** - * 创建钱包充值记录(发起充值) - * - * @param userId 用户 id - * @param userType 用户类型 - * @param createReqVO 钱包充值请求 VO - * @param userIp 用户Ip - * @return 钱包充值记录 - */ - PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, - AppPayWalletRechargeCreateReqVO createReqVO); - - /** - * 更新钱包充值成功 - * - * @param id 钱包充值记录 id - * @param payOrderId 支付订单 id - */ - void updateWalletRechargerPaid(Long id, Long payOrderId); - - /** - * 发起钱包充值退款 - * - * @param id 钱包充值编号 - * @param userIp 用户 ip 地址 - */ - void refundWalletRecharge(Long id, String userIp); - - /** - * 更新钱包充值记录为已退款 - * - * @param id 钱包充值 id - * @param payRefundId 退款单id - */ - void updateWalletRechargeRefunded(Long id, Long payRefundId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java deleted file mode 100644 index 1c6e10611..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java +++ /dev/null @@ -1,281 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.Objects; - -import static cn.hutool.core.util.ObjectUtil.notEqual; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; - -/** - * 钱包充值 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { - - /** - * TODO 芋艿:放到 payconfig - */ - private static final Long WALLET_PAY_APP_ID = 8L; - - private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; - - @Resource - private PayWalletRechargeMapper walletRechargeMapper; - @Resource - private PayWalletService payWalletService; - @Resource - private PayOrderService payOrderService; - @Resource - private PayRefundService payRefundService; - @Resource - private PayWalletRechargePackageService payWalletRechargePackageService; - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, - AppPayWalletRechargeCreateReqVO reqVO) { - - if (Objects.isNull(reqVO.getPayPrice()) && Objects.isNull(reqVO.getPackageId())) { - // TODO @jason @AssertTrue 貌似没有效果。需要查下原因 - throw exception(WALLET_RECHARGE_PACKAGE_AND_PRICE_IS_EMPTY); - } - // 1.1 计算充值金额 - int payPrice; - int bonusPrice = 0; - if (Objects.nonNull(reqVO.getPackageId())) { - PayWalletRechargePackageDO rechargePackage = payWalletRechargePackageService.validWalletRechargePackage(reqVO.getPackageId()); - payPrice = rechargePackage.getPayPrice(); - bonusPrice = rechargePackage.getBonusPrice(); - } else { - payPrice = reqVO.getPayPrice(); - } - // 1.2 插入充值记录 - PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); - PayWalletRechargeDO recharge = INSTANCE.convert(wallet.getId(), payPrice, bonusPrice, reqVO.getPackageId()); - walletRechargeMapper.insert(recharge); - - // 2.1 创建支付单 - Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) - .setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号 - .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("") - .setPrice(recharge.getPayPrice()) - .setExpireTime(addTime(Duration.ofHours(2L)))); // TODO @芋艿:支付超时时间 - // 2.2 更新钱包充值记录中支付订单 - walletRechargeMapper.updateById(new PayWalletRechargeDO().setId(recharge.getId()).setPayOrderId(payOrderId)); - recharge.setPayOrderId(payOrderId); - return recharge; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWalletRechargerPaid(Long id, Long payOrderId) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以支付 - PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); - - // 2. 更新钱包充值的支付状态 - int updateCount = walletRechargeMapper.updateByIdAndPaid(id, false, - new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now()) - .setPayChannelCode(payOrderDO.getChannelCode())); - if (updateCount == 0) { - throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // 3. 更新钱包余额 - // TODO @jason:这样的话,未来提现会不会把充值的,也提现走哈。类似先充 100,送 110;然后提现 110; - // TODO 需要钱包中加个可提现余额 - payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id), - PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void refundWalletRecharge(Long id, String userIp) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[refundWalletRecharge][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以发起退款 - PayWalletDO wallet = validateWalletRechargeCanRefund(walletRecharge); - - // 2. 冻结退款的余额,暂时只处理赠送的余额也全部退回 - payWalletService.freezePrice(wallet.getId(), walletRecharge.getTotalPrice()); - - // 3. 创建退款单 - String walletRechargeId = String.valueOf(id); - String refundId = walletRechargeId + "-refund"; - Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO() - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) - .setMerchantOrderId(walletRechargeId) - .setMerchantRefundId(refundId) - .setReason("想退钱").setPrice(walletRecharge.getPayPrice())); - - // 4. 更新充值记录退款单号 - // TODO @jaosn:一般新建这种 update 对象,建议是,第一个 set id 属性,容易知道以它为更新 - walletRechargeMapper.updateById(new PayWalletRechargeDO().setPayRefundId(payRefundId) - .setRefundStatus(WAITING.getStatus()).setId(walletRecharge.getId())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWalletRechargeRefunded(Long id, Long payRefundId) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以更新已退款 - PayRefundDO payRefund = validateWalletRechargeCanRefunded(walletRecharge, payRefundId); - - PayWalletRechargeDO updateObj = new PayWalletRechargeDO().setId(id); - // 退款成功 - if (PayRefundStatusEnum.isSuccess(payRefund.getStatus())) { - // 2.1 更新钱包余额 - payWalletService.reduceWalletBalance(walletRecharge.getWalletId(), id, - PayWalletBizTypeEnum.RECHARGE_REFUND, walletRecharge.getTotalPrice()); - - updateObj.setRefundStatus(SUCCESS.getStatus()).setRefundTime(payRefund.getSuccessTime()) - .setRefundTotalPrice(walletRecharge.getTotalPrice()).setRefundPayPrice(walletRecharge.getPayPrice()) - .setRefundBonusPrice(walletRecharge.getBonusPrice()); - } - // 退款失败 - if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) { - // 2.2 解冻余额 - payWalletService.unfreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice()); - - updateObj.setRefundStatus(FAILURE.getStatus()); - } - // 3. 更新钱包充值的退款字段 - walletRechargeMapper.updateByIdAndRefunded(id, WAITING.getStatus(), updateObj); - } - - private PayRefundDO validateWalletRechargeCanRefunded(PayWalletRechargeDO walletRecharge, Long payRefundId) { - // 1. 校验退款订单匹配 - if (notEqual(walletRecharge.getPayRefundId(), payRefundId)) { - log.error("[validateWalletRechargeCanRefunded][钱包充值({}) 退款单不匹配({}),请进行处理!钱包充值的数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - - // 2.1 校验退款订单 - PayRefundDO payRefund = payRefundService.getRefund(payRefundId); - if (payRefund == null) { - log.error("[validateWalletRechargeCanRefunded][payRefund({})不存在]", payRefundId); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND); - } - // 2.2 校验退款金额一致 - if (notEqual(payRefund.getRefundPrice(), walletRecharge.getPayPrice())) { - log.error("[validateWalletRechargeCanRefunded][钱包({}) payRefund({}) 退款金额不匹配,请进行处理!钱包数据是:{},payRefund 数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(walletRecharge), toJsonString(payRefund)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH); - } - // 2.3 校验退款订单商户订单是否匹配 - if (notEqual(payRefund.getMerchantOrderId(), walletRecharge.getId().toString())) { - log.error("[validateWalletRechargeCanRefunded][钱包({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(payRefund)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - return payRefund; - } - - private PayWalletDO validateWalletRechargeCanRefund(PayWalletRechargeDO walletRecharge) { - // 校验充值订单是否支付 - if (!walletRecharge.getPayStatus()) { - throw exception(WALLET_RECHARGE_REFUND_FAIL_NOT_PAID); - } - // 校验充值订单是否已退款 - if (walletRecharge.getPayRefundId() != null) { - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUNDED); - } - // 校验钱包余额是否足够 - PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); - Assert.notNull(wallet, "用户钱包({}) 不存在", wallet.getId()); - if (wallet.getBalance() < walletRecharge.getTotalPrice()) { - throw exception(WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH); - } - // TODO @芋艿:需要考虑下,赠送的金额,会不会导致提现超过; - return wallet; - } - - private PayOrderDO validateWalletRechargerCanPaid(PayWalletRechargeDO walletRecharge, Long payOrderId) { - // 1.1 校验充值记录的支付状态 - if (walletRecharge.getPayStatus()) { - log.error("[validateWalletRechargerCanPaid][钱包({}) 不处于未支付状态! 钱包数据是:{}]", - walletRecharge.getId(), toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 1.2 校验支付订单匹配 - if (notEqual(walletRecharge.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateWalletRechargerCanPaid][钱包({}) 支付单不匹配({}),请进行处理! 钱包数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); - } - - // 2.1 校验支付单是否存在 - PayOrderDO payOrder = payOrderService.getOrder(payOrderId); - if (payOrder == null) { - log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 不存在,请进行处理!]", - walletRecharge.getId(), payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 2.2 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 2.3 校验支付金额一致 - if (notEqual(payOrder.getPrice(), walletRecharge.getPayPrice())) { - log.error("[validateDemoOrderCanPaid][钱包({}) payOrder({}) 支付金额不匹配,请进行处理!钱包 数据是:{},payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(walletRecharge), toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH); - } - // 2.4 校验支付订单的商户订单匹配 - if (notEqual(payOrder.getMerchantOrderId(), walletRecharge.getId().toString())) { - log.error("[validateDemoOrderCanPaid][钱包({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); - } - return payOrder; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java deleted file mode 100644 index d9abe958d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; - -/** - * 钱包 Service 接口 - * - * @author jason - */ -public interface PayWalletService { - - /** - * 获取钱包信息 - *

- * 如果不存在,则创建钱包。由于用户注册时候不会创建钱包 - * - * @param userId 用户编号 - * @param userType 用户类型 - */ - PayWalletDO getOrCreateWallet(Long userId, Integer userType); - - /** - * 获取钱包信息 - * - * @param walletId 钱包 id - */ - PayWalletDO getWallet(Long walletId); - - - /** - * 获得会员钱包分页 - * - * @param pageReqVO 分页查询 - * @return 会员钱包分页 - */ - PageResult getWalletPage(Integer userType, PayWalletPageReqVO pageReqVO); - - /** - * 钱包订单支付 - * - * @param userId 用户 id - * @param userType 用户类型 - * @param outTradeNo 外部订单号 - * @param price 金额 - */ - PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price); - - /** - * 钱包订单支付退款 - * - * @param outRefundNo 外部退款号 - * @param refundPrice 退款金额 - * @param reason 退款原因 - */ - PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason); - - /** - * 扣减钱包余额 - * - * @param walletId 钱包 id - * @param bizId 业务关联 id - * @param bizType 业务关联分类 - * @param price 扣减金额 - * @return 钱包流水 - */ - PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, - PayWalletBizTypeEnum bizType, Integer price); - - /** - * 增加钱包余额 - * - * @param walletId 钱包 id - * @param bizId 业务关联 id - * @param bizType 业务关联分类 - * @param price 增加金额 - * @return 钱包流水 - */ - PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, - PayWalletBizTypeEnum bizType, Integer price); - - /** - * 冻结钱包部分余额 - * - * @param id 钱包编号 - * @param price 冻结金额 - */ - void freezePrice(Long id, Integer price); - - /** - * 解冻钱包余额 - * - * @param id 钱包编号 - * @param price 解冻金额 - */ - void unfreezePrice(Long id, Integer price); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java deleted file mode 100644 index db4ad647a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT; -import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT_REFUND; - -/** - * 钱包 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayWalletServiceImpl implements PayWalletService { - - @Resource - private PayWalletMapper walletMapper; - @Resource - private PayWalletTransactionService walletTransactionService; - @Resource - @Lazy - private PayOrderService orderService; - @Resource - @Lazy - private PayRefundService refundService; - - @Override - public PayWalletDO getOrCreateWallet(Long userId, Integer userType) { - PayWalletDO wallet = walletMapper.selectByUserIdAndType(userId, userType); - if (wallet == null) { - wallet = new PayWalletDO().setUserId(userId).setUserType(userType) - .setBalance(0).setTotalExpense(0).setTotalRecharge(0); - wallet.setCreateTime(LocalDateTime.now()); - walletMapper.insert(wallet); - } - return wallet; - } - - @Override - public PayWalletDO getWallet(Long walletId) { - return walletMapper.selectById(walletId); - } - - @Override - public PageResult getWalletPage(Integer userType,PayWalletPageReqVO pageReqVO) { - return walletMapper.selectPage(userType, pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price) { - // 1. 判断支付交易拓展单是否存 - PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - PayWalletDO wallet = getOrCreateWallet(userId, userType); - // 2. 扣减余额 - return reduceWalletBalance(wallet.getId(), orderExtension.getOrderId(), PAYMENT, price); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason) { - // 1.1 判断退款单是否存在 - PayRefundDO payRefund = refundService.getRefundByNo(outRefundNo); - if (payRefund == null) { - throw exception(REFUND_NOT_FOUND); - } - // 1.2 校验是否可以退款 - Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo()); - PayWalletDO wallet = walletMapper.selectById(walletId); - Assert.notNull(wallet, "钱包 {} 不存在", walletId); - - // 2. 增加余额 - return addWalletBalance(walletId, String.valueOf(payRefund.getId()), PAYMENT_REFUND, refundPrice); - } - - /** - * 校验是否能退款 - * - * @param refundId 支付退款单 id - * @param walletPayNo 钱包支付 no - */ - private Long validateWalletCanRefund(Long refundId, String walletPayNo) { - // 1. 校验钱包支付交易存在 - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransactionByNo(walletPayNo); - if (walletTransaction == null) { - throw exception(WALLET_TRANSACTION_NOT_FOUND); - } - // 2. 校验退款是否存在 - PayWalletTransactionDO refundTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(refundId), PAYMENT_REFUND); - if (refundTransaction != null) { - throw exception(WALLET_REFUND_EXIST); - } - return walletTransaction.getWalletId(); - } - - @Override - public PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, - PayWalletBizTypeEnum bizType, Integer price) { - // 1. 获取钱包 - PayWalletDO payWallet = getWallet(walletId); - if (payWallet == null) { - log.error("[reduceWalletBalance],用户钱包({})不存在.", walletId); - throw exception(WALLET_NOT_FOUND); - } - - // 2.1 扣除余额 - int updateCounts; - switch (bizType) { - case PAYMENT: { - updateCounts = walletMapper.updateWhenConsumption(payWallet.getId(), price); - break; - } - case RECHARGE_REFUND: { - updateCounts = walletMapper.updateWhenRechargeRefund(payWallet.getId(), price); - break; - } - default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); - } - } - if (updateCounts == 0) { - throw exception(WALLET_BALANCE_NOT_ENOUGH); - } - // 2.2 生成钱包流水 - Integer afterBalance = payWallet.getBalance() - price; - WalletTransactionCreateReqBO bo = new WalletTransactionCreateReqBO().setWalletId(payWallet.getId()) - .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) - .setBizType(bizType.getType()).setTitle(bizType.getDescription()); - return walletTransactionService.createWalletTransaction(bo); - } - - @Override - public PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, - PayWalletBizTypeEnum bizType, Integer price) { - // 1.1 获取钱包 - PayWalletDO payWallet = getWallet(walletId); - if (payWallet == null) { - log.error("[addWalletBalance],用户钱包({})不存在.", walletId); - throw exception(WALLET_NOT_FOUND); - } - // 1.2 更新钱包金额 - switch (bizType) { - case PAYMENT_REFUND: { // 退款更新 - walletMapper.updateWhenConsumptionRefund(payWallet.getId(), price); - break; - } - case RECHARGE: { // 充值更新 - walletMapper.updateWhenRecharge(payWallet.getId(), price); - break; - } - default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); - } - } - - // 2. 生成钱包流水 - WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO() - .setWalletId(payWallet.getId()).setPrice(price).setBalance(payWallet.getBalance() + price) - .setBizId(bizId).setBizType(bizType.getType()).setTitle(bizType.getDescription()); - return walletTransactionService.createWalletTransaction(transactionCreateReqBO); - } - - @Override - public void freezePrice(Long id, Integer price) { - int updateCounts = walletMapper.freezePrice(id, price); - if (updateCounts == 0) { - throw exception(WALLET_BALANCE_NOT_ENOUGH); - } - } - - @Override - public void unfreezePrice(Long id, Integer price) { - int updateCounts = walletMapper.unFreezePrice(id, price); - if (updateCounts == 0) { - throw exception(WALLET_FREEZE_PRICE_NOT_ENOUGH); - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java deleted file mode 100644 index 21fc0dc18..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; - -import javax.validation.Valid; - -/** - * 钱包余额流水 Service 接口 - * - * @author jason - */ -public interface PayWalletTransactionService { - - /** - * 查询钱包余额流水分页 - * - * @param userId 用户编号 - * @param userType 用户类型 - * @param pageVO 分页查询参数 - */ - PageResult getWalletTransactionPage(Long userId, Integer userType, - AppPayWalletTransactionPageReqVO pageVO); - - /** - * 查询钱包余额流水分页 - * - * @param pageVO 分页查询参数 - */ - PageResult getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO); - - /** - * 新增钱包余额流水 - * - * @param bo 创建钱包流水 bo - * @return 新建的钱包 do - */ - PayWalletTransactionDO createWalletTransaction(@Valid WalletTransactionCreateReqBO bo); - - /** - * 根据 no,获取钱包余流水 - * - * @param no 流水号 - */ - PayWalletTransactionDO getWalletTransactionByNo(String no); - - /** - * 获取钱包流水 - * - * @param bizId 业务编号 - * @param type 业务类型 - * @return 钱包流水 - */ - PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java deleted file mode 100644 index 357ac6a4e..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -/** - * 钱包流水 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -@Validated -public class PayWalletTransactionServiceImpl implements PayWalletTransactionService { - - /** - * 钱包流水的 no 前缀 - */ - private static final String WALLET_NO_PREFIX = "W"; - - @Resource - private PayWalletService payWalletService; - @Resource - private PayWalletTransactionMapper payWalletTransactionMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Override - public PageResult getWalletTransactionPage(Long userId, Integer userType, - AppPayWalletTransactionPageReqVO pageVO) { - PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); - return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO); - } - - @Override - public PageResult getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) { - return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO); - } - - @Override - public PayWalletTransactionDO createWalletTransaction(WalletTransactionCreateReqBO bo) { - PayWalletTransactionDO transaction = PayWalletTransactionConvert.INSTANCE.convert(bo) - .setNo(noRedisDAO.generate(WALLET_NO_PREFIX)); - payWalletTransactionMapper.insert(transaction); - return transaction; - } - - @Override - public PayWalletTransactionDO getWalletTransactionByNo(String no) { - return payWalletTransactionMapper.selectByNo(no); - } - - @Override - public PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type) { - return payWalletTransactionMapper.selectByBiz(bizId, type.getType()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java deleted file mode 100644 index a305ceb0d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 创建钱包流水 BO - * - * @author jason - */ -@Data -public class WalletTransactionCreateReqBO { - - /** - * 钱包编号 - * - */ - @NotNull(message = "钱包编号不能为空") - private Long walletId; - - /** - * 交易金额,单位分 - * - * 正值表示余额增加,负值表示余额减少 - */ - @NotNull(message = "交易金额不能为空") - private Integer price; - - /** - * 交易后余额,单位分 - */ - @NotNull(message = "交易后余额不能为空") - private Integer balance; - - /** - * 关联业务分类 - * - * 枚举 {@link PayWalletBizTypeEnum#getType()} - */ - @NotNull(message = "关联业务分类不能为空") - @InEnum(PayWalletBizTypeEnum.class) - private Integer bizType; - - /** - * 关联业务编号 - */ - @NotEmpty(message = "关联业务编号不能为空") - private String bizId; - - /** - * 流水说明 - */ - @NotEmpty(message = "流水说明不能为空") - private String title; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/MoneyUtils.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/MoneyUtils.java deleted file mode 100644 index 15865f60a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/MoneyUtils.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.util; - -import cn.hutool.core.util.NumberUtil; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -/** - * 金额工具类 - * - * @author 芋道源码 - */ -public class MoneyUtils { - - /** - * 计算百分比金额,四舍五入 - * - * @param price 金额 - * @param rate 百分比,例如说 56.77% 则传入 56.77 - * @return 百分比金额 - */ - public static Integer calculateRatePrice(Integer price, Double rate) { - return calculateRatePrice(price, rate, 0, RoundingMode.HALF_UP).intValue(); - } - - /** - * 计算百分比金额 - * - * @param price 金额 - * @param rate 百分比,例如说 56.77% 则传入 56.77 - * @param scale 保留小数位数 - * @param roundingMode 舍入模式 - */ - public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) { - return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以 - .divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100 - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java deleted file mode 100644 index 3882a2fd3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.util; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; - -import java.time.LocalDateTime; -import java.util.concurrent.atomic.AtomicLong; - -/** - * 支付相关编号的生产 - */ -// TODO @jason:需要改造,基于 db; -public class PaySeqUtils { - - private static final AtomicLong REFUND_REQ_NO_SEQ = new AtomicLong(0L); - - private static final AtomicLong MER_REFUND_NO_SEQ = new AtomicLong(0L); - - private static final AtomicLong MER_ORDER_NO_SEQ = new AtomicLong(0L); - - // TODO 芋艿:需要看看 - /** - * 生成商户退款单号,用于测试,应该由商户系统生成 - * @return 商户退款单 - */ - public static String genMerchantRefundNo() { - return String.format("%s%s%04d", "MR", - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), - (int) MER_REFUND_NO_SEQ.getAndIncrement() % 10000); - } - - // TODO 芋艿:需要看看 - - /** - * 生成退款请求号 - * @return 退款请求号 - */ - public static String genRefundReqNo() { - return String.format("%s%s%04d", "RR", - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), - (int) REFUND_REQ_NO_SEQ.getAndIncrement() % 10000); - } - - /** - * 生成商户订单编号号 用于测试,应该由商户系统生成 - * @return 商户订单编号 - */ - public static String genMerchantOrderNo() { - return String.format("%s%s%04d", "MO", - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), - (int) MER_ORDER_NO_SEQ.getAndIncrement() % 10000); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 30b8ecaf4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,102 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - pay: - order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 - refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 - demo: false # 关闭演示模式 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml deleted file mode 100644 index d250a3d51..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,128 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 - # password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:8000/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.pay.dal.mysql: debug - cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper: INFO # 配置 PayNotifyTaskMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - pay: - order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 - refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 - demo: false # 关闭演示模式 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml deleted file mode 100644 index 24eab6c32..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,108 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.pay - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - - /admin-api/pay/notify/** # 支付回调通知,不携带租户编号 - -debug: false diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 9f25acdb8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: pay-server - - profiles: - active: local - -server: - port: 48085 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/logback-spring.xml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java deleted file mode 100644 index 73b4f6f82..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java +++ /dev/null @@ -1,29 +0,0 @@ -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.weixin.WXPayClientConfig; -import org.junit.jupiter.api.Test; - -public class PayChannelDOTest { - - @Test - public void testSerialization() { - PayChannelDO payChannelDO = new PayChannelDO(); - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - payChannelDO.setConfig(config); - - // 序列化 - String text = JsonUtils.toJsonString(payChannelDO); - System.out.println(text); - - // 反序列化 - payChannelDO = JsonUtils.parseObject(text, PayChannelDO.class); - System.out.println(payChannelDO.getConfig().getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java deleted file mode 100644 index 2150a8a15..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.merchant; - -import cn.hutool.core.io.IoUtil; -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.weixin.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; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.List; - -@Resource -public class PayChannelMapperIntegrationTest extends BaseDbIntegrationTest { - - @Resource - private PayChannelMapper payChannelMapper; - - /** - * 插入 {@link PayChannelEnum#WX_PUB} 初始配置 - */ - @Test - public void testInsertWxPub() throws FileNotFoundException { - PayChannelDO payChannelDO = new PayChannelDO(); - payChannelDO.setCode(PayChannelEnum.WX_PUB.getCode()); - payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - payChannelDO.setFeeRate(1D); - payChannelDO.setAppId(6L); - // 配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - payChannelDO.setConfig(config); - // 执行插入 - payChannelMapper.insert(payChannelDO); - } - - // TODO @ouyang:Zfb 改成 AlipayQr - /** - * 插入 {@link PayChannelEnum#ALIPAY_QR} 初始配置 - */ - @Test - public void testInsertZfb() { - PayChannelDO payChannelDO = new PayChannelDO(); - payChannelDO.setCode(PayChannelEnum.ALIPAY_QR.getCode()); - payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - payChannelDO.setFeeRate(1D); - payChannelDO.setAppId(6L); - // 配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - payChannelDO.setConfig(config); - // 执行插入 - payChannelMapper.insert(payChannelDO); - } - - /** - * 查询所有支付配置,看看是否都是 ok 的 - */ - @Test - public void testSelectList() { - List payChannels = payChannelMapper.selectList(); - System.out.println(payChannels.size()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java deleted file mode 100644 index 55a37ad1a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.iocoder.yudao.module.pay.service.channel.PayAppServiceImpl; -import cn.iocoder.yudao.module.pay.service.channel.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; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; - -@Import({PayOrderServiceImpl.class, PayAppServiceImpl.class, - PayChannelServiceImpl.class, YudaoPayAutoConfiguration.class}) -public class PayOrderServiceIntegrationTest extends BaseDbIntegrationTest { - - @Resource - private PayOrderService payOrderService; - - @Test - public void testCreatePayOrder() { - // 构造请求 - PayOrderCreateReqDTO reqDTO = new PayOrderCreateReqDTO(); - reqDTO.setAppId(6L); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); - reqDTO.setSubject("标题"); - reqDTO.setBody("内容"); - reqDTO.setPrice(100); - reqDTO.setExpireTime(DateUtils.addTime(Duration.ofDays(1))); - // 发起请求 - payOrderService.createPayOrder(reqDTO); - } - - @Test - public void testSubmitPayOrder() { - // 构造请求 - PayOrderSubmitReqDTO reqDTO = new PayOrderSubmitReqDTO(); - reqDTO.setId(10L); - reqDTO.setAppId(6L); - reqDTO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqDTO.setUserIp("127.0.0.1"); - // 发起请求 - payOrderService.submitPayOrder(reqDTO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java deleted file mode 100644 index 2cad91eba..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.pay.service; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java deleted file mode 100644 index 2ee19ebf9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbAndRedisIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java deleted file mode 100644 index 380efa3f4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java deleted file mode 100644 index d01353d72..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseRedisIntegrationTest { - - @Import({ - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml deleted file mode 100644 index 8d17aaa90..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml +++ /dev/null @@ -1,83 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志 - global-config: - db-config: - id-type: AUTO # 自增 ID - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - mapper-locations: classpath*:mapper/*.xml - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.pay - pay: - pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify - refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java deleted file mode 100644 index 1934cfe97..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java +++ /dev/null @@ -1,258 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -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 java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link PayAppServiceImpl} 的单元测试 - * - * @author aquan - */ -@Import(PayAppServiceImpl.class) -public class PayAppServiceTest extends BaseDbUnitTest { - - @Resource - private PayAppServiceImpl appService; - - @Resource - private PayAppMapper appMapper; - - @MockBean - private PayOrderService orderService; - @MockBean - private PayRefundService refundService; - - @Test - public void testCreateApp_success() { - // 准备参数 - PayAppCreateReqVO reqVO = randomPojo(PayAppCreateReqVO.class, o -> - o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())) - .setOrderNotifyUrl(randomURL()) - .setRefundNotifyUrl(randomURL())); - - // 调用 - Long appId = appService.createApp(reqVO); - // 断言 - assertNotNull(appId); - PayAppDO app = appMapper.selectById(appId); - assertPojoEquals(reqVO, app); - } - - @Test - public void testUpdateApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setOrderNotifyUrl(randomURL()).setRefundNotifyUrl(randomURL()); - o.setId(dbApp.getId()); // 设置更新的 ID - }); - - // 调用 - appService.updateApp(reqVO); - // 校验是否更新正确 - PayAppDO app = appMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, app); - } - - @Test - public void testUpdateApp_notExists() { - // 准备参数 - PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> - o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus()))); - // 调用, 并断言异常 - assertServiceException(() -> appService.updateApp(reqVO), APP_NOT_FOUND); - } - - @Test - public void testUpdateAppStatus() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> - o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - - // 准备参数 - Long id = dbApp.getId(); - Integer status = CommonStatusEnum.ENABLE.getStatus(); - // 调用 - appService.updateAppStatus(id, status); - // 断言 - PayAppDO app = appMapper.selectById(id); // 获取最新的 - assertEquals(status, app.getStatus()); - } - - @Test - public void testDeleteApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - appService.deleteApp(id); - // 校验数据不存在了 - assertNull(appMapper.selectById(id)); - } - - @Test - public void testDeleteApp_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_NOT_FOUND); - } - - @Test - public void testDeleteApp_existOrder() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - // mock 订单有订单 - when(orderService.getOrderCountByAppId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_EXIST_ORDER_CANT_DELETE); - } - - @Test - public void testDeleteApp_existRefund() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - // mock 订单有订单 - when(refundService.getRefundCountByAppId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_EXIST_REFUND_CANT_DELETE); - } - - @Test - public void testApp() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - PayAppDO app = appService.getApp(id); - // 校验数据一致 - assertPojoEquals(app, dbApp); - } - - @Test - public void testAppMap() { - // mock 数据 - PayAppDO dbApp01 = randomPojo(PayAppDO.class); - appMapper.insert(dbApp01);// @Sql: 先插入出一条存在的数据 - PayAppDO dbApp02 = randomPojo(PayAppDO.class); - appMapper.insert(dbApp02);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp01.getId(); - - // 调用 - Map appMap = appService.getAppMap(singleton(id)); - // 校验数据一致 - assertEquals(1, appMap.size()); - assertPojoEquals(dbApp01, appMap.get(id)); - } - - @Test - public void testGetAppPage() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 - o.setName("灿灿姐的杂货铺"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021,11,20)); - }); - - appMapper.insert(dbApp); - // 测试 name 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺"))); - // 测试 status 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21)))); - // 准备参数 - PayAppPageReqVO reqVO = new PayAppPageReqVO(); - reqVO.setName("灿灿姐的杂货铺"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2021, 11, 19, 2021, 11, 21)); - - // 调用 - PageResult pageResult = appService.getAppPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbApp, pageResult.getList().get(0)); - } - - @Test - public void testValidPayApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - PayAppDO app = appService.validPayApp(id); - // 校验数据一致 - assertPojoEquals(app, dbApp); - } - - @Test - public void testValidPayApp_notFound() { - assertServiceException(() -> appService.validPayApp(randomLongId()), APP_NOT_FOUND); - } - - @Test - public void testValidPayApp_disable() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用,并断言异常 - assertServiceException(() -> appService.validPayApp(id), APP_IS_DISABLE); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java deleted file mode 100644 index 09631d3d2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java +++ /dev/null @@ -1,343 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -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.weixin.WxPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; -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.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import({PayChannelServiceImpl.class}) -public class PayChannelServiceTest extends BaseDbUnitTest { - - @Resource - private PayChannelServiceImpl channelService; - - @Resource - private PayChannelMapper channelMapper; - - @MockBean - private PayClientFactory payClientFactory; - @MockBean - private Validator validator; - - @Test - public void testCreateChannel_success() { - // 准备参数 - WxPayClientConfig config = randomWxPayClientConfig(); - PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { - o.setStatus(randomCommonStatus()); - o.setCode(PayChannelEnum.WX_PUB.getCode()); - o.setConfig(JsonUtils.toJsonString(config)); - }); - - // 调用 - Long channelId = channelService.createChannel(reqVO); - // 校验记录的属性是否正确 - PayChannelDO channel = channelMapper.selectById(channelId); - assertPojoEquals(reqVO, channel, "config"); - assertPojoEquals(config, channel.getConfig()); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(channelId)); - } - - @Test - public void testCreateChannel_exists() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, - o -> o.setConfig(randomWxPayClientConfig())); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { - o.setAppId(dbChannel.getAppId()); - o.setCode(dbChannel.getCode()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.createChannel(reqVO), CHANNEL_EXIST_SAME_CHANNEL_ERROR); - } - - @Test - public void testUpdateChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - AlipayPayClientConfig config = randomAlipayPayClientConfig(); - PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> { - o.setId(dbChannel.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setConfig(JsonUtils.toJsonString(config)); - }); - - // 调用 - channelService.updateChannel(reqVO); - // 校验是否更新正确 - PayChannelDO channel = channelMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, channel, "config"); - assertPojoEquals(config, channel.getConfig()); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(channel.getId())); - } - - @Test - public void testUpdateChannel_notExists() { - // 准备参数 - AlipayPayClientConfig payClientPublicKeyConfig = randomAlipayPayClientConfig(); - PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setConfig(JSON.toJSONString(payClientPublicKeyConfig)); - }); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.updateChannel(reqVO), CHANNEL_NOT_FOUND); - } - - @Test - public void testDeleteChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - channelService.deleteChannel(id); - // 校验数据不存在了 - assertNull(channelMapper.selectById(id)); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(id)); - } - - @Test - public void testDeleteChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.deleteChannel(id), CHANNEL_NOT_FOUND); - } - - @Test - public void testGetChannel() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - PayChannelDO channel = channelService.getChannel(id); - // 校验是否更新正确 - assertPojoEquals(dbChannel, channel); - } - - @Test - public void testGetChannelListByAppIds() { - // mock 数据 - PayChannelDO dbChannel01 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel01);// @Sql: 先插入出一条存在的数据 - PayChannelDO dbChannel02 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.WX_PUB.getCode()); - o.setConfig(randomWxPayClientConfig()); - }); - channelMapper.insert(dbChannel02);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel01.getAppId(); - - // 调用 - List channels = channelService.getChannelListByAppIds(Collections.singleton(appId)); - // 校验是否更新正确 - assertEquals(1, channels.size()); - assertPojoEquals(dbChannel01, channels.get(0)); - } - - @Test - public void testGetChannelByAppIdAndCode() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode(); - - // 调用 - PayChannelDO channel = channelService.getChannelByAppIdAndCode(appId, code); - // 断言 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testValidPayChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.validPayChannel(id), CHANNEL_NOT_FOUND); - } - - @Test - public void testValidPayChannel_isDisable() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.validPayChannel(id), CHANNEL_IS_DISABLE); - } - - @Test - public void testValidPayChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - PayChannelDO channel = channelService.validPayChannel(id); - // 断言异常 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testValidPayChannel_appIdAndCode() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode(); - - // 调用 - PayChannelDO channel = channelService.validPayChannel(appId, code); - // 断言异常 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testGetEnableChannelList() { - // 准备参数 - Long appId = randomLongId(); - // mock 数据 01(enable 不匹配) - PayChannelDO dbChannel01 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - channelMapper.insert(dbChannel01);// @Sql: 先插入出一条存在的数据 - // mock 数据 02(appId 不匹配) - PayChannelDO dbChannel02 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel02);// @Sql: 先插入出一条存在的数据 - // mock 数据 03 - PayChannelDO dbChannel03 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setAppId(appId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel03);// @Sql: 先插入出一条存在的数据 - - // 调用 - List channel = channelService.getEnableChannelList(appId); - // 断言异常 - assertPojoEquals(channel, dbChannel03); - } - - @Test - public void testGetPayClient() { - // mock 数据 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(channel); - // mock 参数 - Long id = channel.getId(); - // mock 方法 - PayClient mockClient = mock(PayClient.class); - when(payClientFactory.getPayClient(eq(id))).thenReturn(mockClient); - - // 调用 - PayClient client = channelService.getPayClient(id); - // 断言 - assertSame(client, mockClient); - verify(payClientFactory).createOrUpdatePayClient(eq(id), eq(channel.getCode()), - eq(channel.getConfig())); - } - - public WxPayClientConfig randomWxPayClientConfig() { - return new WxPayClientConfig() - .setAppId(randomString()) - .setMchId(randomString()) - .setApiVersion(WxPayClientConfig.API_VERSION_V2) - .setMchKey(randomString()); - } - - public AlipayPayClientConfig randomAlipayPayClientConfig() { - return new AlipayPayClientConfig() - .setServerUrl(randomURL()) - .setAppId(randomString()) - .setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT) - .setMode(AlipayPayClientConfig.MODE_PUBLIC_KEY) - .setPrivateKey(randomString()) - .setAlipayPublicKey(randomString()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java deleted file mode 100644 index eb931f4fb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java +++ /dev/null @@ -1,351 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyLogMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper; -import cn.iocoder.yudao.module.pay.dal.redis.notify.PayNotifyLockRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.framework.job.config.PayJobConfiguration; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundServiceImpl; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayJobConfiguration.class, PayNotifyServiceImpl.class, PayNotifyLockRedisDAO.class}) -public class PayNotifyServiceTest extends BaseDbUnitTest { - - @Resource - private PayNotifyServiceImpl notifyService; - - @MockBean - private PayOrderService orderService; - @MockBean - private PayRefundService refundService; - - @Resource - private PayNotifyTaskMapper notifyTaskMapper; - @Resource - private PayNotifyLogMapper notifyLogMapper; - - @MockBean - private RedissonClient redissonClient; - - @Test - public void testCreatePayNotifyTask_order() { - PayNotifyServiceImpl payNotifyService = mock(PayNotifyServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayNotifyServiceImpl.class))) - .thenReturn(payNotifyService); - - // 准备参数 - Integer type = PayNotifyTypeEnum.ORDER.getType(); - Long dataId = 1L; - // mock 方法(order) - PayOrderDO order = randomPojo(PayOrderDO.class); - when(orderService.getOrder(eq(1L))).thenReturn(order); - // mock 方法(lock) - mockLock(null); // null 的原因,是咱没办法拿到 taskId 新增 - - // 调用 - notifyService.createPayNotifyTask(type, dataId); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectOne(null); - assertNotNull(dbTask.getNextNotifyTime()); - assertThat(dbTask) - .extracting("type", "dataId", "status", "notifyTimes", "maxNotifyTimes", - "appId", "merchantOrderId", "notifyUrl") - .containsExactly(type, dataId, PayNotifyStatusEnum.WAITING.getStatus(), 0, 9, - order.getAppId(), order.getMerchantOrderId(), order.getNotifyUrl()); - // 断言,调用 - verify(payNotifyService).executeNotify0(eq(dbTask)); - } - } - - @Test - public void testCreatePayNotifyTask_refund() { - PayNotifyServiceImpl payNotifyService = mock(PayNotifyServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayNotifyServiceImpl.class))) - .thenReturn(payNotifyService); - - // 准备参数 - Integer type = PayNotifyTypeEnum.REFUND.getType(); - Long dataId = 1L; - // mock 方法(refund) - PayRefundDO refund = randomPojo(PayRefundDO.class); - when(refundService.getRefund(eq(1L))).thenReturn(refund); - // mock 方法(lock) - mockLock(null); // null 的原因,是咱没办法拿到 taskId 新增 - - // 调用 - notifyService.createPayNotifyTask(type, dataId); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectOne(null); - assertNotNull(dbTask.getNextNotifyTime()); - assertThat(dbTask) - .extracting("type", "dataId", "status", "notifyTimes", "maxNotifyTimes", - "appId", "merchantOrderId", "notifyUrl") - .containsExactly(type, dataId, PayNotifyStatusEnum.WAITING.getStatus(), 0, 9, - refund.getAppId(), refund.getMerchantOrderId(), refund.getNotifyUrl()); - // 断言,调用 - verify(payNotifyService).executeNotify0(eq(dbTask)); - } - } - - @Test - public void testExecuteNotify() throws InterruptedException { - // mock 数据(notify) - PayNotifyTaskDO dbTask01 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.WAITING.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask01); - PayNotifyTaskDO dbTask02 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask02); - PayNotifyTaskDO dbTask03 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask03); - PayNotifyTaskDO dbTask04 = randomPojo(PayNotifyTaskDO.class, // 不满足状态 - o -> o.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask04); - PayNotifyTaskDO dbTask05 = randomPojo(PayNotifyTaskDO.class, // 不满足状态 - o -> o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask05); - PayNotifyTaskDO dbTask06 = randomPojo(PayNotifyTaskDO.class, // 不满足时间 - o -> o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(1)))); - notifyTaskMapper.insert(dbTask06); - // mock 方法(lock) - mockLock(dbTask01.getId()); - mockLock(dbTask02.getId()); - mockLock(dbTask03.getId()); - - // 调用 - int count = notifyService.executeNotify(); - // 断言,数量 - assertEquals(count, 3); - } - - @Test // 由于 HttpUtil 不好 mock,所以只测试异常的情况 - public void testExecuteNotify0_exception() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, o -> o.setType(-1) - .setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - - // 调用 - notifyService.executeNotify0(task); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - // 断言,log - PayNotifyLogDO dbLog = notifyLogMapper.selectOne(null); - assertEquals(dbLog.getTaskId(), task.getId()); - assertEquals(dbLog.getNotifyTimes(), 1); - assertTrue(dbLog.getResponse().contains("未知的通知任务类型:")); - assertEquals(dbLog.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - } - - @Test - public void testProcessNotifyResult_success() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.success(randomString()); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.SUCCESS.getStatus()); - } - - @Test - public void testProcessNotifyResult_failure() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(8).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 9); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.FAILURE.getStatus()); - } - - @Test - public void testProcessNotifyResult_requestFailure() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()); - } - - @Test - public void testProcessNotifyResult_requestSuccess() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - RuntimeException invokeException = new RuntimeException(); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, invokeException); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - } - - @Test - public void testGetNotifyTask() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class); - notifyTaskMapper.insert(task); - // 准备参数 - Long id = task.getId(); - - // 调用 - PayNotifyTaskDO dbTask = notifyService.getNotifyTask(id); - // 断言 - assertPojoEquals(dbTask, task); - } - - @Test - public void testGetNotifyTaskPage() { - // mock 数据 - PayNotifyTaskDO dbTask = randomPojo(PayNotifyTaskDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setType(PayNotifyTypeEnum.REFUND.getType()); - o.setDataId(100L); - o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - o.setMerchantOrderId("P110"); - o.setCreateTime(buildTime(2023, 2, 3)); - }); - notifyTaskMapper.insert(dbTask); - // 测试 appId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setAppId(2L))); - // 测试 type 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setType(PayNotifyTypeEnum.ORDER.getType()))); - // 测试 dataId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setDataId(200L))); - // 测试 status 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()))); - // 测试 merchantOrderId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setMerchantOrderId(randomString()))); - // 测试 createTime 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCreateTime(buildTime(2023, 1, 1)))); - // 准备参数 - PayNotifyTaskPageReqVO reqVO = new PayNotifyTaskPageReqVO(); - reqVO.setAppId(1L); - reqVO.setType(PayNotifyTypeEnum.REFUND.getType()); - reqVO.setDataId(100L); - reqVO.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - reqVO.setMerchantOrderId("P110"); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = notifyService.getNotifyTaskPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTask, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyLogList() { - // mock 数据 - PayNotifyLogDO dbLog = randomPojo(PayNotifyLogDO.class); - notifyLogMapper.insert(dbLog); - PayNotifyLogDO dbLog02 = randomPojo(PayNotifyLogDO.class); - notifyLogMapper.insert(dbLog02); - // 准备参数 - Long taskId = dbLog.getTaskId(); - - // 调用 - List logList = notifyService.getNotifyLogList(taskId); - // 断言 - assertEquals(logList.size(), 1); - assertPojoEquals(dbLog, logList.get(0)); - } - - private void mockLock(Long id) { - RLock lock = mock(RLock.class); - if (id == null) { - when(redissonClient.getLock(anyString())) - .thenReturn(lock); - } else { - when(redissonClient.getLock(eq("pay_notify:lock:" + id))) - .thenReturn(lock); - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java deleted file mode 100755 index cf72aa819..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java +++ /dev/null @@ -1,1102 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -/** - * {@link PayOrderServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayOrderServiceImpl.class, PayNoRedisDAO.class}) -public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { - - @Resource - private PayOrderServiceImpl orderService; - - @Resource - private PayOrderMapper orderMapper; - @Resource - private PayOrderExtensionMapper orderExtensionMapper; - - @MockBean - private PayProperties properties; - @MockBean - private PayAppService appService; - @MockBean - private PayChannelService channelService; - @MockBean - private PayNotifyService notifyService; - - @BeforeEach - public void setUp() { - when(properties.getOrderNotifyUrl()).thenReturn("http://127.0.0.1"); - } - - @Test - public void testGetOrder_id() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - - // 调用 - PayOrderDO dbOrder = orderService.getOrder(id); - // 断言 - assertPojoEquals(dbOrder, order); - } - - @Test - public void testGetOrder_appIdAndMerchantOrderId() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class); - orderMapper.insert(order); - // 准备参数 - Long appId = order.getAppId(); - String merchantOrderId = order.getMerchantOrderId(); - - // 调用 - PayOrderDO dbOrder = orderService.getOrder(appId, merchantOrderId); - // 断言 - assertPojoEquals(dbOrder, order); - } - - @Test - public void testGetOrderCountByAppId() { - // mock 数据(PayOrderDO) - PayOrderDO order01 = randomPojo(PayOrderDO.class); - orderMapper.insert(order01); - PayOrderDO order02 = randomPojo(PayOrderDO.class); - orderMapper.insert(order02); - // 准备参数 - Long appId = order01.getAppId(); - - // 调用 - Long count = orderService.getOrderCountByAppId(appId); - // 断言 - assertEquals(count, 1L); - } - - @Test - public void testGetOrderPage() { - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("110"); - o.setChannelOrderNo("220"); - o.setNo("330"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setCreateTime(buildTime(2018, 1, 15)); - }); - orderMapper.insert(dbOrder); - // 测试 appId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(randomString()))); - // 测试 channelOrderNo 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelOrderNo(randomString()))); - // 测试 no 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNo(randomString()))); - // 测试 status 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()))); - // 测试 createTime 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(buildTime(2019, 1, 1)))); - // 准备参数 - PayOrderPageReqVO reqVO = new PayOrderPageReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("11"); - reqVO.setChannelOrderNo("22"); - reqVO.setNo("33"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2018, 1, 10, 2018, 1, 30)); - - // 调用 - PageResult pageResult = orderService.getOrderPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbOrder, pageResult.getList().get(0)); - } - - @Test - public void testGetOrderList() { - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("110"); - o.setChannelOrderNo("220"); - o.setNo("330"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setCreateTime(buildTime(2018, 1, 15)); - }); - orderMapper.insert(dbOrder); - // 测试 appId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(randomString()))); - // 测试 channelOrderNo 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelOrderNo(randomString()))); - // 测试 no 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNo(randomString()))); - // 测试 status 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()))); - // 测试 createTime 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(buildTime(2019, 1, 1)))); - // 准备参数 - PayOrderExportReqVO reqVO = new PayOrderExportReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("11"); - reqVO.setChannelOrderNo("22"); - reqVO.setNo("33"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2018, 1, 10, 2018, 1, 30)); - - // 调用 - List list = orderService.getOrderList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbOrder, list.get(0)); - } - - @Test - public void testCreateOrder_success() { - // mock 参数 - PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("10") - .setSubject(randomString()).setBody(randomString())); - // mock 方法 - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L).setOrderNotifyUrl("http://127.0.0.1")); - when(appService.validPayApp(eq(reqDTO.getAppId()))).thenReturn(app); - - // 调用 - Long orderId = orderService.createOrder(reqDTO); - // 断言 - PayOrderDO order = orderMapper.selectById(orderId); - assertPojoEquals(order, reqDTO); - assertEquals(order.getAppId(), 1L); - assertEquals(order.getNotifyUrl(), "http://127.0.0.1"); - assertEquals(order.getStatus(), PayOrderStatusEnum.WAITING.getStatus()); - assertEquals(order.getRefundPrice(), 0); - } - - @Test - public void testCreateOrder_exists() { - // mock 参数 - PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("10")); - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> o.setAppId(1L).setMerchantOrderId("10")); - orderMapper.insert(dbOrder); - - // 调用 - Long orderId = orderService.createOrder(reqDTO); - // 断言 - PayOrderDO order = orderMapper.selectById(orderId); - assertPojoEquals(dbOrder, order); - } - - @Test - public void testSubmitOrder_notFound() { - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_NOT_FOUND); - } - - @Test - public void testSubmitOrder_notWaiting() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus())); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_NOT_WAITING); - } - - @Test - public void testSubmitOrder_isSuccess() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_SUCCESS); - } - - @Test - public void testSubmitOrder_expired() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofDays(-1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_IS_EXPIRED); - } - - @Test - public void testSubmitOrder_channelNotFound() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), CHANNEL_NOT_FOUND); - } - - @Test // 调用 unifiedOrder 接口,返回存在渠道错误 - public void testSubmitOrder_channelError() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法() - PayOrderRespDTO unifiedOrderResp = randomPojo(PayOrderRespDTO.class, o -> - o.setChannelErrorCode("001").setChannelErrorMsg("模拟异常")); - when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> { - assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo()); - assertThat(payOrderUnifiedReqDTO) - .extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime") - .containsExactly(order.getSubject(), order.getBody(), "http://127.0.0.1/10", - reqVO.getReturnUrl(), order.getPrice(), order.getExpireTime()); - return true; - }))).thenReturn(unifiedOrderResp); - - // 调用,并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), - PAY_ORDER_SUBMIT_CHANNEL_ERROR, "001", "模拟异常"); - // 断言,数据记录(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null); - assertNotNull(orderExtension); - assertThat(orderExtension).extracting("no", "orderId").isNotNull(); - assertThat(orderExtension) - .extracting("channelId", "channelCode","userIp" ,"status", "channelExtras", - "channelErrorCode", "channelErrorMsg", "channelNotifyData") - .containsExactly(10L, PayChannelEnum.ALIPAY_APP.getCode(), userIp, - PayOrderStatusEnum.WAITING.getStatus(), reqVO.getChannelExtras(), - null, null, null); - } - } - - @Test - public void testSubmitOrder_success() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(支付渠道的调用) - PayOrderRespDTO unifiedOrderResp = randomPojo(PayOrderRespDTO.class, o -> o.setChannelErrorCode(null).setChannelErrorMsg(null) - .setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()).setDisplayContent("tudou")); - when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> { - assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo()); - assertThat(payOrderUnifiedReqDTO) - .extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime") - .containsExactly(order.getSubject(), order.getBody(), "http://127.0.0.1/10", - reqVO.getReturnUrl(), order.getPrice(), order.getExpireTime()); - return true; - }))).thenReturn(unifiedOrderResp); - - // 调用 - PayOrderSubmitRespVO result = orderService.submitOrder(reqVO, userIp); - // 断言,数据记录(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null); - assertNotNull(orderExtension); - assertThat(orderExtension).extracting("no", "orderId").isNotNull(); - assertThat(orderExtension) - .extracting("channelId", "channelCode","userIp" ,"status", "channelExtras", - "channelErrorCode", "channelErrorMsg", "channelNotifyData") - .containsExactly(10L, PayChannelEnum.ALIPAY_APP.getCode(), userIp, - PayOrderStatusEnum.WAITING.getStatus(), reqVO.getChannelExtras(), - null, null, null); - // 断言,返回(PayOrderSubmitRespVO) - assertThat(result) - .extracting("status", "displayMode", "displayContent") - .containsExactly(PayOrderStatusEnum.WAITING.getStatus(), PayOrderDisplayModeEnum.URL.getMode(), "tudou"); - // 断言,调用 - verify(payOrderServiceImpl).notifyOrder(same(channel), same(unifiedOrderResp)); - } - } - - @Test - public void testValidateOrderActuallyPaid_dbPaid() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderExtensionMapper.insert(orderExtension); - - // 调用,并断言异常 - assertServiceException(() -> orderService.validateOrderActuallyPaid(id), - PAY_ORDER_EXTENSION_IS_PAID); - } - - @Test - public void testValidateOrderActuallyPaid_remotePaid() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient 已支付) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(orderExtension.getChannelId()))).thenReturn(client); - when(client.getOrder(eq(orderExtension.getNo()))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()))); - - // 调用,并断言异常 - assertServiceException(() -> orderService.validateOrderActuallyPaid(id), - PAY_ORDER_EXTENSION_IS_PAID); - } - - @Test - public void testValidateOrderActuallyPaid_success() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient 已支付) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(orderExtension.getChannelId()))).thenReturn(client); - when(client.getOrder(eq(orderExtension.getNo()))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - - // 调用,并断言异常 - orderService.validateOrderActuallyPaid(id); - } - - @Test - public void testNotifyOrder_channelId() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - // 准备参数 - Long channelId = 10L; - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - orderService.notifyOrder(channelId, notify); - // 断言 - verify(payOrderServiceImpl).notifyOrder(same(channel), same(notify)); - } - } - - @Test - public void testNotifyOrderSuccess_orderExtension_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_NOT_FOUND); - } - - @Test - public void testNotifyOrderSuccess_orderExtension_closed() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyOrderSuccess_order_notFound() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_NOT_FOUND); - // 断言 PayOrderExtensionDO :数据更新被回滚 - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderSuccess_order_closed() { - testNotifyOrderSuccess_order_closedOrRefund(PayOrderStatusEnum.CLOSED.getStatus()); - } - - @Test - public void testNotifyOrderSuccess_order_refund() { - testNotifyOrderSuccess_order_closedOrRefund(PayOrderStatusEnum.REFUND.getStatus()); - } - - private void testNotifyOrderSuccess_order_closedOrRefund(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(status)); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_STATUS_IS_NOT_WAITING); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderSuccess_order_paid() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 重要:需要将 order 的 extensionId 更新下 - order.setExtensionId(orderExtension.getId()); - orderMapper.updateById(order); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - // 断言 PayOrderDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(order, orderMapper.selectOne(null)); - // 断言,调用 - verify(notifyService, never()).createPayNotifyTask(anyInt(), anyLong()); - } - - @Test - public void testNotifyOrderSuccess_order_waiting() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setPrice(10)); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setFeeRate(10D)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - orderExtension.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(notify)); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - // 断言 PayOrderDO :数据未更新,因为它是 SUCCESS - order.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setChannelId(10L).setChannelCode(channel.getCode()) - .setSuccessTime(notify.getSuccessTime()).setExtensionId(orderExtension.getId()).setNo(orderExtension.getNo()) - .setChannelOrderNo(notify.getChannelOrderNo()).setChannelUserId(notify.getChannelUserId()) - .setChannelFeeRate(10D).setChannelFeePrice(1); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - // 断言,调用 - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.ORDER.getType()), - eq(orderExtension.getOrderId())); - } - - @Test - public void testNotifyOrderClosed_orderExtension_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_NOT_FOUND); - } - - @Test - public void testNotifyOrderClosed_orderExtension_closed() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 CLOSED - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderClosed_orderExtension_paid() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderClosed_orderExtension_refund() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyOrderClosed_orderExtension_waiting() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO - orderExtension.setStatus(PayOrderStatusEnum.CLOSED.getStatus()).setChannelNotifyData(toJsonString(notify)) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - } - - @Test - public void testUpdateOrderRefundPrice_notFound() { - // 准备参数 - Long id = randomLongId(); - Integer incrRefundPrice = randomInteger(); - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - PAY_ORDER_NOT_FOUND); - } - - @Test - public void testUpdateOrderRefundPrice_waiting() { - testUpdateOrderRefundPrice_waitingOrClosed(PayOrderStatusEnum.WAITING.getStatus()); - } - - @Test - public void testUpdateOrderRefundPrice_closed() { - testUpdateOrderRefundPrice_waitingOrClosed(PayOrderStatusEnum.CLOSED.getStatus()); - } - - private void testUpdateOrderRefundPrice_waitingOrClosed(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(status)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = randomInteger(); - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - @Test - public void testUpdateOrderRefundPrice_priceExceed() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setRefundPrice(1).setPrice(10)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = 10; - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - REFUND_PRICE_EXCEED); - } - - @Test - public void testUpdateOrderRefundPrice_refund() { - testUpdateOrderRefundPrice_refundOrSuccess(PayOrderStatusEnum.REFUND.getStatus()); - } - - @Test - public void testUpdateOrderRefundPrice_success() { - testUpdateOrderRefundPrice_refundOrSuccess(PayOrderStatusEnum.SUCCESS.getStatus()); - } - - private void testUpdateOrderRefundPrice_refundOrSuccess(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(status).setRefundPrice(1).setPrice(10)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = 8; - - // 调用 - orderService.updateOrderRefundPrice(id, incrRefundPrice); - // 断言 - order.setRefundPrice(9).setStatus(PayOrderStatusEnum.REFUND.getStatus()); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - } - - @Test - public void testGetOrderExtension() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - Long id = orderExtension.getId(); - - // 调用 - PayOrderExtensionDO dbOrderExtension = orderService.getOrderExtension(id); - // 断言 - assertPojoEquals(dbOrderExtension, orderExtension); - } - - @Test - public void testSyncOrder_payClientNotFound() { - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncOrder_exception() { - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L) - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 异常) - when(client.getOrder(any())).thenThrow(new RuntimeException()); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncOrder_orderSuccess() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L).setNo("P110") - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 1); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testSyncOrder_orderClosed() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L).setNo("P110") - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testExpireOrder_orderExtension_isSuccess() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_payClient_notFound() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()) - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_getOrder_isRefund() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 退款返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_getOrder_isSuccess() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testExpireOrder_success() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 关闭返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 1); - // 断言 extension 变化 - orderExtension.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setChannelNotifyData(toJsonString(respDTO)); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - // 断言 order 变化 - order.setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java deleted file mode 100755 index a9296f93f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java +++ /dev/null @@ -1,700 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayRefundServiceImpl.class, PayNoRedisDAO.class}) -public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { - - @Resource - private PayRefundServiceImpl refundService; - - @Resource - private PayRefundMapper refundMapper; - - @MockBean - private PayProperties payProperties; - @MockBean - private PayOrderService orderService; - @MockBean - private PayAppService appService; - @MockBean - private PayChannelService channelService; - @MockBean - private PayNotifyService notifyService; - - @BeforeEach - public void setUp() { - when(payProperties.getRefundNotifyUrl()).thenReturn("http://127.0.0.1"); - } - - @Test - public void testGetRefund() { - // mock 数据 - PayRefundDO refund = randomPojo(PayRefundDO.class); - refundMapper.insert(refund); - // 准备参数 - Long id = refund.getId(); - - // 调用 - PayRefundDO dbRefund = refundService.getRefund(id); - // 断言 - assertPojoEquals(dbRefund, refund); - } - - @Test - public void testGetRefundCountByAppId() { - // mock 数据 - PayRefundDO refund01 = randomPojo(PayRefundDO.class); - refundMapper.insert(refund01); - PayRefundDO refund02 = randomPojo(PayRefundDO.class); - refundMapper.insert(refund02); - // 准备参数 - Long appId = refund01.getAppId(); - - // 调用 - Long count = refundService.getRefundCountByAppId(appId); - // 断言 - assertEquals(count, 1); - } - - @Test - public void testGetRefundPage() { - // mock 数据 - PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("MOT0000001"); - o.setMerchantRefundId("MRF0000001"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setChannelOrderNo("CH0000001"); - o.setChannelRefundNo("CHR0000001"); - o.setCreateTime(buildTime(2021, 1, 10)); - }); - refundMapper.insert(dbRefund); - // 测试 appId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantOrderId(randomString()))); - // 测试 merchantRefundId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundId(randomString()))); - // 测试 channelOrderNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelOrderNo(randomString()))); - // 测试 channelRefundNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelRefundNo(randomString()))); - // 测试 status 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - // 测试 createTime 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("MOT0000001"); - reqVO.setMerchantRefundId("MRF0000001"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setChannelOrderNo("CH0000001"); - reqVO.setChannelRefundNo("CHR0000001"); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 9, 2021, 1, 11)); - - // 调用 - PageResult pageResult = refundService.getRefundPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRefund, pageResult.getList().get(0)); - } - - @Test - public void testGetRefundList() { - // mock 数据 - PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("MOT0000001"); - o.setMerchantRefundId("MRF0000001"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setChannelOrderNo("CH0000001"); - o.setChannelRefundNo("CHR0000001"); - o.setCreateTime(buildTime(2021, 1, 10)); - }); - refundMapper.insert(dbRefund); - // 测试 appId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantOrderId(randomString()))); - // 测试 merchantRefundId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundId(randomString()))); - // 测试 channelOrderNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelOrderNo(randomString()))); - // 测试 channelRefundNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelRefundNo(randomString()))); - // 测试 status 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - // 测试 createTime 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - PayRefundExportReqVO reqVO = new PayRefundExportReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("MOT0000001"); - reqVO.setMerchantRefundId("MRF0000001"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setChannelOrderNo("CH0000001"); - reqVO.setChannelRefundNo("CHR0000001"); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 9, 2021, 1, 11)); - - // 调用 - List list = refundService.getRefundList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRefund, list.get(0)); - } - - @Test - public void testCreateRefund_orderNotFound() { - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - PAY_ORDER_NOT_FOUND); - } - - @Test - public void testCreateRefund_orderWaiting() { - testCreateRefund_orderWaitingOrClosed(PayOrderStatusEnum.WAITING.getStatus()); - } - - @Test - public void testCreateRefund_orderClosed() { - testCreateRefund_orderWaitingOrClosed(PayOrderStatusEnum.CLOSED.getStatus()); - } - - private void testCreateRefund_orderWaitingOrClosed(Integer status) { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(status)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - @Test - public void testCreateRefund_refundPriceExceed() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_PRICE_EXCEED); - } - - @Test - public void testCreateRefund_orderHasRefunding() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 数据(refund 在退款中) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> - o.setOrderId(order.getId()).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_PRICE_EXCEED); - } - - @Test - public void testCreateRefund_channelNotFound() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(1L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L))).thenReturn(channel); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - CHANNEL_NOT_FOUND); - } - - @Test - public void testCreateRefund_refundExists() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(1L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 数据(refund 已存在) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> - o.setAppId(1L).setMerchantRefundId("200")); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_EXISTS); - } - - @Test - public void testCreateRefund_invokeException() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(10L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 调用发生异常) - when(client.unifiedRefund(any(PayRefundUnifiedReqDTO.class))).thenThrow(new RuntimeException()); - - // 调用 - Long refundId = refundService.createPayRefund(reqDTO); - // 断言 - PayRefundDO refundDO = refundMapper.selectById(refundId); - assertPojoEquals(reqDTO, refundDO); - assertNotNull(refundDO.getNo()); - assertThat(refundDO) - .extracting("orderId", "orderNo", "channelId", "channelCode", - "notifyUrl", "channelOrderNo", "status", "payPrice", "refundPrice") - .containsExactly(order.getId(), order.getNo(), channel.getId(), channel.getCode(), - app.getRefundNotifyUrl(), order.getChannelOrderNo(), PayRefundStatusEnum.WAITING.getStatus(), - order.getPrice(), reqDTO.getPrice()); - } - - @Test - public void testCreateRefund_invokeSuccess() { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(10L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 成功) - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class); - when(client.unifiedRefund(argThat(unifiedReqDTO -> { - assertNotNull(unifiedReqDTO.getOutRefundNo()); - assertThat(unifiedReqDTO) - .extracting("payPrice", "refundPrice", "outTradeNo", - "notifyUrl", "reason") - .containsExactly(order.getPrice(), reqDTO.getPrice(), order.getNo(), - "http://127.0.0.1/10", reqDTO.getReason()); - return true; - }))).thenReturn(refundRespDTO); - - // 调用 - Long refundId = refundService.createPayRefund(reqDTO); - // 断言 - PayRefundDO refundDO = refundMapper.selectById(refundId); - assertPojoEquals(reqDTO, refundDO); - assertNotNull(refundDO.getNo()); - assertThat(refundDO) - .extracting("orderId", "orderNo", "channelId", "channelCode", - "notifyUrl", "channelOrderNo", "status", "payPrice", "refundPrice") - .containsExactly(order.getId(), order.getNo(), channel.getId(), channel.getCode(), - app.getRefundNotifyUrl(), order.getChannelOrderNo(), PayRefundStatusEnum.WAITING.getStatus(), - order.getPrice(), reqDTO.getPrice()); - // 断言调用 - verify(payRefundServiceImpl).notifyRefund(same(channel), same(refundRespDTO)); - } - } - - @Test - public void testNotifyRefund() { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - Long channelId = 10L; - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - refundService.notifyRefund(channelId, refundRespDTO); - // 断言 - verify(payRefundServiceImpl).notifyRefund(same(channel), same(refundRespDTO)); - } - } - - @Test - public void testNotifyRefundSuccess_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_NOT_FOUND); - } - - @Test - public void testNotifyRefundSuccess_isSuccess() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus())); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund 没有更新,因为已经退款成功 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundSuccess_failure() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.FAILURE.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyRefundSuccess_updateOrderException() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - // mock 方法(order + 更新异常) - doThrow(new RuntimeException()).when(orderService) - .updateOrderRefundPrice(eq(100L), eq(23)); - - // 调用,并断言异常 - assertThrows(RuntimeException.class, () -> refundService.notifyRefund(channel, refundRespDTO)); - // 断言,refund 没有更新,因为事务回滚了 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundSuccess_success() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund - refund.setSuccessTime(refundRespDTO.getSuccessTime()) - .setChannelRefundNo(refundRespDTO.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(refundRespDTO)); - assertPojoEquals(refund, refundMapper.selectById(refund.getId()), - "updateTime", "updater"); - // 断言,调用 - verify(orderService).updateOrderRefundPrice(eq(100L), eq(23)); - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.REFUND.getType()), - eq(refund.getId())); - } - - @Test - public void testNotifyRefundFailure_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_NOT_FOUND); - } - - @Test - public void testNotifyRefundFailure_isFailure() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 退款失败) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.FAILURE.getStatus())); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund 没有更新,因为已经退款失败 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundFailure_isSuccess() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyRefundFailure_success() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund - refund.setChannelRefundNo(refundRespDTO.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.FAILURE.getStatus()) - .setChannelNotifyData(toJsonString(refundRespDTO)) - .setChannelErrorCode(refundRespDTO.getChannelErrorCode()) - .setChannelErrorMsg(refundRespDTO.getChannelErrorMsg()); - assertPojoEquals(refund, refundMapper.selectById(refund.getId()), - "updateTime", "updater"); - // 断言,调用 - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.REFUND.getType()), - eq(refund.getId())); - } - - @Test - public void testSyncRefund_notFound() { - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus())); - refundMapper.insert(refund); - - // 调用 - int count = refundService.syncRefund(); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncRefund_waiting() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.WAITING.getStatus()), 0); - } - - @Test - public void testSyncRefund_success() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.SUCCESS.getStatus()), 1); - } - - @Test - public void testSyncRefund_failure() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.FAILURE.getStatus()), 1); - } - - private int testSyncRefund_waitingOrSuccessOrFailure(Integer status) { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setChannelId(10L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderNo("P110").setNo("R220")); - refundMapper.insert(refund); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 返回指定状态) - PayRefundRespDTO respDTO = randomPojo(PayRefundRespDTO.class, o -> o.setStatus(status)); - when(client.getRefund(eq("P110"), eq("R220"))).thenReturn(respDTO); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - return refundService.syncRefund(); - } - } - - @Test - public void testSyncRefund_exception() { - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setChannelId(10L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderNo("P110").setNo("R220")); - refundMapper.insert(refund); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 抛出异常) - when(client.getRefund(eq("P110"), eq("R220"))).thenThrow(new RuntimeException()); - - // 调用 - int count = refundService.syncRefund(); - // 断言 - assertEquals(count, 0); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 93bccd939..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,52 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - -mybatis-plus: - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 91fff0cae..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM pay_app; -DELETE FROM pay_channel; -DELETE FROM pay_order; -DELETE FROM pay_order_extension; -DELETE FROM pay_refund; -DELETE FROM pay_notify_task; -DELETE FROM pay_notify_log; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 6ae2ce2d4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,146 +0,0 @@ -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, - `order_notify_url` varchar(1024) NOT NULL, - `refund_notify_url` varchar(1024) 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, - "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, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT = '支付渠道'; - -CREATE TABLE IF NOT EXISTS `pay_order` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `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, - `price` bigint(20) NOT NULL, - `channel_fee_rate` double DEFAULT 0, - `channel_fee_price` bigint(20) DEFAULT 0, - `status` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `expire_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `extension_id` bigint(20) DEFAULT NULL, - `no` varchar(64) NULL, - `refund_price` 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_order_extension` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `no` varchar(64) NOT NULL, - `order_id` bigint(20) NOT NULL, - `channel_id` bigint(20) NOT NULL, - `channel_code` varchar(32) NOT NULL, - `user_ip` varchar(50) NULL DEFAULT NULL, - `status` tinyint(4) NOT NULL, - `channel_extras` varchar(1024) NULL DEFAULT NULL, - `channel_error_code` varchar(64) NULL, - `channel_error_msg` varchar(64) NULL, - `channel_notify_data` varchar(1024) 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 = '支付订单拓展'; - -CREATE TABLE IF NOT EXISTS `pay_refund` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `no` varchar(64) 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, - `order_no` varchar(64) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `merchant_refund_id` varchar(64) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `status` tinyint(4) NOT NULL, - `pay_price` bigint(20) NOT NULL, - `refund_price` 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, - `success_time` datetime(0) NULL DEFAULT NULL, - `channel_error_code` varchar(128) NULL DEFAULT NULL, - `channel_error_msg` varchar(256) NULL DEFAULT NULL, - `channel_notify_data` varchar(1024) 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 = '退款订单'; - -CREATE TABLE IF NOT EXISTS `pay_notify_task` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `app_id` bigint(20) NOT NULL, - `type` tinyint(4) NOT NULL, - `data_id` bigint(20) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `status` tinyint(4) NOT NULL, - `next_notify_time` datetime(0) NULL DEFAULT NULL, - `last_execute_time` datetime(0) NULL DEFAULT NULL, - `notify_times` int NOT NULL, - `max_notify_times` int NOT NULL, - `notify_url` varchar(1024) NOT 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, - `tenant_id` bigint(20) NOT NULL DEFAULT 0, - PRIMARY KEY ("id") -) COMMENT = '支付通知任务'; - -CREATE TABLE IF NOT EXISTS `pay_notify_log` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `task_id` bigint(20) NOT NULL, - `notify_times` int NOT NULL, - `response` varchar(1024) NOT NULL, - `status` tinyint(4) NOT 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 = '支付通知日志'; diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/pom.xml b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/pom.xml deleted file mode 100644 index 92ceed21c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-pay - ${revision} - - 4.0.0 - - yudao-spring-boot-starter-biz-pay - ${project.artifactId} - 支付拓展,接入国内多个支付渠道 - 1. 支付宝,基于官方 SDK 接入 - 2. 微信支付,基于 weixin-java-pay 接入 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springframework.boot - spring-boot-starter - - - - - org.springframework.boot - spring-boot-starter-validation - - - - org.slf4j - slf4j-api - - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - - - com.alipay.sdk - alipay-sdk-java - 4.35.79.ALL - - - org.bouncycastle - bcprov-jdk15on - - - - - com.github.binarywang - weixin-java-pay - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java deleted file mode 100644 index a9a98953c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.framework.pay.config; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.context.annotation.Bean; - -/** - * 支付配置类 - * - * @author 芋道源码 - */ -@AutoConfiguration -public class YudaoPayAutoConfiguration { - - @Bean - public PayClientFactory payClientFactory() { - return new PayClientFactoryImpl(); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java deleted file mode 100644 index 18ae017d1..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; - -import java.util.Map; - -/** - * 支付客户端,用于对接各支付渠道的 SDK,实现发起支付、退款等功能 - * - * @author 芋道源码 - */ -public interface PayClient { - - /** - * 获得渠道编号 - * - * @return 渠道编号 - */ - Long getId(); - - // ============ 支付相关 ========== - - /** - * 调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 支付订单信息 - */ - PayOrderRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO); - - /** - * 解析 order 回调数据 - * - * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 - * @param body HTTP 回调接口的 request body - * @return 支付订单信息 - */ - PayOrderRespDTO parseOrderNotify(Map params, String body); - - /** - * 获得支付订单信息 - * - * @param outTradeNo 外部订单号 - * @return 支付订单信息 - */ - PayOrderRespDTO getOrder(String outTradeNo); - - // ============ 退款相关 ========== - - /** - * 调用支付渠道,进行退款 - * - * @param reqDTO 统一退款请求信息 - * @return 退款信息 - */ - PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO); - - /** - * 解析 refund 回调数据 - * - * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 - * @param body HTTP 回调接口的 request body - * @return 支付订单信息 - */ - PayRefundRespDTO parseRefundNotify(Map params, String body); - - /** - * 获得退款订单信息 - * - * @param outTradeNo 外部订单号 - * @param outRefundNo 外部退款号 - * @return 退款订单信息 - */ - PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo); - - /** - * 调用渠道,进行转账 - * - * @param reqDTO 统一转账请求信息 - * @return 转账信息 - */ - PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java deleted file mode 100644 index c3af46cd3..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import javax.validation.Validator; - -/** - * 支付客户端的配置,本质是支付渠道的配置 - * 每个不同的渠道,需要不同的配置,通过子类来定义 - * - * @author 芋道源码 - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) -// @JsonTypeInfo 注解的作用,Jackson 多态 -// 1. 序列化到时数据库时,增加 @class 属性。 -// 2. 反序列化到内存对象时,通过 @class 属性,可以创建出正确的类型 -public interface PayClientConfig { - - /** - * 参数校验 - * - * @param validator 校验对象 - */ - void validate(Validator validator); - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java deleted file mode 100644 index 53f1a8c06..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; - -/** - * 支付客户端的工厂接口 - * - * @author 芋道源码 - */ -public interface PayClientFactory { - - /** - * 获得支付客户端 - * - * @param channelId 渠道编号 - * @return 支付客户端 - */ - PayClient getPayClient(Long channelId); - - /** - * 创建支付客户端 - * - * @param channelId 渠道编号 - * @param channelCode 渠道编码 - * @param config 支付配置 - */ - void createOrUpdatePayClient(Long channelId, String channelCode, - Config config); - - /** - * 注册支付客户端 Class,用于模块中实现的 PayClient - * - * @param channel 支付渠道的编码的枚举 - * @param payClientClass 支付客户端 class - */ - void registerPayClientClass(PayChannelEnum channel, Class payClientClass); - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java deleted file mode 100644 index 82050a6fc..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.order; - -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 渠道支付订单 Response DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderRespDTO { - - /** - * 支付状态 - * - * 枚举:{@link PayOrderStatusRespEnum} - */ - private Integer status; - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - private String outTradeNo; - - /** - * 支付渠道编号 - */ - private String channelOrderNo; - /** - * 支付渠道用户编号 - */ - private String channelUserId; - - /** - * 支付成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的同步/异步通知结果 - */ - private Object rawData; - - // ========== 主动发起支付时,会返回的字段 ========== - - /** - * 展示模式 - * - * 枚举 {@link PayOrderDisplayModeEnum} 类 - */ - private String displayMode; - /** - * 展示内容 - */ - private String displayContent; - - /** - * 调用渠道的错误码 - * - * 注意:这里返回的是业务异常,而是不系统异常。 - * 如果是系统异常,则会抛出 {@link PayException} - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - public PayOrderRespDTO() { - } - - /** - * 创建【WAITING】状态的订单返回 - */ - public static PayOrderRespDTO waitingOf(String displayMode, String displayContent, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.WAITING.getStatus(); - respDTO.displayMode = displayMode; - respDTO.displayContent = displayContent; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的订单返回 - */ - public static PayOrderRespDTO successOf(String channelOrderNo, String channelUserId, LocalDateTime successTime, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelOrderNo = channelOrderNo; - respDTO.channelUserId = channelUserId; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建指定状态的订单返回,适合支付渠道回调时 - */ - public static PayOrderRespDTO of(Integer status, String channelOrderNo, String channelUserId, LocalDateTime successTime, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = status; - respDTO.channelOrderNo = channelOrderNo; - respDTO.channelUserId = channelUserId; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【CLOSED】状态的订单返回,适合调用支付渠道失败时 - */ - public static PayOrderRespDTO closedOf(String channelErrorCode, String channelErrorMsg, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.CLOSED.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java deleted file mode 100644 index f269d2f8f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.order; - -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import lombok.Data; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.DecimalMin; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 统一下单 Request DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderUnifiedReqDTO { - - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - @NotEmpty(message = "外部订单编号不能为空") - private String outTradeNo; - /** - * 商品标题 - */ - @NotEmpty(message = "商品标题不能为空") - @Length(max = 32, message = "商品标题不能超过 32") - private String subject; - /** - * 商品描述信息 - */ - @Length(max = 128, message = "商品描述信息长度不能超过128") - private String body; - /** - * 支付结果的 notify 回调地址 - */ - @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") - private String notifyUrl; - /** - * 支付结果的 return 回调地址 - */ - @URL(message = "支付结果的 return 回调地址必须是 URL 格式") - private String returnUrl; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer price; - - /** - * 支付过期时间 - */ - @NotNull(message = "支付过期时间不能为空") - private LocalDateTime expireTime; - - // ========== 拓展参数 ========== - /** - * 支付渠道的额外参数 - * - * 例如说,微信公众号需要传递 openid 参数 - */ - private Map channelExtras; - - /** - * 展示模式 - * - * 如果不传递,则每个支付渠道使用默认的方式 - * - * 枚举 {@link PayOrderDisplayModeEnum} - */ - private String displayMode; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java deleted file mode 100644 index 3184f278d..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.refund; - -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 渠道退款订单 Response DTO - * - * @author jason - */ -@Data -public class PayRefundRespDTO { - - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusRespEnum} - */ - private Integer status; - - /** - * 外部退款号 - * - * 对应 PayRefundDO 的 no 字段 - */ - private String outRefundNo; - - /** - * 渠道退款单号 - * - * 对应 PayRefundDO.channelRefundNo 字段 - */ - private String channelRefundNo; - - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的异步通知结果 - */ - private Object rawData; - - /** - * 调用渠道的错误码 - * - * 注意:这里返回的是业务异常,而是不系统异常。 - * 如果是系统异常,则会抛出 {@link PayException} - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - private PayRefundRespDTO() { - } - - /** - * 创建【WAITING】状态的退款返回 - */ - public static PayRefundRespDTO waitingOf(String channelRefundNo, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.WAITING.getStatus(); - respDTO.channelRefundNo = channelRefundNo; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的退款返回 - */ - public static PayRefundRespDTO successOf(String channelRefundNo, LocalDateTime successTime, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelRefundNo = channelRefundNo; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【FAILURE】状态的退款返回 - */ - public static PayRefundRespDTO failureOf(String outRefundNo, Object rawData) { - return failureOf(null, null, - outRefundNo, rawData); - } - - /** - * 创建【FAILURE】状态的退款返回 - */ - public static PayRefundRespDTO failureOf(String channelErrorCode, String channelErrorMsg, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.FAILURE.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java deleted file mode 100644 index 4f5e203d2..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.refund; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.DecimalMin; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 统一 退款 Request DTO - * - * @author jason - */ -@Accessors(chain = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class PayRefundUnifiedReqDTO { - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - @NotEmpty(message = "外部订单编号不能为空") - private String outTradeNo; - - /** - * 外部退款号 - * - * 对应 PayRefundDO 的 no 字段 - */ - @NotEmpty(message = "退款请求单号不能为空") - private String outRefundNo; - - /** - * 退款原因 - */ - @NotEmpty(message = "退款原因不能为空") - private String reason; - - /** - * 支付金额,单位:分 - * - * 目前微信支付在退款的时候,必须传递该字段 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer payPrice; - /** - * 退款金额,单位:分 - */ - @NotNull(message = "退款金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer refundPrice; - - /** - * 退款结果的 notify 回调地址 - */ - @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java deleted file mode 100644 index 400abb510..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; - -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 统一转账 Response DTO - * - * @author jason - */ -@Data -public class PayTransferRespDTO { - - /** - * 转账状态 - * - * 关联 {@link PayTransferStatusRespEnum#getStatus()} - */ - private Integer status; - - /** - * 外部转账单号 - * - */ - private String outTransferNo; - - /** - * 支付渠道编号 - */ - private String channelOrderNo; - - /** - * 支付成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的返回结果 - */ - private Object rawData; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - /** - * 创建【WAITING】状态的转账返回 - */ - public static PayTransferRespDTO waitingOf(String channelOrderNo, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus(); - respDTO.channelOrderNo = channelOrderNo; - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【CLOSED】状态的转账返回 - */ - public static PayTransferRespDTO closedOf(String channelErrorCode, String channelErrorMsg, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.CLOSED.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的转账返回 - */ - public static PayTransferRespDTO successOf(String channelTransferNo, LocalDateTime successTime, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelOrderNo = channelTransferNo; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java deleted file mode 100644 index 17e47aa8b..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -/** - * 统一转账 Request DTO - * - * @author jason - */ -@Data -public class PayTransferUnifiedReqDTO { - - /** - * 转账类型 - * - * 关联 {@link PayTransferTypeEnum#getType()} - */ - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - @NotEmpty(message = "外部转账单编号不能为空") - private String outTransferNo; - - /** - * 转账金额,单位:分 - */ - @NotNull(message = "转账金额不能为空") - @Min(value = 1, message = "转账金额必须大于零") - private Integer price; - - /** - * 转账标题 - */ - @NotEmpty(message = "转账标题不能为空") - @Length(max = 128, message = "转账标题不能超过 128") - private String title; - - /** - * 收款方信息。 - * - * 转账类型 {@link #type} 不同,收款方信息不同 - */ - @NotEmpty(message = "收款方信息 不能为空") - private Map payeeInfo; - - /** - * 支付渠道的额外参数 - */ - private Map channelExtras; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java deleted file mode 100644 index 75f4c3975..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.exception; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 支付系统异常 Exception - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class PayException extends RuntimeException { - - public PayException(Throwable cause) { - super(cause); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java deleted file mode 100644 index 49114fb5b..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 支付客户端的抽象类,提供模板方法,减少子类的冗余代码 - * - * @author 芋道源码 - */ -@Slf4j -public abstract class AbstractPayClient implements PayClient { - - /** - * 渠道编号 - */ - private final Long channelId; - /** - * 渠道编码 - */ - @SuppressWarnings("FieldCanBeLocal") - private final String channelCode; - /** - * 支付配置 - */ - protected Config config; - - public AbstractPayClient(Long channelId, String channelCode, Config config) { - this.channelId = channelId; - this.channelCode = channelCode; - this.config = config; - } - - /** - * 初始化 - */ - public final void init() { - doInit(); - log.debug("[init][客户端({}) 初始化完成]", getId()); - } - - /** - * 自定义初始化 - */ - protected abstract void doInit(); - - public final void refresh(Config config) { - // 判断是否更新 - if (config.equals(this.config)) { - return; - } - log.info("[refresh][客户端({})发生变化,重新初始化]", getId()); - this.config = config; - // 初始化 - this.init(); - } - - @Override - public Long getId() { - return channelId; - } - - // ============ 支付相关 ========== - - @Override - public final PayOrderRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - // 执行统一下单 - PayOrderRespDTO resp; - try { - resp = doUnifiedOrder(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedOrder][客户端({}) request({}) 发起支付异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) - throws Throwable; - - @Override - public final PayOrderRespDTO parseOrderNotify(Map params, String body) { - try { - return doParseOrderNotify(params, body); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[parseOrderNotify][客户端({}) params({}) body({}) 解析失败]", - getId(), params, body, ex); - throw buildPayException(ex); - } - } - - protected abstract PayOrderRespDTO doParseOrderNotify(Map params, String body) - throws Throwable; - - @Override - public final PayOrderRespDTO getOrder(String outTradeNo) { - try { - return doGetOrder(outTradeNo); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getOrder][客户端({}) outTradeNo({}) 查询支付单异常]", - getId(), outTradeNo, ex); - throw buildPayException(ex); - } - } - - protected abstract PayOrderRespDTO doGetOrder(String outTradeNo) - throws Throwable; - - // ============ 退款相关 ========== - - @Override - public final PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - // 执行统一退款 - PayRefundRespDTO resp; - try { - resp = doUnifiedRefund(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedRefund][客户端({}) request({}) 发起退款异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable; - - @Override - public final PayRefundRespDTO parseRefundNotify(Map params, String body) { - try { - return doParseRefundNotify(params, body); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[parseRefundNotify][客户端({}) params({}) body({}) 解析失败]", - getId(), params, body, ex); - throw buildPayException(ex); - } - } - - protected abstract PayRefundRespDTO doParseRefundNotify(Map params, String body) - throws Throwable; - - @Override - public final PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo) { - try { - return doGetRefund(outTradeNo, outRefundNo); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getRefund][客户端({}) outTradeNo({}) outRefundNo({}) 查询退款单异常]", - getId(), outTradeNo, outRefundNo, ex); - throw buildPayException(ex); - } - } - - protected abstract PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) - throws Throwable; - - @Override - public final PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - PayTransferRespDTO resp; - try{ - resp = doUnifiedTransfer(reqDTO); - }catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedTransfer][客户端({}) request({}) 发起转账异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) - throws Throwable; - - // ========== 各种工具方法 ========== - - private PayException buildPayException(Throwable ex) { - if (ex instanceof PayException) { - return (PayException) ex; - } - throw new PayException(ex); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java deleted file mode 100644 index 48319036c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; - -/** - * 无需任何配置 PayClientConfig 实现类 - * - * @author jason - */ -@Data -public class NonePayClientConfig implements PayClientConfig { - - /** - * 配置名称 - *

- * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 - */ - private String name; - - public NonePayClientConfig(){ - this.name = "none-config"; - } - - @Override - public void validate(Validator validator) { - // 无任何配置不需要校验 - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java deleted file mode 100644 index 0b39587ab..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*; -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import static cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum.*; - -/** - * 支付客户端的工厂实现类 - * - * @author 芋道源码 - */ -@Slf4j -public class PayClientFactoryImpl implements PayClientFactory { - - /** - * 支付客户端 Map - * - * key:渠道编号 - */ - private final ConcurrentMap> clients = new ConcurrentHashMap<>(); - - /** - * 支付客户端 Class Map - */ - private final Map> clientClass = new ConcurrentHashMap<>(); - - public PayClientFactoryImpl() { - // 微信支付客户端 - clientClass.put(WX_PUB, WxPubPayClient.class); - clientClass.put(WX_LITE, WxLitePayClient.class); - clientClass.put(WX_APP, WxAppPayClient.class); - clientClass.put(WX_BAR, WxBarPayClient.class); - clientClass.put(WX_NATIVE, WxNativePayClient.class); - // 支付包支付客户端 - clientClass.put(ALIPAY_WAP, AlipayWapPayClient.class); - clientClass.put(ALIPAY_QR, AlipayQrPayClient.class); - clientClass.put(ALIPAY_APP, AlipayAppPayClient.class); - clientClass.put(ALIPAY_PC, AlipayPcPayClient.class); - clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class); - // Mock 支付客户端 - clientClass.put(MOCK, MockPayClient.class); - } - - @Override - public void registerPayClientClass(PayChannelEnum channel, Class payClientClass) { - clientClass.put(channel, payClientClass); - } - - @Override - public PayClient getPayClient(Long channelId) { - AbstractPayClient client = clients.get(channelId); - if (client == null) { - log.error("[getPayClient][渠道编号({}) 找不到客户端]", channelId); - } - return client; - } - - @Override - @SuppressWarnings("unchecked") - public void createOrUpdatePayClient(Long channelId, String channelCode, - Config config) { - AbstractPayClient client = (AbstractPayClient) clients.get(channelId); - if (client == null) { - client = this.createPayClient(channelId, channelCode, config); - client.init(); - clients.put(client.getId(), client); - } else { - client.refresh(config); - } - } - - @SuppressWarnings("unchecked") - private AbstractPayClient createPayClient(Long channelId, String channelCode, - Config config) { - PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode); - Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelCode)); - Class payClientClass = clientClass.get(channelEnum); - Assert.notNull(payClientClass, String.format("支付渠道(%s) Class 为空", channelCode)); - return (AbstractPayClient) ReflectUtil.newInstance(payClientClass, channelId, config); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java deleted file mode 100644 index cb8a0df6e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java +++ /dev/null @@ -1,304 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.AlipayConfig; -import com.alipay.api.AlipayResponse; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.*; -import com.alipay.api.internal.util.AlipaySignature; -import com.alipay.api.request.AlipayFundTransUniTransferRequest; -import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest; -import com.alipay.api.request.AlipayTradeQueryRequest; -import com.alipay.api.request.AlipayTradeRefundRequest; -import com.alipay.api.response.AlipayFundTransUniTransferResponse; -import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse; -import com.alipay.api.response.AlipayTradeQueryResponse; -import com.alipay.api.response.AlipayTradeRefundResponse; -import lombok.Getter; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -import java.nio.charset.StandardCharsets; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; - -import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝抽象类,实现支付宝统一的接口、以及部分实现(退款) - * - * @author jason - */ -@Slf4j -public abstract class AbstractAlipayPayClient extends AbstractPayClient { - - @Getter // 仅用于单测场景 - protected DefaultAlipayClient client; - - public AbstractAlipayPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) { - super(channelId, channelCode, config); - } - - @Override - @SneakyThrows - protected void doInit() { - AlipayConfig alipayConfig = new AlipayConfig(); - BeanUtil.copyProperties(config, alipayConfig, false); - this.client = new DefaultAlipayClient(alipayConfig); - } - - // ============ 支付相关 ========== - - /** - * 构造支付关闭的 {@link PayOrderRespDTO} 对象 - * - * @return 支付关闭的 {@link PayOrderRespDTO} 对象 - */ - protected PayOrderRespDTO buildClosedPayOrderRespDTO(PayOrderUnifiedReqDTO reqDTO, AlipayResponse response) { - Assert.isFalse(response.isSuccess()); - return PayOrderRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTradeNo(), response); - } - - @Override - public PayOrderRespDTO doParseOrderNotify(Map params, String body) throws Throwable { - // 1. 校验回调数据 - Map bodyObj = HttpUtil.decodeParamMap(body, StandardCharsets.UTF_8); - AlipaySignature.rsaCheckV1(bodyObj, config.getAlipayPublicKey(), - StandardCharsets.UTF_8.name(), config.getSignType()); - - // 2. 解析订单的状态 - // 额外说明:支付宝不仅仅支付成功会回调,再各种触发支付单数据变化时,都会进行回调,所以这里 status 的解析会写的比较复杂 - Integer status = parseStatus(bodyObj.get("trade_status")); - // 特殊逻辑: 支付宝没有退款成功的状态,所以,如果有退款金额,我们认为是退款成功 - if (MapUtil.getDouble(bodyObj, "refund_fee", 0D) > 0) { - status = PayOrderStatusRespEnum.REFUND.getStatus(); - } - Assert.notNull(status, (Supplier) () -> { - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body)); - }); - return PayOrderRespDTO.of(status, bodyObj.get("trade_no"), bodyObj.get("seller_id"), parseTime(params.get("gmt_payment")), - bodyObj.get("out_trade_no"), body); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable { - // 1.1 构建 AlipayTradeRefundModel 请求 - AlipayTradeQueryModel model = new AlipayTradeQueryModel(); - model.setOutTradeNo(outTradeNo); - // 1.2 构建 AlipayTradeQueryRequest 请求 - AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); - request.setBizModel(model); - AlipayTradeQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { // 不成功,例如说订单不存在 - return PayOrderRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - outTradeNo, response); - } - // 2.2 解析订单的状态 - Integer status = parseStatus(response.getTradeStatus()); - Assert.notNull(status, () -> { - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", response.getBody())); - }); - return PayOrderRespDTO.of(status, response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getSendPayDate()), - outTradeNo, response); - } - - private static Integer parseStatus(String tradeStatus) { - return Objects.equals("WAIT_BUYER_PAY", tradeStatus) ? PayOrderStatusRespEnum.WAITING.getStatus() - : ObjectUtils.equalsAny(tradeStatus, "TRADE_FINISHED", "TRADE_SUCCESS") ? PayOrderStatusRespEnum.SUCCESS.getStatus() - : Objects.equals("TRADE_CLOSED", tradeStatus) ? PayOrderStatusRespEnum.CLOSED.getStatus() : null; - } - - // ============ 退款相关 ========== - - /** - * 支付宝统一的退款接口 alipay.trade.refund - * - * @param reqDTO 退款请求 request DTO - * @return 退款请求 Response - */ - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeRefundModel 请求 - AlipayTradeRefundModel model = new AlipayTradeRefundModel(); - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setOutRequestNo(reqDTO.getOutRefundNo()); - model.setRefundAmount(formatAmount(reqDTO.getRefundPrice())); - model.setRefundReason(reqDTO.getReason()); - // 1.2 构建 AlipayTradePayRequest 请求 - AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayTradeRefundResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { - // 当出现 ACQ.SYSTEM_ERROR, 退款可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 - if (ObjectUtils.equalsAny(response.getSubCode(), "ACQ.SYSTEM_ERROR", "SYSTEM_ERROR")) { - return PayRefundRespDTO.waitingOf(null, reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(response.getSubCode(), response.getSubMsg(), reqDTO.getOutRefundNo(), response); - } - // 2.2 创建返回结果 - // 支付宝只要退款调用返回 success,就认为退款成功,不需要回调。具体可见 parseNotify 方法的说明。 - // 另外,支付宝没有退款单号,所以不用设置 - return PayRefundRespDTO.successOf(null, LocalDateTimeUtil.of(response.getGmtRefundPay()), - reqDTO.getOutRefundNo(), response); - } - - @Override - public PayRefundRespDTO doParseRefundNotify(Map params, String body) { - // 补充说明:支付宝退款时,没有回调,这点和微信支付是不同的。并且,退款分成部分退款、和全部退款。 - // ① 部分退款:是会有回调,但是它回调的是订单状态的同步回调,不是退款订单的回调 - // ② 全部退款:Wap 支付有订单状态的同步回调,但是 PC/扫码又没有 - // 所以,这里在解析时,即使是退款导致的订单状态同步,我们也忽略不做为“退款同步”,而是订单的回调。 - // 实际上,支付宝退款只要发起成功,就可以认为退款成功,不需要等待回调。 - throw new UnsupportedOperationException("支付宝无退款回调"); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws AlipayApiException { - // 1.1 构建 AlipayTradeFastpayRefundQueryModel 请求 - AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel(); - model.setOutTradeNo(outTradeNo); - model.setOutRequestNo(outRefundNo); - model.setQueryOptions(Collections.singletonList("gmt_refund_pay")); - // 1.2 构建 AlipayTradeFastpayRefundQueryRequest 请求 - AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayTradeFastpayRefundQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { - // 明确不存在的情况,应该就是失败,可进行关闭 - if (ObjectUtils.equalsAny(response.getSubCode(), "TRADE_NOT_EXIST", "ACQ.TRADE_NOT_EXIST")) { - return PayRefundRespDTO.failureOf(outRefundNo, response); - } - // 可能存在“ACQ.SYSTEM_ERROR”系统错误等情况,所以返回 WAIT 继续等待 - return PayRefundRespDTO.waitingOf(null, outRefundNo, response); - } - // 2.2 创建返回结果 - if (Objects.equals(response.getRefundStatus(), "REFUND_SUCCESS")) { - return PayRefundRespDTO.successOf(null, LocalDateTimeUtil.of(response.getGmtRefundPay()), - outRefundNo, response); - } - return PayRefundRespDTO.waitingOf(null, outRefundNo, response); - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 校验公钥类型 必须使用公钥证书模式 - if (!Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - throw new IllegalStateException("支付宝单笔转账必须使用公钥证书模式"); - } - - // 1.2 构建 AlipayFundTransUniTransferModel - AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel(); - // ① 通用的参数 - model.setTransAmount(formatAmount(reqDTO.getPrice())); // 转账金额 - model.setOrderTitle(reqDTO.getTitle()); // 转账业务的标题,用于在支付宝用户的账单里显示。 - model.setOutBizNo(reqDTO.getOutTransferNo()); - model.setProductCode("TRANS_ACCOUNT_NO_PWD"); // 销售产品码。单笔无密转账固定为 TRANS_ACCOUNT_NO_PWD - model.setBizScene("DIRECT_TRANSFER"); // 业务场景 单笔无密转账固定为 DIRECT_TRANSFER - model.setBusinessParams(JsonUtils.toJsonString(reqDTO.getChannelExtras())); - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(reqDTO.getType()); - switch (transferType) { - // TODO @jason:是不是不用传递 transferType 参数哈?因为应该已经明确是支付宝啦? - // @芋艿。 是不是还要考虑转账到银行卡。所以传 transferType 但是转账到银行卡不知道要如何测试?? - case ALIPAY_BALANCE: { - // ② 个性化的参数 - Participant payeeInfo = new Participant(); - payeeInfo.setIdentityType("ALIPAY_LOGON_ID"); - String logonId = MapUtil.getStr(reqDTO.getPayeeInfo(), "ALIPAY_LOGON_ID"); - if (StrUtil.isEmpty(logonId)) { - throw exception0(BAD_REQUEST.getCode(), "支付包登录 ID 不能为空"); - } - String accountName = MapUtil.getStr(reqDTO.getPayeeInfo(), "ALIPAY_ACCOUNT_NAME"); - if (StrUtil.isEmpty(accountName)) { - throw exception0(BAD_REQUEST.getCode(), "支付包账户名称不能为空"); - } - payeeInfo.setIdentity(logonId); // 支付宝登录号 - payeeInfo.setName(accountName); // 支付宝账号姓名 - model.setPayeeInfo(payeeInfo); - // 1.3 构建 AlipayFundTransUniTransferRequest - AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); - request.setBizModel(model); - // 执行请求 - AlipayFundTransUniTransferResponse response = client.certificateExecute(request); - // 处理结果 - if (!response.isSuccess()) { - // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 - if (ObjectUtils.equalsAny(response.getSubCode(), "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) { - return PayTransferRespDTO.waitingOf(null, reqDTO.getOutTransferNo(), response); - } - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTransferNo(), response); - } - return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()), - response.getOutBizNo(), response); - } - case BANK_CARD: { - Participant payeeInfo = new Participant(); - payeeInfo.setIdentityType("BANKCARD_ACCOUNT"); - // TODO 待实现 - throw new UnsupportedOperationException("待实现"); - } - default: { - throw new IllegalStateException("不正确的转账类型: " + transferType); - } - } - } - - // ========== 各种工具方法 ========== - - protected String formatAmount(Integer amount) { - return String.valueOf(amount / 100.0); - } - - protected String formatTime(LocalDateTime time) { - return LocalDateTimeUtil.format(time, NORM_DATETIME_FORMATTER); - } - - protected LocalDateTime parseTime(String str) { - return LocalDateTimeUtil.parse(str, NORM_DATETIME_FORMATTER); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java deleted file mode 100644 index 4e5a37e9d..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeAppPayModel; -import com.alipay.api.request.AlipayTradeAppPayRequest; -import com.alipay.api.response.AlipayTradeAppPayResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 支付宝【App 支付】的 PayClient 实现类 - * - * 文档:App 支付 - * - * // TODO 芋艿:未详细测试,因为手头没 App - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayAppPayClient extends AbstractAlipayPayClient { - - public AlipayAppPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_APP.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeAppPayModel 请求 - AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody() + "test"); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setTimeExpire(formatTime(reqDTO.getExpireTime())); - model.setProductCode("QUICK_MSECURITY_PAY"); // 销售产品码:无线快捷支付产品 - // ② 个性化的参数【无】 - // ③ 支付宝扫码支付只有一种展示 - String displayMode = PayOrderDisplayModeEnum.APP.getMode(); - - // 1.2 构建 AlipayTradePrecreateRequest 请求 - AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradeAppPayResponse response = client.sdkExecute(request); - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java deleted file mode 100644 index 1f90d6b58..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePayModel; -import com.alipay.api.request.AlipayTradePayRequest; -import com.alipay.api.response.AlipayTradePayResponse; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝【条码支付】的 PayClient 实现类 - * - * 文档:当面付 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayBarPayClient extends AbstractAlipayPayClient { - - public AlipayBarPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_BAR.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "auth_code"); - if (StrUtil.isEmpty(authCode)) { - throw exception0(BAD_REQUEST.getCode(), "条形码不能为空"); - } - - // 1.1 构建 AlipayTradePayModel 请求 - AlipayTradePayModel model = new AlipayTradePayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setScene("bar_code"); // 当面付条码支付场景 - // ② 个性化的参数 - model.setAuthCode(authCode); - // ③ 支付宝条码支付只有一种展示 - String displayMode = PayOrderDisplayModeEnum.BAR_CODE.getMode(); - - // 1.2 构建 AlipayTradePayRequest 请求 - AlipayTradePayRequest request = new AlipayTradePayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePayResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - if ("10000".equals(response.getCode())) { // 免密支付 - LocalDateTime successTime = LocalDateTimeUtil.of(response.getGmtPayment()); - return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), successTime, - response.getOutTradeNo(), response) - .setDisplayMode(displayMode).setDisplayContent(""); - } - // 大额支付,需要用户输入密码,所以返回 waiting。此时,前端一般会进行轮询 - return PayOrderRespDTO.waitingOf(displayMode, "", - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java deleted file mode 100644 index 4048e8177..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 支付宝的 PayClientConfig 实现类 - * 属性主要来自 {@link com.alipay.api.AlipayConfig} 的必要属性 - * - * @author 芋道源码 - */ -@Data -public class AlipayPayClientConfig implements PayClientConfig { - - /** - * 公钥类型 - 公钥模式 - */ - public static final Integer MODE_PUBLIC_KEY = 1; - /** - * 公钥类型 - 证书模式 - */ - public static final Integer MODE_CERTIFICATE = 2; - - /** - * 签名算法类型 - RSA - */ - public static final String SIGN_TYPE_DEFAULT = "RSA2"; - - /** - * 网关地址 - * - * 1. 生产环境 - * 2. 沙箱环境 - */ - @NotBlank(message = "网关地址不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String serverUrl; - - /** - * 开放平台上创建的应用的 ID - */ - @NotBlank(message = "开放平台上创建的应用的 ID不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String appId; - - /** - * 签名算法类型,推荐:RSA2 - *

- * {@link #SIGN_TYPE_DEFAULT} - */ - @NotBlank(message = "签名算法类型不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String signType; - - /** - * 公钥类型 - * 1. {@link #MODE_PUBLIC_KEY} 情况,privateKey + alipayPublicKey - * 2. {@link #MODE_CERTIFICATE} 情况,appCertContent + alipayPublicCertContent + rootCertContent - */ - @NotNull(message = "公钥类型不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private Integer mode; - - // ========== 公钥模式 ========== - /** - * 商户私钥 - */ - @NotBlank(message = "商户私钥不能为空", groups = {ModePublicKey.class}) - private String privateKey; - - /** - * 支付宝公钥字符串 - */ - @NotBlank(message = "支付宝公钥字符串不能为空", groups = {ModePublicKey.class}) - private String alipayPublicKey; - - // ========== 证书模式 ========== - /** - * 指定商户公钥应用证书内容字符串 - */ - @NotBlank(message = "指定商户公钥应用证书内容不能为空", groups = {ModeCertificate.class}) - private String appCertContent; - /** - * 指定支付宝公钥证书内容字符串 - */ - @NotBlank(message = "指定支付宝公钥证书内容不能为空", groups = {ModeCertificate.class}) - private String alipayPublicCertContent; - /** - * 指定根证书内容字符串 - */ - @NotBlank(message = "指定根证书内容字符串不能为空", groups = {ModeCertificate.class}) - private String rootCertContent; - - public interface ModePublicKey { - } - - public interface ModeCertificate { - } - - @Override - public void validate(Validator validator) { - ValidationUtils.validate(validator, this, - MODE_PUBLIC_KEY.equals(this.getMode()) ? ModePublicKey.class : ModeCertificate.class); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java deleted file mode 100644 index 6dbd19bef..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePagePayModel; -import com.alipay.api.request.AlipayTradePagePayRequest; -import com.alipay.api.response.AlipayTradePagePayResponse; -import lombok.extern.slf4j.Slf4j; - -import java.util.Objects; - -/** - * 支付宝【PC 网站】的 PayClient 实现类 - * - * 文档:电脑网站支付 - * - * @author XGD - */ -@Slf4j -public class AlipayPcPayClient extends AbstractAlipayPayClient { - - public AlipayPcPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_PC.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradePagePayModel 请求 - AlipayTradePagePayModel model = new AlipayTradePagePayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setTimeExpire(formatTime(reqDTO.getExpireTime())); - model.setProductCode("FAST_INSTANT_TRADE_PAY"); // 销售产品码. 目前 PC 支付场景下仅支持 FAST_INSTANT_TRADE_PAY - // ② 个性化的参数 - // 如果想弄更多个性化的参数,可参考 https://www.pingxx.com/api/支付渠道 extra 参数说明.html 的 alipay_pc_direct 部分进行拓展 - model.setQrPayMode("2"); // 跳转模式 - 订单码,效果参见:https://help.pingxx.com/article/1137360/ - // ③ 支付宝 PC 支付有两种展示模式:FORM、URL - String displayMode = ObjectUtil.defaultIfNull(reqDTO.getDisplayMode(), - PayOrderDisplayModeEnum.URL.getMode()); - - // 1.2 构建 AlipayTradePagePayRequest 请求 - AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePagePayResponse response; - if (Objects.equals(displayMode, PayOrderDisplayModeEnum.FORM.getMode())) { - response = client.pageExecute(request, Method.POST.name()); // 需要特殊使用 POST 请求 - } else { - response = client.pageExecute(request, Method.GET.name()); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java deleted file mode 100644 index bb3ad1771..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePrecreateModel; -import com.alipay.api.request.AlipayTradePrecreateRequest; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import lombok.extern.slf4j.Slf4j; - -import java.util.Objects; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝【扫码支付】的 PayClient 实现类 - * - * 文档:扫码支付 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayQrPayClient extends AbstractAlipayPayClient { - - public AlipayQrPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradePrecreateModel 请求 - AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setProductCode("FACE_TO_FACE_PAYMENT"); // 销售产品码. 目前扫码支付场景下仅支持 FACE_TO_FACE_PAYMENT - // ② 个性化的参数【无】 - // ③ 支付宝扫码支付只有一种展示,考虑到前端可能希望二维码扫描后,手机打开 - String displayMode = PayOrderDisplayModeEnum.QR_CODE.getMode(); - - // 1.2 构建 AlipayTradePrecreateRequest 请求 - AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePrecreateResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getQrCode(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java deleted file mode 100644 index f9dccf5a7..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 支付宝【Wap 网站】的 PayClient 实现类 - * - * 文档:手机网站支付接口 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayWapPayClient extends AbstractAlipayPayClient { - - public AlipayWapPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeWapPayModel 请求 - AlipayTradeWapPayModel model = new AlipayTradeWapPayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setProductCode("QUICK_WAP_PAY"); // 销售产品码. 目前 Wap 支付场景下仅支持 QUICK_WAP_PAY - // ② 个性化的参数【无】 - // ③ 支付宝 Wap 支付只有一种展示:URL - String displayMode = PayOrderDisplayModeEnum.URL.getMode(); - - // 1.2 构建 AlipayTradeWapPayRequest 请求 - AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - model.setQuitUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradeWapPayResponse response = client.pageExecute(request, Method.GET.name()); - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java deleted file mode 100644 index 309813697..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 模拟支付的 PayClient 实现类 - * - * 模拟支付返回结果都是成功,方便大家日常流畅 - * - * @author jason - */ -public class MockPayClient extends AbstractPayClient { - - private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS"; - - public MockPayClient(Long channelId, NonePayClientConfig config) { - super(channelId, PayChannelEnum.MOCK.getCode(), config); - } - - @Override - protected void doInit() { - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - return PayOrderRespDTO.successOf("MOCK-P-" + reqDTO.getOutTradeNo(), "", LocalDateTime.now(), - reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - return PayOrderRespDTO.successOf("MOCK-P-" + outTradeNo, "", LocalDateTime.now(), - outTradeNo, MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - return PayRefundRespDTO.successOf("MOCK-R-" + reqDTO.getOutRefundNo(), LocalDateTime.now(), - reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - return PayRefundRespDTO.successOf("MOCK-R-" + outRefundNo, LocalDateTime.now(), - outRefundNo, MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - throw new UnsupportedOperationException("模拟支付无退款回调"); - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - throw new UnsupportedOperationException("模拟支付无支付回调"); - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java deleted file mode 100644 index 3e35c52dc..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; - -/** - * 模拟支付的 PayClientConfig 实现类 - * - * @author jason - */ -@Data -public class MockPayClientConfig implements PayClientConfig { - - /** - * 配置名称 - * - * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 - */ - private String name; - - @Override - public void validate(Validator validator) { - // 模拟支付配置无需校验 - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java deleted file mode 100644 index bd361e9c0..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java +++ /dev/null @@ -1,476 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.date.TemporalAccessorUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import com.github.binarywang.wxpay.bean.notify.WxPayNotifyV3Result; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result; -import com.github.binarywang.wxpay.bean.request.*; -import com.github.binarywang.wxpay.bean.result.*; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Map; -import java.util.Objects; - -import static cn.hutool.core.date.DatePattern.*; -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V2; - -/** - * 微信支付抽象类,实现微信统一的接口、以及部分实现(退款) - * - * @author 遇到源码 - */ -@Slf4j -public abstract class AbstractWxPayClient extends AbstractPayClient { - - protected WxPayService client; - - public AbstractWxPayClient(Long channelId, String channelCode, WxPayClientConfig config) { - super(channelId, channelCode, config); - } - - /** - * 初始化 client 客户端 - * - * @param tradeType 交易类型 - */ - protected void doInit(String tradeType) { - // 创建 config 配置 - WxPayConfig payConfig = new WxPayConfig(); - BeanUtil.copyProperties(config, payConfig, "keyContent", "privateKeyContent", "privateCertContent"); - payConfig.setTradeType(tradeType); - // weixin-pay-java 无法设置内容,只允许读取文件,所以这里要创建临时文件来解决 - if (Base64.isBase64(config.getKeyContent())) { - payConfig.setKeyPath(FileUtils.createTempFile(Base64.decode(config.getKeyContent())).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { - payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { - payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); - } - - // 创建 client 客户端 - client = new WxPayServiceImpl(); - client.setConfig(payConfig); - } - - // ============ 支付相关 ========== - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doUnifiedOrderV2(reqDTO); - case WxPayClientConfig.API_VERSION_V3: - return doUnifiedOrderV3(reqDTO); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayOrderRespDTO.closedOf(errorCode, errorMessage, - reqDTO.getOutTradeNo(), e.getXmlString()); - } - } - - /** - * 【V2】调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 各支付渠道的返回结果 - */ - protected abstract PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) - throws Exception; - - /** - * 【V3】调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 各支付渠道的返回结果 - */ - protected abstract PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) - throws WxPayException; - - /** - * 【V2】创建微信下单请求 - * - * @param reqDTO 下信息 - * @return 下单请求 - */ - protected WxPayUnifiedOrderRequest buildPayUnifiedOrderRequestV2(PayOrderUnifiedReqDTO reqDTO) { - return WxPayUnifiedOrderRequest.newBuilder() - .outTradeNo(reqDTO.getOutTradeNo()) - .body(reqDTO.getSubject()) - .detail(reqDTO.getBody()) - .totalFee(reqDTO.getPrice()) // 单位分 - .timeExpire(formatDateV2(reqDTO.getExpireTime())) - .spbillCreateIp(reqDTO.getUserIp()) - .notifyUrl(reqDTO.getNotifyUrl()) - .build(); - } - - /** - * 【V3】创建微信下单请求 - * - * @param reqDTO 下信息 - * @return 下单请求 - */ - protected WxPayUnifiedOrderV3Request buildPayUnifiedOrderRequestV3(PayOrderUnifiedReqDTO reqDTO) { - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); - request.setOutTradeNo(reqDTO.getOutTradeNo()); - request.setDescription(reqDTO.getSubject()); - request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getPrice())); // 单位分 - request.setTimeExpire(formatDateV3(reqDTO.getExpireTime())); - request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - return request; - } - - @Override - public PayOrderRespDTO doParseOrderNotify(Map params, String body) throws WxPayException { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doParseOrderNotifyV2(body); - case WxPayClientConfig.API_VERSION_V3: - return doParseOrderNotifyV3(body); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayOrderRespDTO doParseOrderNotifyV2(String body) throws WxPayException { - // 1. 解析回调 - WxPayOrderNotifyResult response = client.parseOrderNotifyResult(body); - // 2. 构建结果 - // V2 微信支付的回调,只有 SUCCESS 支付成功、CLOSED 支付失败两种情况,无需像支付宝一样解析的比较复杂 - Integer status = Objects.equals(response.getResultCode(), "SUCCESS") ? - PayOrderStatusRespEnum.SUCCESS.getStatus() : PayOrderStatusRespEnum.CLOSED.getStatus(); - return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - response.getOutTradeNo(), body); - } - - private PayOrderRespDTO doParseOrderNotifyV3(String body) throws WxPayException { - // 1. 解析回调 - WxPayNotifyV3Result response = client.parseOrderNotifyV3Result(body, null); - WxPayNotifyV3Result.DecryptNotifyResult result = response.getResult(); - // 2. 构建结果 - Integer status = parseStatus(result.getTradeState()); - String openid = result.getPayer() != null ? result.getPayer().getOpenid() : null; - return PayOrderRespDTO.of(status, result.getTransactionId(), openid, parseDateV3(result.getSuccessTime()), - result.getOutTradeNo(), body); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doGetOrderV2(outTradeNo); - case WxPayClientConfig.API_VERSION_V3: - return doGetOrderV3(outTradeNo); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - if (ObjectUtils.equalsAny(e.getErrCode(), "ORDERNOTEXIST", "ORDER_NOT_EXIST")) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayOrderRespDTO.closedOf(errorCode, errorMessage, - outTradeNo, e.getXmlString()); - } - throw e; - } - } - - private PayOrderRespDTO doGetOrderV2(String outTradeNo) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayOrderQueryRequest request = WxPayOrderQueryRequest.newBuilder() - .outTradeNo(outTradeNo).build(); - // 执行请求 - WxPayOrderQueryResult response = client.queryOrder(request); - - // 转换结果 - Integer status = parseStatus(response.getTradeState()); - return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - outTradeNo, response); - } - - private PayOrderRespDTO doGetOrderV3(String outTradeNo) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayOrderQueryV3Request request = new WxPayOrderQueryV3Request() - .setOutTradeNo(outTradeNo); - // 执行请求 - WxPayOrderQueryV3Result response = client.queryOrderV3(request); - - // 转换结果 - Integer status = parseStatus(response.getTradeState()); - String openid = response.getPayer() != null ? response.getPayer().getOpenid() : null; - return PayOrderRespDTO.of(status, response.getTransactionId(), openid, parseDateV3(response.getSuccessTime()), - outTradeNo, response); - } - - private static Integer parseStatus(String tradeState) { - switch (tradeState) { - case "NOTPAY": - case "USERPAYING": // 支付中,等待用户输入密码(条码支付独有) - return PayOrderStatusRespEnum.WAITING.getStatus(); - case "SUCCESS": - return PayOrderStatusRespEnum.SUCCESS.getStatus(); - case "REFUND": - return PayOrderStatusRespEnum.REFUND.getStatus(); - case "CLOSED": - case "REVOKED": // 已撤销(刷卡支付独有) - case "PAYERROR": // 支付失败(其它原因,如银行返回失败) - return PayOrderStatusRespEnum.CLOSED.getStatus(); - default: - throw new IllegalArgumentException(StrUtil.format("未知的支付状态({})", tradeState)); - } - } - - // ============ 退款相关 ========== - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doUnifiedRefundV2(reqDTO); - case WxPayClientConfig.API_VERSION_V3: - return doUnifiedRefundV3(reqDTO); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayRefundRespDTO.failureOf(errorCode, errorMessage, - reqDTO.getOutTradeNo(), e.getXmlString()); - } - } - - private PayRefundRespDTO doUnifiedRefundV2(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundRequest request = new WxPayRefundRequest() - .setOutTradeNo(reqDTO.getOutTradeNo()) - .setOutRefundNo(reqDTO.getOutRefundNo()) - .setRefundFee(reqDTO.getRefundPrice()) - .setRefundDesc(reqDTO.getReason()) - .setTotalFee(reqDTO.getPayPrice()) - .setNotifyUrl(reqDTO.getNotifyUrl()); - // 2.1 执行请求 - WxPayRefundResult response = client.refundV2(request); - // 2.2 创建返回结果 - if (Objects.equals("SUCCESS", response.getResultCode())) { // V2 情况下,不直接返回退款成功,而是等待异步通知 - return PayRefundRespDTO.waitingOf(response.getRefundId(), - reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), response); - } - - private PayRefundRespDTO doUnifiedRefundV3(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo(reqDTO.getOutTradeNo()) - .setOutRefundNo(reqDTO.getOutRefundNo()) - .setAmount(new WxPayRefundV3Request.Amount().setRefund(reqDTO.getRefundPrice()) - .setTotal(reqDTO.getPayPrice()).setCurrency("CNY")) - .setReason(reqDTO.getReason()) - .setNotifyUrl(reqDTO.getNotifyUrl()); - // 2.1 执行请求 - WxPayRefundV3Result response = client.refundV3(request); - // 2.2 创建返回结果 - if (Objects.equals("SUCCESS", response.getStatus())) { - return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()), - reqDTO.getOutRefundNo(), response); - } - if (Objects.equals("PROCESSING", response.getStatus())) { - return PayRefundRespDTO.waitingOf(response.getRefundId(), - reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), response); - } - - @Override - public PayRefundRespDTO doParseRefundNotify(Map params, String body) throws WxPayException { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doParseRefundNotifyV2(body); - case WxPayClientConfig.API_VERSION_V3: - return parseRefundNotifyV3(body); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayRefundRespDTO doParseRefundNotifyV2(String body) throws WxPayException { - // 1. 解析回调 - WxPayRefundNotifyResult response = client.parseRefundNotifyResult(body); - WxPayRefundNotifyResult.ReqInfo result = response.getReqInfo(); - // 2. 构建结果 - if (Objects.equals("SUCCESS", result.getRefundStatus())) { - return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV2B(result.getSuccessTime()), - result.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); - } - - private PayRefundRespDTO parseRefundNotifyV3(String body) throws WxPayException { - // 1. 解析回调 - WxPayRefundNotifyV3Result response = client.parseRefundNotifyV3Result(body, null); - WxPayRefundNotifyV3Result.DecryptNotifyResult result = response.getResult(); - // 2. 构建结果 - if (Objects.equals("SUCCESS", result.getRefundStatus())) { - return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV3(result.getSuccessTime()), - result.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doGetRefundV2(outTradeNo, outRefundNo); - case WxPayClientConfig.API_VERSION_V3: - return doGetRefundV3(outTradeNo, outRefundNo); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - if (ObjectUtils.equalsAny(e.getErrCode(), "REFUNDNOTEXIST", "RESOURCE_NOT_EXISTS")) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayRefundRespDTO.failureOf(errorCode, errorMessage, - outRefundNo, e.getXmlString()); - } - throw e; - } - } - - private PayRefundRespDTO doGetRefundV2(String outTradeNo, String outRefundNo) throws WxPayException { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundQueryRequest request = WxPayRefundQueryRequest.newBuilder() - .outTradeNo(outTradeNo) - .outRefundNo(outRefundNo) - .build(); - // 2.1 执行请求 - WxPayRefundQueryResult response = client.refundQuery(request); - // 2.2 创建返回结果 - if (!Objects.equals("SUCCESS", response.getResultCode())) { - return PayRefundRespDTO.waitingOf(null, - outRefundNo, response); - } - WxPayRefundQueryResult.RefundRecord refund = CollUtil.findOne(response.getRefundRecords(), - record -> record.getOutRefundNo().equals(outRefundNo)); - if (refund == null) { - return PayRefundRespDTO.failureOf(outRefundNo, response); - } - switch (refund.getRefundStatus()) { - case "SUCCESS": - return PayRefundRespDTO.successOf(refund.getRefundId(), parseDateV2B(refund.getRefundSuccessTime()), - outRefundNo, response); - case "PROCESSING": - return PayRefundRespDTO.waitingOf(refund.getRefundId(), - outRefundNo, response); - case "CHANGE": // 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,资金回流到商户的现金帐号,需要商户人工干预,通过线下或者财付通转账的方式进行退款 - case "FAIL": - return PayRefundRespDTO.failureOf(outRefundNo, response); - default: - throw new IllegalArgumentException(String.format("未知的退款状态(%s)", refund.getRefundStatus())); - } - } - - private PayRefundRespDTO doGetRefundV3(String outTradeNo, String outRefundNo) throws WxPayException { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundQueryV3Request request = new WxPayRefundQueryV3Request(); - request.setOutRefundNo(outRefundNo); - // 2.1 执行请求 - WxPayRefundQueryV3Result response = client.refundQueryV3(request); - // 2.2 创建返回结果 - switch (response.getStatus()) { - case "SUCCESS": - return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()), - outRefundNo, response); - case "PROCESSING": - return PayRefundRespDTO.waitingOf(response.getRefundId(), - outRefundNo, response); - case "ABNORMAL": // 退款异常 - case "CLOSED": - return PayRefundRespDTO.failureOf(outRefundNo, response); - default: - throw new IllegalArgumentException(String.format("未知的退款状态(%s)", response.getStatus())); - } - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - // ========== 各种工具方法 ========== - - static String formatDateV2(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), PURE_DATETIME_PATTERN); - } - - static LocalDateTime parseDateV2(String time) { - return LocalDateTimeUtil.parse(time, PURE_DATETIME_PATTERN); - } - - static LocalDateTime parseDateV2B(String time) { - return LocalDateTimeUtil.parse(time, NORM_DATETIME_PATTERN); - } - - static String formatDateV3(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), UTC_WITH_XXX_OFFSET_PATTERN); - } - - static LocalDateTime parseDateV3(String time) { - return LocalDateTimeUtil.parse(time, UTC_WITH_XXX_OFFSET_PATTERN); - } - - static String getErrorCode(WxPayException e) { - if (StrUtil.isNotEmpty(e.getErrCode())) { - return e.getErrCode(); - } - if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) { - return "CUSTOM_ERROR"; - } - return e.getReturnCode(); - } - - static String getErrorMessage(WxPayException e) { - if (StrUtil.isNotEmpty(e.getErrCode())) { - return e.getErrCodeDes(); - } - if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) { - return e.getCustomErrorMsg(); - } - return e.getReturnMsg(); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java deleted file mode 100644 index 396694a75..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付【App 支付】的 PayClient 实现类 - * - * 文档:App 支付 - * - * // TODO 芋艿:未详细测试,因为手头没 App - * - * @author 芋道源码 - */ -@Slf4j -public class WxAppPayClient extends AbstractWxPayClient { - - public WxAppPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_APP.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.APP); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); - // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderV3Request 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO); - // 执行请求 - WxPayUnifiedOrderV3Result.AppResult response = client.createOrderV3(TradeTypeEnum.APP, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java deleted file mode 100644 index d01b50405..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付【付款码支付】的 PayClient 实现类 - * - * 文档:付款码支付 - * - * @author 芋道源码 - */ -@Slf4j -public class WxBarPayClient extends AbstractWxPayClient { - - /** - * 微信付款码的过期时间 - */ - private static final Duration AUTH_CODE_EXPIRE = Duration.ofMinutes(3); - - public WxBarPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_BAR.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.MICROPAY); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 由于付款码需要不断轮询,所以需要在较短的时间完成支付 - LocalDateTime expireTime = LocalDateTimeUtils.addTime(AUTH_CODE_EXPIRE); - if (expireTime.isAfter(reqDTO.getExpireTime())) { - expireTime = reqDTO.getExpireTime(); - } - // 构建 WxPayMicropayRequest 对象 - WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() - .outTradeNo(reqDTO.getOutTradeNo()) - .body(reqDTO.getSubject()) - .detail(reqDTO.getBody()) - .totalFee(reqDTO.getPrice()) // 单位分 - .timeExpire(formatDateV2(expireTime)) - .spbillCreateIp(reqDTO.getUserIp()) - .authCode(getAuthCode(reqDTO)) - .build(); - // 执行请求,重试直到失败(过期),或者成功 - WxPayException lastWxPayException = null; - for (int i = 1; i < Byte.MAX_VALUE; i++) { - try { - WxPayMicropayResult response = client.micropay(request); - // 支付成功,例如说:1)用户输入了密码;2)用户免密支付 - return PayOrderRespDTO.successOf(response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - response.getOutTradeNo(), response) - .setDisplayMode(PayOrderDisplayModeEnum.BAR_CODE.getMode()); - } catch (WxPayException ex) { - lastWxPayException = ex; - // 如果不满足这 3 种任一的,则直接抛出 WxPayException 异常,不仅需处理 - // 1. SYSTEMERROR:接口返回错误:请立即调用被扫订单结果查询API,查询当前订单状态,并根据订单的状态决定下一步的操作。 - // 2. USERPAYING:用户支付中,需要输入密码:等待 5 秒,然后调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 - // 3. BANKERROR:银行系统异常:请立即调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 - if (!StrUtil.equalsAny(ex.getErrCode(), "SYSTEMERROR", "USERPAYING", "BANKERROR")) { - throw ex; - } - // 等待 5 秒,继续下一轮重新发起支付 - log.info("[doUnifiedOrderV2][发起微信 Bar 支付第({})失败,等待下一轮重试,请求({}),响应({})]", i, - toJsonString(request), ex.getMessage()); - ThreadUtil.sleep(5, TimeUnit.SECONDS); - } - } - throw lastWxPayException; - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - return doUnifiedOrderV2(reqDTO); - } - - // ========== 各种工具方法 ========== - - static String getAuthCode(PayOrderUnifiedReqDTO reqDTO) { - String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "authCode"); - if (StrUtil.isEmpty(authCode)) { - throw invalidParamException("支付请求的 authCode 不能为空!"); - } - return authCode; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java deleted file mode 100644 index 9929955ae..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付【小程序】的 PayClient 实现类 - * - * 由于公众号和小程序的微信支付逻辑一致,所以直接进行继承 - * - * 文档:JSAPI 下单 - * - * @author zwy - */ -@Slf4j -public class WxLitePayClient extends WxPubPayClient { - - public WxLitePayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_LITE.getCode(), config); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java deleted file mode 100644 index 5a073501d..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付【Native 二维码】的 PayClient 实现类 - * - * 文档:Native 下单 - * - * @author zwy - */ -@Slf4j -public class WxNativePayClient extends AbstractWxPayClient { - - public WxNativePayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_NATIVE.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.NATIVE); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); - // 执行请求 - WxPayNativeOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.QR_CODE.getMode(), response.getCodeUrl(), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderV3Request 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO); - // 执行请求 - String response = client.createOrderV3(TradeTypeEnum.NATIVE, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.QR_CODE.getMode(), response, - reqDTO.getOutTradeNo(), response); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java deleted file mode 100644 index 77027ae3a..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; -import javax.validation.constraints.NotBlank; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * 微信支付的 PayClientConfig 实现类 - * 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性 - * - * @author 芋道源码 - */ -@Data -public class WxPayClientConfig implements PayClientConfig { - - /** - * API 版本 - V2 - * - * V2 协议说明 - */ - public static final String API_VERSION_V2 = "v2"; - /** - * API 版本 - V3 - * - * V3 协议说明 - */ - public static final String API_VERSION_V3 = "v3"; - - /** - * 公众号或者小程序的 appid - * - * 只有公众号或小程序需要该字段 - */ - @NotBlank(message = "APPID 不能为空", groups = {V2.class, V3.class}) - private String appId; - /** - * 商户号 - */ - @NotBlank(message = "商户号不能为空", groups = {V2.class, V3.class}) - private String mchId; - /** - * API 版本 - */ - @NotBlank(message = "API 版本不能为空", groups = {V2.class, V3.class}) - private String apiVersion; - - // ========== V2 版本的参数 ========== - - /** - * 商户密钥 - */ - @NotBlank(message = "商户密钥不能为空", groups = V2.class) - private String mchKey; - /** - * apiclient_cert.p12 证书文件的对应字符串【base64 格式】 - * - * 为什么采用 base64 格式?因为 p12 读取后是二进制,需要转换成 base64 格式才好传输和存储 - */ - @NotBlank(message = "apiclient_cert.p12 不能为空", groups = V2.class) - private String keyContent; - - // ========== V3 版本的参数 ========== - /** - * apiclient_key.pem 证书文件的对应字符串 - */ - @NotBlank(message = "apiclient_key 不能为空", groups = V3.class) - private String privateKeyContent; - /** - * apiclient_cert.pem 证书文件的对应的字符串 - */ - @NotBlank(message = "apiclient_cert 不能为空", groups = V3.class) - private String privateCertContent; - /** - * apiV3 密钥值 - */ - @NotBlank(message = "apiV3 密钥值不能为空", groups = V3.class) - private String apiV3Key; - - /** - * 分组校验 v2版本 - */ - public interface V2 { - } - - /** - * 分组校验 v3版本 - */ - public interface V3 { - } - - @Override - public void validate(Validator validator) { - ValidationUtils.validate(validator, this, - API_VERSION_V2.equals(this.getApiVersion()) ? V2.class : V3.class); - } - - public static void main(String[] args) throws FileNotFoundException { - String path = "/Users/yunai/Downloads/wx_pay/apiclient_cert.p12"; - /// String path = "/Users/yunai/Downloads/wx_pay/apiclient_key.pem"; - /// String path = "/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"; - System.out.println(IoUtil.readUtf8(new FileInputStream(path))); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java deleted file mode 100644 index 390c51363..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付(公众号)的 PayClient 实现类 - * - * 文档:JSAPI 下单 - * - * @author 芋道源码 - */ -@Slf4j -public class WxPubPayClient extends AbstractWxPayClient { - - public WxPubPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_PUB.getCode(), config); - } - - protected WxPubPayClient(Long channelId, String channelCode, WxPayClientConfig config) { - super(channelId, channelCode, config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.JSAPI); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO) - .setOpenid(getOpenid(reqDTO)); - // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO) - .setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); - // 执行请求 - WxPayUnifiedOrderV3Result.JsapiResult response = client.createOrderV3(TradeTypeEnum.JSAPI, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - // ========== 各种工具方法 ========== - - static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { - String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); - if (StrUtil.isEmpty(openid)) { - throw invalidParamException("支付请求的 openid 不能为空!"); - } - return openid; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java deleted file mode 100644 index e049ad33e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.channel; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付渠道的编码的枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayChannelEnum { - - WX_PUB("wx_pub", "微信 JSAPI 支付", WxPayClientConfig.class), // 公众号网页 - WX_LITE("wx_lite", "微信小程序支付", WxPayClientConfig.class), - WX_APP("wx_app", "微信 App 支付", WxPayClientConfig.class), - WX_NATIVE("wx_native", "微信 Native 支付", WxPayClientConfig.class), - WX_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class), - - ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class), - ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class), - ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class), - ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class), - ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class), - MOCK("mock", "模拟支付", NonePayClientConfig.class), - - WALLET("wallet", "钱包支付", NonePayClientConfig.class); - - /** - * 编码 - * - * 参考 支付渠道属性值 - */ - private final String code; - /** - * 名字 - */ - private final String name; - - /** - * 配置类 - */ - private final Class configClass; - - /** - * 微信支付 - */ - public static final String WECHAT = "WECHAT"; - - /** - * 支付宝支付 - */ - public static final String ALIPAY = "ALIPAY"; - - public static PayChannelEnum getByCode(String code) { - return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java deleted file mode 100644 index 129c40602..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.order; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付 UI 展示模式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderDisplayModeEnum { - - URL("url"), // Redirect 跳转链接的方式 - IFRAME("iframe"), // IFrame 内嵌链接的方式【目前暂时用不到】 - FORM("form"), // HTML 表单提交 - QR_CODE("qr_code"), // 二维码的文字内容 - QR_CODE_URL("qr_code_url"), // 二维码的图片链接 - BAR_CODE("bar_code"), // 条形码 - APP("app"), // 应用:Android、iOS、微信小程序、微信公众号等,需要做自定义处理的 - ; - - /** - * 展示模式 - */ - private final String mode; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java deleted file mode 100644 index eac381c47..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.order; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的支付状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderStatusRespEnum { - - WAITING(0, "未支付"), - SUCCESS(10, "支付成功"), - REFUND(20, "已退款"), - CLOSED(30, "支付关闭"), - ; - - private final Integer status; - private final String name; - - /** - * 判断是否支付成功 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - /** - * 判断是否已退款 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isRefund(Integer status) { - return Objects.equals(status, REFUND.getStatus()); - } - - /** - * 判断是否支付关闭 - * - * @param status 状态 - * @return 是否支付关闭 - */ - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java deleted file mode 100644 index 8ad61a6cf..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.refund; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的退款状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayRefundStatusRespEnum { - - WAITING(0, "等待退款"), - SUCCESS(10, "退款成功"), - FAILURE(20, "退款失败"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isFailure(Integer status) { - return Objects.equals(status, FAILURE.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java deleted file mode 100644 index 145a470cc..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.transfer; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的转账状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayTransferStatusRespEnum { - - WAITING(0, "转账中"), - - /** - * TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现 - * TODO @jason:可以看看其它开源项目,针对这个场景,处理策略是怎么样的?例如说,每天主动轮询?这个状态的单子? - */ - IN_PROGRESS(10, "转账进行中"), - - SUCCESS(20, "转账成功"), - /** - * 转账关闭 (失败,或者其它情况) - */ - CLOSED(30, "转账关闭"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java deleted file mode 100644 index 2de6fd21f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.transfer; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 转账类型枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayTransferTypeEnum implements IntArrayValuable { - - ALIPAY_BALANCE(1, "支付宝余额"), - WX_BALANCE(2, "微信余额"), - BANK_CARD(3, "银行卡"), - WALLET_BALANCE(4, "钱包余额"); - - public static final String ALIPAY_LOGON_ID = "ALIPAY_LOGON_ID"; - public static final String ALIPAY_ACCOUNT_NAME = "ALIPAY_ACCOUNT_NAME"; - - private final Integer type; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - - public static PayTransferTypeEnum typeOf(Integer type) { - return ArrayUtil.firstMatch(item -> item.getType().equals(type), values()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 6fd198210..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java deleted file mode 100644 index 582840e4e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.framework.core.client.impl; - -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import org.junit.jupiter.api.Test; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * {@link PayClientFactoryImpl} 的集成测试 - * - * @author 芋道源码 - */ -public class PayClientFactoryImplTest { - - private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl(); - - /** - * {@link WXPubPayClient} 的 V2 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V2() { - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - CommonResult result = client.unifiedOrder(reqDTO); - System.out.println(result); - } - - /** - * {@link WXPubPayClient} 的 V3 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException { - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V3); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - CommonResult result = client.unifiedOrder(reqDTO); - System.out.println(result); - } - - /** - * {@link AlipayQrPayClient} - */ - @Test - @SuppressWarnings("unchecked") - public void testCreatePayClient_ALIPAY_QR() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - reqDTO.setNotifyUrl("http://niubi.natapp1.cc/api/pay/order/notify/alipay-qr/1"); // TODO @tina: 这里改成你的 natapp 回调地址 - CommonResult result = (CommonResult) client.unifiedOrder(reqDTO); - System.out.println(JsonUtils.toJsonString(result)); - System.out.println(result.getData().getQrCode()); - } - - /** - * {@link AlipayWapPayClient} - */ - @Test - public void testCreatePayClient_ALIPAY_WAP() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - CommonResult result = client.unifiedOrder(reqDTO); - System.out.println(JsonUtils.toJsonString(result)); - } - - private static PayOrderUnifiedReqDTO buildPayOrderUnifiedReqDTO() { - PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); - reqDTO.setAmount(123L); - reqDTO.setSubject("IPhone 13"); - reqDTO.setBody("biubiubiu"); - reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setNotifyUrl("http://127.0.0.1:8080"); - return reqDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java deleted file mode 100644 index 984256063..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * {@link PayClientFactoryImpl} 的集成测试 - * - * @author 芋道源码 - */ -@Disabled -public class PayClientFactoryImplIntegrationTest { - - private static final String SERVER_URL_SANDBOX = "https://openapi.alipaydev.com/gateway.do"; - - private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl(); - - /** - * {@link WxPubPayClient} 的 V2 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V2() { - // 创建配置 - WxPayClientConfig config = new WxPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WxPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(result); - } - - /** - * {@link WxPubPayClient} 的 V3 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException { - // 创建配置 - WxPayClientConfig config = new WxPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WxPayClientConfig.API_VERSION_V3); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(result); - } - - /** - * {@link AlipayQrPayClient} - */ - @Test - @SuppressWarnings("unchecked") - public void testCreatePayClient_ALIPAY_QR() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - reqDTO.setNotifyUrl("http://yunai.natapp1.cc/admin-api/pay/notify/callback/18"); // TODO @tina: 这里改成你的 natapp 回调地址 -// CommonResult result = (CommonResult) client.unifiedOrder(reqDTO); -// System.out.println(JsonUtils.toJsonString(result)); -// System.out.println(result.getData().getQrCode()); - } - - /** - * {@link AlipayWapPayClient} - */ - @Test - public void testCreatePayClient_ALIPAY_WAP() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(JsonUtils.toJsonString(result)); - } - - private static PayOrderUnifiedReqDTO buildPayOrderUnifiedReqDTO() { - PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); - reqDTO.setPrice(123); - reqDTO.setSubject("IPhone 13"); - reqDTO.setBody("biubiubiu"); - reqDTO.setOutTradeNo(String.valueOf(System.currentTimeMillis())); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setNotifyUrl("http://127.0.0.1:8080"); - return reqDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java deleted file mode 100644 index 2d220079e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java +++ /dev/null @@ -1,221 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.alipay.api.AlipayApiException; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.DefaultSigner; -import com.alipay.api.domain.AlipayTradeRefundModel; -import com.alipay.api.request.AlipayTradeRefundRequest; -import com.alipay.api.response.AlipayTradeRefundResponse; -import lombok.Setter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.Mock; - -import javax.validation.ConstraintViolationException; -import java.util.Date; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * 支付宝 Client 的测试基类 - * - * @author jason - */ -public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { - - protected AlipayPayClientConfig config = randomPojo(AlipayPayClientConfig.class, o -> { - o.setServerUrl(randomURL()); - o.setPrivateKey(randomString()); - o.setMode(MODE_PUBLIC_KEY); - o.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - o.setAppCertContent(""); - o.setAlipayPublicCertContent(""); - o.setRootCertContent(""); - }); - - @Mock - protected DefaultAlipayClient defaultAlipayClient; - - @Setter - private AbstractAlipayPayClient client; - - /** - * 子类需要实现该方法. 设置 client 的具体实现 - */ - @BeforeEach - public abstract void setUp(); - - @Test - @DisplayName("支付宝 Client 初始化") - public void testDoInit() { - // 调用 - client.doInit(); - // 断言 - DefaultAlipayClient realClient = client.getClient(); - assertNotSame(defaultAlipayClient, realClient); - assertInstanceOf(DefaultSigner.class, realClient.getSigner()); - assertEquals(config.getPrivateKey(), ((DefaultSigner) realClient.getSigner()).getPrivateKey()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:成功") - public void testUnifiedRefund_success() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - Date refundTime = randomDate(); - String outRefundNo = randomString(); - String outTradeNo = randomString(); - Integer refundAmount = randomInteger(); - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { - o.setSubCode(""); - o.setGmtRefundPay(refundTime); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); - AlipayTradeRefundModel bizModel = (AlipayTradeRefundModel) request.getBizModel(); - assertEquals(outRefundNo, bizModel.getOutRequestNo()); - assertEquals(outTradeNo, bizModel.getOutTradeNo()); - assertEquals(String.valueOf(refundAmount / 100.0), bizModel.getRefundAmount()); - return true; - }))).thenReturn(response); - // 准备请求参数 - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutRefundNo(outRefundNo); - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - o.setRefundPrice(refundAmount); - }); - - // 调用 - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); - // 断言 - assertEquals(PayRefundStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); - assertEquals(outRefundNo, resp.getOutRefundNo()); - assertNull(resp.getChannelRefundNo()); - assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:渠道返回失败") - public void test_unified_refund_channel_failed() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outRefundNo = randomString(); - String outTradeNo = randomString(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutRefundNo(outRefundNo); - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - }); - - // 调用 - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); - // 断言 - assertEquals(PayRefundStatusRespEnum.FAILURE.getStatus(), resp.getStatus()); - assertEquals(outRefundNo, resp.getOutRefundNo()); - assertNull(resp.getChannelRefundNo()); - assertNull(resp.getSuccessTime()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:参数校验不通过") - public void testUnifiedRefund_paramInvalidate() { - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutTradeNo(""); - o.setNotifyUrl(notifyUrl); - }); - - // 调用,并断言 - assertThrows(ConstraintViolationException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一退款:抛出业务异常") - public void testUnifiedRefund_throwServiceException() throws AlipayApiException { - // mock 方法 - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一退款:抛出系统异常") - public void testUnifiedRefund_throwPayException() throws AlipayApiException { - // mock 方法 - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenThrow(new RuntimeException("系统异常")); - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); - - // 调用,并断言 - assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一下单:参数校验不通过") - public void testUnifiedOrder_paramInvalidate() { - // 准备请求参数 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - }); - - // 调用,并断言 - assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); - } - - protected PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo, Integer price) { - return randomPojo(PayOrderUnifiedReqDTO.class, o -> { - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - o.setPrice(price); - o.setSubject(RandomUtil.randomString(32)); - o.setBody(RandomUtil.randomString(32)); - }); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java deleted file mode 100644 index 47f10081c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java +++ /dev/null @@ -1,170 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePayModel; -import com.alipay.api.request.AlipayTradePayRequest; -import com.alipay.api.response.AlipayTradePayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayBarPayClient} 单元测试 - * - * @author jason - */ -public class AlipayBarPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayBarPayClient client = new AlipayBarPayClient(randomLongId(), config); - - @Override - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝条码支付:非免密码支付下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - String authCode = randomString(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradePayModel.class, request.getBizModel()); - assertEquals(notifyUrl, request.getNotifyUrl()); - AlipayTradePayModel model = (AlipayTradePayModel) request.getBizModel(); - assertEquals(outTradeNo, model.getOutTradeNo()); - assertEquals(String.valueOf(price / 100.0), model.getTotalAmount()); - assertEquals(authCode, model.getAuthCode()); - return true; - }))).thenReturn(response); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 调用方法 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); - assertEquals("", resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝条码支付:免密码支付下单成功") - public void testUnifiedOrder_code10000Success() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String channelNo = randomString(); - String channelUserId = randomString(); - Date payTime = randomDate(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { - o.setSubCode(""); - o.setCode("10000"); - o.setOutTradeNo(outTradeNo); - o.setTradeNo(channelNo); - o.setBuyerUserId(channelUserId); - o.setGmtPayment(payTime); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenReturn(response); - // 准备请求参数 - String authCode = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 下单请求 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(PayOrderStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertEquals(channelNo, resp.getChannelOrderNo()); - assertEquals(channelUserId, resp.getChannelUserId()); - assertEquals(LocalDateTimeUtil.of(payTime), resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); - assertEquals("", resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝条码支付:没有传条码") - public void testUnifiedOrder_emptyAuthCode() { - // 准备参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); - } - - @Test - @DisplayName("支付宝条码支付:渠道返回失败") - public void test_unified_order_channel_failed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenReturn(response); - // 准备请求参数 - String authCode = randomString(); - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 调用方法 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java deleted file mode 100644 index a6b3d8743..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.request.AlipayTradePagePayRequest; -import com.alipay.api.response.AlipayTradePagePayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayPcPayClient} 单元测试 - * - * @author jason - */ -public class AlipayPcPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayPcPayClient client = new AlipayPcPayClient(randomLongId(), config); - - @Override - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝 PC 网站支付:URL Display Mode 下单成功") - public void testUnifiedOrder_urlSuccess() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - Integer price = randomInteger(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - reqDTO.setDisplayMode(null); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 PC 网站支付:Form Display Mode 下单成功") - public void testUnifiedOrder_formSuccess() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.POST.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - Integer price = randomInteger(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - reqDTO.setDisplayMode(PayOrderDisplayModeEnum.FORM.getMode()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.FORM.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 PC 网站支付:渠道返回失败") - public void testUnifiedOrder_channelFailed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - reqDTO.setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java deleted file mode 100644 index c7e1eb33f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.request.AlipayTradePrecreateRequest; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayQrPayClient} 单元测试 - * - * @author jason - */ -public class AlipayQrPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayQrPayClient client = new AlipayQrPayClient(randomLongId(), config); - - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝扫描支付:下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String qrCode = randomString(); - Integer price = randomInteger(); - AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { - o.setQrCode(qrCode); - o.setSubCode(""); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.QR_CODE.getMode(), resp.getDisplayMode()); - assertEquals(response.getQrCode(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝扫描支付:渠道返回失败") - public void testUnifiedOrder_channelFailed() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String subCode = randomString(); - String subMsg = randomString(); - Integer price = randomInteger(); - AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - // mock - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝扫描支付, 抛出系统异常") - public void testUnifiedOrder_throwPayException() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenThrow(new RuntimeException("系统异常")); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price); - - // 调用,并断言 - assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一下单:抛出业务异常") - public void testUnifiedOrder_throwServiceException() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java deleted file mode 100644 index cfe3001a5..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayWapPayClient} 单元测试 - * - * @author jason - */ -public class AlipayWapPayClientTest extends AbstractAlipayClientTest { - - /** - * 支付宝 H5 支付 Client - */ - @InjectMocks - private AlipayWapPayClient client = new AlipayWapPayClient(randomLongId(), config); - - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝 H5 支付:下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String h5Body = randomString(); - Integer price = randomInteger(); - AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { - o.setSubCode(""); - o.setBody(h5Body); - }); - String notifyUrl = randomURL(); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeWapPayModel.class, request.getBizModel()); - AlipayTradeWapPayModel bizModel = (AlipayTradeWapPayModel) request.getBizModel(); - assertEquals(String.valueOf(price / 100.0), bizModel.getTotalAmount()); - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }), eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 H5 支付:渠道返回失败") - public void test_unified_order_channel_failed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java deleted file mode 100644 index 9af11ac3f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; -import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; -import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; -import com.github.binarywang.wxpay.bean.result.WxPayRefundResult; -import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.time.Duration; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV2; - -/** - * {@link WxBarPayClient} 的集成测试,用于快速调试微信条码支付 - * - * @author 芋道源码 - */ -@Disabled -public class WxBarPayClientIntegrationTest { - - @Test - public void testPayV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起支付 - WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() - .outTradeNo(String.valueOf(System.currentTimeMillis())) - .body("测试支付-body") - .detail("测试支付-detail") - .totalFee(1) // 单位分 - .timeExpire(formatDateV2(LocalDateTimeUtils.addTime(Duration.ofMinutes(2)))) - .spbillCreateIp("127.0.0.1") - .authCode("134298744426278497") - .build(); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayMicropayResult response = client.micropay(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testParseRefundNotifyV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行解析 - String xml = "SUCCESS"; - WxPayRefundNotifyResult response = client.parseRefundNotifyResult(xml); - System.out.println(response.getReqInfo()); - } - - @Test - public void testRefundV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundRequest request = new WxPayRefundRequest() - .setOutTradeNo("1689545667276") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setRefundFee(1) - .setRefundDesc("就是想退了") - .setTotalFee(1); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundResult response = client.refund(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testRefundV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo("1689506325635") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setAmount(new WxPayRefundV3Request.Amount().setTotal(1).setRefund(1).setCurrency("CNY")) - .setReason("就是想退了"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundV3Result response = client.refundV3(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - private WxPayConfig buildWxPayConfigV2() { - WxPayConfig config = new WxPayConfig(); - config.setAppId("wx62056c0d5e8db250"); - config.setMchId("1545083881"); - config.setMchKey("dS1ngeN63JLr3NRbvPH9AJy3MyUxZdim"); -// config.setSignType(WxPayConstants.SignType.MD5); - config.setKeyPath("/Users/yunai/Downloads/wx_pay/apiclient_cert.p12"); - return config; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java deleted file mode 100644 index 5e73601c2..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.time.Duration; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV3; - -/** - * {@link WxNativePayClient} 的集成测试,用于快速调试微信扫码支付 - * - * @author 芋道源码 - */ -@Disabled -public class WxNativePayClientIntegrationTest { - - @Test - public void testPayV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV3(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起支付 - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request() - .setOutTradeNo(String.valueOf(System.currentTimeMillis())) - .setDescription("测试支付-body") - .setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(1)) // 单位分 - .setTimeExpire(formatDateV3(LocalDateTimeUtils.addTime(Duration.ofMinutes(2)))) - .setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp("127.0.0.1")) - .setNotifyUrl("http://127.0.0.1:48080"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - String response = client.createOrderV3(TradeTypeEnum.NATIVE, request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testRefundV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV3(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo("1689545729695") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setAmount(new WxPayRefundV3Request.Amount().setTotal(1).setRefund(1).setCurrency("CNY")) - .setReason("就是想退了"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundV3Result response = client.refundV3(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - private WxPayConfig buildWxPayConfigV3() { - WxPayConfig config = new WxPayConfig(); - config.setAppId("wx62056c0d5e8db250"); - config.setMchId("1545083881"); - config.setApiV3Key("459arNsYHl1mgkiO6H9ZH5KkhFXSxaA4"); -// config.setCertSerialNo(serialNo); - config.setPrivateCertPath("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"); - config.setPrivateKeyPath("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"); - return config; - } - -} diff --git a/yudao-module-report/pom.xml b/yudao-module-report/pom.xml deleted file mode 100644 index 2c8aecedc..000000000 --- a/yudao-module-report/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - - yudao-module-report-api - yudao-module-report-biz - - yudao-module-report - pom - - ${project.artifactId} - - report 模块,主要实现数据可视化报表等功能。 - - - diff --git a/yudao-module-report/yudao-module-report-api/pom.xml b/yudao-module-report/yudao-module-report-api/pom.xml deleted file mode 100644 index 7d7135538..000000000 --- a/yudao-module-report/yudao-module-report-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-report - ${revision} - - 4.0.0 - - yudao-module-report-api - jar - - ${project.artifactId} - - report 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - diff --git a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java b/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java deleted file mode 100644 index 827bef3fd..000000000 --- a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,避免 api 目录无文件时,git 无法提交 - */ -package cn.iocoder.yudao.module.report.api; diff --git a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java b/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java deleted file mode 100644 index 25629760e..000000000 --- a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.report.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Report 错误码枚举类 - * - * report 系统,使用 1-003-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== GoView 模块 1-003-000-000 ========== - ErrorCode GO_VIEW_PROJECT_NOT_EXISTS = new ErrorCode(1_003_000_000, "GoView 项目不存在"); - -} diff --git a/yudao-module-report/yudao-module-report-biz/Dockerfile b/yudao-module-report/yudao-module-report-biz/Dockerfile deleted file mode 100644 index 06cee9c70..000000000 --- a/yudao-module-report/yudao-module-report-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-report-biz -WORKDIR /yudao-module-report-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-report-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48084 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-report/yudao-module-report-biz/pom.xml b/yudao-module-report/yudao-module-report-biz/pom.xml deleted file mode 100644 index 3b0439d7f..000000000 --- a/yudao-module-report/yudao-module-report-biz/pom.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-report - ${revision} - - 4.0.0 - - yudao-module-report-biz - jar - - ${project.artifactId} - - report 模块,主要实现数据可视化报表等功能: - 1. 基于「积木报表」实现,打印设计、报表设计、图形设计、大屏设计等。 - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - - cn.iocoder.cloud - yudao-module-report-api - ${revision} - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - org.jeecgframework.jimureport - jimureport-spring-boot-starter - - - - xerces - xercesImpl - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/ReportServerApplication.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/ReportServerApplication.java deleted file mode 100644 index 759482a31..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/ReportServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.report; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class ReportServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(ReportServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java deleted file mode 100644 index e32b8b916..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java deleted file mode 100644 index 6b28d1f51..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataGetBySqlReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import cn.iocoder.yudao.module.report.service.goview.GoViewDataService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - GoView 数据", description = "提供 SQL、HTTP 等数据查询的能力") -@RestController -@RequestMapping("/report/go-view/data") -@Validated -public class GoViewDataController { - - @Resource - private GoViewDataService goViewDataService; - - @RequestMapping("/get-by-sql") - @Operation(summary = "使用 SQL 查询数据") - @PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-sql')") - public CommonResult getDataBySQL(@Valid @RequestBody GoViewDataGetBySqlReqVO reqVO) { - return success(goViewDataService.getDataBySQL(reqVO.getSql())); - } - - @RequestMapping("/get-by-http") - @Operation(summary = "使用 HTTP 查询数据", description = "这个只是示例接口,实际应该每个查询,都要写一个接口") - @PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-http')") - public CommonResult getDataByHttp( - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { // params、body 按照需要去接收,这里仅仅是示例 - GoViewDataRespVO respVO = new GoViewDataRespVO(); - // 1. 数据维度 - respVO.setDimensions(Arrays.asList("日期", "PV", "UV")); // PV 是每天访问次数;UV 是每天访问人数 - // 2. 明细数据列表 - // 目前通过随机的方式生成。一般来说,这里你可以写逻辑来实现数据的返回 - respVO.setSource(new LinkedList<>()); - for (int i = 1; i <= 12; i++) { - String date = "2021-" + (i < 10 ? "0" + i : i); - Integer pv = RandomUtil.randomInt(1000, 10000); - Integer uv = RandomUtil.randomInt(100, 1000); - respVO.getSource().add(MapUtil.builder().put("日期", date) - .put("PV", pv).put("UV", uv).build()); - } - return success(respVO); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java deleted file mode 100644 index 1916f0d07..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.service.goview.GoViewProjectService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - GoView 项目") -@RestController -@RequestMapping("/report/go-view/project") -@Validated -public class GoViewProjectController { - - @Resource - private GoViewProjectService goViewProjectService; - - @PostMapping("/create") - @Operation(summary = "创建项目") - @PreAuthorize("@ss.hasPermission('report:go-view-project:create')") - public CommonResult createProject(@Valid @RequestBody GoViewProjectCreateReqVO createReqVO) { - return success(goViewProjectService.createProject(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新项目") - @PreAuthorize("@ss.hasPermission('report:go-view-project:update')") - public CommonResult updateProject(@Valid @RequestBody GoViewProjectUpdateReqVO updateReqVO) { - goViewProjectService.updateProject(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 GoView 项目") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:go-view-project:delete')") - public CommonResult deleteProject(@RequestParam("id") Long id) { - goViewProjectService.deleteProject(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得项目") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:go-view-project:query')") - public CommonResult getProject(@RequestParam("id") Long id) { - GoViewProjectDO project = goViewProjectService.getProject(id); - return success(GoViewProjectConvert.INSTANCE.convert(project)); - } - - @GetMapping("/my-page") - @Operation(summary = "获得我的项目分页") - @PreAuthorize("@ss.hasPermission('report:go-view-project:query')") - public CommonResult> getMyProjectPage(@Valid PageParam pageVO) { - PageResult pageResult = goViewProjectService.getMyProjectPage( - pageVO, getLoginUserId()); - return success(GoViewProjectConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java deleted file mode 100644 index 785a4c5e0..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - GoView 使用 SQL 查询数据 Request VO") -@Data -public class GoViewDataGetBySqlReqVO { - - @Schema(description = "SQL 语句", requiredMode = Schema.RequiredMode.REQUIRED, example = "SELECT * FROM user") - @NotEmpty(message = "SQL 语句不能为空") - private String sql; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java deleted file mode 100644 index 38251ddfa..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - GoView 数据 Response VO") -@Data -public class GoViewDataRespVO { - - @Schema(description = "数据维度", requiredMode = Schema.RequiredMode.REQUIRED, example = "['product', 'data1', 'data2']") - private List dimensions; - - @Schema(description = "数据明细列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List> source; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java deleted file mode 100644 index dce5d9227..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - GoView 项目创建 Request VO") -@Data -public class GoViewProjectCreateReqVO { - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "项目名称不能为空") - private String name; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java deleted file mode 100644 index 3197d995c..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - GoView 项目 Response VO") -@Data -public class GoViewProjectRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993") - private Long id; - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "报表内容") // JSON 格式 - private String content; - - @Schema(description = "预览图片 URL", example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "项目备注", example = "你猜") - private String remark; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String creator; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java deleted file mode 100644 index f5c20046b..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - GoView 项目更新 Request VO") -@Data -public class GoViewProjectUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = CommonStatusEnum.class, message = "发布状态必须是 {value}") - private Integer status; - - @Schema(description = "报表内容") // JSON 格式 - private String content; - - @Schema(description = "预览图片 URL", example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "项目备注", example = "你猜") - private String remark; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java deleted file mode 100644 index ccbf9bb19..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.report.controller; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java deleted file mode 100644 index 72860791f..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,后续删除 - */ -package cn.iocoder.yudao.module.report.convert.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java deleted file mode 100644 index 9c993a19c..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.report.convert.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface GoViewProjectConvert { - - GoViewProjectConvert INSTANCE = Mappers.getMapper(GoViewProjectConvert.class); - - GoViewProjectDO convert(GoViewProjectCreateReqVO bean); - - GoViewProjectDO convert(GoViewProjectUpdateReqVO bean); - - GoViewProjectRespVO convert(GoViewProjectDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java deleted file mode 100644 index 922ec6fd4..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.dal.dataobject.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java deleted file mode 100644 index 38730d29e..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.dataobject.goview; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * GoView 项目表 - * - * 每个大屏图标,对应一个项目 - * - * @author 芋道源码 - */ -@TableName(value = "report_go_view_project", autoResultMap = true) // 由于 SQL Server 的 system_user 是关键字,所以使用 system_users -@KeySequence("report_go_view_project_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class GoViewProjectDO extends BaseDO { - - /** - * 编号,数据库自增 - */ - @TableId - private Long id; - /** - * 项目名称 - */ - private String name; - /** - * 预览图片 URL - */ - private String picUrl; - /** - * 报表内容 - * - * JSON 配置,使用字符串存储 - */ - private String content; - /** - * 发布状态 - * - * 0 - 已发布 - * 1 - 未发布 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 项目备注 - */ - private String remark; -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java deleted file mode 100644 index 0fb86173d..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.dal.mysql.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java deleted file mode 100644 index af1ca6345..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.mysql.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface GoViewProjectMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(GoViewProjectDO::getCreator, userId) - .orderByDesc(GoViewProjectDO::getId)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java deleted file mode 100644 index 1946d052e..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.jmreport.config; - -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.report.framework.jmreport.core.service.JmReportTokenServiceImpl; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * 积木报表的配置类 - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@ComponentScan(basePackages = "org.jeecg.modules.jmreport") // 扫描积木报表的包 -public class JmReportConfiguration { - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public JmReportTokenServiceI jmReportTokenService(OAuth2TokenApi oAuth2TokenApi, - PermissionApi permissionApi, - SecurityProperties securityProperties) { - return new JmReportTokenServiceImpl(oAuth2TokenApi, permissionApi, securityProperties); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java deleted file mode 100644 index f45a8c88c..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.jmreport.core.service; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.framework.security.core.LoginUser; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; -import lombok.RequiredArgsConstructor; -import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; -import org.springframework.http.HttpHeaders; - -import javax.servlet.http.HttpServletRequest; -import java.util.Objects; - -/** - * {@link JmReportTokenServiceI} 实现类,提供积木报表的 Token 校验、用户信息的查询等功能 - * - * @author 随心 - */ -@RequiredArgsConstructor -public class JmReportTokenServiceImpl implements JmReportTokenServiceI { - - /** - * 积木 token head 头 - */ - private static final String JM_TOKEN_HEADER = "X-Access-Token"; - /** - * auth 相关格式 - */ - private static final String AUTHORIZATION_FORMAT = SecurityFrameworkUtils.AUTHORIZATION_BEARER + " %s"; - - private final OAuth2TokenApi oauth2TokenApi; - private final PermissionApi permissionApi; - - private final SecurityProperties securityProperties; - - /** - * 自定义 API 数据集appian自定义 Header,解决 Token 传递。 - * 参考 api数据集token机制详解 文档 - * - * @return 新 head - */ - @Override - public HttpHeaders customApiHeader() { - // 读取积木标标系统的 token - HttpServletRequest request = ServletUtils.getRequest(); - String token = request.getHeader(JM_TOKEN_HEADER); - - // 设置到 yudao 系统的 token - HttpHeaders headers = new HttpHeaders(); - headers.add(securityProperties.getTokenHeader(), String.format(AUTHORIZATION_FORMAT, token)); - return headers; - } - - /** - * 校验 Token 是否有效,即验证通过 - * - * @param token JmReport 前端传递的 token - * @return 是否认证通过 - */ - @Override - public Boolean verifyToken(String token) { - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (!Objects.isNull(userId)) { - return true; - } - return buildLoginUserByToken(token) != null; - } - - /** - * 获得用户编号 - *

- * 虽然方法名获得的是 username,实际对应到项目中是用户编号 - * - * @param token JmReport 前端传递的 token - * @return 用户编号 - */ - @Override - public String getUsername(String token) { - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (ObjectUtil.isNotNull(userId)) { - return String.valueOf(userId); - } - LoginUser user = buildLoginUserByToken(token); - return user == null ? null : String.valueOf(user.getId()); - } - - /** - * 基于 token 构建登录用户 - * - * @param token token - * @return 返回 token 对应的用户信息 - */ - private LoginUser buildLoginUserByToken(String token) { - if (StrUtil.isEmpty(token)) { - return null; - } - // TODO 如下的实现不算特别优雅,主要咱是不想搞的太复杂,所以参考对应的 Filter 先实现了 - - // ① 参考 TokenAuthenticationFilter 的认证逻辑(Security 的上下文清理,交给 Spring Security 完成) - // 目的:实现基于 JmReport 前端传递的 token,实现认证 - TenantContextHolder.setIgnore(true); // 忽略租户,保证可查询到 token 信息 - LoginUser user = null; - try { - OAuth2AccessTokenCheckRespDTO accessToken = oauth2TokenApi.checkAccessToken(token).getCheckedData(); - if (accessToken == null) { - return null; - } - user = new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()); - } catch (ServiceException ignored) { - // do nothing:如果报错,说明认证失败,则返回 false 即可 - } - if (user == null) { - return null; - } - SecurityFrameworkUtils.setLoginUser(user, WebFrameworkUtils.getRequest()); - - // ② 参考 TenantContextWebFilter 实现(Tenant 的上下文清理,交给 TenantContextWebFilter 完成) - // 目的:基于 LoginUser 获得到的租户编号,设置到 Tenant 上下文,避免查询数据库时的报错 - TenantContextHolder.setIgnore(false); - TenantContextHolder.setTenantId(user.getTenantId()); - return user; - } - - @Override - public String[] getRoles(String token) { - // 参见文档 https://help.jeecg.com/jimureport/prodSafe.html 文档 - // 适配:如果是本系统的管理员,则转换成 jimu 报表的管理员 - Long userId = SecurityFrameworkUtils.getLoginUserId(); - return permissionApi.hasAnyRoles(userId, RoleCodeEnum.SUPER_ADMIN.getCode()).getCheckedData() - ? new String[]{"admin"} : null; - } - - @Override - public String getTenantId() { - // 补充说明:不能直接通过 TenantContext 获取,因为 jimu 报表前端请求时,没有带上 tenant-id Header - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (loginUser == null) { - return null; - } - return StrUtil.toStringOrNull(loginUser.getTenantId()); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java deleted file mode 100644 index e082e3bdc..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,后续会基于 Filter 实现积木报表的认证等功能,替代 {@link cn.iocoder.yudao.module.report.framework.jmreport.core.service.JmReportTokenServiceImpl} - */ -package cn.iocoder.yudao.module.report.framework.jmreport.core.web; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java deleted file mode 100644 index c2163d8cd..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 report 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.report.framework; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 05b009661..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Report 模块的 Security 配置 - */ -@Configuration("reportSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("reportAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // 积木报表 - registry.antMatchers("/jmreport/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java deleted file mode 100644 index 61083268f..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.report.framework.security.core; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java deleted file mode 100644 index 3306c0ebb..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * report 模块,主要实现数据可视化报表等功能: - * 1. 基于「积木报表」实现,打印设计、报表设计、图形设计、大屏设计等。URL 前缀是 /jmreport,表名前缀是 jimu_ - * - * 由于「积木报表」的大屏设计器需要收费,后续会自研,对应的是: - * 1. Controller URL:以 /report/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 report_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.report; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java deleted file mode 100644 index 2512e50ed..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.service.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java deleted file mode 100644 index b912373b1..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; - -/** - * GoView 数据 Service 接口 - * - * @author 芋道源码 - */ -public interface GoViewDataService { - - /** - * 使用 SQL 查询数据 - * - * @param sql SQL 语句 - * @return 数据 - */ - GoViewDataRespVO getDataBySQL(String sql); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java deleted file mode 100644 index 8938d3e74..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import com.google.common.collect.Maps; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; -import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.Map; - -/** - * GoView 数据 Service 实现类 - * - * 补充说明: - * 1. 目前默认使用 jdbcTemplate 查询项目配置的数据源。如果你想查询其它数据源,可以新建对应数据源的 jdbcTemplate 来实现。 - * 2. 默认数据源是 MySQL 关系数据源,可能数据量比较大的情况下,会比较慢,可以考虑后续使用 Click House 等等。 - * - * @author 芋道源码 - */ -@Service -@Validated -public class GoViewDataServiceImpl implements GoViewDataService { - - @Resource - private JdbcTemplate jdbcTemplate; - - @Override - public GoViewDataRespVO getDataBySQL(String sql) { - // 1. 执行查询 - SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(sql); - - // 2. 构建返回结果 - GoViewDataRespVO respVO = new GoViewDataRespVO(); - // 2.1 解析元数据 - SqlRowSetMetaData metaData = sqlRowSet.getMetaData(); - String[] columnNames = metaData.getColumnNames(); - respVO.setDimensions(Arrays.asList(columnNames)); - // 2.2 解析数据明细 - respVO.setSource(new LinkedList<>()); // 由于数据量不确认,使用 LinkedList 虽然内存占用大一点,但是不存在扩容复制的问题 - while (sqlRowSet.next()) { - Map data = Maps.newHashMapWithExpectedSize(columnNames.length); - for (String columnName : columnNames) { - data.put(columnName, sqlRowSet.getObject(columnName)); - } - respVO.getSource().add(data); - } - return respVO; - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java deleted file mode 100644 index b171c5905..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; - -import javax.validation.Valid; - -/** - * GoView 项目 Service 接口 - * - * @author 芋道源码 - */ -public interface GoViewProjectService { - - /** - * 创建项目 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProject(@Valid GoViewProjectCreateReqVO createReqVO); - - /** - * 更新项目 - * - * @param updateReqVO 更新信息 - */ - void updateProject(@Valid GoViewProjectUpdateReqVO updateReqVO); - - /** - * 删除项目 - * - * @param id 编号 - */ - void deleteProject(Long id); - - /** - * 获得项目 - * - * @param id 编号 - * @return 项目 - */ - GoViewProjectDO getProject(Long id); - - /** - * 获得我的项目分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return GoView 项目分页 - */ - PageResult getMyProjectPage(PageParam pageReqVO, Long userId); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java deleted file mode 100644 index 2b05052f7..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.dal.mysql.goview.GoViewProjectMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; - -/** - * GoView 项目 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class GoViewProjectServiceImpl implements GoViewProjectService { - - @Resource - private GoViewProjectMapper goViewProjectMapper; - - @Override - public Long createProject(GoViewProjectCreateReqVO createReqVO) { - // 插入 - GoViewProjectDO goViewProject = GoViewProjectConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - goViewProjectMapper.insert(goViewProject); - // 返回 - return goViewProject.getId(); - } - - @Override - public void updateProject(GoViewProjectUpdateReqVO updateReqVO) { - // 校验存在 - validateProjectExists(updateReqVO.getId()); - // 更新 - GoViewProjectDO updateObj = GoViewProjectConvert.INSTANCE.convert(updateReqVO); - goViewProjectMapper.updateById(updateObj); - } - - @Override - public void deleteProject(Long id) { - // 校验存在 - validateProjectExists(id); - // 删除 - goViewProjectMapper.deleteById(id); - } - - private void validateProjectExists(Long id) { - if (goViewProjectMapper.selectById(id) == null) { - throw exception(GO_VIEW_PROJECT_NOT_EXISTS); - } - } - - @Override - public GoViewProjectDO getProject(Long id) { - return goViewProjectMapper.selectById(id); - } - - @Override - public PageResult getMyProjectPage(PageParam pageReqVO, Long userId) { - return goViewProjectMapper.selectPage(pageReqVO, userId); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-dev.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 3508f409d..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,97 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - demo: true # 开启演示模式 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 286556d8e..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,120 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.report.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml deleted file mode 100644 index f5e0022d7..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,106 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -# 积木报表配置 -jeecg: - jmreport: - saas-mode: tenant - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.report - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - -debug: false diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index caf41b17b..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: report-server - - profiles: - active: local - -server: - port: 48084 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/logback-spring.xml b/yudao-module-report/yudao-module-report-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java deleted file mode 100644 index 87b78b8b8..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; -import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; - -import javax.annotation.Resource; -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@Import(GoViewDataServiceImpl.class) -public class GoViewDataServiceImplTest extends BaseDbUnitTest { - - @Resource - private GoViewDataServiceImpl goViewDataService; - - @MockBean - private JdbcTemplate jdbcTemplate; - - @Test - public void testGetDataBySQL() { - // 准备参数 - String sql = "SELECT id, name FROM system_users"; - // mock 方法 - SqlRowSet sqlRowSet = mock(SqlRowSet.class); - when(jdbcTemplate.queryForRowSet(eq(sql))).thenReturn(sqlRowSet); - // mock 元数据 - SqlRowSetMetaData metaData = mock(SqlRowSetMetaData.class); - when(sqlRowSet.getMetaData()).thenReturn(metaData); - when(metaData.getColumnNames()).thenReturn(new String[]{"id", "name"}); - // mock 数据明细 - when(sqlRowSet.next()).thenReturn(true).thenReturn(true).thenReturn(false); - when(sqlRowSet.getObject("id")).thenReturn(1L).thenReturn(2L); - when(sqlRowSet.getObject("name")).thenReturn("芋道源码").thenReturn("芋道"); - - // 调用 - GoViewDataRespVO dataBySQL = goViewDataService.getDataBySQL(sql); - // 断言 - assertEquals(Arrays.asList("id", "name"), dataBySQL.getDimensions()); - assertEquals(2, dataBySQL.getDimensions().size()); - assertEquals(2, dataBySQL.getSource().get(0).size()); - assertEquals(1L, dataBySQL.getSource().get(0).get("id")); - assertEquals("芋道源码", dataBySQL.getSource().get(0).get("name")); - assertEquals(2, dataBySQL.getSource().get(1).size()); - assertEquals(2L, dataBySQL.getSource().get(1).get("id")); - assertEquals("芋道", dataBySQL.getSource().get(1).get("name")); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java deleted file mode 100644 index 2f6bfae7b..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.dal.mysql.goview.GoViewProjectMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link GoViewProjectServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(GoViewProjectServiceImpl.class) -public class GoViewProjectServiceImplTest extends BaseDbUnitTest { - - @Resource - private GoViewProjectServiceImpl goViewProjectService; - - @Resource - private GoViewProjectMapper goViewProjectMapper; - - @Test - public void testCreateProject_success() { - // 准备参数 - GoViewProjectCreateReqVO reqVO = randomPojo(GoViewProjectCreateReqVO.class); - - // 调用 - Long goViewProjectId = goViewProjectService.createProject(reqVO); - // 断言 - assertNotNull(goViewProjectId); - // 校验记录的属性是否正确 - GoViewProjectDO goViewProject = goViewProjectMapper.selectById(goViewProjectId); - assertPojoEquals(reqVO, goViewProject); - } - - @Test - public void testUpdateProject_success() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - GoViewProjectUpdateReqVO reqVO = randomPojo(GoViewProjectUpdateReqVO.class, o -> { - o.setId(dbGoViewProject.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - goViewProjectService.updateProject(reqVO); - // 校验是否更新正确 - GoViewProjectDO goViewProject = goViewProjectMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, goViewProject); - } - - @Test - public void testUpdateProject_notExists() { - // 准备参数 - GoViewProjectUpdateReqVO reqVO = randomPojo(GoViewProjectUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> goViewProjectService.updateProject(reqVO), GO_VIEW_PROJECT_NOT_EXISTS); - } - - @Test - public void testDeleteProject_success() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGoViewProject.getId(); - - // 调用 - goViewProjectService.deleteProject(id); - // 校验数据不存在了 - assertNull(goViewProjectMapper.selectById(id)); - } - - @Test - public void testDeleteProject_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> goViewProjectService.deleteProject(id), GO_VIEW_PROJECT_NOT_EXISTS); - } - - @Test - public void testGetProject() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGoViewProject.getId(); - - // 调用 - GoViewProjectDO goViewProject = goViewProjectService.getProject(id); - // 断言 - assertPojoEquals(dbGoViewProject, goViewProject); - } - - @Test - public void testGetMyGoViewProjectPage() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class, o -> { // 等会查询到 - o.setCreator("1"); - }); - goViewProjectMapper.insert(dbGoViewProject); - // 测试 userId 不匹配 - goViewProjectMapper.insert(cloneIgnoreId(dbGoViewProject, o -> o.setCreator("2"))); - // 准备参数 - PageParam reqVO = new PageParam(); - Long userId = 1L; - - // 调用 - PageResult pageResult = goViewProjectService.getMyProjectPage(reqVO, userId); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbGoViewProject, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml b/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 63ba0991f..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,51 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.report diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml b/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql b/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 152915143..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM "report_go_view_project"; \ No newline at end of file diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql b/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index a77397fea..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE IF NOT EXISTS "report_go_view_project" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "pic_url" varchar, - "content" varchar, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'GoView 项目表'; diff --git a/yudao-module-system/yudao-module-system-biz/pom.xml b/yudao-module-system/yudao-module-system-biz/pom.xml index 0c95e5340..4b924c0eb 100644 --- a/yudao-module-system/yudao-module-system-biz/pom.xml +++ b/yudao-module-system/yudao-module-system-biz/pom.xml @@ -108,13 +108,6 @@ - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - cn.iocoder.cloud diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java deleted file mode 100644 index 128e7593e..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java +++ /dev/null @@ -1,337 +0,0 @@ -package cn.iocoder.yudao.module.system.controller.admin.oauth2; - -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2OpenAccessTokenRespVO; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2OpenAuthorizeInfoRespVO; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.open.OAuth2OpenCheckTokenRespVO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ApproveDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2GrantTypeEnum; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ApproveService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2ClientService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2GrantService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import javax.servlet.http.HttpServletRequest; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static java.util.Arrays.asList; -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2OpenController} 的单元测试 - * - * @author 芋道源码 - */ -public class OAuth2OpenControllerTest extends BaseMockitoUnitTest { - - @InjectMocks - private OAuth2OpenController oauth2OpenController; - - @Mock - private OAuth2GrantService oauth2GrantService; - @Mock - private OAuth2ClientService oauth2ClientService; - @Mock - private OAuth2ApproveService oauth2ApproveService; - @Mock - private OAuth2TokenService oauth2TokenService; - - @Test - public void testPostAccessToken_authorizationCode() { - // 准备参数 - String granType = OAuth2GrantTypeEnum.AUTHORIZATION_CODE.getGrantType(); - String code = randomString(); - String redirectUri = randomString(); - String state = randomString(); - HttpServletRequest request = mockRequest("test_client_id", "test_client_secret"); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("test_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("test_client_id"), eq("test_client_secret"), eq(granType), eq(new ArrayList<>()), eq(redirectUri))).thenReturn(client); - - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30000L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantAuthorizationCodeForAccessToken(eq("test_client_id"), - eq(code), eq(redirectUri), eq(state))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.postAccessToken(request, granType, - code, redirectUri, state, null, null, null, null); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertTrue(ObjectUtils.equalsAny(result.getData().getExpiresIn(), 29L, 30L)); // 执行过程会过去几毫秒 - } - - @Test - public void testPostAccessToken_password() { - // 准备参数 - String granType = OAuth2GrantTypeEnum.PASSWORD.getGrantType(); - String username = randomString(); - String password = randomString(); - String scope = "write read"; - HttpServletRequest request = mockRequest("test_client_id", "test_client_secret"); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("test_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("test_client_id"), eq("test_client_secret"), - eq(granType), eq(Lists.newArrayList("write", "read")), isNull())).thenReturn(client); - - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30000L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantPassword(eq(username), eq(password), eq("test_client_id"), - eq(Lists.newArrayList("write", "read")))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.postAccessToken(request, granType, - null, null, null, username, password, scope, null); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertTrue(ObjectUtils.equalsAny(result.getData().getExpiresIn(), 29L, 30L)); // 执行过程会过去几毫秒 - } - - @Test - public void testPostAccessToken_refreshToken() { - // 准备参数 - String granType = OAuth2GrantTypeEnum.REFRESH_TOKEN.getGrantType(); - String refreshToken = randomString(); - String password = randomString(); - HttpServletRequest request = mockRequest("test_client_id", "test_client_secret"); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("test_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("test_client_id"), eq("test_client_secret"), - eq(granType), eq(Lists.newArrayList()), isNull())).thenReturn(client); - - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30000L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantRefreshToken(eq(refreshToken), eq("test_client_id"))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.postAccessToken(request, granType, - null, null, null, null, password, null, refreshToken); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertTrue(ObjectUtils.equalsAny(result.getData().getExpiresIn(), 29L, 30L)); // 执行过程会过去几毫秒 - } - - @Test - public void testPostAccessToken_implicit() { - // 调用,并断言 - assertServiceException(() -> oauth2OpenController.postAccessToken(null, - OAuth2GrantTypeEnum.IMPLICIT.getGrantType(), null, null, null, - null, null, null, null), - new ErrorCode(400, "Token 接口不支持 implicit 授权模式")); - } - - @Test - public void testRevokeToken() { - // 准备参数 - HttpServletRequest request = mockRequest("demo_client_id", "demo_client_secret"); - String token = randomString(); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("demo_client_id"); - when(oauth2ClientService.validOAuthClientFromCache(eq("demo_client_id"), - eq("demo_client_secret"), isNull(), isNull(), isNull())).thenReturn(client); - // mock 方法(移除) - when(oauth2GrantService.revokeToken(eq("demo_client_id"), eq(token))).thenReturn(true); - - // 调用 - CommonResult result = oauth2OpenController.revokeToken(request, token); - // 断言 - assertEquals(0, result.getCode()); - assertTrue(result.getData()); - } - - @Test - public void testCheckToken() { - // 准备参数 - HttpServletRequest request = mockRequest("demo_client_id", "demo_client_secret"); - String token = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class).setUserType(UserTypeEnum.ADMIN.getValue()).setExpiresTime(LocalDateTimeUtil.of(1653485731195L)); - when(oauth2TokenService.checkAccessToken(eq(token))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.checkToken(request, token); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(accessTokenDO, result.getData()); - assertEquals(1653485731L, result.getData().getExp()); // 执行过程会过去几毫秒 - } - - @Test - public void testAuthorize() { - // 准备参数 - String clientId = randomString(); - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("demo_client_id").setScopes(ListUtil.toList("read", "write", "all")); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(client); - // mock 方法(approve) - List approves = asList( - randomPojo(OAuth2ApproveDO.class).setScope("read").setApproved(true), - randomPojo(OAuth2ApproveDO.class).setScope("write").setApproved(false)); - when(oauth2ApproveService.getApproveList(isNull(), eq(UserTypeEnum.ADMIN.getValue()), eq(clientId))).thenReturn(approves); - - // 调用 - CommonResult result = oauth2OpenController.authorize(clientId); - // 断言 - assertEquals(0, result.getCode()); - assertPojoEquals(client, result.getData().getClient()); - assertEquals(new KeyValue<>("read", true), result.getData().getScopes().get(0)); - assertEquals(new KeyValue<>("write", false), result.getData().getScopes().get(1)); - assertEquals(new KeyValue<>("all", false), result.getData().getScopes().get(2)); - } - - @Test - public void testApproveOrDeny_grantTypeError() { - // 调用,并断言 - assertServiceException(() -> oauth2OpenController.approveOrDeny(randomString(), null, - null, null, null, null), - new ErrorCode(400, "response_type 参数值只允许 code 和 token")); - } - - @Test // autoApprove = true,但是不通过 - public void testApproveOrDeny_autoApproveNo() { - // 准备参数 - String responseType = "code"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = randomString(); - String state = randomString(); - // mock 方法 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("authorization_code"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, true, state); - // 断言 - assertEquals(0, result.getCode()); - assertNull(result.getData()); - } - - @Test // autoApprove = false,但是不通过 - public void testApproveOrDeny_ApproveNo() { - // 准备参数 - String responseType = "token"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = "https://www.iocoder.cn"; - String state = "test"; - // mock 方法 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("implicit"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, false, state); - // 断言 - assertEquals(0, result.getCode()); - assertEquals("https://www.iocoder.cn#error=access_denied&error_description=User%20denied%20access&state=test", result.getData()); - } - - @Test // autoApprove = true,通过 + token - public void testApproveOrDeny_autoApproveWithToken() { - // 准备参数 - String responseType = "token"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = "https://www.iocoder.cn"; - String state = "test"; - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId(clientId).setAdditionalInformation(null); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("implicit"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - // mock 方法(场景一) - when(oauth2ApproveService.checkForPreApproval(isNull(), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(SetUtils.asSet("read", "write")))).thenReturn(true); - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setAccessToken("test_access_token").setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 30010L, ChronoUnit.MILLIS)); - when(oauth2GrantService.grantImplicit(isNull(), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(ListUtil.toList("read")))).thenReturn(accessTokenDO); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, true, state); - // 断言 - assertEquals(0, result.getCode()); - assertThat(result.getData(), anyOf( // 29 和 30 都有一定概率,主要是时间计算 - is("https://www.iocoder.cn#access_token=test_access_token&token_type=bearer&state=test&expires_in=29&scope=read"), - is("https://www.iocoder.cn#access_token=test_access_token&token_type=bearer&state=test&expires_in=30&scope=read") - )); - } - - @Test // autoApprove = false,通过 + code - public void testApproveOrDeny_approveWithCode() { - // 准备参数 - String responseType = "code"; - String clientId = randomString(); - String scope = "{\"read\": true, \"write\": false}"; - String redirectUri = "https://www.iocoder.cn"; - String state = "test"; - // mock 方法(client) - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId(clientId).setAdditionalInformation(null); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId), isNull(), eq("authorization_code"), - eq(asSet("read", "write")), eq(redirectUri))).thenReturn(client); - // mock 方法(场景二) - when(oauth2ApproveService.updateAfterApproval(isNull(), eq(UserTypeEnum.ADMIN.getValue()), eq(clientId), - eq(MapUtil.builder(new LinkedHashMap()).put("read", true).put("write", false).build()))) - .thenReturn(true); - // mock 方法(访问令牌) - String authorizationCode = "test_code"; - when(oauth2GrantService.grantAuthorizationCodeForCode(isNull(), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(ListUtil.toList("read")), eq(redirectUri), eq(state))).thenReturn(authorizationCode); - - // 调用 - CommonResult result = oauth2OpenController.approveOrDeny(responseType, clientId, - scope, redirectUri, false, state); - // 断言 - assertEquals(0, result.getCode()); - assertEquals("https://www.iocoder.cn?code=test_code&state=test", result.getData()); - } - - private HttpServletRequest mockRequest(String clientId, String secret) { - HttpServletRequest request = mock(HttpServletRequest.class); - when(request.getParameter(eq("client_id"))).thenReturn(clientId); - when(request.getParameter(eq("client_secret"))).thenReturn(secret); - return request; - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClientTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClientTest.java deleted file mode 100644 index b2b6fbb4e..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/AliyunSmsClientTest.java +++ /dev/null @@ -1,188 +0,0 @@ -package cn.iocoder.yudao.module.system.framework.sms.core.client.impl; - -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsSendRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.client.impl.AliyunSmsClient; -import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; -import cn.iocoder.yudao.module.system.framework.sms.core.property.SmsChannelProperties; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateRequest; -import com.aliyuncs.dysmsapi.model.v20170525.QuerySmsTemplateResponse; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; -import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AliyunSmsClient} 的单元测试 - * - * @author 芋道源码 - */ -public class AliyunSmsClientTest extends BaseMockitoUnitTest { - - private final SmsChannelProperties properties = new SmsChannelProperties() - .setApiKey(randomString()) // 随机一个 apiKey,避免构建报错 - .setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错 - .setSignature("芋道源码"); - - @InjectMocks - private final AliyunSmsClient smsClient = new AliyunSmsClient(properties); - - @Mock - private IAcsClient client; - - @Test - public void testDoInit() { - // 准备参数 - // mock 方法 - - // 调用 - smsClient.doInit(); - // 断言 - assertNotSame(client, ReflectUtil.getFieldValue(smsClient, "acsClient")); - } - - @Test - public void tesSendSms_success() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("code", 1234), new KeyValue<>("op", "login")); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> o.setCode("OK")); - when(client.getAcsResponse(argThat((ArgumentMatcher) acsRequest -> { - assertEquals(mobile, acsRequest.getPhoneNumbers()); - assertEquals(properties.getSignature(), acsRequest.getSignName()); - assertEquals(apiTemplateId, acsRequest.getTemplateCode()); - assertEquals(toJsonString(MapUtils.convertMap(templateParams)), acsRequest.getTemplateParam()); - assertEquals(sendLogId.toString(), acsRequest.getOutId()); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, - apiTemplateId, templateParams); - // 断言 - assertTrue(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getCode(), result.getApiCode()); - assertEquals(response.getMessage(), result.getApiMsg()); - assertEquals(response.getBizId(), result.getSerialNo()); - } - - @Test - public void tesSendSms_fail() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("code", 1234), new KeyValue<>("op", "login")); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> o.setCode("ERROR")); - when(client.getAcsResponse(argThat((ArgumentMatcher) acsRequest -> { - assertEquals(mobile, acsRequest.getPhoneNumbers()); - assertEquals(properties.getSignature(), acsRequest.getSignName()); - assertEquals(apiTemplateId, acsRequest.getTemplateCode()); - assertEquals(toJsonString(MapUtils.convertMap(templateParams)), acsRequest.getTemplateParam()); - assertEquals(sendLogId.toString(), acsRequest.getOutId()); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, apiTemplateId, templateParams); - // 断言 - assertFalse(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getCode(), result.getApiCode()); - assertEquals(response.getMessage(), result.getApiMsg()); - assertEquals(response.getBizId(), result.getSerialNo()); - } - - @Test - public void testParseSmsReceiveStatus() { - // 准备参数 - String text = "[\n" + - " {\n" + - " \"phone_number\" : \"13900000001\",\n" + - " \"send_time\" : \"2017-01-01 11:12:13\",\n" + - " \"report_time\" : \"2017-02-02 22:23:24\",\n" + - " \"success\" : true,\n" + - " \"err_code\" : \"DELIVERED\",\n" + - " \"err_msg\" : \"用户接收成功\",\n" + - " \"sms_size\" : \"1\",\n" + - " \"biz_id\" : \"12345\",\n" + - " \"out_id\" : \"67890\"\n" + - " }\n" + - "]"; - // mock 方法 - - // 调用 - List statuses = smsClient.parseSmsReceiveStatus(text); - // 断言 - assertEquals(1, statuses.size()); - assertTrue(statuses.get(0).getSuccess()); - assertEquals("DELIVERED", statuses.get(0).getErrorCode()); - assertEquals("用户接收成功", statuses.get(0).getErrorMsg()); - assertEquals("13900000001", statuses.get(0).getMobile()); - assertEquals(LocalDateTime.of(2017, 2, 2, 22, 23, 24), - statuses.get(0).getReceiveTime()); - assertEquals("12345", statuses.get(0).getSerialNo()); - assertEquals(67890L, statuses.get(0).getLogId()); - } - - @Test - public void testGetSmsTemplate() throws Throwable { - // 准备参数 - String apiTemplateId = randomString(); - // mock 方法 - QuerySmsTemplateResponse response = randomPojo(QuerySmsTemplateResponse.class, o -> { - o.setCode("OK"); - o.setTemplateStatus(1); // 设置模板通过 - }); - when(client.getAcsResponse(argThat((ArgumentMatcher) acsRequest -> { - assertEquals(apiTemplateId, acsRequest.getTemplateCode()); - return true; - }))).thenReturn(response); - - // 调用 - SmsTemplateRespDTO result = smsClient.getSmsTemplate(apiTemplateId); - // 断言 - assertEquals(response.getTemplateCode(), result.getId()); - assertEquals(response.getTemplateContent(), result.getContent()); - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), result.getAuditStatus()); - assertEquals(response.getReason(), result.getAuditReason()); - } - - @Test - public void testConvertSmsTemplateAuditStatus() { - assertEquals(SmsTemplateAuditStatusEnum.CHECKING.getStatus(), - smsClient.convertSmsTemplateAuditStatus(0)); - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), - smsClient.convertSmsTemplateAuditStatus(1)); - assertEquals(SmsTemplateAuditStatusEnum.FAIL.getStatus(), - smsClient.convertSmsTemplateAuditStatus(2)); - assertThrows(IllegalArgumentException.class, () -> smsClient.convertSmsTemplateAuditStatus(3), - "未知审核状态(3)"); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/TencentSmsClientTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/TencentSmsClientTest.java deleted file mode 100644 index e93435f4d..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/framework/sms/core/client/impl/TencentSmsClientTest.java +++ /dev/null @@ -1,230 +0,0 @@ -package cn.iocoder.yudao.module.system.framework.sms.core.client.impl; - -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsSendRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; -import cn.iocoder.yudao.module.system.framework.sms.core.property.SmsChannelProperties; -import com.google.common.collect.Lists; -import com.tencentcloudapi.sms.v20210111.SmsClient; -import com.tencentcloudapi.sms.v20210111.models.DescribeSmsTemplateListResponse; -import com.tencentcloudapi.sms.v20210111.models.DescribeTemplateListStatus; -import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; -import com.tencentcloudapi.sms.v20210111.models.SendStatus; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link TencentSmsClient} 的单元测试 - * - * @author shiwp - */ -public class TencentSmsClientTest extends BaseMockitoUnitTest { - - private final SmsChannelProperties properties = new SmsChannelProperties() - .setApiKey(randomString() + " " + randomString()) // 随机一个 apiKey,避免构建报错 - .setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错 - .setSignature("芋道源码"); - - @InjectMocks - private TencentSmsClient smsClient = new TencentSmsClient(properties); - - @Mock - private SmsClient client; - - @Test - public void testDoInit() { - // 准备参数 - // mock 方法 - - // 调用 - smsClient.doInit(); - // 断言 - assertNotSame(client, ReflectUtil.getFieldValue(smsClient, "client")); - } - - @Test - public void testRefresh() { - // 准备参数 - SmsChannelProperties p = new SmsChannelProperties() - .setApiKey(randomString() + " " + randomString()) // 随机一个 apiKey,避免构建报错 - .setApiSecret(randomString()) // 随机一个 apiSecret,避免构建报错 - .setSignature("芋道源码"); - // 调用 - smsClient.refresh(p); - // 断言 - assertNotSame(client, ReflectUtil.getFieldValue(smsClient, "client")); - } - - @Test - public void testDoSendSms_success() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("1", 1234), new KeyValue<>("2", "login")); - String requestId = randomString(); - String serialNo = randomString(); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> { - o.setRequestId(requestId); - SendStatus[] sendStatuses = new SendStatus[1]; - o.setSendStatusSet(sendStatuses); - SendStatus sendStatus = new SendStatus(); - sendStatuses[0] = sendStatus; - sendStatus.setCode(TencentSmsClient.API_CODE_SUCCESS); - sendStatus.setMessage("send success"); - sendStatus.setSerialNo(serialNo); - }); - when(client.SendSms(argThat(request -> { - assertEquals(mobile, request.getPhoneNumberSet()[0]); - assertEquals(properties.getSignature(), request.getSignName()); - assertEquals(apiTemplateId, request.getTemplateId()); - assertEquals(toJsonString(ArrayUtils.toArray(new ArrayList<>(MapUtils.convertMap(templateParams).values()), String::valueOf)), - toJsonString(request.getTemplateParamSet())); - assertEquals(sendLogId, ReflectUtil.getFieldValue(JsonUtils.parseObject(request.getSessionContext(), TencentSmsClient.SessionContext.class), "logId")); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, apiTemplateId, templateParams); - // 断言 - assertTrue(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getSendStatusSet()[0].getCode(), result.getApiCode()); - assertEquals(response.getSendStatusSet()[0].getMessage(), result.getApiMsg()); - assertEquals(response.getSendStatusSet()[0].getSerialNo(), result.getSerialNo()); - } - - @Test - public void testDoSendSms_fail() throws Throwable { - // 准备参数 - Long sendLogId = randomLongId(); - String mobile = randomString(); - String apiTemplateId = randomString(); - List> templateParams = Lists.newArrayList( - new KeyValue<>("1", 1234), new KeyValue<>("2", "login")); - String requestId = randomString(); - String serialNo = randomString(); - // mock 方法 - SendSmsResponse response = randomPojo(SendSmsResponse.class, o -> { - o.setRequestId(requestId); - SendStatus[] sendStatuses = new SendStatus[1]; - o.setSendStatusSet(sendStatuses); - SendStatus sendStatus = new SendStatus(); - sendStatuses[0] = sendStatus; - sendStatus.setCode("ERROR"); - sendStatus.setMessage("send success"); - sendStatus.setSerialNo(serialNo); - }); - when(client.SendSms(argThat(request -> { - assertEquals(mobile, request.getPhoneNumberSet()[0]); - assertEquals(properties.getSignature(), request.getSignName()); - assertEquals(apiTemplateId, request.getTemplateId()); - assertEquals(toJsonString(ArrayUtils.toArray(new ArrayList<>(MapUtils.convertMap(templateParams).values()), String::valueOf)), - toJsonString(request.getTemplateParamSet())); - assertEquals(sendLogId, ReflectUtil.getFieldValue(JsonUtils.parseObject(request.getSessionContext(), TencentSmsClient.SessionContext.class), "logId")); - return true; - }))).thenReturn(response); - - // 调用 - SmsSendRespDTO result = smsClient.sendSms(sendLogId, mobile, apiTemplateId, templateParams); - // 断言 - assertFalse(result.getSuccess()); - assertEquals(response.getRequestId(), result.getApiRequestId()); - assertEquals(response.getSendStatusSet()[0].getCode(), result.getApiCode()); - assertEquals(response.getSendStatusSet()[0].getMessage(), result.getApiMsg()); - assertEquals(response.getSendStatusSet()[0].getSerialNo(), result.getSerialNo()); - } - - @Test - public void testParseSmsReceiveStatus() { - // 准备参数 - String text = "[\n" + - " {\n" + - " \"user_receive_time\": \"2015-10-17 08:03:04\",\n" + - " \"nationcode\": \"86\",\n" + - " \"mobile\": \"13900000001\",\n" + - " \"report_status\": \"SUCCESS\",\n" + - " \"errmsg\": \"DELIVRD\",\n" + - " \"description\": \"用户短信送达成功\",\n" + - " \"sid\": \"12345\",\n" + - " \"ext\": {\"logId\":\"67890\"}\n" + - " }\n" + - "]"; - // mock 方法 - - // 调用 - List statuses = smsClient.parseSmsReceiveStatus(text); - // 断言 - assertEquals(1, statuses.size()); - assertTrue(statuses.get(0).getSuccess()); - assertEquals("DELIVRD", statuses.get(0).getErrorCode()); - assertEquals("用户短信送达成功", statuses.get(0).getErrorMsg()); - assertEquals("13900000001", statuses.get(0).getMobile()); - assertEquals(LocalDateTime.of(2015, 10, 17, 8, 3, 4), statuses.get(0).getReceiveTime()); - assertEquals("12345", statuses.get(0).getSerialNo()); - assertEquals(67890L, statuses.get(0).getLogId()); - } - - @Test - public void testGetSmsTemplate() throws Throwable { - // 准备参数 - Long apiTemplateId = randomLongId(); - String requestId = randomString(); - - // mock 方法 - DescribeSmsTemplateListResponse response = randomPojo(DescribeSmsTemplateListResponse.class, o -> { - DescribeTemplateListStatus[] describeTemplateListStatuses = new DescribeTemplateListStatus[1]; - DescribeTemplateListStatus templateStatus = new DescribeTemplateListStatus(); - templateStatus.setTemplateId(apiTemplateId); - templateStatus.setStatusCode(0L);// 设置模板通过 - describeTemplateListStatuses[0] = templateStatus; - o.setDescribeTemplateStatusSet(describeTemplateListStatuses); - o.setRequestId(requestId); - }); - when(client.DescribeSmsTemplateList(argThat(request -> { - assertEquals(apiTemplateId, request.getTemplateIdSet()[0]); - return true; - }))).thenReturn(response); - - // 调用 - SmsTemplateRespDTO result = smsClient.getSmsTemplate(apiTemplateId.toString()); - // 断言 - assertEquals(response.getDescribeTemplateStatusSet()[0].getTemplateId().toString(), result.getId()); - assertEquals(response.getDescribeTemplateStatusSet()[0].getTemplateContent(), result.getContent()); - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), result.getAuditStatus()); - assertEquals(response.getDescribeTemplateStatusSet()[0].getReviewReply(), result.getAuditReason()); - } - - @Test - public void testConvertSmsTemplateAuditStatus() { - assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), - smsClient.convertSmsTemplateAuditStatus(0)); - assertEquals(SmsTemplateAuditStatusEnum.CHECKING.getStatus(), - smsClient.convertSmsTemplateAuditStatus(1)); - assertEquals(SmsTemplateAuditStatusEnum.FAIL.getStatus(), - smsClient.convertSmsTemplateAuditStatus(-1)); - assertThrows(IllegalArgumentException.class, () -> smsClient.convertSmsTemplateAuditStatus(3), - "未知审核状态(3)"); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java deleted file mode 100644 index 9b927c63a..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java +++ /dev/null @@ -1,381 +0,0 @@ -package cn.iocoder.yudao.module.system.service.auth; - -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; -import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import cn.iocoder.yudao.module.system.service.logger.LoginLogService; -import cn.iocoder.yudao.module.system.service.member.MemberService; -import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; -import cn.iocoder.yudao.module.system.service.social.SocialUserService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import com.xingyuv.captcha.model.common.ResponseModel; -import com.xingyuv.captcha.service.CaptchaService; -import org.junit.jupiter.api.BeforeEach; -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.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.Validator; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import(AdminAuthServiceImpl.class) -public class AdminAuthServiceImplTest extends BaseDbUnitTest { - - @Resource - private AdminAuthServiceImpl authService; - - @MockBean - private AdminUserService userService; - @MockBean - private CaptchaService captchaService; - @MockBean - private LoginLogService loginLogService; - @MockBean - private SocialUserService socialUserService; - @MockBean - private SmsCodeApi smsCodeApi; - @MockBean - private OAuth2TokenService oauth2TokenService; - @MockBean - private MemberService memberService; - @MockBean - private Validator validator; - - @BeforeEach - public void setUp() { - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - // 注入一个 Validator 对象 - ReflectUtil.setFieldValue(authService, "validator", - Validation.buildDefaultValidatorFactory().getValidator()); - } - - @Test - public void testAuthenticate_success() { - // 准备参数 - String username = randomString(); - String password = randomString(); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setUsername(username) - .setPassword(password).setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(userService.getUserByUsername(eq(username))).thenReturn(user); - // mock password 匹配 - when(userService.isPasswordMatch(eq(password), eq(user.getPassword()))).thenReturn(true); - - // 调用 - AdminUserDO loginUser = authService.authenticate(username, password); - // 校验 - assertPojoEquals(user, loginUser); - } - - @Test - public void testAuthenticate_userNotFound() { - // 准备参数 - String username = randomString(); - String password = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> authService.authenticate(username, password), - AUTH_LOGIN_BAD_CREDENTIALS); - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.BAD_CREDENTIALS.getResult()) - && o.getUserId() == null) - ); - } - - @Test - public void testAuthenticate_badCredentials() { - // 准备参数 - String username = randomString(); - String password = randomString(); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setUsername(username) - .setPassword(password).setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(userService.getUserByUsername(eq(username))).thenReturn(user); - - // 调用, 并断言异常 - assertServiceException(() -> authService.authenticate(username, password), - AUTH_LOGIN_BAD_CREDENTIALS); - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.BAD_CREDENTIALS.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testAuthenticate_userDisabled() { - // 准备参数 - String username = randomString(); - String password = randomString(); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setUsername(username) - .setPassword(password).setStatus(CommonStatusEnum.DISABLE.getStatus())); - when(userService.getUserByUsername(eq(username))).thenReturn(user); - // mock password 匹配 - when(userService.isPasswordMatch(eq(password), eq(user.getPassword()))).thenReturn(true); - - // 调用, 并断言异常 - assertServiceException(() -> authService.authenticate(username, password), - AUTH_LOGIN_USER_DISABLED); - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.USER_DISABLED.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testLogin_success() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class, o -> - o.setUsername("test_username").setPassword("test_password") - .setSocialType(randomEle(SocialTypeEnum.values()).getType())); - - // mock 验证码正确 - ReflectUtil.setFieldValue(authService, "captchaEnable", false); - // mock user 数据 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(1L).setUsername("test_username") - .setPassword("test_password").setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(userService.getUserByUsername(eq("test_username"))).thenReturn(user); - // mock password 匹配 - when(userService.isPasswordMatch(eq("test_password"), eq(user.getPassword()))).thenReturn(true); - // mock 缓存登录用户到 Redis - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.createAccessToken(eq(1L), eq(UserTypeEnum.ADMIN.getValue()), eq("default"), isNull())) - .thenReturn(accessTokenDO); - - // 调用,并校验 - AuthLoginRespVO loginRespVO = authService.login(reqVO); - assertPojoEquals(accessTokenDO, loginRespVO); - // 校验调用参数 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult()) - && o.getUserId().equals(user.getId())) - ); - verify(socialUserService).bindSocialUser(eq(new SocialUserBindReqDTO( - user.getId(), UserTypeEnum.ADMIN.getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState()))); - } - - @Test - public void testSendSmsCode() { - // 准备参数 - String mobile = randomString(); - Integer scene = randomEle(SmsSceneEnum.values()).getScene(); - AuthSmsSendReqVO reqVO = new AuthSmsSendReqVO(mobile, scene); - // mock 方法(用户信息) - AdminUserDO user = randomPojo(AdminUserDO.class); - when(userService.getUserByMobile(eq(mobile))).thenReturn(user); - - // 调用 - authService.sendSmsCode(reqVO); - // 断言 - verify(smsCodeApi).sendSmsCode(argThat(sendReqDTO -> { - assertEquals(mobile, sendReqDTO.getMobile()); - assertEquals(scene, sendReqDTO.getScene()); - return true; - })); - } - - @Test - public void testSmsLogin_success() { - // 准备参数 - String mobile = randomString(); - String code = randomString(); - AuthSmsLoginReqVO reqVO = new AuthSmsLoginReqVO(mobile, code); - // mock 方法(校验验证码) - when(smsCodeApi.useSmsCode(argThat(reqDTO -> { - assertEquals(mobile, reqDTO.getMobile()); - assertEquals(code, reqDTO.getCode()); - assertEquals(SmsSceneEnum.ADMIN_MEMBER_LOGIN.getScene(), reqDTO.getScene()); - return true; - }))).thenReturn(success(true)); - // mock 方法(用户信息) - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(1L)); - when(userService.getUserByMobile(eq(mobile))).thenReturn(user); - // mock 缓存登录用户到 Redis - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.createAccessToken(eq(1L), eq(UserTypeEnum.ADMIN.getValue()), eq("default"), isNull())) - .thenReturn(accessTokenDO); - - // 调用,并断言 - AuthLoginRespVO loginRespVO = authService.smsLogin(reqVO); - assertPojoEquals(accessTokenDO, loginRespVO); - // 断言调用 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_MOBILE.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testSocialLogin_success() { - // 准备参数 - AuthSocialLoginReqVO reqVO = randomPojo(AuthSocialLoginReqVO.class); - // mock 方法(绑定的用户编号) - Long userId = 1L; - when(socialUserService.getSocialUserByCode(eq(UserTypeEnum.ADMIN.getValue()), eq(reqVO.getType()), - eq(reqVO.getCode()), eq(reqVO.getState()))).thenReturn(new SocialUserRespDTO(randomString(), randomString(), randomString(), userId)); - // mock(用户) - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setId(userId)); - when(userService.getUser(eq(userId))).thenReturn(user); - // mock 缓存登录用户到 Redis - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.createAccessToken(eq(1L), eq(UserTypeEnum.ADMIN.getValue()), eq("default"), isNull())) - .thenReturn(accessTokenDO); - - // 调用,并断言 - AuthLoginRespVO loginRespVO = authService.socialLogin(reqVO); - assertPojoEquals(accessTokenDO, loginRespVO); - // 断言调用 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_SOCIAL.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult()) - && o.getUserId().equals(user.getId())) - ); - } - - @Test - public void testValidateCaptcha_successWithEnable() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class); - - // mock 验证码打开 - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - // mock 验证通过 - when(captchaService.verification(argThat(captchaVO -> { - assertEquals(reqVO.getCaptchaVerification(), captchaVO.getCaptchaVerification()); - return true; - }))).thenReturn(ResponseModel.success()); - - // 调用,无需断言 - authService.validateCaptcha(reqVO); - } - - @Test - public void testValidateCaptcha_successWithDisable() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class); - - // mock 验证码关闭 - ReflectUtil.setFieldValue(authService, "captchaEnable", false); - - // 调用,无需断言 - authService.validateCaptcha(reqVO); - } - - @Test - public void testValidateCaptcha_constraintViolationException() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class).setCaptchaVerification(null); - - // mock 验证码打开 - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - - // 调用,并断言异常 - assertThrows(ConstraintViolationException.class, () -> authService.validateCaptcha(reqVO), - "验证码不能为空"); - } - - - @Test - public void testCaptcha_fail() { - // 准备参数 - AuthLoginReqVO reqVO = randomPojo(AuthLoginReqVO.class); - - // mock 验证码打开 - ReflectUtil.setFieldValue(authService, "captchaEnable", true); - // mock 验证通过 - when(captchaService.verification(argThat(captchaVO -> { - assertEquals(reqVO.getCaptchaVerification(), captchaVO.getCaptchaVerification()); - return true; - }))).thenReturn(ResponseModel.errorMsg("就是不对")); - - // 调用, 并断言异常 - assertServiceException(() -> authService.validateCaptcha(reqVO), AUTH_LOGIN_CAPTCHA_CODE_ERROR, "就是不对"); - // 校验调用参数 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType()) - && o.getResult().equals(LoginResultEnum.CAPTCHA_CODE_ERROR.getResult())) - ); - } - - @Test - public void testRefreshToken() { - // 准备参数 - String refreshToken = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.refreshAccessToken(eq(refreshToken), eq("default"))) - .thenReturn(accessTokenDO); - - // 调用 - AuthLoginRespVO loginRespVO = authService.refreshToken(refreshToken); - // 断言 - assertPojoEquals(accessTokenDO, loginRespVO); - } - - @Test - public void testLogout_success() { - // 准备参数 - String token = randomString(); - // mock - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class, o -> o.setUserId(1L) - .setUserType(UserTypeEnum.ADMIN.getValue())); - when(oauth2TokenService.removeAccessToken(eq(token))).thenReturn(accessTokenDO); - - // 调用 - authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType()); - // 校验调用参数 - verify(loginLogService).createLoginLog( - argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGOUT_SELF.getType()) - && o.getResult().equals(LoginResultEnum.SUCCESS.getResult())) - ); - // 调用,并校验 - - } - - @Test - public void testLogout_fail() { - // 准备参数 - String token = randomString(); - - // 调用 - authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType()); - // 校验调用参数 - verify(loginLogService, never()).createLoginLog(any()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java deleted file mode 100644 index abfa225da..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImplTest.java +++ /dev/null @@ -1,296 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dept; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link DeptServiceImpl} 的单元测试类 - * - * @author niudehua - */ -@Import(DeptServiceImpl.class) -public class DeptServiceImplTest extends BaseDbUnitTest { - - @Resource - private DeptServiceImpl deptService; - @Resource - private DeptMapper deptMapper; - - @Test - public void testCreateDept() { - // 准备参数 - DeptSaveReqVO reqVO = randomPojo(DeptSaveReqVO.class, o -> { - o.setId(null); // 防止 id 被设置 - o.setParentId(DeptDO.PARENT_ID_ROOT); - o.setStatus(randomCommonStatus()); - }); - - // 调用 - Long deptId = deptService.createDept(reqVO); - // 断言 - assertNotNull(deptId); - // 校验记录的属性是否正确 - DeptDO deptDO = deptMapper.selectById(deptId); - assertPojoEquals(reqVO, deptDO, "id"); - } - - @Test - public void testUpdateDept() { - // mock 数据 - DeptDO dbDeptDO = randomPojo(DeptDO.class, o -> o.setStatus(randomCommonStatus())); - deptMapper.insert(dbDeptDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DeptSaveReqVO reqVO = randomPojo(DeptSaveReqVO.class, o -> { - // 设置更新的 ID - o.setParentId(DeptDO.PARENT_ID_ROOT); - o.setId(dbDeptDO.getId()); - o.setStatus(randomCommonStatus()); - }); - - // 调用 - deptService.updateDept(reqVO); - // 校验是否更新正确 - DeptDO deptDO = deptMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, deptDO); - } - - @Test - public void testDeleteDept_success() { - // mock 数据 - DeptDO dbDeptDO = randomPojo(DeptDO.class); - deptMapper.insert(dbDeptDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDeptDO.getId(); - - // 调用 - deptService.deleteDept(id); - // 校验数据不存在了 - assertNull(deptMapper.selectById(id)); - } - - @Test - public void testDeleteDept_exitsChildren() { - // mock 数据 - DeptDO parentDept = randomPojo(DeptDO.class); - deptMapper.insert(parentDept);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DeptDO childrenDeptDO = randomPojo(DeptDO.class, o -> { - o.setParentId(parentDept.getId()); - o.setStatus(randomCommonStatus()); - }); - // 插入子部门 - deptMapper.insert(childrenDeptDO); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.deleteDept(parentDept.getId()), DEPT_EXITS_CHILDREN); - } - - @Test - public void testValidateDeptExists_notFound() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptExists(id), DEPT_NOT_FOUND); - } - - @Test - public void testValidateParentDept_parentError() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateParentDept(id, id), - DEPT_PARENT_ERROR); - } - - @Test - public void testValidateParentDept_parentIsChild() { - // mock 数据(父节点) - DeptDO parentDept = randomPojo(DeptDO.class); - deptMapper.insert(parentDept); - // mock 数据(子节点) - DeptDO childDept = randomPojo(DeptDO.class, o -> { - o.setParentId(parentDept.getId()); - }); - deptMapper.insert(childDept); - - // 准备参数 - Long id = parentDept.getId(); - Long parentId = childDept.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateParentDept(id, parentId), DEPT_PARENT_IS_CHILD); - } - - @Test - public void testValidateNameUnique_duplicate() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class); - deptMapper.insert(deptDO); - - // 准备参数 - Long id = randomLongId(); - Long parentId = deptDO.getParentId(); - String name = deptDO.getName(); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptNameUnique(id, parentId, name), - DEPT_NAME_DUPLICATE); - } - - @Test - public void testGetDept() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class); - deptMapper.insert(deptDO); - // 准备参数 - Long id = deptDO.getId(); - - // 调用 - DeptDO dbDept = deptService.getDept(id); - // 断言 - assertEquals(deptDO, dbDept); - } - - @Test - public void testGetDeptList_ids() { - // mock 数据 - DeptDO deptDO01 = randomPojo(DeptDO.class); - deptMapper.insert(deptDO01); - DeptDO deptDO02 = randomPojo(DeptDO.class); - deptMapper.insert(deptDO02); - // 准备参数 - List ids = Arrays.asList(deptDO01.getId(), deptDO02.getId()); - - // 调用 - List deptDOList = deptService.getDeptList(ids); - // 断言 - assertEquals(2, deptDOList.size()); - assertEquals(deptDO01, deptDOList.get(0)); - assertEquals(deptDO02, deptDOList.get(1)); - } - - @Test - public void testGetDeptList_reqVO() { - // mock 数据 - DeptDO dept = randomPojo(DeptDO.class, o -> { // 等会查询到 - o.setName("开发部"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - deptMapper.insert(dept); - // 测试 name 不匹配 - deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> o.setName("发"))); - // 测试 status 不匹配 - deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - DeptListReqVO reqVO = new DeptListReqVO(); - reqVO.setName("开"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - List sysDeptDOS = deptService.getDeptList(reqVO); - // 断言 - assertEquals(1, sysDeptDOS.size()); - assertPojoEquals(dept, sysDeptDOS.get(0)); - } - - @Test - public void testGetChildDeptList() { - // mock 数据(1 级别子节点) - DeptDO dept1 = randomPojo(DeptDO.class, o -> o.setName("1")); - deptMapper.insert(dept1); - DeptDO dept2 = randomPojo(DeptDO.class, o -> o.setName("2")); - deptMapper.insert(dept2); - // mock 数据(2 级子节点) - DeptDO dept1a = randomPojo(DeptDO.class, o -> o.setName("1-a").setParentId(dept1.getId())); - deptMapper.insert(dept1a); - DeptDO dept2a = randomPojo(DeptDO.class, o -> o.setName("2-a").setParentId(dept2.getId())); - deptMapper.insert(dept2a); - // 准备参数 - Long id = dept1.getParentId(); - - // 调用 - List result = deptService.getChildDeptList(id); - // 断言 - assertEquals(result.size(), 2); - assertPojoEquals(dept1, result.get(0)); - assertPojoEquals(dept1a, result.get(1)); - } - - @Test - public void testGetChildDeptListFromCache() { - // mock 数据(1 级别子节点) - DeptDO dept1 = randomPojo(DeptDO.class, o -> o.setName("1")); - deptMapper.insert(dept1); - DeptDO dept2 = randomPojo(DeptDO.class, o -> o.setName("2")); - deptMapper.insert(dept2); - // mock 数据(2 级子节点) - DeptDO dept1a = randomPojo(DeptDO.class, o -> o.setName("1-a").setParentId(dept1.getId())); - deptMapper.insert(dept1a); - DeptDO dept2a = randomPojo(DeptDO.class, o -> o.setName("2-a").setParentId(dept2.getId())); - deptMapper.insert(dept2a); - // 准备参数 - Long id = dept1.getParentId(); - - // 调用 - Set result = deptService.getChildDeptIdListFromCache(id); - // 断言 - assertEquals(result.size(), 2); - assertTrue(result.contains(dept1.getId())); - assertTrue(result.contains(dept1a.getId())); - } - - @Test - public void testValidateDeptList_success() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class).setStatus(CommonStatusEnum.ENABLE.getStatus()); - deptMapper.insert(deptDO); - // 准备参数 - List ids = singletonList(deptDO.getId()); - - // 调用,无需断言 - deptService.validateDeptList(ids); - } - - @Test - public void testValidateDeptList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptList(ids), DEPT_NOT_FOUND); - } - - @Test - public void testValidateDeptList_notEnable() { - // mock 数据 - DeptDO deptDO = randomPojo(DeptDO.class).setStatus(CommonStatusEnum.DISABLE.getStatus()); - deptMapper.insert(deptDO); - // 准备参数 - List ids = singletonList(deptDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> deptService.validateDeptList(ids), DEPT_NOT_ENABLE, deptDO.getName()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java deleted file mode 100644 index a6412277c..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImplTest.java +++ /dev/null @@ -1,248 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dept; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.PostMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link PostServiceImpl} 的单元测试类 - * - * @author niudehua - */ -@Import(PostServiceImpl.class) -public class PostServiceImplTest extends BaseDbUnitTest { - - @Resource - private PostServiceImpl postService; - - @Resource - private PostMapper postMapper; - - @Test - public void testCreatePost_success() { - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, - o -> o.setStatus(randomEle(CommonStatusEnum.values()).getStatus())) - .setId(null); // 防止 id 被设置 - // 调用 - Long postId = postService.createPost(reqVO); - - // 断言 - assertNotNull(postId); - // 校验记录的属性是否正确 - PostDO post = postMapper.selectById(postId); - assertPojoEquals(reqVO, post, "id"); - } - - @Test - public void testUpdatePost_success() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, o -> { - // 设置更新的 ID - o.setId(postDO.getId()); - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); - }); - - // 调用 - postService.updatePost(reqVO); - // 校验是否更新正确 - PostDO post = postMapper.selectById(reqVO.getId()); - assertPojoEquals(reqVO, post); - } - - @Test - public void testDeletePost_success() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO); - // 准备参数 - Long id = postDO.getId(); - - // 调用 - postService.deletePost(id); - assertNull(postMapper.selectById(id)); - } - - @Test - public void testValidatePost_notFoundForDelete() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> postService.deletePost(id), POST_NOT_FOUND); - } - - @Test - public void testValidatePost_nameDuplicateForCreate() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, - // 模拟 name 重复 - o -> o.setName(postDO.getName())); - assertServiceException(() -> postService.createPost(reqVO), POST_NAME_DUPLICATE); - } - - @Test - public void testValidatePost_codeDuplicateForUpdate() { - // mock 数据 - PostDO postDO = randomPostDO(); - postMapper.insert(postDO); - // mock 数据:稍后模拟重复它的 code - PostDO codePostDO = randomPostDO(); - postMapper.insert(codePostDO); - // 准备参数 - PostSaveReqVO reqVO = randomPojo(PostSaveReqVO.class, o -> { - // 设置更新的 ID - o.setId(postDO.getId()); - // 模拟 code 重复 - o.setCode(codePostDO.getCode()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> postService.updatePost(reqVO), POST_CODE_DUPLICATE); - } - - @Test - public void testGetPostPage() { - // mock 数据 - PostDO postDO = randomPojo(PostDO.class, o -> { - o.setName("码仔"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - postMapper.insert(postDO); - // 测试 name 不匹配 - postMapper.insert(cloneIgnoreId(postDO, o -> o.setName("程序员"))); - // 测试 status 不匹配 - postMapper.insert(cloneIgnoreId(postDO, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - PostPageReqVO reqVO = new PostPageReqVO(); - reqVO.setName("码"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = postService.getPostPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(postDO, pageResult.getList().get(0)); - } - - @Test - public void testGetPostList() { - // mock 数据 - PostDO postDO01 = randomPojo(PostDO.class); - postMapper.insert(postDO01); - // 测试 id 不匹配 - PostDO postDO02 = randomPojo(PostDO.class); - postMapper.insert(postDO02); - // 准备参数 - List ids = singletonList(postDO01.getId()); - - // 调用 - List list = postService.getPostList(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(postDO01, list.get(0)); - } - - @Test - public void testGetPostList_idsAndStatus() { - // mock 数据 - PostDO postDO01 = randomPojo(PostDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - postMapper.insert(postDO01); - // 测试 status 不匹配 - PostDO postDO02 = randomPojo(PostDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - postMapper.insert(postDO02); - // 准备参数 - List ids = Arrays.asList(postDO01.getId(), postDO02.getId()); - - // 调用 - List list = postService.getPostList(ids, singletonList(CommonStatusEnum.ENABLE.getStatus())); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(postDO01, list.get(0)); - } - - @Test - public void testGetPost() { - // mock 数据 - PostDO dbPostDO = randomPostDO(); - postMapper.insert(dbPostDO); - // 准备参数 - Long id = dbPostDO.getId(); - // 调用 - PostDO post = postService.getPost(id); - // 断言 - assertNotNull(post); - assertPojoEquals(dbPostDO, post); - } - - @Test - public void testValidatePostList_success() { - // mock 数据 - PostDO postDO = randomPostDO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - postMapper.insert(postDO); - // 准备参数 - List ids = singletonList(postDO.getId()); - - // 调用,无需断言 - postService.validatePostList(ids); - } - - @Test - public void testValidatePostList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> postService.validatePostList(ids), POST_NOT_FOUND); - } - - @Test - public void testValidatePostList_notEnable() { - // mock 数据 - PostDO postDO = randomPostDO().setStatus(CommonStatusEnum.DISABLE.getStatus()); - postMapper.insert(postDO); - // 准备参数 - List ids = singletonList(postDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> postService.validatePostList(ids), POST_NOT_ENABLE, - postDO.getName()); - } - - @SafeVarargs - private static PostDO randomPostDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomCommonStatus()); // 保证 status 的范围 - }; - return randomPojo(PostDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImplTest.java deleted file mode 100644 index 68edd735f..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImplTest.java +++ /dev/null @@ -1,352 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dict; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; -import cn.iocoder.yudao.module.system.dal.mysql.dict.DictDataMapper; -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 java.util.List; -import java.util.function.Consumer; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(DictDataServiceImpl.class) -public class DictDataServiceImplTest extends BaseDbUnitTest { - - @Resource - private DictDataServiceImpl dictDataService; - - @Resource - private DictDataMapper dictDataMapper; - @MockBean - private DictTypeService dictTypeService; - - @Test - public void testGetDictDataList() { - // mock 数据 - DictDataDO dictDataDO01 = randomDictDataDO().setDictType("yunai").setSort(2) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - dictDataMapper.insert(dictDataDO01); - DictDataDO dictDataDO02 = randomDictDataDO().setDictType("yunai").setSort(1) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - dictDataMapper.insert(dictDataDO02); - DictDataDO dictDataDO03 = randomDictDataDO().setDictType("yunai").setSort(3) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - dictDataMapper.insert(dictDataDO03); - DictDataDO dictDataDO04 = randomDictDataDO().setDictType("yunai2").setSort(3) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - dictDataMapper.insert(dictDataDO04); - // 准备参数 - Integer status = CommonStatusEnum.ENABLE.getStatus(); - String dictType = "yunai"; - - // 调用 - List dictDataDOList = dictDataService.getDictDataList(status, dictType); - // 断言 - assertEquals(2, dictDataDOList.size()); - assertPojoEquals(dictDataDO02, dictDataDOList.get(0)); - assertPojoEquals(dictDataDO01, dictDataDOList.get(1)); - } - - @Test - public void testGetDictDataPage() { - // mock 数据 - DictDataDO dbDictData = randomPojo(DictDataDO.class, o -> { // 等会查询到 - o.setLabel("芋艿"); - o.setDictType("yunai"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - dictDataMapper.insert(dbDictData); - // 测试 label 不匹配 - dictDataMapper.insert(cloneIgnoreId(dbDictData, o -> o.setLabel("艿"))); - // 测试 dictType 不匹配 - dictDataMapper.insert(cloneIgnoreId(dbDictData, o -> o.setDictType("nai"))); - // 测试 status 不匹配 - dictDataMapper.insert(cloneIgnoreId(dbDictData, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - DictDataPageReqVO reqVO = new DictDataPageReqVO(); - reqVO.setLabel("芋"); - reqVO.setDictType("yunai"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = dictDataService.getDictDataPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDictData, pageResult.getList().get(0)); - } - - @Test - public void testGetDictData() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData); - // 准备参数 - Long id = dbDictData.getId(); - - // 调用 - DictDataDO dictData = dictDataService.getDictData(id); - // 断言 - assertPojoEquals(dbDictData, dictData); - } - - @Test - public void testCreateDictData_success() { - // 准备参数 - DictDataSaveReqVO reqVO = randomPojo(DictDataSaveReqVO.class, - o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - // mock 方法 - when(dictTypeService.getDictType(eq(reqVO.getDictType()))).thenReturn(randomDictTypeDO(reqVO.getDictType())); - - // 调用 - Long dictDataId = dictDataService.createDictData(reqVO); - // 断言 - assertNotNull(dictDataId); - // 校验记录的属性是否正确 - DictDataDO dictData = dictDataMapper.selectById(dictDataId); - assertPojoEquals(reqVO, dictData, "id"); - } - - @Test - public void testUpdateDictData_success() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DictDataSaveReqVO reqVO = randomPojo(DictDataSaveReqVO.class, o -> { - o.setId(dbDictData.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - // mock 方法,字典类型 - when(dictTypeService.getDictType(eq(reqVO.getDictType()))).thenReturn(randomDictTypeDO(reqVO.getDictType())); - - // 调用 - dictDataService.updateDictData(reqVO); - // 校验是否更新正确 - DictDataDO dictData = dictDataMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, dictData); - } - - @Test - public void testDeleteDictData_success() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDictData.getId(); - - // 调用 - dictDataService.deleteDictData(id); - // 校验数据不存在了 - assertNull(dictDataMapper.selectById(id)); - } - - @Test - public void testValidateDictDataExists_success() { - // mock 数据 - DictDataDO dbDictData = randomDictDataDO(); - dictDataMapper.insert(dbDictData);// @Sql: 先插入出一条存在的数据 - - // 调用成功 - dictDataService.validateDictDataExists(dbDictData.getId()); - } - - @Test - public void testValidateDictDataExists_notExists() { - assertServiceException(() -> dictDataService.validateDictDataExists(randomLongId()), DICT_DATA_NOT_EXISTS); - } - - @Test - public void testValidateDictTypeExists_success() { - // mock 方法,数据类型被禁用 - String type = randomString(); - when(dictTypeService.getDictType(eq(type))).thenReturn(randomDictTypeDO(type)); - - // 调用, 成功 - dictDataService.validateDictTypeExists(type); - } - - @Test - public void testValidateDictTypeExists_notExists() { - assertServiceException(() -> dictDataService.validateDictTypeExists(randomString()), DICT_TYPE_NOT_EXISTS); - } - - @Test - public void testValidateDictTypeExists_notEnable() { - // mock 方法,数据类型被禁用 - String dictType = randomString(); - when(dictTypeService.getDictType(eq(dictType))).thenReturn( - randomPojo(DictTypeDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - - // 调用, 并断言异常 - assertServiceException(() -> dictDataService.validateDictTypeExists(dictType), DICT_TYPE_NOT_ENABLE); - } - - @Test - public void testValidateDictDataValueUnique_success() { - // 调用,成功 - dictDataService.validateDictDataValueUnique(randomLongId(), randomString(), randomString()); - } - - @Test - public void testValidateDictDataValueUnique_valueDuplicateForCreate() { - // 准备参数 - String dictType = randomString(); - String value = randomString(); - // mock 数据 - dictDataMapper.insert(randomDictDataDO(o -> { - o.setDictType(dictType); - o.setValue(value); - })); - - // 调用,校验异常 - assertServiceException(() -> dictDataService.validateDictDataValueUnique(null, dictType, value), - DICT_DATA_VALUE_DUPLICATE); - } - - @Test - public void testValidateDictDataValueUnique_valueDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String dictType = randomString(); - String value = randomString(); - // mock 数据 - dictDataMapper.insert(randomDictDataDO(o -> { - o.setDictType(dictType); - o.setValue(value); - })); - - // 调用,校验异常 - assertServiceException(() -> dictDataService.validateDictDataValueUnique(id, dictType, value), - DICT_DATA_VALUE_DUPLICATE); - } - - @Test - public void testGetDictDataCountByDictType() { - // mock 数据 - dictDataMapper.insert(randomDictDataDO(o -> o.setDictType("yunai"))); - dictDataMapper.insert(randomDictDataDO(o -> o.setDictType("tudou"))); - dictDataMapper.insert(randomDictDataDO(o -> o.setDictType("yunai"))); - // 准备参数 - String dictType = "yunai"; - - // 调用 - long count = dictDataService.getDictDataCountByDictType(dictType); - // 校验 - assertEquals(2L, count); - } - - @Test - public void testValidateDictDataList_success() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - dictDataMapper.insert(dictDataDO); - // 准备参数 - String dictType = dictDataDO.getDictType(); - List values = singletonList(dictDataDO.getValue()); - - // 调用,无需断言 - dictDataService.validateDictDataList(dictType, values); - } - - @Test - public void testValidateDictDataList_notFound() { - // 准备参数 - String dictType = randomString(); - List values = singletonList(randomString()); - - // 调用, 并断言异常 - assertServiceException(() -> dictDataService.validateDictDataList(dictType, values), DICT_DATA_NOT_EXISTS); - } - - @Test - public void testValidateDictDataList_notEnable() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setStatus(CommonStatusEnum.DISABLE.getStatus()); - dictDataMapper.insert(dictDataDO); - // 准备参数 - String dictType = dictDataDO.getDictType(); - List values = singletonList(dictDataDO.getValue()); - - // 调用, 并断言异常 - assertServiceException(() -> dictDataService.validateDictDataList(dictType, values), - DICT_DATA_NOT_ENABLE, dictDataDO.getLabel()); - } - - @Test - public void testGetDictData_dictType() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setDictType("yunai").setValue("1"); - dictDataMapper.insert(dictDataDO); - DictDataDO dictDataDO02 = randomDictDataDO().setDictType("yunai").setValue("2"); - dictDataMapper.insert(dictDataDO02); - // 准备参数 - String dictType = "yunai"; - String value = "1"; - - // 调用 - DictDataDO dbDictData = dictDataService.getDictData(dictType, value); - // 断言 - assertEquals(dictDataDO, dbDictData); - } - - @Test - public void testParseDictData() { - // mock 数据 - DictDataDO dictDataDO = randomDictDataDO().setDictType("yunai").setLabel("1"); - dictDataMapper.insert(dictDataDO); - DictDataDO dictDataDO02 = randomDictDataDO().setDictType("yunai").setLabel("2"); - dictDataMapper.insert(dictDataDO02); - // 准备参数 - String dictType = "yunai"; - String label = "1"; - - // 调用 - DictDataDO dbDictData = dictDataService.parseDictData(dictType, label); - // 断言 - assertEquals(dictDataDO, dbDictData); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static DictDataDO randomDictDataDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomCommonStatus()); // 保证 status 的范围 - }; - return randomPojo(DictDataDO.class, ArrayUtils.append(consumer, consumers)); - } - - /** - * 生成一个有效的字典类型 - * - * @param type 字典类型 - * @return DictTypeDO 对象 - */ - private static DictTypeDO randomDictTypeDO(String type) { - return randomPojo(DictTypeDO.class, o -> { - o.setType(type); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 是开启 - }); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImplTest.java deleted file mode 100644 index 82b4b2f2e..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImplTest.java +++ /dev/null @@ -1,271 +0,0 @@ -package cn.iocoder.yudao.module.system.service.dict; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO; -import cn.iocoder.yudao.module.system.dal.mysql.dict.DictTypeMapper; -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 java.util.List; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(DictTypeServiceImpl.class) -public class DictTypeServiceImplTest extends BaseDbUnitTest { - - @Resource - private DictTypeServiceImpl dictTypeService; - - @Resource - private DictTypeMapper dictTypeMapper; - @MockBean - private DictDataService dictDataService; - - @Test - public void testGetDictTypePage() { - // mock 数据 - DictTypeDO dbDictType = randomPojo(DictTypeDO.class, o -> { // 等会查询到 - o.setName("yunai"); - o.setType("芋艿"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021, 1, 15)); - }); - dictTypeMapper.insert(dbDictType); - // 测试 name 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setName("tudou"))); - // 测试 type 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setType("土豆"))); - // 测试 status 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - dictTypeMapper.insert(cloneIgnoreId(dbDictType, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - DictTypePageReqVO reqVO = new DictTypePageReqVO(); - reqVO.setName("nai"); - reqVO.setType("艿"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 10, 2021, 1, 20)); - - // 调用 - PageResult pageResult = dictTypeService.getDictTypePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbDictType, pageResult.getList().get(0)); - } - - @Test - public void testGetDictType_id() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType); - // 准备参数 - Long id = dbDictType.getId(); - - // 调用 - DictTypeDO dictType = dictTypeService.getDictType(id); - // 断言 - assertNotNull(dictType); - assertPojoEquals(dbDictType, dictType); - } - - @Test - public void testGetDictType_type() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType); - // 准备参数 - String type = dbDictType.getType(); - - // 调用 - DictTypeDO dictType = dictTypeService.getDictType(type); - // 断言 - assertNotNull(dictType); - assertPojoEquals(dbDictType, dictType); - } - - @Test - public void testCreateDictType_success() { - // 准备参数 - DictTypeSaveReqVO reqVO = randomPojo(DictTypeSaveReqVO.class, - o -> o.setStatus(randomEle(CommonStatusEnum.values()).getStatus())) - .setId(null); // 避免 id 被赋值 - - // 调用 - Long dictTypeId = dictTypeService.createDictType(reqVO); - // 断言 - assertNotNull(dictTypeId); - // 校验记录的属性是否正确 - DictTypeDO dictType = dictTypeMapper.selectById(dictTypeId); - assertPojoEquals(reqVO, dictType, "id"); - } - - @Test - public void testUpdateDictType_success() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - DictTypeSaveReqVO reqVO = randomPojo(DictTypeSaveReqVO.class, o -> { - o.setId(dbDictType.getId()); // 设置更新的 ID - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); - }); - - // 调用 - dictTypeService.updateDictType(reqVO); - // 校验是否更新正确 - DictTypeDO dictType = dictTypeMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, dictType); - } - - @Test - public void testDeleteDictType_success() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDictType.getId(); - - // 调用 - dictTypeService.deleteDictType(id); - // 校验数据不存在了 - assertNull(dictTypeMapper.selectById(id)); - } - - @Test - public void testDeleteDictType_hasChildren() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbDictType.getId(); - // mock 方法 - when(dictDataService.getDictDataCountByDictType(eq(dbDictType.getType()))).thenReturn(1L); - - // 调用, 并断言异常 - assertServiceException(() -> dictTypeService.deleteDictType(id), DICT_TYPE_HAS_CHILDREN); - } - - @Test - public void testGetDictTypeList() { - // 准备参数 - DictTypeDO dictTypeDO01 = randomDictTypeDO(); - dictTypeMapper.insert(dictTypeDO01); - DictTypeDO dictTypeDO02 = randomDictTypeDO(); - dictTypeMapper.insert(dictTypeDO02); - // mock 方法 - - // 调用 - List dictTypeDOList = dictTypeService.getDictTypeList(); - // 断言 - assertEquals(2, dictTypeDOList.size()); - assertPojoEquals(dictTypeDO01, dictTypeDOList.get(0)); - assertPojoEquals(dictTypeDO02, dictTypeDOList.get(1)); - } - - @Test - public void testValidateDictDataExists_success() { - // mock 数据 - DictTypeDO dbDictType = randomDictTypeDO(); - dictTypeMapper.insert(dbDictType);// @Sql: 先插入出一条存在的数据 - - // 调用成功 - dictTypeService.validateDictTypeExists(dbDictType.getId()); - } - - @Test - public void testValidateDictDataExists_notExists() { - assertServiceException(() -> dictTypeService.validateDictTypeExists(randomLongId()), DICT_TYPE_NOT_EXISTS); - } - - @Test - public void testValidateDictTypeUnique_success() { - // 调用,成功 - dictTypeService.validateDictTypeUnique(randomLongId(), randomString()); - } - - @Test - public void testValidateDictTypeUnique_valueDuplicateForCreate() { - // 准备参数 - String type = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setType(type))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeUnique(null, type), - DICT_TYPE_TYPE_DUPLICATE); - } - - @Test - public void testValidateDictTypeUnique_valueDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String type = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setType(type))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeUnique(id, type), - DICT_TYPE_TYPE_DUPLICATE); - } - - @Test - public void testValidateDictTypNameUnique_success() { - // 调用,成功 - dictTypeService.validateDictTypeNameUnique(randomLongId(), randomString()); - } - - @Test - public void testValidateDictTypeNameUnique_nameDuplicateForCreate() { - // 准备参数 - String name = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setName(name))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeNameUnique(null, name), - DICT_TYPE_NAME_DUPLICATE); - } - - @Test - public void testValidateDictTypeNameUnique_nameDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String name = randomString(); - // mock 数据 - dictTypeMapper.insert(randomDictTypeDO(o -> o.setName(name))); - - // 调用,校验异常 - assertServiceException(() -> dictTypeService.validateDictTypeNameUnique(id, name), - DICT_TYPE_NAME_DUPLICATE); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static DictTypeDO randomDictTypeDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - }; - return randomPojo(DictTypeDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java deleted file mode 100644 index 530c27408..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.system.service.logger; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; -import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO; -import cn.iocoder.yudao.module.system.dal.mysql.logger.LoginLogMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.CAPTCHA_CODE_ERROR; -import static cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.SUCCESS; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@Import(LoginLogServiceImpl.class) -public class LoginLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private LoginLogServiceImpl loginLogService; - - @Resource - private LoginLogMapper loginLogMapper; - - @Test - public void testGetLoginLogPage() { - // mock 数据 - LoginLogDO loginLogDO = randomPojo(LoginLogDO.class, o -> { - o.setUserIp("192.168.199.16"); - o.setUsername("wang"); - o.setResult(SUCCESS.getResult()); - o.setCreateTime(buildTime(2021, 3, 6)); - }); - loginLogMapper.insert(loginLogDO); - // 测试 status 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setResult(CAPTCHA_CODE_ERROR.getResult()))); - // 测试 ip 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setUserIp("192.168.128.18"))); - // 测试 username 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setUsername("yunai"))); - // 测试 createTime 不匹配 - loginLogMapper.insert(cloneIgnoreId(loginLogDO, o -> o.setCreateTime(buildTime(2021, 2, 6)))); - // 构造调用参数 - LoginLogPageReqVO reqVO = new LoginLogPageReqVO(); - reqVO.setUsername("wang"); - reqVO.setUserIp("192.168.199"); - reqVO.setStatus(true); - reqVO.setCreateTime(buildBetweenTime(2021, 3, 5, 2021, 3, 7)); - - // 调用 - PageResult pageResult = loginLogService.getLoginLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(loginLogDO, pageResult.getList().get(0)); - } - - @Test - public void testCreateLoginLog() { - LoginLogCreateReqDTO reqDTO = randomPojo(LoginLogCreateReqDTO.class); - - // 调用 - loginLogService.createLoginLog(reqDTO); - // 断言 - LoginLogDO loginLogDO = loginLogMapper.selectOne(null); - assertPojoEquals(reqDTO, loginLogDO); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java deleted file mode 100644 index f41d39c23..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.system.service.logger; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; -import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogPageReqDTO; -import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; -import cn.iocoder.yudao.module.system.dal.mysql.logger.OperateLogMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; - -@Import({OperateLogServiceImpl.class}) -public class OperateLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private OperateLogService operateLogServiceImpl; - - @Resource - private OperateLogMapper operateLogMapper; - - @Test - public void testCreateOperateLog() { - OperateLogCreateReqDTO reqVO = RandomUtils.randomPojo(OperateLogCreateReqDTO.class); - - // 调研 - operateLogServiceImpl.createOperateLog(reqVO); - // 断言 - OperateLogDO operateLogDO = operateLogMapper.selectOne(null); - assertPojoEquals(reqVO, operateLogDO); - } - - @Test - public void testGetOperateLogPage_vo() { - // 构造操作日志 - OperateLogDO operateLogDO = RandomUtils.randomPojo(OperateLogDO.class, o -> { - o.setUserId(2048L); - o.setBizId(999L); - o.setType("订单"); - o.setSubType("创建订单"); - o.setAction("修改编号为 1 的用户信息"); - o.setCreateTime(buildTime(2021, 3, 6)); - }); - operateLogMapper.insert(operateLogDO); - // 测试 userId 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setUserId(1024L))); - // 测试 bizId 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setBizId(888L))); - // 测试 type 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setType("退款"))); - // 测试 subType 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setSubType("创建退款"))); - // 测试 action 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setAction("修改编号为 1 退款信息"))); - // 测试 createTime 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setCreateTime(buildTime(2021, 2, 6)))); - - // 构造调用参数 - OperateLogPageReqVO reqVO = new OperateLogPageReqVO(); - reqVO.setUserId(2048L); - reqVO.setBizId(999L); - reqVO.setType("订"); - reqVO.setSubType("订单"); - reqVO.setAction("用户信息"); - reqVO.setCreateTime(buildBetweenTime(2021, 3, 5, 2021, 3, 7)); - - // 调用 - PageResult pageResult = operateLogServiceImpl.getOperateLogPage(reqVO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(operateLogDO, pageResult.getList().get(0)); - } - - @Test - public void testGetOperateLogPage_dto() { - // 构造操作日志 - OperateLogDO operateLogDO = RandomUtils.randomPojo(OperateLogDO.class, o -> { - o.setUserId(2048L); - o.setBizId(999L); - o.setType("订单"); - }); - operateLogMapper.insert(operateLogDO); - // 测试 userId 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setUserId(1024L))); - // 测试 bizId 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setBizId(888L))); - // 测试 type 不匹配 - operateLogMapper.insert(cloneIgnoreId(operateLogDO, o -> o.setType("退款"))); - - // 构造调用参数 - OperateLogPageReqDTO reqDTO = new OperateLogPageReqDTO(); - reqDTO.setUserId(2048L); - reqDTO.setBizId(999L); - reqDTO.setType("订单"); - - // 调用 - PageResult pageResult = operateLogServiceImpl.getOperateLogPage(reqDTO); - // 断言,只查到了一条符合条件的 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(operateLogDO, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImplTest.java deleted file mode 100755 index 6e1bf0d05..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailAccountServiceImplTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; -import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper; -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 java.util.List; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_ACCOUNT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link MailAccountServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MailAccountServiceImpl.class) -public class MailAccountServiceImplTest extends BaseDbUnitTest { - - @Resource - private MailAccountServiceImpl mailAccountService; - - @Resource - private MailAccountMapper mailAccountMapper; - - @MockBean - private MailTemplateService mailTemplateService; - - @Test - public void testCreateMailAccount_success() { - // 准备参数 - MailAccountSaveReqVO reqVO = randomPojo(MailAccountSaveReqVO.class, o -> o.setMail(randomEmail())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long mailAccountId = mailAccountService.createMailAccount(reqVO); - // 断言 - assertNotNull(mailAccountId); - // 校验记录的属性是否正确 - MailAccountDO mailAccount = mailAccountMapper.selectById(mailAccountId); - assertPojoEquals(reqVO, mailAccount, "id"); - } - - @Test - public void testUpdateMailAccount_success() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MailAccountSaveReqVO reqVO = randomPojo(MailAccountSaveReqVO.class, o -> { - o.setId(dbMailAccount.getId()); // 设置更新的 ID - o.setMail(randomEmail()); - }); - - // 调用 - mailAccountService.updateMailAccount(reqVO); - // 校验是否更新正确 - MailAccountDO mailAccount = mailAccountMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, mailAccount); - } - - @Test - public void testUpdateMailAccount_notExists() { - // 准备参数 - MailAccountSaveReqVO reqVO = randomPojo(MailAccountSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> mailAccountService.updateMailAccount(reqVO), MAIL_ACCOUNT_NOT_EXISTS); - } - - @Test - public void testDeleteMailAccount_success() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailAccount.getId(); - // mock 方法(无关联模版) - when(mailTemplateService.getMailTemplateCountByAccountId(eq(id))).thenReturn(0L); - - // 调用 - mailAccountService.deleteMailAccount(id); - // 校验数据不存在了 - assertNull(mailAccountMapper.selectById(id)); - } - - @Test - public void testGetMailAccountFromCache() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailAccount.getId(); - - // 调用 - MailAccountDO mailAccount = mailAccountService.getMailAccountFromCache(id); - // 断言 - assertPojoEquals(dbMailAccount, mailAccount); - } - - @Test - public void testDeleteMailAccount_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> mailAccountService.deleteMailAccount(id), MAIL_ACCOUNT_NOT_EXISTS); - } - - @Test - public void testGetMailAccountPage() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class, o -> { // 等会查询到 - o.setMail("768@qq.com"); - o.setUsername("yunai"); - }); - mailAccountMapper.insert(dbMailAccount); - // 测试 mail 不匹配 - mailAccountMapper.insert(cloneIgnoreId(dbMailAccount, o -> o.setMail("788@qq.com"))); - // 测试 username 不匹配 - mailAccountMapper.insert(cloneIgnoreId(dbMailAccount, o -> o.setUsername("tudou"))); - // 准备参数 - MailAccountPageReqVO reqVO = new MailAccountPageReqVO(); - reqVO.setMail("768"); - reqVO.setUsername("yu"); - - // 调用 - PageResult pageResult = mailAccountService.getMailAccountPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMailAccount, pageResult.getList().get(0)); - } - - @Test - public void testGetMailAccount() { - // mock 数据 - MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailAccount.getId(); - - // 调用 - MailAccountDO mailAccount = mailAccountService.getMailAccount(id); - // 断言 - assertPojoEquals(dbMailAccount, mailAccount); - } - - @Test - public void testGetMailAccountList() { - // mock 数据 - MailAccountDO dbMailAccount01 = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount01); - MailAccountDO dbMailAccount02 = randomPojo(MailAccountDO.class); - mailAccountMapper.insert(dbMailAccount02); - // 准备参数 - - // 调用 - List list = mailAccountService.getMailAccountList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(dbMailAccount01, list.get(0)); - assertPojoEquals(dbMailAccount02, list.get(1)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailLogServiceImplTest.java deleted file mode 100755 index d570c5744..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailLogServiceImplTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.mail.MailLogMapper; -import cn.iocoder.yudao.module.system.enums.mail.MailSendStatusEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link MailLogServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MailLogServiceImpl.class) -public class MailLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private MailLogServiceImpl mailLogService; - - @Resource - private MailLogMapper mailLogMapper; - - @Test - public void testCreateMailLog() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String toMail = randomEmail(); - MailAccountDO account = randomPojo(MailAccountDO.class); - MailTemplateDO template = randomPojo(MailTemplateDO.class); - String templateContent = randomString(); - Map templateParams = randomTemplateParams(); - Boolean isSend = true; - // mock 方法 - - // 调用 - Long logId = mailLogService.createMailLog(userId, userType, toMail, account, template, templateContent, templateParams, isSend); - // 断言 - MailLogDO log = mailLogMapper.selectById(logId); - assertNotNull(log); - assertEquals(MailSendStatusEnum.INIT.getStatus(), log.getSendStatus()); - assertEquals(userId, log.getUserId()); - assertEquals(userType, log.getUserType()); - assertEquals(toMail, log.getToMail()); - assertEquals(account.getId(), log.getAccountId()); - assertEquals(account.getMail(), log.getFromMail()); - assertEquals(template.getId(), log.getTemplateId()); - assertEquals(template.getCode(), log.getTemplateCode()); - assertEquals(template.getNickname(), log.getTemplateNickname()); - assertEquals(template.getTitle(), log.getTemplateTitle()); - assertEquals(templateContent, log.getTemplateContent()); - assertEquals(templateParams, log.getTemplateParams()); - } - - @Test - public void testUpdateMailSendResult_success() { - // mock 数据 - MailLogDO log = randomPojo(MailLogDO.class, o -> { - o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - o.setSendTime(null).setSendMessageId(null).setSendException(null) - .setTemplateParams(randomTemplateParams()); - }); - mailLogMapper.insert(log); - // 准备参数 - Long logId = log.getId(); - String messageId = randomString(); - - // 调用 - mailLogService.updateMailSendResult(logId, messageId, null); - // 断言 - MailLogDO dbLog = mailLogMapper.selectById(logId); - assertEquals(MailSendStatusEnum.SUCCESS.getStatus(), dbLog.getSendStatus()); - assertNotNull(dbLog.getSendTime()); - assertEquals(messageId, dbLog.getSendMessageId()); - assertNull(dbLog.getSendException()); - } - - @Test - public void testUpdateMailSendResult_exception() { - // mock 数据 - MailLogDO log = randomPojo(MailLogDO.class, o -> { - o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - o.setSendTime(null).setSendMessageId(null).setSendException(null) - .setTemplateParams(randomTemplateParams()); - }); - mailLogMapper.insert(log); - // 准备参数 - Long logId = log.getId(); - Exception exception = new NullPointerException("测试异常"); - - // 调用 - mailLogService.updateMailSendResult(logId, null, exception); - // 断言 - MailLogDO dbLog = mailLogMapper.selectById(logId); - assertEquals(MailSendStatusEnum.FAILURE.getStatus(), dbLog.getSendStatus()); - assertNotNull(dbLog.getSendTime()); - assertNull(dbLog.getSendMessageId()); - assertEquals("NullPointerException: 测试异常", dbLog.getSendException()); - } - - @Test - public void testGetMailLog() { - // mock 数据 - MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> o.setTemplateParams(randomTemplateParams())); - mailLogMapper.insert(dbMailLog); - // 准备参数 - Long id = dbMailLog.getId(); - - // 调用 - MailLogDO mailLog = mailLogService.getMailLog(id); - // 断言 - assertPojoEquals(dbMailLog, mailLog); - } - - @Test - public void testGetMailLogPage() { - // mock 数据 - MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setToMail("768@qq.com"); - o.setAccountId(10L); - o.setTemplateId(100L); - o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - o.setSendTime(buildTime(2023, 2, 10)); - o.setTemplateParams(randomTemplateParams()); - }); - mailLogMapper.insert(dbMailLog); - // 测试 userId 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 toMail 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setToMail("788@.qq.com"))); - // 测试 accountId 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setAccountId(11L))); - // 测试 templateId 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setTemplateId(101L))); - // 测试 sendStatus 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendStatus(MailSendStatusEnum.SUCCESS.getStatus()))); - // 测试 sendTime 不匹配 - mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendTime(buildTime(2023, 3, 10)))); - // 准备参数 - MailLogPageReqVO reqVO = new MailLogPageReqVO(); - reqVO.setUserId(1L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setToMail("768"); - reqVO.setAccountId(10L); - reqVO.setTemplateId(100L); - reqVO.setSendStatus(MailSendStatusEnum.INIT.getStatus()); - reqVO.setSendTime((buildBetweenTime(2023, 2, 1, 2023, 2, 15))); - - // 调用 - PageResult pageResult = mailLogService.getMailLogPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMailLog, pageResult.getList().get(0)); - } - - private static Map randomTemplateParams() { - return MapUtil.builder().put(randomString(), randomString()) - .put(randomString(), randomString()).build(); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java deleted file mode 100644 index 56590dbdc..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java +++ /dev/null @@ -1,332 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.extra.mail.MailAccount; -import cn.hutool.extra.mail.MailUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage; -import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer; -import cn.iocoder.yudao.module.system.service.member.MemberService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockedStatic; - -import java.util.HashMap; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -public class MailSendServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private MailSendServiceImpl mailSendService; - - @Mock - private AdminUserService adminUserService; - @Mock - private MemberService memberService; - @Mock - private MailAccountService mailAccountService; - @Mock - private MailTemplateService mailTemplateService; - @Mock - private MailLogService mailLogService; - @Mock - private MailProducer mailProducer; - - /** - * 用于快速测试你的邮箱账号是否正常 - */ - @Test - @Disabled - public void testDemo() { - MailAccount mailAccount = new MailAccount() -// .setFrom("奥特曼 ") - .setFrom("ydym_test@163.com") // 邮箱地址 - .setHost("smtp.163.com").setPort(465).setSslEnable(true) // SMTP 服务器 - .setAuth(true).setUser("ydym_test@163.com").setPass("WBZTEINMIFVRYSOE"); // 登录账号密码 - String messageId = MailUtil.send(mailAccount, "7685413@qq.com", "主题", "内容", false); - System.out.println("发送结果:" + messageId); - } - - @Test - public void testSendSingleMailToAdmin() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock adminUserService 的方法 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setMobile("15601691300")); - when(adminUserService.getUser(eq(userId))).thenReturn(user); - - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(UserTypeEnum.ADMIN.getValue()), eq(user.getEmail()), - eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMailToAdmin(null, userId, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(user.getEmail()), - eq(account.getId()), eq(template.getNickname()), eq(title), eq(content)); - } - - @Test - public void testSendSingleMailToMember() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock memberService 的方法 - String mail = randomEmail(); - when(memberService.getMemberUserEmail(eq(userId))).thenReturn(mail); - - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(UserTypeEnum.MEMBER.getValue()), eq(mail), - eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMailToMember(null, userId, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail), - eq(account.getId()), eq(template.getNickname()), eq(title), eq(content)); - } - - /** - * 发送成功,当短信模板开启时 - */ - @Test - public void testSendSingleMail_successWhenMailTemplateEnable() { - // 准备参数 - String mail = randomEmail(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(userType), eq(mail), - eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMail(mail, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail), - eq(account.getId()), eq(template.getNickname()), eq(title), eq(content)); - } - - /** - * 发送成功,当短信模板关闭时 - */ - @Test - public void testSendSingleMail_successWhenSmsTemplateDisable() { - // 准备参数 - String mail = randomEmail(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = RandomUtils.randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock MailTemplateService 的方法 - MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String title = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getTitle()), eq(templateParams))) - .thenReturn(title); - String content = RandomUtils.randomString(); - when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock MailAccountService 的方法 - MailAccountDO account = randomPojo(MailAccountDO.class); - when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account); - // mock MailLogService 的方法 - Long mailLogId = randomLongId(); - when(mailLogService.createMailLog(eq(userId), eq(userType), eq(mail), - eq(account), eq(template), eq(content), eq(templateParams), eq(false))).thenReturn(mailLogId); - - // 调用 - Long resultMailLogId = mailSendService.sendSingleMail(mail, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(mailLogId, resultMailLogId); - // 断言调用 - verify(mailProducer, times(0)).sendMailSendMessage(anyLong(), anyString(), - anyLong(), anyString(), anyString(), anyString()); - } - - @Test - public void testValidateMailTemplateValid_notExists() { - // 准备参数 - String templateCode = RandomUtils.randomString(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> mailSendService.validateMailTemplate(templateCode), - MAIL_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testValidateTemplateParams_paramMiss() { - // 准备参数 - MailTemplateDO template = randomPojo(MailTemplateDO.class, - o -> o.setParams(Lists.newArrayList("code"))); - Map templateParams = new HashMap<>(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> mailSendService.validateTemplateParams(template, templateParams), - MAIL_SEND_TEMPLATE_PARAM_MISS, "code"); - } - - @Test - public void testValidateMail_notExists() { - // 准备参数 - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> mailSendService.validateMail(null), - MAIL_SEND_MAIL_NOT_EXISTS); - } - - @Test - public void testDoSendMail_success() { - try (MockedStatic mailUtilMock = mockStatic(MailUtil.class)) { - // 准备参数 - MailSendMessage message = randomPojo(MailSendMessage.class, o -> o.setNickname("芋艿")); - // mock 方法(获得邮箱账号) - MailAccountDO account = randomPojo(MailAccountDO.class, o -> o.setMail("7685@qq.com")); - when(mailAccountService.getMailAccountFromCache(eq(message.getAccountId()))) - .thenReturn(account); - - // mock 方法(发送邮件) - String messageId = randomString(); - mailUtilMock.when(() -> MailUtil.send( - argThat(mailAccount -> { - assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom()); - assertTrue(mailAccount.isAuth()); - assertEquals(account.getUsername(), mailAccount.getUser()); - assertEquals(account.getPassword(), mailAccount.getPass()); - assertEquals(account.getHost(), mailAccount.getHost()); - assertEquals(account.getPort(), mailAccount.getPort()); - assertEquals(account.getSslEnable(), mailAccount.isSslEnable()); - return true; - }), eq(message.getMail()), eq(message.getTitle()), eq(message.getContent()), eq(true))) - .thenReturn(messageId); - - // 调用 - mailSendService.doSendMail(message); - // 断言 - verify(mailLogService).updateMailSendResult(eq(message.getLogId()), eq(messageId), isNull()); - } - } - - @Test - public void testDoSendMail_exception() { - try (MockedStatic mailUtilMock = mockStatic(MailUtil.class)) { - // 准备参数 - MailSendMessage message = randomPojo(MailSendMessage.class, o -> o.setNickname("芋艿")); - // mock 方法(获得邮箱账号) - MailAccountDO account = randomPojo(MailAccountDO.class, o -> o.setMail("7685@qq.com")); - when(mailAccountService.getMailAccountFromCache(eq(message.getAccountId()))) - .thenReturn(account); - - // mock 方法(发送邮件) - Exception e = new NullPointerException("啦啦啦"); - mailUtilMock.when(() -> MailUtil.send(argThat(mailAccount -> { - assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom()); - assertTrue(mailAccount.isAuth()); - assertEquals(account.getUsername(), mailAccount.getUser()); - assertEquals(account.getPassword(), mailAccount.getPass()); - assertEquals(account.getHost(), mailAccount.getHost()); - assertEquals(account.getPort(), mailAccount.getPort()); - assertEquals(account.getSslEnable(), mailAccount.isSslEnable()); - return true; - }), eq(message.getMail()), eq(message.getTitle()), eq(message.getContent()), eq(true))) - .thenThrow(e); - - // 调用 - mailSendService.doSendMail(message); - // 断言 - verify(mailLogService).updateMailSendResult(eq(message.getLogId()), isNull(), same(e)); - } - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImplTest.java deleted file mode 100755 index 7199bd325..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailTemplateServiceImplTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.module.system.service.mail; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link MailTemplateServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(MailTemplateServiceImpl.class) -public class MailTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private MailTemplateServiceImpl mailTemplateService; - - @Resource - private MailTemplateMapper mailTemplateMapper; - - @Test - public void testCreateMailTemplate_success() { - // 准备参数 - MailTemplateSaveReqVO reqVO = randomPojo(MailTemplateSaveReqVO.class) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long mailTemplateId = mailTemplateService.createMailTemplate(reqVO); - // 断言 - assertNotNull(mailTemplateId); - // 校验记录的属性是否正确 - MailTemplateDO mailTemplate = mailTemplateMapper.selectById(mailTemplateId); - assertPojoEquals(reqVO, mailTemplate, "id"); - } - - @Test - public void testUpdateMailTemplate_success() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - MailTemplateSaveReqVO reqVO = randomPojo(MailTemplateSaveReqVO.class, o -> { - o.setId(dbMailTemplate.getId()); // 设置更新的 ID - }); - - // 调用 - mailTemplateService.updateMailTemplate(reqVO); - // 校验是否更新正确 - MailTemplateDO mailTemplate = mailTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, mailTemplate); - } - - @Test - public void testUpdateMailTemplate_notExists() { - // 准备参数 - MailTemplateSaveReqVO reqVO = randomPojo(MailTemplateSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> mailTemplateService.updateMailTemplate(reqVO), MAIL_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteMailTemplate_success() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMailTemplate.getId(); - - // 调用 - mailTemplateService.deleteMailTemplate(id); - // 校验数据不存在了 - assertNull(mailTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteMailTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> mailTemplateService.deleteMailTemplate(id), MAIL_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetMailTemplatePage() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class, o -> { // 等会查询到 - o.setName("源码"); - o.setCode("test_01"); - o.setAccountId(1L); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2023, 2, 3)); - }); - mailTemplateMapper.insert(dbMailTemplate); - // 测试 name 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setName("芋道"))); - // 测试 code 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setCode("test_02"))); - // 测试 accountId 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setAccountId(2L))); - // 测试 status 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setCreateTime(buildTime(2023, 1, 5)))); - // 准备参数 - MailTemplatePageReqVO reqVO = new MailTemplatePageReqVO(); - reqVO.setName("源"); - reqVO.setCode("est_01"); - reqVO.setAccountId(1L); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 5)); - - // 调用 - PageResult pageResult = mailTemplateService.getMailTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMailTemplate, pageResult.getList().get(0)); - } - - @Test - public void testGetMailTemplateList() { - // mock 数据 - MailTemplateDO dbMailTemplate01 = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate01); - MailTemplateDO dbMailTemplate02 = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate02); - - // 调用 - List list = mailTemplateService.getMailTemplateList(); - // 断言 - assertEquals(2, list.size()); - assertEquals(dbMailTemplate01, list.get(0)); - assertEquals(dbMailTemplate02, list.get(1)); - } - - @Test - public void testGetMailTemplate() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate); - // 准备参数 - Long id = dbMailTemplate.getId(); - - // 调用 - MailTemplateDO mailTemplate = mailTemplateService.getMailTemplate(id); - // 断言 - assertPojoEquals(dbMailTemplate, mailTemplate); - } - - @Test - public void testGetMailTemplateByCodeFromCache() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate); - // 准备参数 - String code = dbMailTemplate.getCode(); - - // 调用 - MailTemplateDO mailTemplate = mailTemplateService.getMailTemplateByCodeFromCache(code); - // 断言 - assertPojoEquals(dbMailTemplate, mailTemplate); - } - - @Test - public void testFormatMailTemplateContent() { - // 准备参数 - Map params = new HashMap<>(); - params.put("name", "小红"); - params.put("what", "饭"); - - // 调用,并断言 - assertEquals("小红,你好,饭吃了吗?", - mailTemplateService.formatMailTemplateContent("{name},你好,{what}吃了吗?", params)); - } - - @Test - public void testCountByAccountId() { - // mock 数据 - MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class); - mailTemplateMapper.insert(dbMailTemplate); - // 测试 accountId 不匹配 - mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setAccountId(2L))); - // 准备参数 - Long accountId = dbMailTemplate.getAccountId(); - - // 调用 - long count = mailTemplateService.getMailTemplateCountByAccountId(accountId); - // 断言 - assertEquals(1, count); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java deleted file mode 100644 index dfde83538..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notice/NoticeServiceImplTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notice; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.notice.vo.NoticeSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO; -import cn.iocoder.yudao.module.system.dal.mysql.notice.NoticeMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; -import static org.junit.jupiter.api.Assertions.*; - -@Import(NoticeServiceImpl.class) -class NoticeServiceImplTest extends BaseDbUnitTest { - - @Resource - private NoticeServiceImpl noticeService; - - @Resource - private NoticeMapper noticeMapper; - - @Test - public void testGetNoticePage_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class, o -> { - o.setTitle("尼古拉斯赵四来啦!"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - noticeMapper.insert(dbNotice); - // 测试 title 不匹配 - noticeMapper.insert(cloneIgnoreId(dbNotice, o -> o.setTitle("尼古拉斯凯奇也来啦!"))); - // 测试 status 不匹配 - noticeMapper.insert(cloneIgnoreId(dbNotice, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - NoticePageReqVO reqVO = new NoticePageReqVO(); - reqVO.setTitle("尼古拉斯赵四来啦!"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = noticeService.getNoticePage(reqVO); - // 验证查询结果经过筛选 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotice, pageResult.getList().get(0)); - } - - @Test - public void testGetNotice_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNotice); - - // 查询 - NoticeDO notice = noticeService.getNotice(dbNotice.getId()); - - // 验证插入与读取对象是否一致 - assertNotNull(notice); - assertPojoEquals(dbNotice, notice); - } - - @Test - public void testCreateNotice_success() { - // 准备参数 - NoticeSaveReqVO reqVO = randomPojo(NoticeSaveReqVO.class) - .setId(null); // 避免 id 被赋值 - - // 调用 - Long noticeId = noticeService.createNotice(reqVO); - // 校验插入属性是否正确 - assertNotNull(noticeId); - NoticeDO notice = noticeMapper.selectById(noticeId); - assertPojoEquals(reqVO, notice, "id"); - } - - @Test - public void testUpdateNotice_success() { - // 插入前置数据 - NoticeDO dbNoticeDO = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNoticeDO); - - // 准备更新参数 - NoticeSaveReqVO reqVO = randomPojo(NoticeSaveReqVO.class, o -> o.setId(dbNoticeDO.getId())); - - // 更新 - noticeService.updateNotice(reqVO); - // 检验是否更新成功 - NoticeDO notice = noticeMapper.selectById(reqVO.getId()); - assertPojoEquals(reqVO, notice); - } - - @Test - public void testDeleteNotice_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNotice); - - // 删除 - noticeService.deleteNotice(dbNotice.getId()); - - // 检查是否删除成功 - assertNull(noticeMapper.selectById(dbNotice.getId())); - } - - @Test - public void testValidateNoticeExists_success() { - // 插入前置数据 - NoticeDO dbNotice = randomPojo(NoticeDO.class); - noticeMapper.insert(dbNotice); - - // 成功调用 - noticeService.validateNoticeExists(dbNotice.getId()); - } - - @Test - public void testValidateNoticeExists_noExists() { - assertServiceException(() -> - noticeService.validateNoticeExists(randomLongId()), NOTICE_NOT_FOUND); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java deleted file mode 100644 index 9e2158da1..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java +++ /dev/null @@ -1,280 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notify; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper; -import com.baomidou.mybatisplus.annotation.DbType; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link NotifyMessageServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(NotifyMessageServiceImpl.class) -public class NotifyMessageServiceImplTest extends BaseDbUnitTest { - - @Resource - private NotifyMessageServiceImpl notifyMessageService; - - @Resource - private NotifyMessageMapper notifyMessageMapper; - - @Test - public void testCreateNotifyMessage_success() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class); - String templateContent = randomString(); - Map templateParams = randomTemplateParams(); - // mock 方法 - - // 调用 - Long messageId = notifyMessageService.createNotifyMessage(userId, userType, - template, templateContent, templateParams); - // 断言 - NotifyMessageDO message = notifyMessageMapper.selectById(messageId); - assertNotNull(message); - assertEquals(userId, message.getUserId()); - assertEquals(userType, message.getUserType()); - assertEquals(template.getId(), message.getTemplateId()); - assertEquals(template.getCode(), message.getTemplateCode()); - assertEquals(template.getType(), message.getTemplateType()); - assertEquals(template.getNickname(), message.getTemplateNickname()); - assertEquals(templateContent, message.getTemplateContent()); - assertEquals(templateParams, message.getTemplateParams()); - assertEquals(false, message.getReadStatus()); - assertNull(message.getReadTime()); - } - - @Test - public void testGetNotifyMessagePage() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setTemplateCode("test_01"); - o.setTemplateType(10); - o.setCreateTime(buildTime(2022, 1, 2)); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 templateCode 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateCode("test_11"))); - // 测试 templateType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateType(20))); - // 测试 createTime 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1)))); - // 准备参数 - NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO(); - reqVO.setUserId(1L); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setTemplateCode("est_01"); - reqVO.setTemplateType(10); - reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10)); - - // 调用 - PageResult pageResult = notifyMessageService.getNotifyMessagePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyMessage() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, - o -> o.setTemplateParams(randomTemplateParams())); - notifyMessageMapper.insert(dbNotifyMessage); - // 准备参数 - Long id = dbNotifyMessage.getId(); - - // 调用 - NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id); - assertPojoEquals(dbNotifyMessage, notifyMessage); - } - - @Test - public void testGetMyNotifyMessagePage() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(true); - o.setCreateTime(buildTime(2022, 1, 2)); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(false))); - // 测试 createTime 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1)))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - NotifyMessageMyPageReqVO reqVO = new NotifyMessageMyPageReqVO(); - reqVO.setReadStatus(true); - reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10)); - - // 调用 - PageResult pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO, userId, userType); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0)); - } - - @Test - public void testGetUnreadNotifyMessageList() { - SqlConstants.init(DbType.MYSQL); - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - Integer size = 10; - - // 调用 - List list = notifyMessageService.getUnreadNotifyMessageList(userId, userType, size); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbNotifyMessage, list.get(0)); - } - - @Test - public void testGetUnreadNotifyMessageCount() { - SqlConstants.init(DbType.MYSQL); - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - - // 调用,并断言 - assertEquals(1, notifyMessageService.getUnreadNotifyMessageCount(userId, userType)); - } - - @Test - public void testUpdateNotifyMessageRead() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setReadTime(null); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Collection ids = Arrays.asList(dbNotifyMessage.getId(), dbNotifyMessage.getId() + 1, - dbNotifyMessage.getId() + 2, dbNotifyMessage.getId() + 3); - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - - // 调用 - int updateCount = notifyMessageService.updateNotifyMessageRead(ids, userId, userType); - // 断言 - assertEquals(1, updateCount); - NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId()); - assertTrue(notifyMessage.getReadStatus()); - assertNotNull(notifyMessage.getReadTime()); - } - - @Test - public void testUpdateAllNotifyMessageRead() { - // mock 数据 - NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到 - o.setUserId(1L); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setReadStatus(false); - o.setReadTime(null); - o.setTemplateParams(randomTemplateParams()); - }); - notifyMessageMapper.insert(dbNotifyMessage); - // 测试 userId 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L))); - // 测试 userType 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 readStatus 不匹配 - notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true))); - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - - // 调用 - int updateCount = notifyMessageService.updateAllNotifyMessageRead(userId, userType); - // 断言 - assertEquals(1, updateCount); - NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId()); - assertTrue(notifyMessage.getReadStatus()); - assertNotNull(notifyMessage.getReadTime()); - } - - private static Map randomTemplateParams() { - return MapUtil.builder().put(randomString(), randomString()) - .put(randomString(), randomString()).build(); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java deleted file mode 100644 index 9dbdac431..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notify; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.HashMap; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_SEND_TEMPLATE_PARAM_MISS; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -class NotifySendServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private NotifySendServiceImpl notifySendService; - - @Mock - private NotifyTemplateService notifyTemplateService; - @Mock - private NotifyMessageService notifyMessageService; - - @Test - public void testSendSingleNotifyToAdmin() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock NotifyMessageService 的方法 - Long messageId = randomLongId(); - when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.ADMIN.getValue()), - eq(template), eq(content), eq(templateParams))).thenReturn(messageId); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotifyToAdmin(userId, templateCode, templateParams); - // 断言 - assertEquals(messageId, resultMessageId); - } - - @Test - public void testSendSingleNotifyToMember() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock NotifyMessageService 的方法 - Long messageId = randomLongId(); - when(notifyMessageService.createNotifyMessage(eq(userId), eq(UserTypeEnum.MEMBER.getValue()), - eq(template), eq(content), eq(templateParams))).thenReturn(messageId); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotifyToMember(userId, templateCode, templateParams); - // 断言 - assertEquals(messageId, resultMessageId); - } - - /** - * 发送成功,当短信模板开启时 - */ - @Test - public void testSendSingleNotify_successWhenMailTemplateEnable() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock NotifyMessageService 的方法 - Long messageId = randomLongId(); - when(notifyMessageService.createNotifyMessage(eq(userId), eq(userType), - eq(template), eq(content), eq(templateParams))).thenReturn(messageId); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams); - // 断言 - assertEquals(messageId, resultMessageId); - } - - /** - * 发送成功,当短信模板关闭时 - */ - @Test - public void testSendSingleMail_successWhenSmsTemplateDisable() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock NotifyTemplateService 的方法 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - - // 调用 - Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams); - // 断言 - assertNull(resultMessageId); - verify(notifyTemplateService, never()).formatNotifyTemplateContent(anyString(), anyMap()); - verify(notifyMessageService, never()).createNotifyMessage(anyLong(), anyInt(), any(), anyString(), anyMap()); - } - - @Test - public void testCheckMailTemplateValid_notExists() { - // 准备参数 - String templateCode = randomString(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> notifySendService.validateNotifyTemplate(templateCode), - NOTICE_NOT_FOUND); - } - - @Test - public void testCheckTemplateParams_paramMiss() { - // 准备参数 - NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, - o -> o.setParams(Lists.newArrayList("code"))); - Map templateParams = new HashMap<>(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> notifySendService.validateTemplateParams(template, templateParams), - NOTIFY_SEND_TEMPLATE_PARAM_MISS, "code"); - } - - @Test - public void testSendBatchNotify() { - // 准备参数 - // mock 方法 - - // 调用 - UnsupportedOperationException exception = Assertions.assertThrows( - UnsupportedOperationException.class, - () -> notifySendService.sendBatchNotify(null, null, null, null, null) - ); - // 断言 - assertEquals("暂时不支持该操作,感兴趣可以实现该功能哟!", exception.getMessage()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java deleted file mode 100644 index d49f48cce..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java +++ /dev/null @@ -1,178 +0,0 @@ -package cn.iocoder.yudao.module.system.service.notify; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_TEMPLATE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link NotifyTemplateServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(NotifyTemplateServiceImpl.class) -public class NotifyTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private NotifyTemplateServiceImpl notifyTemplateService; - - @Resource - private NotifyTemplateMapper notifyTemplateMapper; - - @Test - public void testCreateNotifyTemplate_success() { - // 准备参数 - NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class, - o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long notifyTemplateId = notifyTemplateService.createNotifyTemplate(reqVO); - // 断言 - assertNotNull(notifyTemplateId); - // 校验记录的属性是否正确 - NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(notifyTemplateId); - assertPojoEquals(reqVO, notifyTemplate, "id"); - } - - @Test - public void testUpdateNotifyTemplate_success() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class, o -> { - o.setId(dbNotifyTemplate.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - notifyTemplateService.updateNotifyTemplate(reqVO); - // 校验是否更新正确 - NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, notifyTemplate); - } - - @Test - public void testUpdateNotifyTemplate_notExists() { - // 准备参数 - NotifyTemplateSaveReqVO reqVO = randomPojo(NotifyTemplateSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> notifyTemplateService.updateNotifyTemplate(reqVO), NOTIFY_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteNotifyTemplate_success() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbNotifyTemplate.getId(); - - // 调用 - notifyTemplateService.deleteNotifyTemplate(id); - // 校验数据不存在了 - assertNull(notifyTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteNotifyTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> notifyTemplateService.deleteNotifyTemplate(id), NOTIFY_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetNotifyTemplatePage() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class, o -> { // 等会查询到 - o.setName("芋头"); - o.setCode("test_01"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 3)); - }); - notifyTemplateMapper.insert(dbNotifyTemplate); - // 测试 name 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setName("投"))); - // 测试 code 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCode("test_02"))); - // 测试 status 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCreateTime(buildTime(2022, 1, 5)))); - // 准备参数 - NotifyTemplatePageReqVO reqVO = new NotifyTemplatePageReqVO(); - reqVO.setName("芋"); - reqVO.setCode("est_01"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 5)); - - // 调用 - PageResult pageResult = notifyTemplateService.getNotifyTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbNotifyTemplate, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyTemplate() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate); - // 准备参数 - Long id = dbNotifyTemplate.getId(); - - // 调用 - NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplate(id); - // 断言 - assertPojoEquals(dbNotifyTemplate, notifyTemplate); - } - - @Test - public void testGetNotifyTemplateByCodeFromCache() { - // mock 数据 - NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class); - notifyTemplateMapper.insert(dbNotifyTemplate); - // 准备参数 - String code = dbNotifyTemplate.getCode(); - - // 调用 - NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplateByCodeFromCache(code); - // 断言 - assertPojoEquals(dbNotifyTemplate, notifyTemplate); - } - - @Test - public void testFormatNotifyTemplateContent() { - // 准备参数 - Map params = new HashMap<>(); - params.put("name", "小红"); - params.put("what", "饭"); - - // 调用,并断言 - assertEquals("小红,你好,饭吃了吗?", - notifyTemplateService.formatNotifyTemplateContent("{name},你好,{what}吃了吗?", params)); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java deleted file mode 100644 index 1ca22a999..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java +++ /dev/null @@ -1,269 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ApproveDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ApproveMapper; -import org.assertj.core.util.Lists; -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 java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.temporal.ChronoUnit; -import java.util.*; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2ApproveServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(OAuth2ApproveServiceImpl.class) -public class OAuth2ApproveServiceImplTest extends BaseDbUnitTest { - - @Resource - private OAuth2ApproveServiceImpl oauth2ApproveService; - - @Resource - private OAuth2ApproveMapper oauth2ApproveMapper; - - @MockBean - private OAuth2ClientService oauth2ClientService; - - @Test - public void checkForPreApproval_clientAutoApprove() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List requestedScopes = Lists.newArrayList("read"); - // mock 方法 - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))) - .thenReturn(randomPojo(OAuth2ClientDO.class).setAutoApproveScopes(requestedScopes)); - - // 调用 - boolean success = oauth2ApproveService.checkForPreApproval(userId, userType, - clientId, requestedScopes); - // 断言 - assertTrue(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals("read", result.get(0).getScope()); - assertTrue(result.get(0).getApproved()); - assertFalse(DateUtils.isExpired(result.get(0).getExpiresTime())); - } - - @Test - public void checkForPreApproval_approve() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List requestedScopes = Lists.newArrayList("read"); - // mock 方法 - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))) - .thenReturn(randomPojo(OAuth2ClientDO.class).setAutoApproveScopes(null)); - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId) - .setUserType(userType).setClientId(clientId).setScope("read") - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS)).setApproved(true); // 同意 - oauth2ApproveMapper.insert(approve); - - // 调用 - boolean success = oauth2ApproveService.checkForPreApproval(userId, userType, - clientId, requestedScopes); - // 断言 - assertTrue(success); - } - - @Test - public void checkForPreApproval_reject() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List requestedScopes = Lists.newArrayList("read"); - // mock 方法 - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))) - .thenReturn(randomPojo(OAuth2ClientDO.class).setAutoApproveScopes(null)); - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId) - .setUserType(userType).setClientId(clientId).setScope("read") - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS)).setApproved(false); // 拒绝 - oauth2ApproveMapper.insert(approve); - - // 调用 - boolean success = oauth2ApproveService.checkForPreApproval(userId, userType, - clientId, requestedScopes); - // 断言 - assertFalse(success); - } - - @Test - public void testUpdateAfterApproval_none() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - - // 调用 - boolean success = oauth2ApproveService.updateAfterApproval(userId, userType, clientId, - null); - // 断言 - assertTrue(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(0, result.size()); - } - - @Test - public void testUpdateAfterApproval_approved() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - Map requestedScopes = new LinkedHashMap<>(); // 有序,方便判断 - requestedScopes.put("read", true); - requestedScopes.put("write", false); - // mock 方法 - - // 调用 - boolean success = oauth2ApproveService.updateAfterApproval(userId, userType, clientId, - requestedScopes); - // 断言 - assertTrue(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(2, result.size()); - // read - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals("read", result.get(0).getScope()); - assertTrue(result.get(0).getApproved()); - assertFalse(DateUtils.isExpired(result.get(0).getExpiresTime())); - // write - assertEquals(userId, result.get(1).getUserId()); - assertEquals(userType, result.get(1).getUserType()); - assertEquals(clientId, result.get(1).getClientId()); - assertEquals("write", result.get(1).getScope()); - assertFalse(result.get(1).getApproved()); - assertFalse(DateUtils.isExpired(result.get(1).getExpiresTime())); - } - - @Test - public void testUpdateAfterApproval_reject() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - Map requestedScopes = new LinkedHashMap<>(); - requestedScopes.put("write", false); - // mock 方法 - - // 调用 - boolean success = oauth2ApproveService.updateAfterApproval(userId, userType, clientId, - requestedScopes); - // 断言 - assertFalse(success); - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - // write - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals("write", result.get(0).getScope()); - assertFalse(result.get(0).getApproved()); - assertFalse(DateUtils.isExpired(result.get(0).getExpiresTime())); - } - - @Test - public void testGetApproveList() { - // 准备参数 - Long userId = 10L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - String clientId = randomString(); - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId) - .setUserType(userType).setClientId(clientId).setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS)); - oauth2ApproveMapper.insert(approve); // 未过期 - oauth2ApproveMapper.insert(ObjectUtil.clone(approve).setId(null) - .setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), -1L, ChronoUnit.DAYS))); // 已过期 - - // 调用 - List result = oauth2ApproveService.getApproveList(userId, userType, clientId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(approve, result.get(0)); - } - - @Test - public void testSaveApprove_insert() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - String scope = randomString(); - Boolean approved = randomBoolean(); - LocalDateTime expireTime = LocalDateTime.ofInstant(randomDay(1, 30).toInstant(), ZoneId.systemDefault()); - // mock 方法 - - // 调用 - oauth2ApproveService.saveApprove(userId, userType, clientId, - scope, approved, expireTime); - // 断言 - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals(scope, result.get(0).getScope()); - assertEquals(approved, result.get(0).getApproved()); - assertEquals(expireTime, result.get(0).getExpiresTime()); - } - - @Test - public void testSaveApprove_update() { - // mock 数据 - OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class); - oauth2ApproveMapper.insert(approve); - // 准备参数 - Long userId = approve.getUserId(); - Integer userType = approve.getUserType(); - String clientId = approve.getClientId(); - String scope = approve.getScope(); - Boolean approved = randomBoolean(); - LocalDateTime expireTime = LocalDateTime.ofInstant(randomDay(1, 30).toInstant(), ZoneId.systemDefault()); - // mock 方法 - - // 调用 - oauth2ApproveService.saveApprove(userId, userType, clientId, - scope, approved, expireTime); - // 断言 - List result = oauth2ApproveMapper.selectList(); - assertEquals(1, result.size()); - assertEquals(approve.getId(), result.get(0).getId()); - assertEquals(userId, result.get(0).getUserId()); - assertEquals(userType, result.get(0).getUserType()); - assertEquals(clientId, result.get(0).getClientId()); - assertEquals(scope, result.get(0).getScope()); - assertEquals(approved, result.get(0).getApproved()); - assertEquals(expireTime, result.get(0).getExpiresTime()); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImplTest.java deleted file mode 100755 index 3d4e436ab..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ClientServiceImplTest.java +++ /dev/null @@ -1,220 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.client.OAuth2ClientSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2ClientMapper; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Collections; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mockStatic; - -/** - * {@link OAuth2ClientServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(OAuth2ClientServiceImpl.class) -public class OAuth2ClientServiceImplTest extends BaseDbUnitTest { - - @Resource - private OAuth2ClientServiceImpl oauth2ClientService; - - @Resource - private OAuth2ClientMapper oauth2ClientMapper; - - @Test - public void testCreateOAuth2Client_success() { - // 准备参数 - OAuth2ClientSaveReqVO reqVO = randomPojo(OAuth2ClientSaveReqVO.class, - o -> o.setLogo(randomString())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long oauth2ClientId = oauth2ClientService.createOAuth2Client(reqVO); - // 断言 - assertNotNull(oauth2ClientId); - // 校验记录的属性是否正确 - OAuth2ClientDO oAuth2Client = oauth2ClientMapper.selectById(oauth2ClientId); - assertPojoEquals(reqVO, oAuth2Client, "id"); - } - - @Test - public void testUpdateOAuth2Client_success() { - // mock 数据 - OAuth2ClientDO dbOAuth2Client = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(dbOAuth2Client);// @Sql: 先插入出一条存在的数据 - // 准备参数 - OAuth2ClientSaveReqVO reqVO = randomPojo(OAuth2ClientSaveReqVO.class, o -> { - o.setId(dbOAuth2Client.getId()); // 设置更新的 ID - o.setLogo(randomString()); - }); - - // 调用 - oauth2ClientService.updateOAuth2Client(reqVO); - // 校验是否更新正确 - OAuth2ClientDO oAuth2Client = oauth2ClientMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, oAuth2Client); - } - - @Test - public void testUpdateOAuth2Client_notExists() { - // 准备参数 - OAuth2ClientSaveReqVO reqVO = randomPojo(OAuth2ClientSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> oauth2ClientService.updateOAuth2Client(reqVO), OAUTH2_CLIENT_NOT_EXISTS); - } - - @Test - public void testDeleteOAuth2Client_success() { - // mock 数据 - OAuth2ClientDO dbOAuth2Client = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(dbOAuth2Client);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbOAuth2Client.getId(); - - // 调用 - oauth2ClientService.deleteOAuth2Client(id); - // 校验数据不存在了 - assertNull(oauth2ClientMapper.selectById(id)); - } - - @Test - public void testDeleteOAuth2Client_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> oauth2ClientService.deleteOAuth2Client(id), OAUTH2_CLIENT_NOT_EXISTS); - } - - @Test - public void testValidateClientIdExists_withId() { - // mock 数据 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("tudou"); - oauth2ClientMapper.insert(client); - // 准备参数 - Long id = randomLongId(); - String clientId = "tudou"; - - // 调用,不会报错 - assertServiceException(() -> oauth2ClientService.validateClientIdExists(id, clientId), OAUTH2_CLIENT_EXISTS); - } - - @Test - public void testValidateClientIdExists_noId() { - // mock 数据 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("tudou"); - oauth2ClientMapper.insert(client); - // 准备参数 - String clientId = "tudou"; - - // 调用,不会报错 - assertServiceException(() -> oauth2ClientService.validateClientIdExists(null, clientId), OAUTH2_CLIENT_EXISTS); - } - - @Test - public void testGetOAuth2Client() { - // mock 数据 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(clientDO); - // 准备参数 - Long id = clientDO.getId(); - - // 调用,并断言 - OAuth2ClientDO dbClientDO = oauth2ClientService.getOAuth2Client(id); - assertPojoEquals(clientDO, dbClientDO); - } - - @Test - public void testGetOAuth2ClientFromCache() { - // mock 数据 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class); - oauth2ClientMapper.insert(clientDO); - // 准备参数 - String clientId = clientDO.getClientId(); - - // 调用,并断言 - OAuth2ClientDO dbClientDO = oauth2ClientService.getOAuth2ClientFromCache(clientId); - assertPojoEquals(clientDO, dbClientDO); - } - - @Test - public void testGetOAuth2ClientPage() { - // mock 数据 - OAuth2ClientDO dbOAuth2Client = randomPojo(OAuth2ClientDO.class, o -> { // 等会查询到 - o.setName("潜龙"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - oauth2ClientMapper.insert(dbOAuth2Client); - // 测试 name 不匹配 - oauth2ClientMapper.insert(cloneIgnoreId(dbOAuth2Client, o -> o.setName("凤凰"))); - // 测试 status 不匹配 - oauth2ClientMapper.insert(cloneIgnoreId(dbOAuth2Client, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - OAuth2ClientPageReqVO reqVO = new OAuth2ClientPageReqVO(); - reqVO.setName("龙"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = oauth2ClientService.getOAuth2ClientPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbOAuth2Client, pageResult.getList().get(0)); - } - - @Test - public void testValidOAuthClientFromCache() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(OAuth2ClientServiceImpl.class))) - .thenReturn(oauth2ClientService); - - // mock 方法 - OAuth2ClientDO client = randomPojo(OAuth2ClientDO.class).setClientId("default") - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - oauth2ClientMapper.insert(client); - OAuth2ClientDO client02 = randomPojo(OAuth2ClientDO.class).setClientId("disable") - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - oauth2ClientMapper.insert(client02); - - // 调用,并断言 - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache(randomString(), - null, null, null, null), OAUTH2_CLIENT_NOT_EXISTS); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("disable", - null, null, null, null), OAUTH2_CLIENT_DISABLE); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - randomString(), null, null, null), OAUTH2_CLIENT_CLIENT_SECRET_ERROR); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - null, randomString(), null, null), OAUTH2_CLIENT_AUTHORIZED_GRANT_TYPE_NOT_EXISTS); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - null, null, Collections.singleton(randomString()), null), OAUTH2_CLIENT_SCOPE_OVER); - assertServiceException(() -> oauth2ClientService.validOAuthClientFromCache("default", - null, null, null, "test"), OAUTH2_CLIENT_REDIRECT_URI_NOT_MATCH, "test"); - // 成功调用(1:参数完整) - OAuth2ClientDO result = oauth2ClientService.validOAuthClientFromCache(client.getClientId(), client.getSecret(), - client.getAuthorizedGrantTypes().get(0), client.getScopes(), client.getRedirectUris().get(0)); - assertPojoEquals(client, result); - // 成功调用(2:只有 clientId 参数) - result = oauth2ClientService.validOAuthClientFromCache(client.getClientId()); - assertPojoEquals(client, result); - } - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java deleted file mode 100644 index 2ed9c978f..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2CodeDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2CodeMapper; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.OAUTH2_CODE_EXPIRE; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.OAUTH2_CODE_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link OAuth2CodeServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(OAuth2CodeServiceImpl.class) -class OAuth2CodeServiceImplTest extends BaseDbUnitTest { - - @Resource - private OAuth2CodeServiceImpl oauth2CodeService; - - @Resource - private OAuth2CodeMapper oauth2CodeMapper; - - @Test - public void testCreateAuthorizationCode() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = RandomUtil.randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - String redirectUri = randomString(); - String state = randomString(); - - // 调用 - OAuth2CodeDO codeDO = oauth2CodeService.createAuthorizationCode(userId, userType, clientId, - scopes, redirectUri, state); - // 断言 - OAuth2CodeDO dbCodeDO = oauth2CodeMapper.selectByCode(codeDO.getCode()); - assertPojoEquals(codeDO, dbCodeDO, "createTime", "updateTime", "deleted"); - assertEquals(userId, codeDO.getUserId()); - assertEquals(userType, codeDO.getUserType()); - assertEquals(clientId, codeDO.getClientId()); - assertEquals(scopes, codeDO.getScopes()); - assertEquals(redirectUri, codeDO.getRedirectUri()); - assertEquals(state, codeDO.getState()); - assertFalse(DateUtils.isExpired(codeDO.getExpiresTime())); - } - - @Test - public void testConsumeAuthorizationCode_null() { - // 调用,并断言 - assertServiceException(() -> oauth2CodeService.consumeAuthorizationCode(randomString()), - OAUTH2_CODE_NOT_EXISTS); - } - - @Test - public void testConsumeAuthorizationCode_expired() { - // 准备参数 - String code = "test_code"; - // mock 数据 - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class).setCode(code) - .setExpiresTime(LocalDateTime.now().minusDays(1)); - oauth2CodeMapper.insert(codeDO); - - // 调用,并断言 - assertServiceException(() -> oauth2CodeService.consumeAuthorizationCode(code), - OAUTH2_CODE_EXPIRE); - } - - @Test - public void testConsumeAuthorizationCode_success() { - // 准备参数 - String code = "test_code"; - // mock 数据 - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class).setCode(code) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2CodeMapper.insert(codeDO); - - // 调用 - OAuth2CodeDO result = oauth2CodeService.consumeAuthorizationCode(code); - assertPojoEquals(codeDO, result); - assertNull(oauth2CodeMapper.selectByCode(code)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantServiceImplTest.java deleted file mode 100644 index 52c722831..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantServiceImplTest.java +++ /dev/null @@ -1,173 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2CodeDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; -import com.google.common.collect.Lists; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.List; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static java.util.Collections.emptyList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2GrantServiceImpl} 的单元测试 - * - * @author 芋道源码 - */ -public class OAuth2GrantServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private OAuth2GrantServiceImpl oauth2GrantService; - - @Mock - private OAuth2TokenService oauth2TokenService; - @Mock - private OAuth2CodeService oauth2CodeService; - @Mock - private AdminAuthService adminAuthService; - - @Test - public void testGrantImplicit() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.createAccessToken(eq(userId), eq(userType), - eq(clientId), eq(scopes))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantImplicit( - userId, userType, clientId, scopes)); - } - - @Test - public void testGrantAuthorizationCodeForCode() { - // 准备参数 - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - String redirectUri = randomString(); - String state = randomString(); - // mock 方法 - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class); - when(oauth2CodeService.createAuthorizationCode(eq(userId), eq(userType), - eq(clientId), eq(scopes), eq(redirectUri), eq(state))).thenReturn(codeDO); - - // 调用,并断言 - assertEquals(codeDO.getCode(), oauth2GrantService.grantAuthorizationCodeForCode(userId, userType, - clientId, scopes, redirectUri, state)); - } - - @Test - public void testGrantAuthorizationCodeForAccessToken() { - // 准备参数 - String clientId = randomString(); - String code = randomString(); - List scopes = Lists.newArrayList("read", "write"); - String redirectUri = randomString(); - String state = randomString(); - // mock 方法(code) - OAuth2CodeDO codeDO = randomPojo(OAuth2CodeDO.class, o -> { - o.setClientId(clientId); - o.setRedirectUri(redirectUri); - o.setState(state); - o.setScopes(scopes); - }); - when(oauth2CodeService.consumeAuthorizationCode(eq(code))).thenReturn(codeDO); - // mock 方法(创建令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.createAccessToken(eq(codeDO.getUserId()), eq(codeDO.getUserType()), - eq(codeDO.getClientId()), eq(codeDO.getScopes()))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantAuthorizationCodeForAccessToken( - clientId, code, redirectUri, state)); - } - - @Test - public void testGrantPassword() { - // 准备参数 - String username = randomString(); - String password = randomString(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - // mock 方法(认证) - AdminUserDO user = randomPojo(AdminUserDO.class); - when(adminAuthService.authenticate(eq(username), eq(password))).thenReturn(user); - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.createAccessToken(eq(user.getId()), eq(UserTypeEnum.ADMIN.getValue()), - eq(clientId), eq(scopes))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantPassword( - username, password, clientId, scopes)); - } - - @Test - public void testGrantRefreshToken() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.refreshAccessToken(eq(refreshToken), eq(clientId))) - .thenReturn(accessTokenDO); - - // 调用,并断言 - assertPojoEquals(accessTokenDO, oauth2GrantService.grantRefreshToken( - refreshToken, clientId)); - } - - @Test - public void testGrantClientCredentials() { - assertThrows(UnsupportedOperationException.class, - () -> oauth2GrantService.grantClientCredentials(randomString(), emptyList()), - "暂时不支持 client_credentials 授权模式"); - } - - @Test - public void testRevokeToken_clientIdError() { - // 准备参数 - String clientId = randomString(); - String accessToken = randomString(); - // mock 方法 - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class); - when(oauth2TokenService.getAccessToken(eq(accessToken))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertFalse(oauth2GrantService.revokeToken(clientId, accessToken)); - } - - @Test - public void testRevokeToken_success() { - // 准备参数 - String clientId = randomString(); - String accessToken = randomString(); - // mock 方法(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class).setClientId(clientId); - when(oauth2TokenService.getAccessToken(eq(accessToken))).thenReturn(accessTokenDO); - // mock 方法(移除) - when(oauth2TokenService.removeAccessToken(eq(accessToken))).thenReturn(accessTokenDO); - - // 调用,并断言 - assertTrue(oauth2GrantService.revokeToken(clientId, accessToken)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java deleted file mode 100644 index 03e4a02b9..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java +++ /dev/null @@ -1,303 +0,0 @@ -package cn.iocoder.yudao.module.system.service.oauth2; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2ClientDO; -import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2RefreshTokenDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2AccessTokenMapper; -import cn.iocoder.yudao.module.system.dal.mysql.oauth2.OAuth2RefreshTokenMapper; -import cn.iocoder.yudao.module.system.dal.redis.oauth2.OAuth2AccessTokenRedisDAO; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.assertj.core.util.Lists; -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 java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link OAuth2TokenServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import({OAuth2TokenServiceImpl.class, OAuth2AccessTokenRedisDAO.class}) -public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { - - @Resource - private OAuth2TokenServiceImpl oauth2TokenService; - - @Resource - private OAuth2AccessTokenMapper oauth2AccessTokenMapper; - @Resource - private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper; - - @Resource - private OAuth2AccessTokenRedisDAO oauth2AccessTokenRedisDAO; - - @MockBean - private OAuth2ClientService oauth2ClientService; - @MockBean - private AdminUserService adminUserService; - - @Test - public void testCreateAccessToken() { - TenantContextHolder.setTenantId(0L); - // 准备参数 - Long userId = randomLongId(); - Integer userType = UserTypeEnum.ADMIN.getValue(); - String clientId = randomString(); - List scopes = Lists.newArrayList("read", "write"); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId) - .setAccessTokenValiditySeconds(30).setRefreshTokenValiditySeconds(60); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(用户) - AdminUserDO user = randomPojo(AdminUserDO.class); - when(adminUserService.getUser(userId)).thenReturn(user); - - // 调用 - OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(userId, userType, clientId, scopes); - // 断言访问令牌 - OAuth2AccessTokenDO dbAccessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, dbAccessTokenDO, "createTime", "updateTime", "deleted"); - assertEquals(userId, accessTokenDO.getUserId()); - assertEquals(userType, accessTokenDO.getUserType()); - assertEquals(2, accessTokenDO.getUserInfo().size()); - assertEquals(user.getNickname(), accessTokenDO.getUserInfo().get("nickname")); - assertEquals(user.getDeptId().toString(), accessTokenDO.getUserInfo().get("deptId")); - assertEquals(clientId, accessTokenDO.getClientId()); - assertEquals(scopes, accessTokenDO.getScopes()); - assertFalse(DateUtils.isExpired(accessTokenDO.getExpiresTime())); - // 断言访问令牌的缓存 - OAuth2AccessTokenDO redisAccessTokenDO = oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, redisAccessTokenDO, "createTime", "updateTime", "deleted"); - // 断言刷新令牌 - OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectList().get(0); - assertPojoEquals(accessTokenDO, refreshTokenDO, "id", "expiresTime", "createTime", "updateTime", "deleted"); - assertFalse(DateUtils.isExpired(refreshTokenDO.getExpiresTime())); - } - - @Test - public void testRefreshAccessToken_null() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - - // 调用,并断言 - assertServiceException(() -> oauth2TokenService.refreshAccessToken(refreshToken, clientId), - new ErrorCode(400, "无效的刷新令牌")); - } - - @Test - public void testRefreshAccessToken_clientIdError() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(访问令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(refreshToken).setClientId("error"); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - - // 调用,并断言 - assertServiceException(() -> oauth2TokenService.refreshAccessToken(refreshToken, clientId), - new ErrorCode(400, "刷新令牌的客户端编号不正确")); - } - - @Test - public void testRefreshAccessToken_expired() { - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(访问令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(refreshToken).setClientId(clientId) - .setExpiresTime(LocalDateTime.now().minusDays(1)); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - - // 调用,并断言 - assertServiceException(() -> oauth2TokenService.refreshAccessToken(refreshToken, clientId), - new ErrorCode(401, "刷新令牌已过期")); - assertEquals(0, oauth2RefreshTokenMapper.selectCount()); - } - - @Test - public void testRefreshAccessToken_success() { - TenantContextHolder.setTenantId(0L); - // 准备参数 - String refreshToken = randomString(); - String clientId = randomString(); - // mock 方法 - OAuth2ClientDO clientDO = randomPojo(OAuth2ClientDO.class).setClientId(clientId) - .setAccessTokenValiditySeconds(30); - when(oauth2ClientService.validOAuthClientFromCache(eq(clientId))).thenReturn(clientDO); - // mock 数据(访问令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(refreshToken).setClientId(clientId) - .setExpiresTime(LocalDateTime.now().plusDays(1)) - .setUserType(UserTypeEnum.ADMIN.getValue()); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class).setRefreshToken(refreshToken) - .setUserType(refreshTokenDO.getUserType()); - oauth2AccessTokenMapper.insert(accessTokenDO); - oauth2AccessTokenRedisDAO.set(accessTokenDO); - // mock 数据(用户) - AdminUserDO user = randomPojo(AdminUserDO.class); - when(adminUserService.getUser(refreshTokenDO.getUserId())).thenReturn(user); - - // 调用 - OAuth2AccessTokenDO newAccessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, clientId); - // 断言,老的访问令牌被删除 - assertNull(oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken())); - assertNull(oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken())); - // 断言,新的访问令牌 - OAuth2AccessTokenDO dbAccessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(newAccessTokenDO.getAccessToken()); - assertPojoEquals(newAccessTokenDO, dbAccessTokenDO, "createTime", "updateTime", "deleted"); - assertPojoEquals(newAccessTokenDO, refreshTokenDO, "id", "expiresTime", "createTime", "updateTime", "deleted", - "creator", "updater"); - assertFalse(DateUtils.isExpired(newAccessTokenDO.getExpiresTime())); - // 断言,新的访问令牌的缓存 - OAuth2AccessTokenDO redisAccessTokenDO = oauth2AccessTokenRedisDAO.get(newAccessTokenDO.getAccessToken()); - assertPojoEquals(newAccessTokenDO, redisAccessTokenDO, "createTime", "updateTime", "deleted"); - } - - @Test - public void testGetAccessToken() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // 准备参数 - String accessToken = accessTokenDO.getAccessToken(); - - // 调用 - OAuth2AccessTokenDO result = oauth2TokenService.getAccessToken(accessToken); - // 断言 - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", - "creator", "updater"); - assertPojoEquals(accessTokenDO, oauth2AccessTokenRedisDAO.get(accessToken), "createTime", "updateTime", "deleted", - "creator", "updater"); - } - - @Test - public void testCheckAccessToken_null() { - // 调研,并断言 - assertServiceException(() -> oauth2TokenService.checkAccessToken(randomString()), - new ErrorCode(401, "访问令牌不存在")); - } - - @Test - public void testCheckAccessToken_expired() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().minusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // 准备参数 - String accessToken = accessTokenDO.getAccessToken(); - - // 调研,并断言 - assertServiceException(() -> oauth2TokenService.checkAccessToken(accessToken), - new ErrorCode(401, "访问令牌已过期")); - } - - @Test - public void testCheckAccessToken_success() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // 准备参数 - String accessToken = accessTokenDO.getAccessToken(); - - // 调研,并断言 - OAuth2AccessTokenDO result = oauth2TokenService.getAccessToken(accessToken); - // 断言 - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", - "creator", "updater"); - } - - @Test - public void testRemoveAccessToken_null() { - // 调用,并断言 - assertNull(oauth2TokenService.removeAccessToken(randomString())); - } - - @Test - public void testRemoveAccessToken_success() { - // mock 数据(访问令牌) - OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class) - .setExpiresTime(LocalDateTime.now().plusDays(1)); - oauth2AccessTokenMapper.insert(accessTokenDO); - // mock 数据(刷新令牌) - OAuth2RefreshTokenDO refreshTokenDO = randomPojo(OAuth2RefreshTokenDO.class) - .setRefreshToken(accessTokenDO.getRefreshToken()); - oauth2RefreshTokenMapper.insert(refreshTokenDO); - // 调用 - OAuth2AccessTokenDO result = oauth2TokenService.removeAccessToken(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", - "creator", "updater"); - // 断言数据 - assertNull(oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken())); - assertNull(oauth2RefreshTokenMapper.selectByRefreshToken(accessTokenDO.getRefreshToken())); - assertNull(oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken())); - } - - - @Test - public void testGetAccessTokenPage() { - // mock 数据 - OAuth2AccessTokenDO dbAccessToken = randomPojo(OAuth2AccessTokenDO.class, o -> { // 等会查询到 - o.setUserId(10L); - o.setUserType(1); - o.setClientId("test_client"); - o.setExpiresTime(LocalDateTime.now().plusDays(1)); - }); - oauth2AccessTokenMapper.insert(dbAccessToken); - // 测试 userId 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setUserId(20L))); - // 测试 userType 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setUserType(2))); - // 测试 userType 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setClientId("it_client"))); - // 测试 expireTime 不匹配 - oauth2AccessTokenMapper.insert(cloneIgnoreId(dbAccessToken, o -> o.setExpiresTime(LocalDateTimeUtil.now()))); - // 准备参数 - OAuth2AccessTokenPageReqVO reqVO = new OAuth2AccessTokenPageReqVO(); - reqVO.setUserId(10L); - reqVO.setUserType(1); - reqVO.setClientId("test"); - - // 调用 - PageResult pageResult = oauth2TokenService.getAccessTokenPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbAccessToken, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java deleted file mode 100644 index 4a1c87386..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImplTest.java +++ /dev/null @@ -1,331 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuSaveVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; -import cn.iocoder.yudao.module.system.dal.mysql.permission.MenuMapper; -import cn.iocoder.yudao.module.system.enums.permission.MenuTypeEnum; -import cn.iocoder.yudao.module.system.service.tenant.TenantService; -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 java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO.ID_ROOT; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.verify; - -@Import(MenuServiceImpl.class) -public class MenuServiceImplTest extends BaseDbUnitTest { - - @Resource - private MenuServiceImpl menuService; - - @Resource - private MenuMapper menuMapper; - - @MockBean - private PermissionService permissionService; - @MockBean - private TenantService tenantService; - - @Test - public void testCreateMenu_success() { - // mock 数据(构造父菜单) - MenuDO menuDO = buildMenuDO(MenuTypeEnum.MENU, - "parent", 0L); - menuMapper.insert(menuDO); - Long parentId = menuDO.getId(); - // 准备参数 - MenuSaveVO reqVO = randomPojo(MenuSaveVO.class, o -> { - o.setParentId(parentId); - o.setName("testSonName"); - o.setType(MenuTypeEnum.MENU.getType()); - }).setId(null); // 防止 id 被赋值 - Long menuId = menuService.createMenu(reqVO); - - // 校验记录的属性是否正确 - MenuDO dbMenu = menuMapper.selectById(menuId); - assertPojoEquals(reqVO, dbMenu, "id"); - } - - @Test - public void testUpdateMenu_success() { - // mock 数据(构造父子菜单) - MenuDO sonMenuDO = createParentAndSonMenu(); - Long sonId = sonMenuDO.getId(); - // 准备参数 - MenuSaveVO reqVO = randomPojo(MenuSaveVO.class, o -> { - o.setId(sonId); - o.setName("testSonName"); // 修改名字 - o.setParentId(sonMenuDO.getParentId()); - o.setType(MenuTypeEnum.MENU.getType()); - }); - - // 调用 - menuService.updateMenu(reqVO); - // 校验记录的属性是否正确 - MenuDO dbMenu = menuMapper.selectById(sonId); - assertPojoEquals(reqVO, dbMenu); - } - - @Test - public void testUpdateMenu_sonIdNotExist() { - // 准备参数 - MenuSaveVO reqVO = randomPojo(MenuSaveVO.class); - // 调用,并断言异常 - assertServiceException(() -> menuService.updateMenu(reqVO), MENU_NOT_EXISTS); - } - - @Test - public void testDeleteMenu_success() { - // mock 数据 - MenuDO menuDO = randomPojo(MenuDO.class); - menuMapper.insert(menuDO); - // 准备参数 - Long id = menuDO.getId(); - - // 调用 - menuService.deleteMenu(id); - // 断言 - MenuDO dbMenuDO = menuMapper.selectById(id); - assertNull(dbMenuDO); - verify(permissionService).processMenuDeleted(id); - } - - @Test - public void testDeleteMenu_menuNotExist() { - assertServiceException(() -> menuService.deleteMenu(randomLongId()), - MENU_NOT_EXISTS); - } - - @Test - public void testDeleteMenu_existChildren() { - // mock 数据(构造父子菜单) - MenuDO sonMenu = createParentAndSonMenu(); - // 准备参数 - Long parentId = sonMenu.getParentId(); - - // 调用并断言异常 - assertServiceException(() -> menuService.deleteMenu(parentId), MENU_EXISTS_CHILDREN); - } - - @Test - public void testGetMenuList_all() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class); - menuMapper.insert(menu101); - // 准备参数 - - // 调用 - List list = menuService.getMenuList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(menu100, list.get(0)); - assertPojoEquals(menu101, list.get(1)); - } - - @Test - public void testGetMenuList() { - // mock 数据 - MenuDO menuDO = randomPojo(MenuDO.class, o -> o.setName("芋艿").setStatus(CommonStatusEnum.ENABLE.getStatus())); - menuMapper.insert(menuDO); - // 测试 status 不匹配 - menuMapper.insert(cloneIgnoreId(menuDO, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 name 不匹配 - menuMapper.insert(cloneIgnoreId(menuDO, o -> o.setName("艿"))); - // 准备参数 - MenuListReqVO reqVO = new MenuListReqVO().setName("芋").setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - List result = menuService.getMenuList(reqVO); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(menuDO, result.get(0)); - } - - @Test - public void testGetMenuListByTenant() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class, o -> o.setId(100L).setStatus(CommonStatusEnum.ENABLE.getStatus())); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class, o -> o.setId(101L).setStatus(CommonStatusEnum.DISABLE.getStatus())); - menuMapper.insert(menu101); - MenuDO menu102 = randomPojo(MenuDO.class, o -> o.setId(102L).setStatus(CommonStatusEnum.ENABLE.getStatus())); - menuMapper.insert(menu102); - // mock 过滤菜单 - Set menuIds = asSet(100L, 101L); - doNothing().when(tenantService).handleTenantMenu(argThat(handler -> { - handler.handle(menuIds); - return true; - })); - // 准备参数 - MenuListReqVO reqVO = new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - List result = menuService.getMenuListByTenant(reqVO); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(menu100, result.get(0)); - } - - @Test - public void testGetMenuIdListByPermissionFromCache() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class); - menuMapper.insert(menu101); - // 准备参数 - String permission = menu100.getPermission(); - - // 调用 - List ids = menuService.getMenuIdListByPermissionFromCache(permission); - // 断言 - assertEquals(1, ids.size()); - assertEquals(menu100.getId(), ids.get(0)); - } - - @Test - public void testGetMenuList_ids() { - // mock 数据 - MenuDO menu100 = randomPojo(MenuDO.class); - menuMapper.insert(menu100); - MenuDO menu101 = randomPojo(MenuDO.class); - menuMapper.insert(menu101); - // 准备参数 - Collection ids = Collections.singleton(menu100.getId()); - - // 调用 - List list = menuService.getMenuList(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(menu100, list.get(0)); - } - - @Test - public void testGetMenu() { - // mock 数据 - MenuDO menu = randomPojo(MenuDO.class); - menuMapper.insert(menu); - // 准备参数 - Long id = menu.getId(); - - // 调用 - MenuDO dbMenu = menuService.getMenu(id); - // 断言 - assertPojoEquals(menu, dbMenu); - } - - @Test - public void testValidateParentMenu_success() { - // mock 数据 - MenuDO menuDO = buildMenuDO(MenuTypeEnum.MENU, "parent", 0L); - menuMapper.insert(menuDO); - // 准备参数 - Long parentId = menuDO.getId(); - - // 调用,无需断言 - menuService.validateParentMenu(parentId, null); - } - - @Test - public void testValidateParentMenu_canNotSetSelfToBeParent() { - // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(1L, 1L), - MENU_PARENT_ERROR); - } - - @Test - public void testValidateParentMenu_parentNotExist() { - // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(randomLongId(), null), - MENU_PARENT_NOT_EXISTS); - } - - @Test - public void testValidateParentMenu_parentTypeError() { - // mock 数据 - MenuDO menuDO = buildMenuDO(MenuTypeEnum.BUTTON, "parent", 0L); - menuMapper.insert(menuDO); - // 准备参数 - Long parentId = menuDO.getId(); - - // 调用,并断言异常 - assertServiceException(() -> menuService.validateParentMenu(parentId, null), - MENU_PARENT_NOT_DIR_OR_MENU); - } - - @Test - public void testValidateMenu_success() { - // mock 父子菜单 - MenuDO sonMenu = createParentAndSonMenu(); - // 准备参数 - Long parentId = sonMenu.getParentId(); - Long otherSonMenuId = randomLongId(); - String otherSonMenuName = randomString(); - - // 调用,无需断言 - menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId); - } - - @Test - public void testValidateMenu_sonMenuNameDuplicate() { - // mock 父子菜单 - MenuDO sonMenu = createParentAndSonMenu(); - // 准备参数 - Long parentId = sonMenu.getParentId(); - Long otherSonMenuId = randomLongId(); - String otherSonMenuName = sonMenu.getName(); //相同名称 - - // 调用,并断言异常 - assertServiceException(() -> menuService.validateMenu(parentId, otherSonMenuName, otherSonMenuId), - MENU_NAME_DUPLICATE); - } - - // ====================== 初始化方法 ====================== - - /** - * 插入父子菜单,返回子菜单 - * - * @return 子菜单 - */ - private MenuDO createParentAndSonMenu() { - // 构造父子菜单 - MenuDO parentMenuDO = buildMenuDO(MenuTypeEnum.MENU, "parent", ID_ROOT); - menuMapper.insert(parentMenuDO); - // 构建子菜单 - MenuDO sonMenuDO = buildMenuDO(MenuTypeEnum.MENU, "testSonName", - parentMenuDO.getParentId()); - menuMapper.insert(sonMenuDO); - return sonMenuDO; - } - - private MenuDO buildMenuDO(MenuTypeEnum type, String name, Long parentId) { - return buildMenuDO(type, name, parentId, randomCommonStatus()); - } - - private MenuDO buildMenuDO(MenuTypeEnum type, String name, Long parentId, Integer status) { - return randomPojo(MenuDO.class, o -> o.setId(null).setName(name).setParentId(parentId) - .setType(type.getType()).setStatus(status)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java deleted file mode 100644 index 442abd741..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceTest.java +++ /dev/null @@ -1,527 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleMenuDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMenuMapper; -import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; -import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; -import cn.iocoder.yudao.module.system.service.dept.DeptService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.hutool.core.collection.ListUtil.toList; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import({PermissionServiceImpl.class}) -public class PermissionServiceTest extends BaseDbUnitTest { - - @Resource - private PermissionServiceImpl permissionService; - - @Resource - private RoleMenuMapper roleMenuMapper; - @Resource - private UserRoleMapper userRoleMapper; - - @MockBean - private RoleService roleService; - @MockBean - private MenuService menuService; - @MockBean - private DeptService deptService; - @MockBean - private AdminUserService userService; - - @Test - public void testHasAnyPermissions_superAdmin() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - String[] roles = new String[]{"system:user:query", "system:user:create"}; - // mock 用户登录的角色 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - RoleDO role = randomPojo(RoleDO.class, o -> o.setId(100L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(100L)))).thenReturn(toList(role)); - // mock 其它方法 - when(roleService.hasAnySuperAdmin(eq(asSet(100L)))).thenReturn(true); - - // 调用,并断言 - assertTrue(permissionService.hasAnyPermissions(userId, roles)); - } - } - - @Test - public void testHasAnyPermissions_normal() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - String[] roles = new String[]{"system:user:query", "system:user:create"}; - // mock 用户登录的角色 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - RoleDO role = randomPojo(RoleDO.class, o -> o.setId(100L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(100L)))).thenReturn(toList(role)); - // mock 菜单 - Long menuId = 1000L; - when(menuService.getMenuIdListByPermissionFromCache( - eq("system:user:create"))).thenReturn(singletonList(menuId)); - roleMenuMapper.insert(randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(1000L)); - - // 调用,并断言 - assertTrue(permissionService.hasAnyPermissions(userId, roles)); - } - } - - @Test - public void testHasAnyRoles() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - String[] roles = new String[]{"yunai", "tudou"}; - // mock 用户与角色的缓存 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - RoleDO role = randomPojo(RoleDO.class, o -> o.setId(100L).setCode("tudou") - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(100L)))).thenReturn(toList(role)); - - // 调用,并断言 - assertTrue(permissionService.hasAnyRoles(userId, roles)); - } - } - - // ========== 角色-菜单的相关方法 ========== - - @Test - public void testAssignRoleMenu() { - // 准备参数 - Long roleId = 1L; - Set menuIds = asSet(200L, 300L); - // mock 数据 - RoleMenuDO roleMenu01 = randomPojo(RoleMenuDO.class).setRoleId(1L).setMenuId(100L); - roleMenuMapper.insert(roleMenu01); - RoleMenuDO roleMenu02 = randomPojo(RoleMenuDO.class).setRoleId(1L).setMenuId(200L); - roleMenuMapper.insert(roleMenu02); - - // 调用 - permissionService.assignRoleMenu(roleId, menuIds); - // 断言 - List roleMenuList = roleMenuMapper.selectList(); - assertEquals(2, roleMenuList.size()); - assertEquals(1L, roleMenuList.get(0).getRoleId()); - assertEquals(200L, roleMenuList.get(0).getMenuId()); - assertEquals(1L, roleMenuList.get(1).getRoleId()); - assertEquals(300L, roleMenuList.get(1).getMenuId()); - } - - @Test - public void testProcessRoleDeleted() { - // 准备参数 - Long roleId = randomLongId(); - // mock 数据 UserRole - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setRoleId(roleId)); // 被删除 - userRoleMapper.insert(userRoleDO01); - UserRoleDO userRoleDO02 = randomPojo(UserRoleDO.class); // 不被删除 - userRoleMapper.insert(userRoleDO02); - // mock 数据 RoleMenu - RoleMenuDO roleMenuDO01 = randomPojo(RoleMenuDO.class, o -> o.setRoleId(roleId)); // 被删除 - roleMenuMapper.insert(roleMenuDO01); - RoleMenuDO roleMenuDO02 = randomPojo(RoleMenuDO.class); // 不被删除 - roleMenuMapper.insert(roleMenuDO02); - - // 调用 - permissionService.processRoleDeleted(roleId); - // 断言数据 RoleMenuDO - List dbRoleMenus = roleMenuMapper.selectList(); - assertEquals(1, dbRoleMenus.size()); - assertPojoEquals(dbRoleMenus.get(0), roleMenuDO02); - // 断言数据 UserRoleDO - List dbUserRoles = userRoleMapper.selectList(); - assertEquals(1, dbUserRoles.size()); - assertPojoEquals(dbUserRoles.get(0), userRoleDO02); - } - - @Test - public void testProcessMenuDeleted() { - // 准备参数 - Long menuId = randomLongId(); - // mock 数据 - RoleMenuDO roleMenuDO01 = randomPojo(RoleMenuDO.class, o -> o.setMenuId(menuId)); // 被删除 - roleMenuMapper.insert(roleMenuDO01); - RoleMenuDO roleMenuDO02 = randomPojo(RoleMenuDO.class); // 不被删除 - roleMenuMapper.insert(roleMenuDO02); - - // 调用 - permissionService.processMenuDeleted(menuId); - // 断言数据 - List dbRoleMenus = roleMenuMapper.selectList(); - assertEquals(1, dbRoleMenus.size()); - assertPojoEquals(dbRoleMenus.get(0), roleMenuDO02); - } - - @Test - public void testGetRoleMenuIds_superAdmin() { - // 准备参数 - Long roleId = 100L; - // mock 方法 - when(roleService.hasAnySuperAdmin(eq(singleton(100L)))).thenReturn(true); - List menuList = singletonList(randomPojo(MenuDO.class).setId(1L)); - when(menuService.getMenuList()).thenReturn(menuList); - - // 调用 - Set menuIds = permissionService.getRoleMenuListByRoleId(roleId); - // 断言 - assertEquals(singleton(1L), menuIds); - } - - @Test - public void testGetRoleMenuIds_normal() { - // 准备参数 - Long roleId = 100L; - // mock 数据 - RoleMenuDO roleMenu01 = randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(1L); - roleMenuMapper.insert(roleMenu01); - RoleMenuDO roleMenu02 = randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(2L); - roleMenuMapper.insert(roleMenu02); - - // 调用 - Set menuIds = permissionService.getRoleMenuListByRoleId(roleId); - // 断言 - assertEquals(asSet(1L, 2L), menuIds); - } - - @Test - public void testGetMenuRoleIdListByMenuIdFromCache() { - // 准备参数 - Long menuId = 1L; - // mock 数据 - RoleMenuDO roleMenu01 = randomPojo(RoleMenuDO.class).setRoleId(100L).setMenuId(1L); - roleMenuMapper.insert(roleMenu01); - RoleMenuDO roleMenu02 = randomPojo(RoleMenuDO.class).setRoleId(200L).setMenuId(1L); - roleMenuMapper.insert(roleMenu02); - - // 调用 - Set roleIds = permissionService.getMenuRoleIdListByMenuIdFromCache(menuId); - // 断言 - assertEquals(asSet(100L, 200L), roleIds); - } - - // ========== 用户-角色的相关方法 ========== - - @Test - public void testAssignUserRole() { - // 准备参数 - Long userId = 1L; - Set roleIds = asSet(200L, 300L); - // mock 数据 - UserRoleDO userRole01 = randomPojo(UserRoleDO.class).setUserId(1L).setRoleId(100L); - userRoleMapper.insert(userRole01); - UserRoleDO userRole02 = randomPojo(UserRoleDO.class).setUserId(1L).setRoleId(200L); - userRoleMapper.insert(userRole02); - - // 调用 - permissionService.assignUserRole(userId, roleIds); - // 断言 - List userRoleDOList = userRoleMapper.selectList(); - assertEquals(2, userRoleDOList.size()); - assertEquals(1L, userRoleDOList.get(0).getUserId()); - assertEquals(200L, userRoleDOList.get(0).getRoleId()); - assertEquals(1L, userRoleDOList.get(1).getUserId()); - assertEquals(300L, userRoleDOList.get(1).getRoleId()); - } - - @Test - public void testProcessUserDeleted() { - // 准备参数 - Long userId = randomLongId(); - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(userId)); // 被删除 - userRoleMapper.insert(userRoleDO01); - UserRoleDO userRoleDO02 = randomPojo(UserRoleDO.class); // 不被删除 - userRoleMapper.insert(userRoleDO02); - - // 调用 - permissionService.processUserDeleted(userId); - // 断言数据 - List dbUserRoles = userRoleMapper.selectList(); - assertEquals(1, dbUserRoles.size()); - assertPojoEquals(dbUserRoles.get(0), userRoleDO02); - } - - @Test - public void testGetUserRoleIdListByUserId() { - // 准备参数 - Long userId = 1L; - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByUserId(userId); - // 断言 - assertEquals(asSet(10L, 20L), result); - } - - @Test - public void testGetUserRoleIdListByUserIdFromCache() { - // 准备参数 - Long userId = 1L; - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByUserIdFromCache(userId); - // 断言 - assertEquals(asSet(10L, 20L), result); - } - - @Test - public void testGetUserRoleIdsFromCache() { - // 准备参数 - Long userId = 1L; - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByUserIdFromCache(userId); - // 断言 - assertEquals(asSet(10L, 20L), result); - } - - @Test - public void testGetUserRoleIdListByRoleId() { - // 准备参数 - Collection roleIds = asSet(10L, 20L); - // mock 数据 - UserRoleDO userRoleDO01 = randomPojo(UserRoleDO.class, o -> o.setUserId(1L).setRoleId(10L)); - userRoleMapper.insert(userRoleDO01); - UserRoleDO roleMenuDO02 = randomPojo(UserRoleDO.class, o -> o.setUserId(2L).setRoleId(20L)); - userRoleMapper.insert(roleMenuDO02); - - // 调用 - Set result = permissionService.getUserRoleIdListByRoleId(roleIds); - // 断言 - assertEquals(asSet(1L, 2L), result); - } - - @Test - public void testGetEnableUserRoleListByUserIdFromCache() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户登录的角色 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(100L)); - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(200L)); - RoleDO role01 = randomPojo(RoleDO.class, o -> o.setId(100L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - RoleDO role02 = randomPojo(RoleDO.class, o -> o.setId(200L) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(asSet(100L, 200L)))) - .thenReturn(toList(role01, role02)); - - // 调用 - List result = permissionService.getEnableUserRoleListByUserIdFromCache(userId); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(role01, result.get(0)); - } - } - - // ========== 用户-部门的相关方法 ========== - - @Test - public void testAssignRoleDataScope() { - // 准备参数 - Long roleId = 1L; - Integer dataScope = 2; - Set dataScopeDeptIds = asSet(10L, 20L); - - // 调用 - permissionService.assignRoleDataScope(roleId, dataScope, dataScopeDeptIds); - // 断言 - verify(roleService).updateRoleDataScope(eq(roleId), eq(dataScope), eq(dataScopeDeptIds)); - } - - @Test - public void testGetDeptDataPermission_All() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.ALL.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertTrue(result.getAll()); - assertFalse(result.getSelf()); - assertTrue(CollUtil.isEmpty(result.getDeptIds())); - } - } - - @Test - public void testGetDeptDataPermission_DeptCustom() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.DEPT_CUSTOM.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - // mock 部门的返回 - when(userService.getUser(eq(1L))).thenReturn(new AdminUserDO().setDeptId(3L), - null, null); // 最后返回 null 的目的,看看会不会重复调用 - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertFalse(result.getSelf()); - assertEquals(roleDO.getDataScopeDeptIds().size() + 1, result.getDeptIds().size()); - assertTrue(CollUtil.containsAll(result.getDeptIds(), roleDO.getDataScopeDeptIds())); - assertTrue(CollUtil.contains(result.getDeptIds(), 3L)); - } - } - - @Test - public void testGetDeptDataPermission_DeptOnly() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.DEPT_ONLY.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - // mock 部门的返回 - when(userService.getUser(eq(1L))).thenReturn(new AdminUserDO().setDeptId(3L), - null, null); // 最后返回 null 的目的,看看会不会重复调用 - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertFalse(result.getSelf()); - assertEquals(1, result.getDeptIds().size()); - assertTrue(CollUtil.contains(result.getDeptIds(), 3L)); - } - } - - @Test - public void testGetDeptDataPermission_DeptAndChild() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.DEPT_AND_CHILD.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - // mock 部门的返回 - when(userService.getUser(eq(1L))).thenReturn(new AdminUserDO().setDeptId(3L), - null, null); // 最后返回 null 的目的,看看会不会重复调用 - // mock 方法(部门) - DeptDO deptDO = randomPojo(DeptDO.class); - when(deptService.getChildDeptIdListFromCache(eq(3L))).thenReturn(singleton(deptDO.getId())); - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertFalse(result.getSelf()); - assertEquals(2, result.getDeptIds().size()); - assertTrue(CollUtil.contains(result.getDeptIds(), deptDO.getId())); - assertTrue(CollUtil.contains(result.getDeptIds(), 3L)); - } - } - - @Test - public void testGetDeptDataPermission_Self() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PermissionServiceImpl.class))) - .thenReturn(permissionService); - - // 准备参数 - Long userId = 1L; - // mock 用户的角色编号 - userRoleMapper.insert(randomPojo(UserRoleDO.class).setUserId(userId).setRoleId(2L)); - // mock 获得用户的角色 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setDataScope(DataScopeEnum.SELF.getScope()) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(roleService.getRoleListFromCache(eq(singleton(2L)))).thenReturn(toList(roleDO)); - - // 调用 - DeptDataPermissionRespDTO result = permissionService.getDeptDataPermission(userId); - // 断言 - assertFalse(result.getAll()); - assertTrue(result.getSelf()); - assertTrue(CollUtil.isEmpty(result.getDeptIds())); - } - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java deleted file mode 100644 index 51c1de6ca..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImplTest.java +++ /dev/null @@ -1,371 +0,0 @@ -package cn.iocoder.yudao.module.system.service.permission; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMapper; -import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; -import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.verify; - -@Import(RoleServiceImpl.class) -public class RoleServiceImplTest extends BaseDbUnitTest { - - @Resource - private RoleServiceImpl roleService; - - @Resource - private RoleMapper roleMapper; - - @MockBean - private PermissionService permissionService; - - @Test - public void testCreateRole() { - // 准备参数 - RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long roleId = roleService.createRole(reqVO, null); - // 断言 - RoleDO roleDO = roleMapper.selectById(roleId); - assertPojoEquals(reqVO, roleDO, "id"); - assertEquals(RoleTypeEnum.CUSTOM.getType(), roleDO.getType()); - assertEquals(CommonStatusEnum.ENABLE.getStatus(), roleDO.getStatus()); - assertEquals(DataScopeEnum.ALL.getScope(), roleDO.getDataScope()); - } - - @Test - public void testUpdateRole() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - RoleSaveReqVO reqVO = randomPojo(RoleSaveReqVO.class, o -> o.setId(id)); - - // 调用 - roleService.updateRole(reqVO); - // 断言 - RoleDO newRoleDO = roleMapper.selectById(id); - assertPojoEquals(reqVO, newRoleDO); - } - - @Test - public void testUpdateRoleDataScope() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - Integer dataScope = randomEle(DataScopeEnum.values()).getScope(); - Set dataScopeRoleIds = randomSet(Long.class); - - // 调用 - roleService.updateRoleDataScope(id, dataScope, dataScopeRoleIds); - // 断言 - RoleDO dbRoleDO = roleMapper.selectById(id); - assertEquals(dataScope, dbRoleDO.getDataScope()); - assertEquals(dataScopeRoleIds, dbRoleDO.getDataScopeDeptIds()); - } - - @Test - public void testDeleteRole() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.CUSTOM.getType())); - roleMapper.insert(roleDO); - // 参数准备 - Long id = roleDO.getId(); - - // 调用 - roleService.deleteRole(id); - // 断言 - assertNull(roleMapper.selectById(id)); - // verify 删除相关数据 - verify(permissionService).processRoleDeleted(id); - } - - @Test - public void testValidateRoleDuplicate_success() { - // 调用,不会抛异常 - roleService.validateRoleDuplicate(randomString(), randomString(), null); - } - - @Test - public void testValidateRoleDuplicate_nameDuplicate() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setName("role_name")); - roleMapper.insert(roleDO); - // 准备参数 - String name = "role_name"; - - // 调用,并断言异常 - assertServiceException(() -> roleService.validateRoleDuplicate(name, randomString(), null), - ROLE_NAME_DUPLICATE, name); - } - - @Test - public void testValidateRoleDuplicate_codeDuplicate() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setCode("code")); - roleMapper.insert(roleDO); - // 准备参数 - String code = "code"; - - // 调用,并断言异常 - assertServiceException(() -> roleService.validateRoleDuplicate(randomString(), code, null), - ROLE_CODE_DUPLICATE, code); - } - - @Test - public void testValidateUpdateRole_success() { - RoleDO roleDO = randomPojo(RoleDO.class); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - - // 调用,无异常 - roleService.validateRoleForUpdate(id); - } - - @Test - public void testValidateUpdateRole_roleIdNotExist() { - assertServiceException(() -> roleService.validateRoleForUpdate(randomLongId()), ROLE_NOT_EXISTS); - } - - @Test - public void testValidateUpdateRole_systemRoleCanNotBeUpdate() { - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setType(RoleTypeEnum.SYSTEM.getType())); - roleMapper.insert(roleDO); - // 准备参数 - Long id = roleDO.getId(); - - assertServiceException(() -> roleService.validateRoleForUpdate(id), - ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE); - } - - @Test - public void testGetRole() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class); - roleMapper.insert(roleDO); - // 参数准备 - Long id = roleDO.getId(); - - // 调用 - RoleDO dbRoleDO = roleService.getRole(id); - // 断言 - assertPojoEquals(roleDO, dbRoleDO); - } - - @Test - public void testGetRoleFromCache() { - // mock 数据(缓存) - RoleDO roleDO = randomPojo(RoleDO.class); - roleMapper.insert(roleDO); - // 参数准备 - Long id = roleDO.getId(); - - // 调用 - RoleDO dbRoleDO = roleService.getRoleFromCache(id); - // 断言 - assertPojoEquals(roleDO, dbRoleDO); - } - - @Test - public void testGetRoleListByStatus() { - // mock 数据 - RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole01); - RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(dbRole02); - - // 调用 - List list = roleService.getRoleListByStatus( - singleton(CommonStatusEnum.ENABLE.getStatus())); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRole01, list.get(0)); - } - - @Test - public void testGetRoleList() { - // mock 数据 - RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole01); - RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(dbRole02); - - // 调用 - List list = roleService.getRoleList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(dbRole01, list.get(0)); - assertPojoEquals(dbRole02, list.get(1)); - } - - @Test - public void testGetRoleList_ids() { - // mock 数据 - RoleDO dbRole01 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole01); - RoleDO dbRole02 = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(dbRole02); - // 准备参数 - Collection ids = singleton(dbRole01.getId()); - - // 调用 - List list = roleService.getRoleList(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRole01, list.get(0)); - } - - @Test - public void testGetRoleListFromCache() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(RoleServiceImpl.class))) - .thenReturn(roleService); - - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(dbRole); - // 测试 id 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> {})); - // 准备参数 - Collection ids = singleton(dbRole.getId()); - - // 调用 - List list = roleService.getRoleListFromCache(ids); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRole, list.get(0)); - } - } - - @Test - public void testGetRolePage() { - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class, o -> { // 等会查询到 - o.setName("土豆"); - o.setCode("tudou"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2022, 2, 8)); - }); - roleMapper.insert(dbRole); - // 测试 name 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> o.setName("红薯"))); - // 测试 code 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> o.setCode("hong"))); - // 测试 createTime 不匹配 - roleMapper.insert(cloneIgnoreId(dbRole, o -> o.setCreateTime(buildTime(2022, 2, 16)))); - // 准备参数 - RolePageReqVO reqVO = new RolePageReqVO(); - reqVO.setName("土豆"); - reqVO.setCode("tu"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 12)); - - // 调用 - PageResult pageResult = roleService.getRolePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRole, pageResult.getList().get(0)); - } - - @Test - public void testHasAnySuperAdmin_true() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(RoleServiceImpl.class))) - .thenReturn(roleService); - - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class).setCode("super_admin"); - roleMapper.insert(dbRole); - // 准备参数 - Long id = dbRole.getId(); - - // 调用,并调用 - assertTrue(roleService.hasAnySuperAdmin(singletonList(id))); - } - } - - @Test - public void testHasAnySuperAdmin_false() { - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(RoleServiceImpl.class))) - .thenReturn(roleService); - - // mock 数据 - RoleDO dbRole = randomPojo(RoleDO.class).setCode("tenant_admin"); - roleMapper.insert(dbRole); - // 准备参数 - Long id = dbRole.getId(); - - // 调用,并调用 - assertFalse(roleService.hasAnySuperAdmin(singletonList(id))); - } - } - - @Test - public void testValidateRoleList_success() { - // mock 数据 - RoleDO roleDO = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - roleMapper.insert(roleDO); - // 准备参数 - List ids = singletonList(roleDO.getId()); - - // 调用,无需断言 - roleService.validateRoleList(ids); - } - - @Test - public void testValidateRoleList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> roleService.validateRoleList(ids), ROLE_NOT_EXISTS); - } - - @Test - public void testValidateRoleList_notEnable() { - // mock 数据 - RoleDO RoleDO = randomPojo(RoleDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - roleMapper.insert(RoleDO); - // 准备参数 - List ids = singletonList(RoleDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> roleService.validateRoleList(ids), ROLE_IS_DISABLE, RoleDO.getName()); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceTest.java deleted file mode 100644 index f22701cc0..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsChannelServiceTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; -import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClientFactory; -import cn.iocoder.yudao.module.system.framework.sms.core.property.SmsChannelProperties; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper; -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 java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SMS_CHANNEL_HAS_CHILDREN; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SMS_CHANNEL_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import(SmsChannelServiceImpl.class) -public class SmsChannelServiceTest extends BaseDbUnitTest { - - @Resource - private SmsChannelServiceImpl smsChannelService; - - @Resource - private SmsChannelMapper smsChannelMapper; - - @MockBean - private SmsClientFactory smsClientFactory; - @MockBean - private SmsTemplateService smsTemplateService; - - @Test - public void testCreateSmsChannel_success() { - // 准备参数 - SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class, o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long smsChannelId = smsChannelService.createSmsChannel(reqVO); - // 断言 - assertNotNull(smsChannelId); - // 校验记录的属性是否正确 - SmsChannelDO smsChannel = smsChannelMapper.selectById(smsChannelId); - assertPojoEquals(reqVO, smsChannel, "id"); - // 断言 cache - assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); - assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); - } - - @Test - public void testUpdateSmsChannel_success() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class, o -> { - o.setId(dbSmsChannel.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setCallbackUrl(randomString()); - }); - - // 调用 - smsChannelService.updateSmsChannel(reqVO); - // 校验是否更新正确 - SmsChannelDO smsChannel = smsChannelMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, smsChannel); - // 断言 cache - assertNull(smsChannelService.getIdClientCache().getIfPresent(smsChannel.getId())); - assertNull(smsChannelService.getCodeClientCache().getIfPresent(smsChannel.getCode())); - } - - @Test - public void testUpdateSmsChannel_notExists() { - // 准备参数 - SmsChannelSaveReqVO reqVO = randomPojo(SmsChannelSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> smsChannelService.updateSmsChannel(reqVO), SMS_CHANNEL_NOT_EXISTS); - } - - @Test - public void testDeleteSmsChannel_success() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsChannel.getId(); - - // 调用 - smsChannelService.deleteSmsChannel(id); - // 校验数据不存在了 - assertNull(smsChannelMapper.selectById(id)); - // 断言 cache - assertNull(smsChannelService.getIdClientCache().getIfPresent(dbSmsChannel.getId())); - assertNull(smsChannelService.getCodeClientCache().getIfPresent(dbSmsChannel.getCode())); - } - - @Test - public void testDeleteSmsChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> smsChannelService.deleteSmsChannel(id), SMS_CHANNEL_NOT_EXISTS); - } - - @Test - public void testDeleteSmsChannel_hasChildren() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsChannel.getId(); - // mock 方法 - when(smsTemplateService.getSmsTemplateCountByChannelId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> smsChannelService.deleteSmsChannel(id), SMS_CHANNEL_HAS_CHILDREN); - } - - @Test - public void testGetSmsChannel() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel); // @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsChannel.getId(); - - // 调用,并断言 - assertPojoEquals(dbSmsChannel, smsChannelService.getSmsChannel(id)); - } - - @Test - public void testGetSmsChannelList() { - // mock 数据 - SmsChannelDO dbSmsChannel01 = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel01); - SmsChannelDO dbSmsChannel02 = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(dbSmsChannel02); - // 准备参数 - - // 调用 - List list = smsChannelService.getSmsChannelList(); - // 断言 - assertEquals(2, list.size()); - assertPojoEquals(dbSmsChannel01, list.get(0)); - assertPojoEquals(dbSmsChannel02, list.get(1)); - } - - @Test - public void testGetSmsChannelPage() { - // mock 数据 - SmsChannelDO dbSmsChannel = randomPojo(SmsChannelDO.class, o -> { // 等会查询到 - o.setSignature("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2020, 12, 12)); - }); - smsChannelMapper.insert(dbSmsChannel); - // 测试 signature 不匹配 - smsChannelMapper.insert(cloneIgnoreId(dbSmsChannel, o -> o.setSignature("源码"))); - // 测试 status 不匹配 - smsChannelMapper.insert(cloneIgnoreId(dbSmsChannel, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - smsChannelMapper.insert(cloneIgnoreId(dbSmsChannel, o -> o.setCreateTime(buildTime(2020, 11, 11)))); - // 准备参数 - SmsChannelPageReqVO reqVO = new SmsChannelPageReqVO(); - reqVO.setSignature("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2020, 12, 1, 2020, 12, 24)); - - // 调用 - PageResult pageResult = smsChannelService.getSmsChannelPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSmsChannel, pageResult.getList().get(0)); - } - - @Test - public void testGetSmsClient_id() { - // mock 数据 - SmsChannelDO channel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(channel); - // mock 参数 - Long id = channel.getId(); - // mock 方法 - SmsClient mockClient = mock(SmsClient.class); - when(smsClientFactory.getSmsClient(eq(id))).thenReturn(mockClient); - - // 调用 - SmsClient client = smsChannelService.getSmsClient(id); - // 断言 - assertSame(client, mockClient); - verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { - SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class); - return properties.equals(arg); - })); - } - - @Test - public void testGetSmsClient_code() { - // mock 数据 - SmsChannelDO channel = randomPojo(SmsChannelDO.class); - smsChannelMapper.insert(channel); - // mock 参数 - String code = channel.getCode(); - // mock 方法 - SmsClient mockClient = mock(SmsClient.class); - when(smsClientFactory.getSmsClient(eq(code))).thenReturn(mockClient); - - // 调用 - SmsClient client = smsChannelService.getSmsClient(code); - // 断言 - assertSame(client, mockClient); - verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> { - SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class); - return properties.equals(arg); - })); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImplTest.java deleted file mode 100644 index fea1419ca..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImplTest.java +++ /dev/null @@ -1,209 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; -import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeValidateReqDTO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsCodeDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsCodeMapper; -import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; -import cn.iocoder.yudao.module.system.framework.sms.config.SmsCodeProperties; -import com.baomidou.mybatisplus.annotation.DbType; -import org.junit.jupiter.api.BeforeEach; -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 java.time.Duration; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@Import(SmsCodeServiceImpl.class) -public class SmsCodeServiceImplTest extends BaseDbUnitTest { - - @Resource - private SmsCodeServiceImpl smsCodeService; - - @Resource - private SmsCodeMapper smsCodeMapper; - - @MockBean - private SmsCodeProperties smsCodeProperties; - @MockBean - private SmsSendService smsSendService; - - @BeforeEach - public void setUp() { - when(smsCodeProperties.getExpireTimes()).thenReturn(Duration.ofMinutes(5)); - when(smsCodeProperties.getSendFrequency()).thenReturn(Duration.ofMinutes(1)); - when(smsCodeProperties.getSendMaximumQuantityPerDay()).thenReturn(10); - when(smsCodeProperties.getBeginCode()).thenReturn(9999); - when(smsCodeProperties.getEndCode()).thenReturn(9999); - } - - @Test - public void sendSmsCode_success() { - // 准备参数 - SmsCodeSendReqDTO reqDTO = randomPojo(SmsCodeSendReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(SmsSceneEnum.MEMBER_LOGIN.getScene()); - }); - // mock 方法 - SqlConstants.init(DbType.MYSQL); - - // 调用 - smsCodeService.sendSmsCode(reqDTO); - // 断言 code 验证码 - SmsCodeDO smsCodeDO = smsCodeMapper.selectOne(null); - assertPojoEquals(reqDTO, smsCodeDO); - assertEquals("9999", smsCodeDO.getCode()); - assertEquals(1, smsCodeDO.getTodayIndex()); - assertFalse(smsCodeDO.getUsed()); - // 断言调用 - verify(smsSendService).sendSingleSms(eq(reqDTO.getMobile()), isNull(), isNull(), - eq("user-sms-login"), eq(MapUtil.of("code", "9999"))); - } - - @Test - public void sendSmsCode_tooFast() { - // mock 数据 - SmsCodeDO smsCodeDO = randomPojo(SmsCodeDO.class, - o -> o.setMobile("15601691300").setTodayIndex(1)); - smsCodeMapper.insert(smsCodeDO); - // 准备参数 - SmsCodeSendReqDTO reqDTO = randomPojo(SmsCodeSendReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(SmsSceneEnum.MEMBER_LOGIN.getScene()); - }); - // mock 方法 - SqlConstants.init(DbType.MYSQL); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.sendSmsCode(reqDTO), - SMS_CODE_SEND_TOO_FAST); - } - - @Test - public void sendSmsCode_exceedDay() { - // mock 数据 - SmsCodeDO smsCodeDO = randomPojo(SmsCodeDO.class, - o -> o.setMobile("15601691300").setTodayIndex(10).setCreateTime(LocalDateTime.now())); - smsCodeMapper.insert(smsCodeDO); - // 准备参数 - SmsCodeSendReqDTO reqDTO = randomPojo(SmsCodeSendReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(SmsSceneEnum.MEMBER_LOGIN.getScene()); - }); - // mock 方法 - SqlConstants.init(DbType.MYSQL); - when(smsCodeProperties.getSendFrequency()).thenReturn(Duration.ofMillis(0)); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.sendSmsCode(reqDTO), - SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY); - } - - @Test - public void testUseSmsCode_success() { - // 准备参数 - SmsCodeUseReqDTO reqDTO = randomPojo(SmsCodeUseReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> { - o.setMobile(reqDTO.getMobile()).setScene(reqDTO.getScene()) - .setCode(reqDTO.getCode()).setUsed(false); - })); - - // 调用 - smsCodeService.useSmsCode(reqDTO); - // 断言 - SmsCodeDO smsCodeDO = smsCodeMapper.selectOne(null); - assertTrue(smsCodeDO.getUsed()); - assertNotNull(smsCodeDO.getUsedTime()); - assertEquals(reqDTO.getUsedIp(), smsCodeDO.getUsedIp()); - } - - @Test - public void validateSmsCode_success() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> o.setMobile(reqDTO.getMobile()) - .setScene(reqDTO.getScene()).setCode(reqDTO.getCode()).setUsed(false))); - - // 调用 - smsCodeService.validateSmsCode(reqDTO); - } - - @Test - public void validateSmsCode_notFound() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.validateSmsCode(reqDTO), - SMS_CODE_NOT_FOUND); - } - - @Test - public void validateSmsCode_expired() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> o.setMobile(reqDTO.getMobile()) - .setScene(reqDTO.getScene()).setCode(reqDTO.getCode()).setUsed(false) - .setCreateTime(LocalDateTime.now().minusMinutes(6)))); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.validateSmsCode(reqDTO), - SMS_CODE_EXPIRED); - } - - @Test - public void validateSmsCode_used() { - // 准备参数 - SmsCodeValidateReqDTO reqDTO = randomPojo(SmsCodeValidateReqDTO.class, o -> { - o.setMobile("15601691300"); - o.setScene(randomEle(SmsSceneEnum.values()).getScene()); - }); - // mock 数据 - SqlConstants.init(DbType.MYSQL); - smsCodeMapper.insert(randomPojo(SmsCodeDO.class, o -> o.setMobile(reqDTO.getMobile()) - .setScene(reqDTO.getScene()).setCode(reqDTO.getCode()).setUsed(true) - .setCreateTime(LocalDateTime.now()))); - - // 调用,并断言异常 - assertServiceException(() -> smsCodeService.validateSmsCode(reqDTO), - SMS_CODE_USED); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImplTest.java deleted file mode 100644 index eed34b988..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceImplTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsLogMapper; -import cn.iocoder.yudao.module.system.enums.sms.SmsReceiveStatusEnum; -import cn.iocoder.yudao.module.system.enums.sms.SmsSendStatusEnum; -import cn.iocoder.yudao.module.system.enums.sms.SmsTemplateTypeEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Map; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomBoolean; -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Import(SmsLogServiceImpl.class) -public class SmsLogServiceImplTest extends BaseDbUnitTest { - - @Resource - private SmsLogServiceImpl smsLogService; - - @Resource - private SmsLogMapper smsLogMapper; - - @Test - public void testGetSmsLogPage() { - // mock 数据 - SmsLogDO dbSmsLog = randomSmsLogDO(o -> { // 等会查询到 - o.setChannelId(1L); - o.setTemplateId(10L); - o.setMobile("15601691300"); - o.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); - o.setSendTime(buildTime(2020, 11, 11)); - o.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); - o.setReceiveTime(buildTime(2021, 11, 11)); - }); - smsLogMapper.insert(dbSmsLog); - // 测试 channelId 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setChannelId(2L))); - // 测试 templateId 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setTemplateId(20L))); - // 测试 mobile 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setMobile("18818260999"))); - // 测试 sendStatus 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setSendStatus(SmsSendStatusEnum.IGNORE.getStatus()))); - // 测试 sendTime 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setSendTime(buildTime(2020, 12, 12)))); - // 测试 receiveStatus 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setReceiveStatus(SmsReceiveStatusEnum.SUCCESS.getStatus()))); - // 测试 receiveTime 不匹配 - smsLogMapper.insert(cloneIgnoreId(dbSmsLog, o -> o.setReceiveTime(buildTime(2021, 12, 12)))); - // 准备参数 - SmsLogPageReqVO reqVO = new SmsLogPageReqVO(); - reqVO.setChannelId(1L); - reqVO.setTemplateId(10L); - reqVO.setMobile("156"); - reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); - reqVO.setSendTime(buildBetweenTime(2020, 11, 1, 2020, 11, 30)); - reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); - reqVO.setReceiveTime(buildBetweenTime(2021, 11, 1, 2021, 11, 30)); - - // 调用 - PageResult pageResult = smsLogService.getSmsLogPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSmsLog, pageResult.getList().get(0)); - } - - @Test - public void testCreateSmsLog() { - // 准备参数 - String mobile = randomString(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - Boolean isSend = randomBoolean(); - SmsTemplateDO templateDO = randomPojo(SmsTemplateDO.class, - o -> o.setType(randomEle(SmsTemplateTypeEnum.values()).getType())); - String templateContent = randomString(); - Map templateParams = randomTemplateParams(); - // mock 方法 - - // 调用 - Long logId = smsLogService.createSmsLog(mobile, userId, userType, isSend, - templateDO, templateContent, templateParams); - // 断言 - SmsLogDO logDO = smsLogMapper.selectById(logId); - assertEquals(isSend ? SmsSendStatusEnum.INIT.getStatus() : SmsSendStatusEnum.IGNORE.getStatus(), - logDO.getSendStatus()); - assertEquals(mobile, logDO.getMobile()); - assertEquals(userType, logDO.getUserType()); - assertEquals(userId, logDO.getUserId()); - assertEquals(templateDO.getId(), logDO.getTemplateId()); - assertEquals(templateDO.getCode(), logDO.getTemplateCode()); - assertEquals(templateDO.getType(), logDO.getTemplateType()); - assertEquals(templateDO.getChannelId(), logDO.getChannelId()); - assertEquals(templateDO.getChannelCode(), logDO.getChannelCode()); - assertEquals(templateContent, logDO.getTemplateContent()); - assertEquals(templateParams, logDO.getTemplateParams()); - assertEquals(SmsReceiveStatusEnum.INIT.getStatus(), logDO.getReceiveStatus()); - } - - @Test - public void testUpdateSmsSendResult() { - // mock 数据 - SmsLogDO dbSmsLog = randomSmsLogDO( - o -> o.setSendStatus(SmsSendStatusEnum.IGNORE.getStatus())); - smsLogMapper.insert(dbSmsLog); - // 准备参数 - Long id = dbSmsLog.getId(); - Boolean success = randomBoolean(); - String apiSendCode = randomString(); - String apiSendMsg = randomString(); - String apiRequestId = randomString(); - String apiSerialNo = randomString(); - - // 调用 - smsLogService.updateSmsSendResult(id, success, - apiSendCode, apiSendMsg, apiRequestId, apiSerialNo); - // 断言 - dbSmsLog = smsLogMapper.selectById(id); - assertEquals(success ? SmsSendStatusEnum.SUCCESS.getStatus() : SmsSendStatusEnum.FAILURE.getStatus(), - dbSmsLog.getSendStatus()); - assertNotNull(dbSmsLog.getSendTime()); - assertEquals(apiSendCode, dbSmsLog.getApiSendCode()); - assertEquals(apiSendMsg, dbSmsLog.getApiSendMsg()); - assertEquals(apiRequestId, dbSmsLog.getApiRequestId()); - assertEquals(apiSerialNo, dbSmsLog.getApiSerialNo()); - } - - @Test - public void testUpdateSmsReceiveResult() { - // mock 数据 - SmsLogDO dbSmsLog = randomSmsLogDO( - o -> o.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus())); - smsLogMapper.insert(dbSmsLog); - // 准备参数 - Long id = dbSmsLog.getId(); - Boolean success = randomBoolean(); - LocalDateTime receiveTime = randomLocalDateTime(); - String apiReceiveCode = randomString(); - String apiReceiveMsg = randomString(); - - // 调用 - smsLogService.updateSmsReceiveResult(id, success, receiveTime, apiReceiveCode, apiReceiveMsg); - // 断言 - dbSmsLog = smsLogMapper.selectById(id); - assertEquals(success ? SmsReceiveStatusEnum.SUCCESS.getStatus() - : SmsReceiveStatusEnum.FAILURE.getStatus(), dbSmsLog.getReceiveStatus()); - assertEquals(receiveTime, dbSmsLog.getReceiveTime()); - assertEquals(apiReceiveCode, dbSmsLog.getApiReceiveCode()); - assertEquals(apiReceiveMsg, dbSmsLog.getApiReceiveMsg()); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static SmsLogDO randomSmsLogDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setTemplateParams(randomTemplateParams()); - o.setTemplateType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 templateType 的范围 - o.setUserType(randomEle(UserTypeEnum.values()).getValue()); // 保证 userType 的范围 - o.setSendStatus(randomEle(SmsSendStatusEnum.values()).getStatus()); // 保证 sendStatus 的范围 - o.setReceiveStatus(randomEle(SmsReceiveStatusEnum.values()).getStatus()); // 保证 receiveStatus 的范围 - }; - return randomPojo(SmsLogDO.class, ArrayUtils.append(consumer, consumers)); - } - - private static Map randomTemplateParams() { - return MapUtil.builder().put(randomString(), randomString()) - .put(randomString(), randomString()).build(); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImplTest.java deleted file mode 100644 index 487c6f7fe..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsSendServiceImplTest.java +++ /dev/null @@ -1,298 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsReceiveRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsSendRespDTO; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; -import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer; -import cn.iocoder.yudao.module.system.service.member.MemberService; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.assertj.core.util.Lists; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -public class SmsSendServiceImplTest extends BaseMockitoUnitTest { - - @InjectMocks - private SmsSendServiceImpl smsSendService; - - @Mock - private AdminUserService adminUserService; - @Mock - private MemberService memberService; - @Mock - private SmsChannelService smsChannelService; - @Mock - private SmsTemplateService smsTemplateService; - @Mock - private SmsLogService smsLogService; - @Mock - private SmsProducer smsProducer; - - @Test - public void testSendSingleSmsToAdmin() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock adminUserService 的方法 - AdminUserDO user = randomPojo(AdminUserDO.class, o -> o.setMobile("15601691300")); - when(adminUserService.getUser(eq(userId))).thenReturn(user); - - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(user.getMobile()), eq(userId), eq(UserTypeEnum.ADMIN.getValue()), eq(Boolean.TRUE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSmsToAdmin(null, userId, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(user.getMobile()), - eq(template.getChannelId()), eq(template.getApiTemplateId()), - eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); - } - - @Test - public void testSendSingleSmsToUser() { - // 准备参数 - Long userId = randomLongId(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock memberService 的方法 - String mobile = "15601691300"; - when(memberService.getMemberUserMobile(eq(userId))).thenReturn(mobile); - - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(UserTypeEnum.MEMBER.getValue()), eq(Boolean.TRUE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSmsToMember(null, userId, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), - eq(template.getChannelId()), eq(template.getApiTemplateId()), - eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); - } - - /** - * 发送成功,当短信模板开启时 - */ - @Test - public void testSendSingleSms_successWhenSmsTemplateEnable() { - // 准备参数 - String mobile = randomString(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.TRUE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), - eq(template.getChannelId()), eq(template.getApiTemplateId()), - eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login")))); - } - - /** - * 发送成功,当短信模板关闭时 - */ - @Test - public void testSendSingleSms_successWhenSmsTemplateDisable() { - // 准备参数 - String mobile = randomString(); - Long userId = randomLongId(); - Integer userType = randomEle(UserTypeEnum.values()).getValue(); - String templateCode = randomString(); - Map templateParams = MapUtil.builder().put("code", "1234") - .put("op", "login").build(); - // mock SmsTemplateService 的方法 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, o -> { - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - o.setContent("验证码为{code}, 操作为{op}"); - o.setParams(Lists.newArrayList("code", "op")); - }); - when(smsTemplateService.getSmsTemplateByCodeFromCache(eq(templateCode))).thenReturn(template); - String content = randomString(); - when(smsTemplateService.formatSmsTemplateContent(eq(template.getContent()), eq(templateParams))) - .thenReturn(content); - // mock SmsChannelService 的方法 - SmsChannelDO smsChannel = randomPojo(SmsChannelDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(smsChannelService.getSmsChannel(eq(template.getChannelId()))).thenReturn(smsChannel); - // mock SmsLogService 的方法 - Long smsLogId = randomLongId(); - when(smsLogService.createSmsLog(eq(mobile), eq(userId), eq(userType), eq(Boolean.FALSE), eq(template), - eq(content), eq(templateParams))).thenReturn(smsLogId); - - // 调用 - Long resultSmsLogId = smsSendService.sendSingleSms(mobile, userId, userType, templateCode, templateParams); - // 断言 - assertEquals(smsLogId, resultSmsLogId); - // 断言调用 - verify(smsProducer, times(0)).sendSmsSendMessage(anyLong(), anyString(), - anyLong(), any(), anyList()); - } - - @Test - public void testCheckSmsTemplateValid_notExists() { - // 准备参数 - String templateCode = randomString(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> smsSendService.validateSmsTemplate(templateCode), - SMS_SEND_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testBuildTemplateParams_paramMiss() { - // 准备参数 - SmsTemplateDO template = randomPojo(SmsTemplateDO.class, - o -> o.setParams(Lists.newArrayList("code"))); - Map templateParams = new HashMap<>(); - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> smsSendService.buildTemplateParams(template, templateParams), - SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS, "code"); - } - - @Test - public void testCheckMobile_notExists() { - // 准备参数 - // mock 方法 - - // 调用,并断言异常 - assertServiceException(() -> smsSendService.validateMobile(null), - SMS_SEND_MOBILE_NOT_EXISTS); - } - - @Test - public void testSendBatchNotify() { - // 准备参数 - // mock 方法 - - // 调用 - UnsupportedOperationException exception = Assertions.assertThrows( - UnsupportedOperationException.class, - () -> smsSendService.sendBatchSms(null, null, null, null, null) - ); - // 断言 - assertEquals("暂时不支持该操作,感兴趣可以实现该功能哟!", exception.getMessage()); - } - - @Test - @SuppressWarnings("unchecked") - public void testDoSendSms() throws Throwable { - // 准备参数 - SmsSendMessage message = randomPojo(SmsSendMessage.class); - // mock SmsClientFactory 的方法 - SmsClient smsClient = spy(SmsClient.class); - when(smsChannelService.getSmsClient(eq(message.getChannelId()))).thenReturn(smsClient); - // mock SmsClient 的方法 - SmsSendRespDTO sendResult = randomPojo(SmsSendRespDTO.class); - when(smsClient.sendSms(eq(message.getLogId()), eq(message.getMobile()), eq(message.getApiTemplateId()), - eq(message.getTemplateParams()))).thenReturn(sendResult); - - // 调用 - smsSendService.doSendSms(message); - // 断言 - verify(smsLogService).updateSmsSendResult(eq(message.getLogId()), - eq(sendResult.getSuccess()), eq(sendResult.getApiCode()), - eq(sendResult.getApiMsg()), eq(sendResult.getApiRequestId()), eq(sendResult.getSerialNo())); - } - - @Test - public void testReceiveSmsStatus() throws Throwable { - // 准备参数 - String channelCode = randomString(); - String text = randomString(); - // mock SmsClientFactory 的方法 - SmsClient smsClient = spy(SmsClient.class); - when(smsChannelService.getSmsClient(eq(channelCode))).thenReturn(smsClient); - // mock SmsClient 的方法 - List receiveResults = randomPojoList(SmsReceiveRespDTO.class); - - // 调用 - smsSendService.receiveSmsStatus(channelCode, text); - // 断言 - receiveResults.forEach(result -> smsLogService.updateSmsReceiveResult(eq(result.getLogId()), eq(result.getSuccess()), - eq(result.getReceiveTime()), eq(result.getErrorCode()), eq(result.getErrorCode()))); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java deleted file mode 100644 index 5cad48163..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java +++ /dev/null @@ -1,348 +0,0 @@ -package cn.iocoder.yudao.module.system.service.sms; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.system.framework.sms.core.client.SmsClient; -import cn.iocoder.yudao.module.system.framework.sms.core.client.dto.SmsTemplateRespDTO; -import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplatePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.sms.vo.template.SmsTemplateSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsChannelDO; -import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO; -import cn.iocoder.yudao.module.system.dal.mysql.sms.SmsTemplateMapper; -import cn.iocoder.yudao.module.system.enums.sms.SmsTemplateTypeEnum; -import com.google.common.collect.Lists; -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 java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -@Import(SmsTemplateServiceImpl.class) -public class SmsTemplateServiceImplTest extends BaseDbUnitTest { - - @Resource - private SmsTemplateServiceImpl smsTemplateService; - - @Resource - private SmsTemplateMapper smsTemplateMapper; - - @MockBean - private SmsChannelService smsChannelService; - @MockBean - private SmsClient smsClient; - - @Test - public void testFormatSmsTemplateContent() { - // 准备参数 - String content = "正在进行登录操作{operation},您的验证码是{code}"; - Map params = MapUtil.builder("operation", "登录") - .put("code", "1234").build(); - - // 调用 - String result = smsTemplateService.formatSmsTemplateContent(content, params); - // 断言 - assertEquals("正在进行登录操作登录,您的验证码是1234", result); - } - - @Test - public void testParseTemplateContentParams() { - // 准备参数 - String content = "正在进行登录操作{operation},您的验证码是{code}"; - // mock 方法 - - // 调用 - List params = smsTemplateService.parseTemplateContentParams(content); - // 断言 - assertEquals(Lists.newArrayList("operation", "code"), params); - } - - @Test - @SuppressWarnings("unchecked") - public void testCreateSmsTemplate_success() throws Throwable { - // 准备参数 - SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class, o -> { - o.setContent("正在进行登录操作{operation},您的验证码是{code}"); - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 - }).setId(null); // 防止 id 被赋值 - // mock Channel 的方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(reqVO.getChannelId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态 - }); - when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); - // mock 获得 API 短信模板成功 - when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); - when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn( - randomPojo(SmsTemplateRespDTO.class, o -> o.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus()))); - - // 调用 - Long smsTemplateId = smsTemplateService.createSmsTemplate(reqVO); - // 断言 - assertNotNull(smsTemplateId); - // 校验记录的属性是否正确 - SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(smsTemplateId); - assertPojoEquals(reqVO, smsTemplate, "id"); - assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams()); - assertEquals(channelDO.getCode(), smsTemplate.getChannelCode()); - } - - @Test - @SuppressWarnings("unchecked") - public void testUpdateSmsTemplate_success() throws Throwable { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class, o -> { - o.setId(dbSmsTemplate.getId()); // 设置更新的 ID - o.setContent("正在进行登录操作{operation},您的验证码是{code}"); - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 - }); - // mock 方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(reqVO.getChannelId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态 - }); - when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); - // mock 获得 API 短信模板成功 - when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); - when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn( - randomPojo(SmsTemplateRespDTO.class, o -> o.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus()))); - - // 调用 - smsTemplateService.updateSmsTemplate(reqVO); - // 校验是否更新正确 - SmsTemplateDO smsTemplate = smsTemplateMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, smsTemplate); - assertEquals(Lists.newArrayList("operation", "code"), smsTemplate.getParams()); - assertEquals(channelDO.getCode(), smsTemplate.getChannelCode()); - } - - @Test - public void testUpdateSmsTemplate_notExists() { - // 准备参数 - SmsTemplateSaveReqVO reqVO = randomPojo(SmsTemplateSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> smsTemplateService.updateSmsTemplate(reqVO), SMS_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testDeleteSmsTemplate_success() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsTemplate.getId(); - - // 调用 - smsTemplateService.deleteSmsTemplate(id); - // 校验数据不存在了 - assertNull(smsTemplateMapper.selectById(id)); - } - - @Test - public void testDeleteSmsTemplate_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> smsTemplateService.deleteSmsTemplate(id), SMS_TEMPLATE_NOT_EXISTS); - } - - @Test - public void testGetSmsTemplate() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSmsTemplate.getId(); - - // 调用 - SmsTemplateDO smsTemplate = smsTemplateService.getSmsTemplate(id); - // 校验 - assertPojoEquals(dbSmsTemplate, smsTemplate); - } - - @Test - public void testGetSmsTemplateByCodeFromCache() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomSmsTemplateDO(); - smsTemplateMapper.insert(dbSmsTemplate);// @Sql: 先插入出一条存在的数据 - // 准备参数 - String code = dbSmsTemplate.getCode(); - - // 调用 - SmsTemplateDO smsTemplate = smsTemplateService.getSmsTemplateByCodeFromCache(code); - // 校验 - assertPojoEquals(dbSmsTemplate, smsTemplate); - } - - @Test - public void testGetSmsTemplatePage() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomPojo(SmsTemplateDO.class, o -> { // 等会查询到 - o.setType(SmsTemplateTypeEnum.PROMOTION.getType()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCode("tudou"); - o.setContent("芋道源码"); - o.setApiTemplateId("yunai"); - o.setChannelId(1L); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - smsTemplateMapper.insert(dbSmsTemplate); - // 测试 type 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setType(SmsTemplateTypeEnum.VERIFICATION_CODE.getType()))); - // 测试 status 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 code 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setCode("yuanma"))); - // 测试 content 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setContent("源码"))); - // 测试 apiTemplateId 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setApiTemplateId("nai"))); - // 测试 channelId 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setChannelId(2L))); - // 测试 createTime 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - SmsTemplatePageReqVO reqVO = new SmsTemplatePageReqVO(); - reqVO.setType(SmsTemplateTypeEnum.PROMOTION.getType()); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCode("tu"); - reqVO.setContent("芋道"); - reqVO.setApiTemplateId("yu"); - reqVO.setChannelId(1L); - reqVO.setCreateTime(buildBetweenTime(2021, 11, 1, 2021, 12, 1)); - - // 调用 - PageResult pageResult = smsTemplateService.getSmsTemplatePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSmsTemplate, pageResult.getList().get(0)); - } - - @Test - public void testGetSmsTemplateCountByChannelId() { - // mock 数据 - SmsTemplateDO dbSmsTemplate = randomPojo(SmsTemplateDO.class, o -> o.setChannelId(1L)); - smsTemplateMapper.insert(dbSmsTemplate); - // 测试 channelId 不匹配 - smsTemplateMapper.insert(ObjectUtils.cloneIgnoreId(dbSmsTemplate, o -> o.setChannelId(2L))); - // 准备参数 - Long channelId = 1L; - - // 调用 - Long count = smsTemplateService.getSmsTemplateCountByChannelId(channelId); - // 断言 - assertEquals(1, count); - } - - @Test - public void testValidateSmsChannel_success() { - // 准备参数 - Long channelId = randomLongId(); - // mock 方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(channelId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 保证 status 开启,创建必须处于这个状态 - }); - when(smsChannelService.getSmsChannel(eq(channelId))).thenReturn(channelDO); - - // 调用 - SmsChannelDO returnChannelDO = smsTemplateService.validateSmsChannel(channelId); - // 断言 - assertPojoEquals(returnChannelDO, channelDO); - } - - @Test - public void testValidateSmsChannel_notExists() { - // 准备参数 - Long channelId = randomLongId(); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsChannel(channelId), - SMS_CHANNEL_NOT_EXISTS); - } - - @Test - public void testValidateSmsChannel_disable() { - // 准备参数 - Long channelId = randomLongId(); - // mock 方法 - SmsChannelDO channelDO = randomPojo(SmsChannelDO.class, o -> { - o.setId(channelId); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); // 保证 status 禁用,触发失败 - }); - when(smsChannelService.getSmsChannel(eq(channelId))).thenReturn(channelDO); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsChannel(channelId), - SMS_CHANNEL_DISABLE); - } - - @Test - public void testValidateDictDataValueUnique_success() { - // 调用,成功 - smsTemplateService.validateSmsTemplateCodeDuplicate(randomLongId(), randomString()); - } - - @Test - public void testValidateSmsTemplateCodeDuplicate_valueDuplicateForCreate() { - // 准备参数 - String code = randomString(); - // mock 数据 - smsTemplateMapper.insert(randomSmsTemplateDO(o -> o.setCode(code))); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsTemplateCodeDuplicate(null, code), - SMS_TEMPLATE_CODE_DUPLICATE, code); - } - - @Test - public void testValidateDictDataValueUnique_valueDuplicateForUpdate() { - // 准备参数 - Long id = randomLongId(); - String code = randomString(); - // mock 数据 - smsTemplateMapper.insert(randomSmsTemplateDO(o -> o.setCode(code))); - - // 调用,校验异常 - assertServiceException(() -> smsTemplateService.validateSmsTemplateCodeDuplicate(id, code), - SMS_TEMPLATE_CODE_DUPLICATE, code); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static SmsTemplateDO randomSmsTemplateDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setType(randomEle(SmsTemplateTypeEnum.values()).getType()); // 保证 type 的 范围 - }; - return randomPojo(SmsTemplateDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java deleted file mode 100644 index 7e094d896..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImplTest.java +++ /dev/null @@ -1,472 +0,0 @@ -package cn.iocoder.yudao.module.system.service.social; - -import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.api.WxMaUserService; -import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO; -import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import com.xingyuv.jushauth.config.AuthConfig; -import com.xingyuv.jushauth.model.AuthResponse; -import com.xingyuv.jushauth.model.AuthUser; -import com.xingyuv.jushauth.request.AuthDefaultRequest; -import com.xingyuv.jushauth.request.AuthRequest; -import com.xingyuv.jushauth.utils.AuthStateUtils; -import com.xingyuv.justauth.AuthRequestFactory; -import me.chanjar.weixin.common.bean.WxJsapiSignature; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.data.redis.core.StringRedisTemplate; - -import javax.annotation.Resource; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link SocialClientServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(SocialClientServiceImpl.class) -public class SocialClientServiceImplTest extends BaseDbUnitTest { - - @Resource - private SocialClientServiceImpl socialClientService; - - @Resource - private SocialClientMapper socialClientMapper; - - @MockBean - private AuthRequestFactory authRequestFactory; - - @MockBean - private WxMpService wxMpService; - @MockBean - private WxMpProperties wxMpProperties; - @MockBean - private StringRedisTemplate stringRedisTemplate; - @MockBean - private WxMaService wxMaService; - @MockBean - private WxMaProperties wxMaProperties; - - @Test - public void testGetAuthorizeUrl() { - try (MockedStatic authStateUtilsMock = mockStatic(AuthStateUtils.class)) { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String redirectUri = "sss"; - // mock 获得对应的 AuthRequest 实现 - AuthRequest authRequest = mock(AuthRequest.class); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 方法 - authStateUtilsMock.when(AuthStateUtils::createState).thenReturn("aoteman"); - when(authRequest.authorize(eq("aoteman"))).thenReturn("https://www.iocoder.cn?redirect_uri=yyy"); - - // 调用 - String url = socialClientService.getAuthorizeUrl(socialType, userType, redirectUri); - // 断言 - assertEquals("https://www.iocoder.cn?redirect_uri=sss", url); - } - } - - @Test - public void testAuthSocialUser_success() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String code = randomString(); - String state = randomString(); - // mock 方法(AuthRequest) - AuthRequest authRequest = mock(AuthRequest.class); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 方法(AuthResponse) - AuthUser authUser = randomPojo(AuthUser.class); - AuthResponse authResponse = new AuthResponse<>(2000, null, authUser); - when(authRequest.login(argThat(authCallback -> { - assertEquals(code, authCallback.getCode()); - assertEquals(state, authCallback.getState()); - return true; - }))).thenReturn(authResponse); - - // 调用 - AuthUser result = socialClientService.getAuthUser(socialType, userType, code, state); - // 断言 - assertSame(authUser, result); - } - - @Test - public void testAuthSocialUser_fail() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String code = randomString(); - String state = randomString(); - // mock 方法(AuthRequest) - AuthRequest authRequest = mock(AuthRequest.class); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 方法(AuthResponse) - AuthResponse authResponse = new AuthResponse<>(0, "模拟失败", null); - when(authRequest.login(argThat(authCallback -> { - assertEquals(code, authCallback.getCode()); - assertEquals(state, authCallback.getState()); - return true; - }))).thenReturn(authResponse); - - // 调用并断言 - assertServiceException( - () -> socialClientService.getAuthUser(socialType, userType, code, state), - SOCIAL_USER_AUTH_FAILURE, "模拟失败"); - } - - @Test - public void testBuildAuthRequest_clientNull() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(SocialTypeEnum.class).getType(); - // mock 获得对应的 AuthRequest 实现 - AuthRequest authRequest = mock(AuthDefaultRequest.class); - AuthConfig authConfig = (AuthConfig) ReflectUtil.getFieldValue(authRequest, "config"); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - - // 调用 - AuthRequest result = socialClientService.buildAuthRequest(socialType, userType); - // 断言 - assertSame(authRequest, result); - assertSame(authConfig, ReflectUtil.getFieldValue(authConfig, "config")); - } - - @Test - public void testBuildAuthRequest_clientDisable() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(SocialTypeEnum.class).getType(); - // mock 获得对应的 AuthRequest 实现 - AuthRequest authRequest = mock(AuthDefaultRequest.class); - AuthConfig authConfig = (AuthConfig) ReflectUtil.getFieldValue(authRequest, "config"); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUserType(userType).setSocialType(socialType)); - socialClientMapper.insert(client); - - // 调用 - AuthRequest result = socialClientService.buildAuthRequest(socialType, userType); - // 断言 - assertSame(authRequest, result); - assertSame(authConfig, ReflectUtil.getFieldValue(authConfig, "config")); - } - - @Test - public void testBuildAuthRequest_clientEnable() { - // 准备参数 - Integer socialType = SocialTypeEnum.WECHAT_MP.getType(); - Integer userType = randomPojo(SocialTypeEnum.class).getType(); - // mock 获得对应的 AuthRequest 实现 - AuthConfig authConfig = mock(AuthConfig.class); - AuthRequest authRequest = mock(AuthDefaultRequest.class); - ReflectUtil.setFieldValue(authRequest, "config", authConfig); - when(authRequestFactory.get(eq("WECHAT_MP"))).thenReturn(authRequest); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setUserType(userType).setSocialType(socialType)); - socialClientMapper.insert(client); - - // 调用 - AuthRequest result = socialClientService.buildAuthRequest(socialType, userType); - // 断言 - assertSame(authRequest, result); - assertNotSame(authConfig, ReflectUtil.getFieldValue(authRequest, "config")); - } - - // =================== 微信公众号独有 =================== - - @Test - public void testCreateWxMpJsapiSignature() throws WxErrorException { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String url = randomString(); - // mock 方法 - WxJsapiSignature signature = randomPojo(WxJsapiSignature.class); - when(wxMpService.createJsapiSignature(eq(url))).thenReturn(signature); - - // 调用 - WxJsapiSignature result = socialClientService.createWxMpJsapiSignature(userType, url); - // 断言 - assertSame(signature, result); - } - - @Test - public void testGetWxMpService_clientNull() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 方法 - - // 调用 - WxMpService result = socialClientService.getWxMpService(userType); - // 断言 - assertSame(wxMpService, result); - } - - @Test - public void testGetWxMpService_clientDisable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MP.getType())); - socialClientMapper.insert(client); - - // 调用 - WxMpService result = socialClientService.getWxMpService(userType); - // 断言 - assertSame(wxMpService, result); - } - - @Test - public void testGetWxMpService_clientEnable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MP.getType())); - socialClientMapper.insert(client); - // mock 方法 - WxMpProperties.ConfigStorage configStorage = mock(WxMpProperties.ConfigStorage.class); - when(wxMpProperties.getConfigStorage()).thenReturn(configStorage); - - // 调用 - WxMpService result = socialClientService.getWxMpService(userType); - // 断言 - assertNotSame(wxMpService, result); - assertEquals(client.getClientId(), result.getWxMpConfigStorage().getAppId()); - assertEquals(client.getClientSecret(), result.getWxMpConfigStorage().getSecret()); - } - - // =================== 微信小程序独有 =================== - - @Test - public void testGetWxMaPhoneNumberInfo_success() throws WxErrorException { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String phoneCode = randomString(); - // mock 方法 - WxMaUserService userService = mock(WxMaUserService.class); - when(wxMaService.getUserService()).thenReturn(userService); - WxMaPhoneNumberInfo phoneNumber = randomPojo(WxMaPhoneNumberInfo.class); - when(userService.getPhoneNoInfo(eq(phoneCode))).thenReturn(phoneNumber); - - // 调用 - WxMaPhoneNumberInfo result = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode); - // 断言 - assertSame(phoneNumber, result); - } - - @Test - public void testGetWxMaPhoneNumberInfo_exception() throws WxErrorException { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - String phoneCode = randomString(); - // mock 方法 - WxMaUserService userService = mock(WxMaUserService.class); - when(wxMaService.getUserService()).thenReturn(userService); - WxErrorException wxErrorException = randomPojo(WxErrorException.class); - when(userService.getPhoneNoInfo(eq(phoneCode))).thenThrow(wxErrorException); - - // 调用并断言异常 - assertServiceException(() -> socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode), - SOCIAL_CLIENT_WEIXIN_MINI_APP_PHONE_CODE_ERROR); - } - - @Test - public void testGetWxMaService_clientNull() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 方法 - - // 调用 - WxMaService result = socialClientService.getWxMaService(userType); - // 断言 - assertSame(wxMaService, result); - } - - @Test - public void testGetWxMaService_clientDisable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType())); - socialClientMapper.insert(client); - - // 调用 - WxMaService result = socialClientService.getWxMaService(userType); - // 断言 - assertSame(wxMaService, result); - } - - @Test - public void testGetWxMaService_clientEnable() { - // 准备参数 - Integer userType = randomPojo(UserTypeEnum.class).getValue(); - // mock 数据 - SocialClientDO client = randomPojo(SocialClientDO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setUserType(userType).setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType())); - socialClientMapper.insert(client); - // mock 方法 - WxMaProperties.ConfigStorage configStorage = mock(WxMaProperties.ConfigStorage.class); - when(wxMaProperties.getConfigStorage()).thenReturn(configStorage); - - // 调用 - WxMaService result = socialClientService.getWxMaService(userType); - // 断言 - assertNotSame(wxMaService, result); - assertEquals(client.getClientId(), result.getWxMaConfig().getAppid()); - assertEquals(client.getClientSecret(), result.getWxMaConfig().getSecret()); - } - - // =================== 客户端管理 =================== - - @Test - public void testCreateSocialClient_success() { - // 准备参数 - SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class, - o -> o.setSocialType(randomEle(SocialTypeEnum.values()).getType()) - .setUserType(randomEle(UserTypeEnum.values()).getValue()) - .setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long socialClientId = socialClientService.createSocialClient(reqVO); - // 断言 - assertNotNull(socialClientId); - // 校验记录的属性是否正确 - SocialClientDO socialClient = socialClientMapper.selectById(socialClientId); - assertPojoEquals(reqVO, socialClient, "id"); - } - - @Test - public void testUpdateSocialClient_success() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); - socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 - // 准备参数 - SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class, o -> { - o.setId(dbSocialClient.getId()); // 设置更新的 ID - o.setSocialType(randomEle(SocialTypeEnum.values()).getType()) - .setUserType(randomEle(UserTypeEnum.values()).getValue()) - .setStatus(randomCommonStatus()); - }); - - // 调用 - socialClientService.updateSocialClient(reqVO); - // 校验是否更新正确 - SocialClientDO socialClient = socialClientMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, socialClient); - } - - @Test - public void testUpdateSocialClient_notExists() { - // 准备参数 - SocialClientSaveReqVO reqVO = randomPojo(SocialClientSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> socialClientService.updateSocialClient(reqVO), SOCIAL_CLIENT_NOT_EXISTS); - } - - @Test - public void testDeleteSocialClient_success() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); - socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSocialClient.getId(); - - // 调用 - socialClientService.deleteSocialClient(id); - // 校验数据不存在了 - assertNull(socialClientMapper.selectById(id)); - } - - @Test - public void testDeleteSocialClient_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> socialClientService.deleteSocialClient(id), SOCIAL_CLIENT_NOT_EXISTS); - } - - @Test - public void testGetSocialClient() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class); - socialClientMapper.insert(dbSocialClient);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbSocialClient.getId(); - - // 调用 - SocialClientDO socialClient = socialClientService.getSocialClient(id); - // 校验数据正确 - assertPojoEquals(dbSocialClient, socialClient); - } - - @Test - public void testGetSocialClientPage() { - // mock 数据 - SocialClientDO dbSocialClient = randomPojo(SocialClientDO.class, o -> { // 等会查询到 - o.setName("芋头"); - o.setSocialType(SocialTypeEnum.GITEE.getType()); - o.setUserType(UserTypeEnum.ADMIN.getValue()); - o.setClientId("yudao"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - socialClientMapper.insert(dbSocialClient); - // 测试 name 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setName(randomString()))); - // 测试 socialType 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setSocialType(SocialTypeEnum.DINGTALK.getType()))); - // 测试 userType 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); - // 测试 clientId 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setClientId("dao"))); - // 测试 status 不匹配 - socialClientMapper.insert(cloneIgnoreId(dbSocialClient, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 准备参数 - SocialClientPageReqVO reqVO = new SocialClientPageReqVO(); - reqVO.setName("芋"); - reqVO.setSocialType(SocialTypeEnum.GITEE.getType()); - reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); - reqVO.setClientId("yu"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - - // 调用 - PageResult pageResult = socialClientService.getSocialClientPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSocialClient, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java deleted file mode 100644 index c3e753882..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImplTest.java +++ /dev/null @@ -1,288 +0,0 @@ -package cn.iocoder.yudao.module.system.service.social; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; -import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; -import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper; -import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserMapper; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; -import com.xingyuv.jushauth.model.AuthUser; -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 java.util.List; - -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.hutool.core.util.RandomUtil.randomLong; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SOCIAL_USER_NOT_FOUND; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.when; - -/** - * {@link SocialUserServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(SocialUserServiceImpl.class) -public class SocialUserServiceImplTest extends BaseDbUnitTest { - - @Resource - private SocialUserServiceImpl socialUserService; - - @Resource - private SocialUserMapper socialUserMapper; - @Resource - private SocialUserBindMapper socialUserBindMapper; - - @MockBean - private SocialClientService socialClientService; - - @Test - public void testGetSocialUserList() { - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - // mock 获得社交用户 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(SocialTypeEnum.GITEE.getType()); - socialUserMapper.insert(socialUser); // 可被查到 - socialUserMapper.insert(randomPojo(SocialUserDO.class)); // 不可被查到 - // mock 获得绑定 - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class) // 可被查询到 - .setUserId(userId).setUserType(userType).setSocialType(SocialTypeEnum.GITEE.getType()) - .setSocialUserId(socialUser.getId())); - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class) // 不可被查询到 - .setUserId(2L).setUserType(userType).setSocialType(SocialTypeEnum.DINGTALK.getType())); - - // 调用 - List result = socialUserService.getSocialUserList(userId, userType); - // 断言 - assertEquals(1, result.size()); - assertPojoEquals(socialUser, result.get(0)); - } - - @Test - public void testBindSocialUser() { - // 准备参数 - SocialUserBindReqDTO reqDTO = new SocialUserBindReqDTO() - .setUserId(1L).setUserType(UserTypeEnum.ADMIN.getValue()) - .setSocialType(SocialTypeEnum.GITEE.getType()).setCode("test_code").setState("test_state"); - // mock 数据:获得社交用户 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(reqDTO.getSocialType()) - .setCode(reqDTO.getCode()).setState(reqDTO.getState()); - socialUserMapper.insert(socialUser); - // mock 数据:用户可能之前已经绑定过该社交类型 - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class).setUserId(1L).setUserType(UserTypeEnum.ADMIN.getValue()) - .setSocialType(SocialTypeEnum.GITEE.getType()).setSocialUserId(-1L)); - // mock 数据:社交用户可能之前绑定过别的用户 - socialUserBindMapper.insert(randomPojo(SocialUserBindDO.class).setUserType(UserTypeEnum.ADMIN.getValue()) - .setSocialType(SocialTypeEnum.GITEE.getType()).setSocialUserId(socialUser.getId())); - - // 调用 - String openid = socialUserService.bindSocialUser(reqDTO); - // 断言 - List socialUserBinds = socialUserBindMapper.selectList(); - assertEquals(1, socialUserBinds.size()); - assertEquals(socialUser.getOpenid(), openid); - } - - @Test - public void testUnbindSocialUser_success() { - // 准备参数 - Long userId = 1L; - Integer userType = UserTypeEnum.ADMIN.getValue(); - Integer type = SocialTypeEnum.GITEE.getType(); - String openid = "test_openid"; - // mock 数据:社交用户 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(type).setOpenid(openid); - socialUserMapper.insert(socialUser); - // mock 数据:社交绑定关系 - SocialUserBindDO socialUserBind = randomPojo(SocialUserBindDO.class).setUserType(userType) - .setUserId(userId).setSocialType(type); - socialUserBindMapper.insert(socialUserBind); - - // 调用 - socialUserService.unbindSocialUser(userId, userType, type, openid); - // 断言 - assertEquals(0, socialUserBindMapper.selectCount(null).intValue()); - } - - @Test - public void testUnbindSocialUser_notFound() { - // 调用,并断言 - assertServiceException( - () -> socialUserService.unbindSocialUser(randomLong(), UserTypeEnum.ADMIN.getValue(), - SocialTypeEnum.GITEE.getType(), "test_openid"), - SOCIAL_USER_NOT_FOUND); - } - - @Test - public void testGetSocialUser() { - // 准备参数 - Integer userType = UserTypeEnum.ADMIN.getValue(); - Integer type = SocialTypeEnum.GITEE.getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 社交用户 - SocialUserDO socialUserDO = randomPojo(SocialUserDO.class).setType(type).setCode(code).setState(state); - socialUserMapper.insert(socialUserDO); - // mock 社交用户的绑定 - Long userId = randomLong(); - SocialUserBindDO socialUserBind = randomPojo(SocialUserBindDO.class).setUserType(userType).setUserId(userId) - .setSocialType(type).setSocialUserId(socialUserDO.getId()); - socialUserBindMapper.insert(socialUserBind); - - // 调用 - SocialUserRespDTO socialUser = socialUserService.getSocialUserByCode(userType, type, code, state); - // 断言 - assertEquals(userId, socialUser.getUserId()); - assertEquals(socialUserDO.getOpenid(), socialUser.getOpenid()); - } - - @Test - public void testAuthSocialUser_exists() { - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 方法 - SocialUserDO socialUser = randomPojo(SocialUserDO.class).setType(socialType).setCode(code).setState(state); - socialUserMapper.insert(socialUser); - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertPojoEquals(socialUser, result); - } - - @Test - public void testAuthSocialUser_notNull() { - // mock 数据 - SocialUserDO socialUser = randomPojo(SocialUserDO.class, - o -> o.setType(SocialTypeEnum.GITEE.getType()).setCode("tudou").setState("yuanma")); - socialUserMapper.insert(socialUser); - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertPojoEquals(socialUser, result); - } - - @Test - public void testAuthSocialUser_insert() { - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 方法 - AuthUser authUser = randomPojo(AuthUser.class); - when(socialClientService.getAuthUser(eq(socialType), eq(userType), eq(code), eq(state))).thenReturn(authUser); - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertBindSocialUser(socialType, result, authUser); - assertEquals(code, result.getCode()); - assertEquals(state, result.getState()); - } - - @Test - public void testAuthSocialUser_update() { - // 准备参数 - Integer socialType = SocialTypeEnum.GITEE.getType(); - Integer userType = randomEle(SocialTypeEnum.values()).getType(); - String code = "tudou"; - String state = "yuanma"; - // mock 数据 - socialUserMapper.insert(randomPojo(SocialUserDO.class).setType(socialType).setOpenid("test_openid")); - // mock 方法 - AuthUser authUser = randomPojo(AuthUser.class); - when(socialClientService.getAuthUser(eq(socialType), eq(userType), eq(code), eq(state))).thenReturn(authUser); - - // 调用 - SocialUserDO result = socialUserService.authSocialUser(socialType, userType, code, state); - // 断言 - assertBindSocialUser(socialType, result, authUser); - assertEquals(code, result.getCode()); - assertEquals(state, result.getState()); - } - - private void assertBindSocialUser(Integer type, SocialUserDO socialUser, AuthUser authUser) { - assertEquals(authUser.getToken().getAccessToken(), socialUser.getToken()); - assertEquals(toJsonString(authUser.getToken()), socialUser.getRawTokenInfo()); - assertEquals(authUser.getNickname(), socialUser.getNickname()); - assertEquals(authUser.getAvatar(), socialUser.getAvatar()); - assertEquals(toJsonString(authUser.getRawUserInfo()), socialUser.getRawUserInfo()); - assertEquals(type, socialUser.getType()); - assertEquals(authUser.getUuid(), socialUser.getOpenid()); - } - - @Test - public void testGetSocialUser_id() { - // mock 数据 - SocialUserDO socialUserDO = randomPojo(SocialUserDO.class); - socialUserMapper.insert(socialUserDO); - // 参数准备 - Long id = socialUserDO.getId(); - - // 调用 - SocialUserDO dbSocialUserDO = socialUserService.getSocialUser(id); - // 断言 - assertPojoEquals(socialUserDO, dbSocialUserDO); - } - - @Test - public void testGetSocialUserPage() { - // mock 数据 - SocialUserDO dbSocialUser = randomPojo(SocialUserDO.class, o -> { // 等会查询到 - o.setType(SocialTypeEnum.GITEE.getType()); - o.setNickname("芋艿"); - o.setOpenid("yudaoyuanma"); - o.setCreateTime(buildTime(2020, 1, 15)); - }); - socialUserMapper.insert(dbSocialUser); - // 测试 type 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setType(SocialTypeEnum.DINGTALK.getType()))); - // 测试 nickname 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setNickname(randomString()))); - // 测试 openid 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setOpenid("java"))); - // 测试 createTime 不匹配 - socialUserMapper.insert(cloneIgnoreId(dbSocialUser, o -> o.setCreateTime(buildTime(2020, 1, 21)))); - // 准备参数 - SocialUserPageReqVO reqVO = new SocialUserPageReqVO(); - reqVO.setType(SocialTypeEnum.GITEE.getType()); - reqVO.setNickname("芋"); - reqVO.setOpenid("yudao"); - reqVO.setCreateTime(buildBetweenTime(2020, 1, 10, 2020, 1, 20)); - - // 调用 - PageResult pageResult = socialUserService.getSocialUserPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbSocialUser, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java deleted file mode 100755 index ab4784b97..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java +++ /dev/null @@ -1,236 +0,0 @@ -package cn.iocoder.yudao.module.system.service.tenant; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; -import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; -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 java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** -* {@link TenantPackageServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(TenantPackageServiceImpl.class) -public class TenantPackageServiceImplTest extends BaseDbUnitTest { - - @Resource - private TenantPackageServiceImpl tenantPackageService; - - @Resource - private TenantPackageMapper tenantPackageMapper; - - @MockBean - private TenantService tenantService; - - @Test - public void testCreateTenantPackage_success() { - // 准备参数 - TenantPackageSaveReqVO reqVO = randomPojo(TenantPackageSaveReqVO.class, - o -> o.setStatus(randomCommonStatus())) - .setId(null); // 防止 id 被赋值 - - // 调用 - Long tenantPackageId = tenantPackageService.createTenantPackage(reqVO); - // 断言 - assertNotNull(tenantPackageId); - // 校验记录的属性是否正确 - TenantPackageDO tenantPackage = tenantPackageMapper.selectById(tenantPackageId); - assertPojoEquals(reqVO, tenantPackage, "id"); - } - - @Test - public void testUpdateTenantPackage_success() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(randomCommonStatus())); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TenantPackageSaveReqVO reqVO = randomPojo(TenantPackageSaveReqVO.class, o -> { - o.setId(dbTenantPackage.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - // mock 方法 - Long tenantId01 = randomLongId(); - Long tenantId02 = randomLongId(); - when(tenantService.getTenantListByPackageId(eq(reqVO.getId()))).thenReturn( - asList(randomPojo(TenantDO.class, o -> o.setId(tenantId01)), - randomPojo(TenantDO.class, o -> o.setId(tenantId02)))); - - // 调用 - tenantPackageService.updateTenantPackage(reqVO); - // 校验是否更新正确 - TenantPackageDO tenantPackage = tenantPackageMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, tenantPackage); - // 校验调用租户的菜单 - verify(tenantService).updateTenantRoleMenu(eq(tenantId01), eq(reqVO.getMenuIds())); - verify(tenantService).updateTenantRoleMenu(eq(tenantId02), eq(reqVO.getMenuIds())); - } - - @Test - public void testUpdateTenantPackage_notExists() { - // 准备参数 - TenantPackageSaveReqVO reqVO = randomPojo(TenantPackageSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.updateTenantPackage(reqVO), TENANT_PACKAGE_NOT_EXISTS); - } - - @Test - public void testDeleteTenantPackage_success() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenantPackage.getId(); - // mock 租户未使用该套餐 - when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(0L); - - // 调用 - tenantPackageService.deleteTenantPackage(id); - // 校验数据不存在了 - assertNull(tenantPackageMapper.selectById(id)); - } - - @Test - public void testDeleteTenantPackage_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.deleteTenantPackage(id), TENANT_PACKAGE_NOT_EXISTS); - } - - @Test - public void testDeleteTenantPackage_used() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenantPackage.getId(); - // mock 租户在使用该套餐 - when(tenantService.getTenantCountByPackageId(eq(id))).thenReturn(1L); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.deleteTenantPackage(id), TENANT_PACKAGE_USED); - } - - @Test - public void testGetTenantPackagePage() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("源码解析"); - o.setCreateTime(buildTime(2022, 10, 10)); - }); - tenantPackageMapper.insert(dbTenantPackage); - // 测试 name 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setName("源码"))); - // 测试 status 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 remark 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setRemark("解析"))); - // 测试 createTime 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setCreateTime(buildTime(2022, 11, 11)))); - // 准备参数 - TenantPackagePageReqVO reqVO = new TenantPackagePageReqVO(); - reqVO.setName("芋道"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setRemark("源码"); - reqVO.setCreateTime(buildBetweenTime(2022, 10, 9, 2022, 10, 11)); - - // 调用 - PageResult pageResult = tenantPackageService.getTenantPackagePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTenantPackage, pageResult.getList().get(0)); - } - - @Test - public void testValidTenantPackage_success() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantPackageDO result = tenantPackageService.validTenantPackage(dbTenantPackage.getId()); - // 断言 - assertPojoEquals(dbTenantPackage, result); - } - - @Test - public void testValidTenantPackage_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.validTenantPackage(id), TENANT_PACKAGE_NOT_EXISTS); - } - - @Test - public void testValidTenantPackage_disable() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - - // 调用, 并断言异常 - assertServiceException(() -> tenantPackageService.validTenantPackage(dbTenantPackage.getId()), - TENANT_PACKAGE_DISABLE, dbTenantPackage.getName()); - } - - @Test - public void testGetTenantPackage() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); - tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantPackageDO result = tenantPackageService.getTenantPackage(dbTenantPackage.getId()); - // 断言 - assertPojoEquals(result, dbTenantPackage); - } - - @Test - public void testGetTenantPackageListByStatus() { - // mock 数据 - TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - tenantPackageMapper.insert(dbTenantPackage); - // 测试 status 不匹配 - tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - - // 调用 - List list = tenantPackageService.getTenantPackageListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - assertEquals(1, list.size()); - assertPojoEquals(dbTenantPackage, list.get(0)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java deleted file mode 100644 index 87d66ea6c..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImplTest.java +++ /dev/null @@ -1,458 +0,0 @@ -package cn.iocoder.yudao.module.system.service.tenant; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.tenant.config.TenantProperties; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; -import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper; -import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; -import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; -import cn.iocoder.yudao.module.system.service.permission.MenuService; -import cn.iocoder.yudao.module.system.service.permission.PermissionService; -import cn.iocoder.yudao.module.system.service.permission.RoleService; -import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; -import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; -import cn.iocoder.yudao.module.system.service.user.AdminUserService; -import org.junit.jupiter.api.BeforeEach; -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 java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO.PACKAGE_ID_SYSTEM; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -/** - * {@link TenantServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(TenantServiceImpl.class) -public class TenantServiceImplTest extends BaseDbUnitTest { - - @Resource - private TenantServiceImpl tenantService; - - @Resource - private TenantMapper tenantMapper; - - @MockBean - private TenantProperties tenantProperties; - @MockBean - private TenantPackageService tenantPackageService; - @MockBean - private AdminUserService userService; - @MockBean - private RoleService roleService; - @MockBean - private MenuService menuService; - @MockBean - private PermissionService permissionService; - - @BeforeEach - public void setUp() { - // 清理租户上下文 - TenantContextHolder.clear(); - } - - @Test - public void testGetTenantIdList() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L)); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - List result = tenantService.getTenantIdList(); - assertEquals(Collections.singletonList(1L), result); - } - - @Test - public void testValidTenant_notExists() { - assertServiceException(() -> tenantService.validTenant(randomLongId()), TENANT_NOT_EXISTS); - } - - @Test - public void testValidTenant_disable() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.DISABLE.getStatus())); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - assertServiceException(() -> tenantService.validTenant(1L), TENANT_DISABLE, tenant.getName()); - } - - @Test - public void testValidTenant_expired() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setExpireTime(buildTime(2020, 2, 2))); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - assertServiceException(() -> tenantService.validTenant(1L), TENANT_EXPIRE, tenant.getName()); - } - - @Test - public void testValidTenant_success() { - // mock 数据 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setId(1L).setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setExpireTime(LocalDateTime.now().plusDays(1))); - tenantMapper.insert(tenant); - - // 调用,并断言业务异常 - tenantService.validTenant(1L); - } - - @Test - public void testCreateTenant() { - // mock 套餐 100L - TenantPackageDO tenantPackage = randomPojo(TenantPackageDO.class, o -> o.setId(100L)); - when(tenantPackageService.validTenantPackage(eq(100L))).thenReturn(tenantPackage); - // mock 角色 200L - when(roleService.createRole(argThat(role -> { - assertEquals(RoleCodeEnum.TENANT_ADMIN.getName(), role.getName()); - assertEquals(RoleCodeEnum.TENANT_ADMIN.getCode(), role.getCode()); - assertEquals(0, role.getSort()); - assertEquals("系统自动生成", role.getRemark()); - return true; - }), eq(RoleTypeEnum.SYSTEM.getType()))).thenReturn(200L); - // mock 用户 300L - when(userService.createUser(argThat(user -> { - assertEquals("yunai", user.getUsername()); - assertEquals("yuanma", user.getPassword()); - assertEquals("芋道", user.getNickname()); - assertEquals("15601691300", user.getMobile()); - return true; - }))).thenReturn(300L); - - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { - o.setContactName("芋道"); - o.setContactMobile("15601691300"); - o.setPackageId(100L); - o.setStatus(randomCommonStatus()); - o.setWebsite("https://www.iocoder.cn"); - o.setUsername("yunai"); - o.setPassword("yuanma"); - }).setId(null); // 设置为 null,方便后面校验 - - // 调用 - Long tenantId = tenantService.createTenant(reqVO); - // 断言 - assertNotNull(tenantId); - // 校验记录的属性是否正确 - TenantDO tenant = tenantMapper.selectById(tenantId); - assertPojoEquals(reqVO, tenant, "id"); - assertEquals(300L, tenant.getContactUserId()); - // verify 分配权限 - verify(permissionService).assignRoleMenu(eq(200L), same(tenantPackage.getMenuIds())); - // verify 分配角色 - verify(permissionService).assignUserRole(eq(300L), eq(singleton(200L))); - } - - @Test - public void testUpdateTenant_success() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setStatus(randomCommonStatus())); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { - o.setId(dbTenant.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setWebsite(randomString()); - }); - - // mock 套餐 - TenantPackageDO tenantPackage = randomPojo(TenantPackageDO.class, - o -> o.setMenuIds(asSet(200L, 201L))); - when(tenantPackageService.validTenantPackage(eq(reqVO.getPackageId()))).thenReturn(tenantPackage); - // mock 所有角色 - RoleDO role100 = randomPojo(RoleDO.class, o -> o.setId(100L).setCode(RoleCodeEnum.TENANT_ADMIN.getCode())); - role100.setTenantId(dbTenant.getId()); - RoleDO role101 = randomPojo(RoleDO.class, o -> o.setId(101L)); - role101.setTenantId(dbTenant.getId()); - when(roleService.getRoleList()).thenReturn(asList(role100, role101)); - // mock 每个角色的权限 - when(permissionService.getRoleMenuListByRoleId(eq(101L))).thenReturn(asSet(201L, 202L)); - - // 调用 - tenantService.updateTenant(reqVO); - // 校验是否更新正确 - TenantDO tenant = tenantMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, tenant); - // verify 设置角色权限 - verify(permissionService).assignRoleMenu(eq(100L), eq(asSet(200L, 201L))); - verify(permissionService).assignRoleMenu(eq(101L), eq(asSet(201L))); - } - - @Test - public void testUpdateTenant_notExists() { - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> tenantService.updateTenant(reqVO), TENANT_NOT_EXISTS); - } - - @Test - public void testUpdateTenant_system() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(PACKAGE_ID_SYSTEM)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - TenantSaveReqVO reqVO = randomPojo(TenantSaveReqVO.class, o -> { - o.setId(dbTenant.getId()); // 设置更新的 ID - }); - - // 调用,校验业务异常 - assertServiceException(() -> tenantService.updateTenant(reqVO), TENANT_CAN_NOT_UPDATE_SYSTEM); - } - - @Test - public void testDeleteTenant_success() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, - o -> o.setStatus(randomCommonStatus())); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenant.getId(); - - // 调用 - tenantService.deleteTenant(id); - // 校验数据不存在了 - assertNull(tenantMapper.selectById(id)); - } - - @Test - public void testDeleteTenant_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantService.deleteTenant(id), TENANT_NOT_EXISTS); - } - - @Test - public void testDeleteTenant_system() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(PACKAGE_ID_SYSTEM)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenant.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> tenantService.deleteTenant(id), TENANT_CAN_NOT_UPDATE_SYSTEM); - } - - @Test - public void testGetTenant() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbTenant.getId(); - - // 调用 - TenantDO result = tenantService.getTenant(id); - // 校验存在 - assertPojoEquals(result, dbTenant); - } - - @Test - public void testGetTenantPage() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setContactName("芋艿"); - o.setContactMobile("15601691300"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2020, 12, 12)); - }); - tenantMapper.insert(dbTenant); - // 测试 name 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setName(randomString()))); - // 测试 contactName 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setContactName(randomString()))); - // 测试 contactMobile 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setContactMobile(randomString()))); - // 测试 status 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - tenantMapper.insert(cloneIgnoreId(dbTenant, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - TenantPageReqVO reqVO = new TenantPageReqVO(); - reqVO.setName("芋道"); - reqVO.setContactName("艿"); - reqVO.setContactMobile("1560"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2020, 12, 1, 2020, 12, 24)); - - // 调用 - PageResult pageResult = tenantService.getTenantPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTenant, pageResult.getList().get(0)); - } - - @Test - public void testGetTenantByName() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setName("芋道")); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantDO result = tenantService.getTenantByName("芋道"); - // 校验存在 - assertPojoEquals(result, dbTenant); - } - - @Test - public void testGetTenantByWebsite() { - // mock 数据 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setWebsite("https://www.iocoder.cn")); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - - // 调用 - TenantDO result = tenantService.getTenantByWebsite("https://www.iocoder.cn"); - // 校验存在 - assertPojoEquals(result, dbTenant); - } - - @Test - public void testGetTenantListByPackageId() { - // mock 数据 - TenantDO dbTenant1 = randomPojo(TenantDO.class, o -> o.setPackageId(1L)); - tenantMapper.insert(dbTenant1);// @Sql: 先插入出一条存在的数据 - TenantDO dbTenant2 = randomPojo(TenantDO.class, o -> o.setPackageId(2L)); - tenantMapper.insert(dbTenant2);// @Sql: 先插入出一条存在的数据 - - // 调用 - List result = tenantService.getTenantListByPackageId(1L); - assertEquals(1, result.size()); - assertPojoEquals(dbTenant1, result.get(0)); - } - - @Test - public void testGetTenantCountByPackageId() { - // mock 数据 - TenantDO dbTenant1 = randomPojo(TenantDO.class, o -> o.setPackageId(1L)); - tenantMapper.insert(dbTenant1);// @Sql: 先插入出一条存在的数据 - TenantDO dbTenant2 = randomPojo(TenantDO.class, o -> o.setPackageId(2L)); - tenantMapper.insert(dbTenant2);// @Sql: 先插入出一条存在的数据 - - // 调用 - Long count = tenantService.getTenantCountByPackageId(1L); - assertEquals(1, count); - } - - @Test - public void testHandleTenantInfo_disable() { - // 准备参数 - TenantInfoHandler handler = mock(TenantInfoHandler.class); - // mock 禁用 - when(tenantProperties.getEnable()).thenReturn(false); - - // 调用 - tenantService.handleTenantInfo(handler); - // 断言 - verify(handler, never()).handle(any()); - } - - @Test - public void testHandleTenantInfo_success() { - // 准备参数 - TenantInfoHandler handler = mock(TenantInfoHandler.class); - // mock 未禁用 - when(tenantProperties.getEnable()).thenReturn(true); - // mock 租户 - TenantDO dbTenant = randomPojo(TenantDO.class); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - TenantContextHolder.setTenantId(dbTenant.getId()); - - // 调用 - tenantService.handleTenantInfo(handler); - // 断言 - verify(handler).handle(argThat(argument -> { - assertPojoEquals(dbTenant, argument); - return true; - })); - } - - @Test - public void testHandleTenantMenu_disable() { - // 准备参数 - TenantMenuHandler handler = mock(TenantMenuHandler.class); - // mock 禁用 - when(tenantProperties.getEnable()).thenReturn(false); - - // 调用 - tenantService.handleTenantMenu(handler); - // 断言 - verify(handler, never()).handle(any()); - } - - @Test // 系统租户的情况 - public void testHandleTenantMenu_system() { - // 准备参数 - TenantMenuHandler handler = mock(TenantMenuHandler.class); - // mock 未禁用 - when(tenantProperties.getEnable()).thenReturn(true); - // mock 租户 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(PACKAGE_ID_SYSTEM)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - TenantContextHolder.setTenantId(dbTenant.getId()); - // mock 菜单 - when(menuService.getMenuList()).thenReturn(Arrays.asList(randomPojo(MenuDO.class, o -> o.setId(100L)), - randomPojo(MenuDO.class, o -> o.setId(101L)))); - - // 调用 - tenantService.handleTenantMenu(handler); - // 断言 - verify(handler).handle(asSet(100L, 101L)); - } - - @Test // 普通租户的情况 - public void testHandleTenantMenu_normal() { - // 准备参数 - TenantMenuHandler handler = mock(TenantMenuHandler.class); - // mock 未禁用 - when(tenantProperties.getEnable()).thenReturn(true); - // mock 租户 - TenantDO dbTenant = randomPojo(TenantDO.class, o -> o.setPackageId(200L)); - tenantMapper.insert(dbTenant);// @Sql: 先插入出一条存在的数据 - TenantContextHolder.setTenantId(dbTenant.getId()); - // mock 菜单 - when(tenantPackageService.getTenantPackage(eq(200L))).thenReturn(randomPojo(TenantPackageDO.class, - o -> o.setMenuIds(asSet(100L, 101L)))); - - // 调用 - tenantService.handleTenantMenu(handler); - // 断言 - verify(handler).handle(asSet(100L, 101L)); - } -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java deleted file mode 100644 index 03d7f8808..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java +++ /dev/null @@ -1,765 +0,0 @@ -package cn.iocoder.yudao.module.system.service.user; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportExcelVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; -import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; -import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; -import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; -import cn.iocoder.yudao.module.system.enums.common.SexEnum; -import cn.iocoder.yudao.module.system.service.dept.DeptService; -import cn.iocoder.yudao.module.system.service.dept.PostService; -import cn.iocoder.yudao.module.system.service.permission.PermissionService; -import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import org.junit.jupiter.api.Test; -import org.mockito.stubbing.Answer; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.security.crypto.password.PasswordEncoder; - -import javax.annotation.Resource; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import static cn.hutool.core.util.RandomUtil.randomBytes; -import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.assertj.core.util.Lists.newArrayList; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -@Import(AdminUserServiceImpl.class) -public class AdminUserServiceImplTest extends BaseDbUnitTest { - - @Resource - private AdminUserServiceImpl userService; - - @Resource - private AdminUserMapper userMapper; - @Resource - private UserPostMapper userPostMapper; - - @MockBean - private DeptService deptService; - @MockBean - private PostService postService; - @MockBean - private PermissionService permissionService; - @MockBean - private PasswordEncoder passwordEncoder; - @MockBean - private TenantService tenantService; - @MockBean - private FileApi fileApi; - - @Test - public void testCreatUser_success() { - // 准备参数 - UserSaveReqVO reqVO = randomPojo(UserSaveReqVO.class, o -> { - o.setSex(RandomUtil.randomEle(SexEnum.values()).getSex()); - o.setMobile(randomString()); - o.setPostIds(asSet(1L, 2L)); - }).setId(null); // 避免 id 被赋值 - // mock 账户额度充足 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setAccountCount(1)); - doNothing().when(tenantService).handleTenantInfo(argThat(handler -> { - handler.handle(tenant); - return true; - })); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(reqVO.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - // mock postService 的方法 - List posts = CollectionUtils.convertList(reqVO.getPostIds(), postId -> - randomPojo(PostDO.class, o -> { - o.setId(postId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - })); - when(postService.getPostList(eq(reqVO.getPostIds()), isNull())).thenReturn(posts); - // mock passwordEncoder 的方法 - when(passwordEncoder.encode(eq(reqVO.getPassword()))).thenReturn("yudaoyuanma"); - - // 调用 - Long userId = userService.createUser(reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertPojoEquals(reqVO, user, "password", "id"); - assertEquals("yudaoyuanma", user.getPassword()); - assertEquals(CommonStatusEnum.ENABLE.getStatus(), user.getStatus()); - // 断言关联岗位 - List userPosts = userPostMapper.selectListByUserId(user.getId()); - assertEquals(1L, userPosts.get(0).getPostId()); - assertEquals(2L, userPosts.get(1).getPostId()); - } - - @Test - public void testCreatUser_max() { - // 准备参数 - UserSaveReqVO reqVO = randomPojo(UserSaveReqVO.class); - // mock 账户额度不足 - TenantDO tenant = randomPojo(TenantDO.class, o -> o.setAccountCount(-1)); - doNothing().when(tenantService).handleTenantInfo(argThat(handler -> { - handler.handle(tenant); - return true; - })); - - // 调用,并断言异常 - assertServiceException(() -> userService.createUser(reqVO), USER_COUNT_MAX, -1); - } - - @Test - public void testUpdateUser_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> o.setPostIds(asSet(1L, 2L))); - userMapper.insert(dbUser); - userPostMapper.insert(new UserPostDO().setUserId(dbUser.getId()).setPostId(1L)); - userPostMapper.insert(new UserPostDO().setUserId(dbUser.getId()).setPostId(2L)); - // 准备参数 - UserSaveReqVO reqVO = randomPojo(UserSaveReqVO.class, o -> { - o.setId(dbUser.getId()); - o.setSex(RandomUtil.randomEle(SexEnum.values()).getSex()); - o.setMobile(randomString()); - o.setPostIds(asSet(2L, 3L)); - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(reqVO.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - // mock postService 的方法 - List posts = CollectionUtils.convertList(reqVO.getPostIds(), postId -> - randomPojo(PostDO.class, o -> { - o.setId(postId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - })); - when(postService.getPostList(eq(reqVO.getPostIds()), isNull())).thenReturn(posts); - - // 调用 - userService.updateUser(reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(reqVO.getId()); - assertPojoEquals(reqVO, user, "password"); - // 断言关联岗位 - List userPosts = userPostMapper.selectListByUserId(user.getId()); - assertEquals(2L, userPosts.get(0).getPostId()); - assertEquals(3L, userPosts.get(1).getPostId()); - } - - @Test - public void testUpdateUserLogin() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(o -> o.setLoginDate(null)); - userMapper.insert(user); - // 准备参数 - Long id = user.getId(); - String loginIp = randomString(); - - // 调用 - userService.updateUserLogin(id, loginIp); - // 断言 - AdminUserDO dbUser = userMapper.selectById(id); - assertEquals(loginIp, dbUser.getLoginIp()); - assertNotNull(dbUser.getLoginDate()); - } - - @Test - public void testUpdateUserProfile_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - UserProfileUpdateReqVO reqVO = randomPojo(UserProfileUpdateReqVO.class, o -> { - o.setMobile(randomString()); - o.setSex(RandomUtil.randomEle(SexEnum.values()).getSex()); - }); - - // 调用 - userService.updateUserProfile(userId, reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertPojoEquals(reqVO, user); - } - - @Test - public void testUpdateUserPassword_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> o.setPassword("encode:tudou")); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - UserProfileUpdatePasswordReqVO reqVO = randomPojo(UserProfileUpdatePasswordReqVO.class, o -> { - o.setOldPassword("tudou"); - o.setNewPassword("yuanma"); - }); - // mock 方法 - when(passwordEncoder.encode(anyString())).then( - (Answer) invocationOnMock -> "encode:" + invocationOnMock.getArgument(0)); - when(passwordEncoder.matches(eq(reqVO.getOldPassword()), eq(dbUser.getPassword()))).thenReturn(true); - - // 调用 - userService.updateUserPassword(userId, reqVO); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals("encode:yuanma", user.getPassword()); - } - - @Test - public void testUpdateUserAvatar_success() throws Exception { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - byte[] avatarFileBytes = randomBytes(10); - ByteArrayInputStream avatarFile = new ByteArrayInputStream(avatarFileBytes); - // mock 方法 - String avatar = randomString(); - when(fileApi.createFile(eq( avatarFileBytes))).thenReturn(avatar); - - // 调用 - userService.updateUserAvatar(userId, avatarFile); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals(avatar, user.getAvatar()); - } - - @Test - public void testUpdateUserPassword02_success() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - String password = "yudao"; - // mock 方法 - when(passwordEncoder.encode(anyString())).then( - (Answer) invocationOnMock -> "encode:" + invocationOnMock.getArgument(0)); - - // 调用 - userService.updateUserPassword(userId, password); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals("encode:" + password, user.getPassword()); - } - - @Test - public void testUpdateUserStatus() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - Integer status = randomCommonStatus(); - - // 调用 - userService.updateUserStatus(userId, status); - // 断言 - AdminUserDO user = userMapper.selectById(userId); - assertEquals(status, user.getStatus()); - } - - @Test - public void testDeleteUser_success(){ - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - - // 调用数据 - userService.deleteUser(userId); - // 校验结果 - assertNull(userMapper.selectById(userId)); - // 校验调用次数 - verify(permissionService, times(1)).processUserDeleted(eq(userId)); - } - - @Test - public void testGetUserByUsername() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - String username = dbUser.getUsername(); - - // 调用 - AdminUserDO user = userService.getUserByUsername(username); - // 断言 - assertPojoEquals(dbUser, user); - } - - @Test - public void testGetUserByMobile() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - String mobile = dbUser.getMobile(); - - // 调用 - AdminUserDO user = userService.getUserByMobile(mobile); - // 断言 - assertPojoEquals(dbUser, user); - } - - @Test - public void testGetUserPage() { - // mock 数据 - AdminUserDO dbUser = initGetUserPageData(); - // 准备参数 - UserPageReqVO reqVO = new UserPageReqVO(); - reqVO.setUsername("tu"); - reqVO.setMobile("1560"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2020, 12, 1, 2020, 12, 24)); - reqVO.setDeptId(1L); // 其中,1L 是 2L 的父部门 - // mock 方法 - List deptList = newArrayList(randomPojo(DeptDO.class, o -> o.setId(2L))); - when(deptService.getChildDeptList(eq(reqVO.getDeptId()))).thenReturn(deptList); - - // 调用 - PageResult pageResult = userService.getUserPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbUser, pageResult.getList().get(0)); - } - - /** - * 初始化 getUserPage 方法的测试数据 - */ - private AdminUserDO initGetUserPageData() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> { // 等会查询到 - o.setUsername("tudou"); - o.setMobile("15601691300"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2020, 12, 12)); - o.setDeptId(2L); - }); - userMapper.insert(dbUser); - // 测试 username 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setUsername("dou"))); - // 测试 mobile 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setMobile("18818260888"))); - // 测试 status 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setCreateTime(buildTime(2020, 11, 11)))); - // 测试 dept 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setDeptId(0L))); - return dbUser; - } - - @Test - public void testGetUser() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - Long userId = dbUser.getId(); - - // 调用 - AdminUserDO user = userService.getUser(userId); - // 断言 - assertPojoEquals(dbUser, user); - } - - @Test - public void testGetUserListByDeptIds() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(o -> o.setDeptId(1L)); - userMapper.insert(dbUser); - // 测试 deptId 不匹配 - userMapper.insert(cloneIgnoreId(dbUser, o -> o.setDeptId(2L))); - // 准备参数 - Collection deptIds = singleton(1L); - - // 调用 - List list = userService.getUserListByDeptIds(deptIds); - // 断言 - assertEquals(1, list.size()); - assertEquals(dbUser, list.get(0)); - } - - /** - * 情况一,校验不通过,导致插入失败 - */ - @Test - public void testImportUserList_01() { - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - }); - // mock 方法,模拟失败 - doThrow(new ServiceException(DEPT_NOT_FOUND)).when(deptService).validateDeptList(any()); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), true); - // 断言 - assertEquals(0, respVO.getCreateUsernames().size()); - assertEquals(0, respVO.getUpdateUsernames().size()); - assertEquals(1, respVO.getFailureUsernames().size()); - assertEquals(DEPT_NOT_FOUND.getMsg(), respVO.getFailureUsernames().get(importUser.getUsername())); - } - - /** - * 情况二,不存在,进行插入 - */ - @Test - public void testImportUserList_02() { - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(importUser.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - // mock passwordEncoder 的方法 - when(passwordEncoder.encode(eq("yudaoyuanma"))).thenReturn("java"); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), true); - // 断言 - assertEquals(1, respVO.getCreateUsernames().size()); - AdminUserDO user = userMapper.selectByUsername(respVO.getCreateUsernames().get(0)); - assertPojoEquals(importUser, user); - assertEquals("java", user.getPassword()); - assertEquals(0, respVO.getUpdateUsernames().size()); - assertEquals(0, respVO.getFailureUsernames().size()); - } - - /** - * 情况三,存在,但是不强制更新 - */ - @Test - public void testImportUserList_03() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - o.setUsername(dbUser.getUsername()); - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(importUser.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), false); - // 断言 - assertEquals(0, respVO.getCreateUsernames().size()); - assertEquals(0, respVO.getUpdateUsernames().size()); - assertEquals(1, respVO.getFailureUsernames().size()); - assertEquals(USER_USERNAME_EXISTS.getMsg(), respVO.getFailureUsernames().get(importUser.getUsername())); - } - - /** - * 情况四,存在,强制更新 - */ - @Test - public void testImportUserList_04() { - // mock 数据 - AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); - // 准备参数 - UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - o.setUsername(dbUser.getUsername()); - }); - // mock deptService 的方法 - DeptDO dept = randomPojo(DeptDO.class, o -> { - o.setId(importUser.getDeptId()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - when(deptService.getDept(eq(dept.getId()))).thenReturn(dept); - - // 调用 - UserImportRespVO respVO = userService.importUserList(newArrayList(importUser), true); - // 断言 - assertEquals(0, respVO.getCreateUsernames().size()); - assertEquals(1, respVO.getUpdateUsernames().size()); - AdminUserDO user = userMapper.selectByUsername(respVO.getUpdateUsernames().get(0)); - assertPojoEquals(importUser, user); - assertEquals(0, respVO.getFailureUsernames().size()); - } - - @Test - public void testValidateUserExists_notExists() { - assertServiceException(() -> userService.validateUserExists(randomLongId()), USER_NOT_EXISTS); - } - - @Test - public void testValidateUsernameUnique_usernameExistsForCreate() { - // 准备参数 - String username = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateUsernameUnique(null, username), - USER_USERNAME_EXISTS); - } - - @Test - public void testValidateUsernameUnique_usernameExistsForUpdate() { - // 准备参数 - Long id = randomLongId(); - String username = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateUsernameUnique(id, username), - USER_USERNAME_EXISTS); - } - - @Test - public void testValidateEmailUnique_emailExistsForCreate() { - // 准备参数 - String email = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateEmailUnique(null, email), - USER_EMAIL_EXISTS); - } - - @Test - public void testValidateEmailUnique_emailExistsForUpdate() { - // 准备参数 - Long id = randomLongId(); - String email = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateEmailUnique(id, email), - USER_EMAIL_EXISTS); - } - - @Test - public void testValidateMobileUnique_mobileExistsForCreate() { - // 准备参数 - String mobile = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateMobileUnique(null, mobile), - USER_MOBILE_EXISTS); - } - - @Test - public void testValidateMobileUnique_mobileExistsForUpdate() { - // 准备参数 - Long id = randomLongId(); - String mobile = randomString(); - // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); - - // 调用,校验异常 - assertServiceException(() -> userService.validateMobileUnique(id, mobile), - USER_MOBILE_EXISTS); - } - - @Test - public void testValidateOldPassword_notExists() { - assertServiceException(() -> userService.validateOldPassword(randomLongId(), randomString()), - USER_NOT_EXISTS); - } - - @Test - public void testValidateOldPassword_passwordFailed() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); - // 准备参数 - Long id = user.getId(); - String oldPassword = user.getPassword(); - - // 调用,校验异常 - assertServiceException(() -> userService.validateOldPassword(id, oldPassword), - USER_PASSWORD_FAILED); - // 校验调用 - verify(passwordEncoder, times(1)).matches(eq(oldPassword), eq(user.getPassword())); - } - - @Test - public void testUserListByPostIds() { - // 准备参数 - Collection postIds = asSet(10L, 20L); - // mock user1 数据 - AdminUserDO user1 = randomAdminUserDO(o -> o.setPostIds(asSet(10L, 30L))); - userMapper.insert(user1); - userPostMapper.insert(new UserPostDO().setUserId(user1.getId()).setPostId(10L)); - userPostMapper.insert(new UserPostDO().setUserId(user1.getId()).setPostId(30L)); - // mock user2 数据 - AdminUserDO user2 = randomAdminUserDO(o -> o.setPostIds(singleton(100L))); - userMapper.insert(user2); - userPostMapper.insert(new UserPostDO().setUserId(user2.getId()).setPostId(100L)); - - // 调用 - List result = userService.getUserListByPostIds(postIds); - // 断言 - assertEquals(1, result.size()); - assertEquals(user1, result.get(0)); - } - - @Test - public void testGetUserList() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); - // 测试 id 不匹配 - userMapper.insert(randomAdminUserDO()); - // 准备参数 - Collection ids = singleton(user.getId()); - - // 调用 - List result = userService.getUserList(ids); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(0)); - } - - @Test - public void testGetUserMap() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); - // 测试 id 不匹配 - userMapper.insert(randomAdminUserDO()); - // 准备参数 - Collection ids = singleton(user.getId()); - - // 调用 - Map result = userService.getUserMap(ids); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(user.getId())); - } - - @Test - public void testGetUserListByNickname() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(o -> o.setNickname("芋头")); - userMapper.insert(user); - // 测试 nickname 不匹配 - userMapper.insert(randomAdminUserDO(o -> o.setNickname("源码"))); - // 准备参数 - String nickname = "芋"; - - // 调用 - List result = userService.getUserListByNickname(nickname); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(0)); - } - - @Test - public void testGetUserListByStatus() { - // mock 数据 - AdminUserDO user = randomAdminUserDO(o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - userMapper.insert(user); - // 测试 status 不匹配 - userMapper.insert(randomAdminUserDO(o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus()))); - // 准备参数 - Integer status = CommonStatusEnum.DISABLE.getStatus(); - - // 调用 - List result = userService.getUserListByStatus(status); - // 断言 - assertEquals(1, result.size()); - assertEquals(user, result.get(0)); - } - - @Test - public void testValidateUserList_success() { - // mock 数据 - AdminUserDO userDO = randomAdminUserDO().setStatus(CommonStatusEnum.ENABLE.getStatus()); - userMapper.insert(userDO); - // 准备参数 - List ids = singletonList(userDO.getId()); - - // 调用,无需断言 - userService.validateUserList(ids); - } - - @Test - public void testValidateUserList_notFound() { - // 准备参数 - List ids = singletonList(randomLongId()); - - // 调用, 并断言异常 - assertServiceException(() -> userService.validateUserList(ids), USER_NOT_EXISTS); - } - - @Test - public void testValidateUserList_notEnable() { - // mock 数据 - AdminUserDO userDO = randomAdminUserDO().setStatus(CommonStatusEnum.DISABLE.getStatus()); - userMapper.insert(userDO); - // 准备参数 - List ids = singletonList(userDO.getId()); - - // 调用, 并断言异常 - assertServiceException(() -> userService.validateUserList(ids), USER_IS_DISABLE, - userDO.getNickname()); - } - - // ========== 随机对象 ========== - - @SafeVarargs - private static AdminUserDO randomAdminUserDO(Consumer... consumers) { - Consumer consumer = (o) -> { - o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 - o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 - }; - return randomPojo(AdminUserDO.class, ArrayUtils.append(consumer, consumers)); - } - -} diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml b/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index dfa782ea7..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,57 +0,0 @@ -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;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - -mybatis-plus: - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - captcha: - timeout: 5m - width: 160 - height: 60 - enable: true diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/logback.xml b/yudao-module-system/yudao-module-system-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql b/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index e7946a105..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,33 +0,0 @@ -DELETE FROM "system_dept"; -DELETE FROM "system_dict_data"; -DELETE FROM "system_role"; -DELETE FROM "system_role_menu"; -DELETE FROM "system_menu"; -DELETE FROM "system_user_role"; -DELETE FROM "system_dict_type"; -DELETE FROM "system_user_session"; -DELETE FROM "system_post"; -DELETE FROM "system_user_post"; -DELETE FROM "system_notice"; -DELETE FROM "system_login_log"; -DELETE FROM "system_operate_log"; -DELETE FROM "system_users"; -DELETE FROM "system_sms_channel"; -DELETE FROM "system_sms_template"; -DELETE FROM "system_sms_log"; -DELETE FROM "system_sms_code"; -DELETE FROM "system_social_client"; -DELETE FROM "system_social_user"; -DELETE FROM "system_social_user_bind"; -DELETE FROM "system_tenant"; -DELETE FROM "system_tenant_package"; -DELETE FROM "system_oauth2_client"; -DELETE FROM "system_oauth2_approve"; -DELETE FROM "system_oauth2_access_token"; -DELETE FROM "system_oauth2_refresh_token"; -DELETE FROM "system_oauth2_code"; -DELETE FROM "system_mail_account"; -DELETE FROM "system_mail_template"; -DELETE FROM "system_mail_log"; -DELETE FROM "system_notify_template"; -DELETE FROM "system_notify_message"; diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql b/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 087540a6e..000000000 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,614 +0,0 @@ -CREATE TABLE IF NOT EXISTS "system_dept" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL DEFAULT '', - "parent_id" bigint NOT NULL DEFAULT '0', - "sort" int NOT NULL DEFAULT '0', - "leader_user_id" bigint DEFAULT NULL, - "phone" varchar(11) DEFAULT NULL, - "email" varchar(50) DEFAULT NULL, - "status" tinyint 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, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '部门表'; - -CREATE TABLE IF NOT EXISTS "system_dict_data" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "sort" int NOT NULL DEFAULT '0', - "label" varchar(100) NOT NULL DEFAULT '', - "value" varchar(100) NOT NULL DEFAULT '', - "dict_type" varchar(100) NOT NULL DEFAULT '', - "status" tinyint NOT NULL DEFAULT '0', - "color_type" varchar(100) NOT NULL DEFAULT '', - "css_class" varchar(100) NOT NULL DEFAULT '', - "remark" varchar(500) DEFAULT 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 '字典数据表'; - -CREATE TABLE IF NOT EXISTS "system_role" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL, - "code" varchar(100) NOT NULL, - "sort" int NOT NULL, - "data_scope" tinyint NOT NULL DEFAULT '1', - "data_scope_dept_ids" varchar(500) NOT NULL DEFAULT '', - "status" tinyint NOT NULL, - "type" tinyint NOT NULL, - "remark" varchar(500) DEFAULT 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, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '角色信息表'; - -CREATE TABLE IF NOT EXISTS "system_role_menu" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "role_id" bigint NOT NULL, - "menu_id" bigint 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, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '角色和菜单关联表'; - -CREATE TABLE IF NOT EXISTS "system_menu" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(50) NOT NULL, - "permission" varchar(100) NOT NULL DEFAULT '', - "type" tinyint NOT NULL, - "sort" int NOT NULL DEFAULT '0', - "parent_id" bigint NOT NULL DEFAULT '0', - "path" varchar(200) DEFAULT '', - "icon" varchar(100) DEFAULT '#', - "component" varchar(255) DEFAULT NULL, - "component_name" varchar(255) DEFAULT NULL, - "status" tinyint NOT NULL DEFAULT '0', - "visible" bit NOT NULL DEFAULT TRUE, - "keep_alive" bit NOT NULL DEFAULT TRUE, - "always_show" bit NOT NULL DEFAULT TRUE, - "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 '菜单权限表'; - -CREATE TABLE IF NOT EXISTS "system_user_role" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "role_id" bigint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp DEFAULT NULL, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp DEFAULT NULL, - "deleted" bit DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '用户和角色关联表'; - -CREATE TABLE IF NOT EXISTS "system_dict_type" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(100) NOT NULL DEFAULT '', - "type" varchar(100) NOT NULL DEFAULT '', - "status" tinyint NOT NULL DEFAULT '0', - "remark" varchar(500) DEFAULT 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, - "deleted_time" timestamp NOT NULL, - PRIMARY KEY ("id") -) COMMENT '字典类型表'; - -CREATE TABLE IF NOT EXISTS `system_user_session` ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `token` varchar(32) NOT NULL, - `user_id` bigint DEFAULT NULL, - "user_type" tinyint NOT NULL, - `username` varchar(50) NOT NULL DEFAULT '', - `user_ip` varchar(50) DEFAULT NULL, - `user_agent` varchar(512) DEFAULT NULL, - `session_timeout` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "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, - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT '用户在线 Session'; - -CREATE TABLE IF NOT EXISTS "system_post" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "code" varchar(64) NOT NULL, - "name" varchar(50) NOT NULL, - "sort" integer NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(500) DEFAULT 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, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '岗位信息表'; - -CREATE TABLE IF NOT EXISTS `system_user_post`( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint DEFAULT NULL, - "post_id" bigint DEFAULT 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, - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT ='用户岗位表'; - -CREATE TABLE IF NOT EXISTS "system_notice" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL COMMENT '公告标题', - "content" text NOT NULL COMMENT '公告内容', - "type" tinyint NOT NULL COMMENT '公告类型(1通知 2公告)', - "status" tinyint NOT NULL DEFAULT '0' COMMENT '公告状态(0正常 1关闭)', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit NOT NULL DEFAULT 0 COMMENT '是否删除', - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '通知公告表'; - -CREATE TABLE IF NOT EXISTS `system_login_log` ( - `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `log_type` bigint(4) NOT NULL, - "user_id" bigint not null default '0', - "user_type" tinyint NOT NULL, - `trace_id` varchar(64) NOT NULL DEFAULT '', - `username` varchar(50) NOT NULL DEFAULT '', - `result` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `user_agent` varchar(512) 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 '0', - PRIMARY KEY (`id`) -) COMMENT ='系统访问记录'; - -CREATE TABLE IF NOT EXISTS `system_operate_log` ( - `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `trace_id` varchar(64) NOT NULL DEFAULT '', - `user_id` bigint(20) NOT NULL, - "user_type" tinyint not null default '0', - `type` varchar(50) NOT NULL, - `sub_type` varchar(50) NOT NULL, - `biz_id` bigint(20) NOT NULL, - `action` varchar(2000) NOT NULL DEFAULT '', - `extra` varchar(512) NOT NULL DEFAULT '', - `request_method` varchar(16) DEFAULT '', - `request_url` varchar(255) DEFAULT '', - `user_ip` varchar(50) DEFAULT NULL, - `user_agent` varchar(200) 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 '0', - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT ='操作日志记录'; - -CREATE TABLE IF NOT EXISTS "system_users" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "username" varchar(30) not null, - "password" varchar(100) not null default '', - "nickname" varchar(30) not null, - "remark" varchar(500) default null, - "dept_id" bigint default null, - "post_ids" varchar(255) default null, - "email" varchar(50) default '', - "mobile" varchar(11) default '', - "sex" tinyint default '0', - "avatar" varchar(100) default '', - "status" tinyint not null default '0', - "login_ip" varchar(50) default '', - "login_date" timestamp default 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, - "tenant_id" bigint not null default '0', - primary key ("id") -) comment '用户信息表'; - -CREATE TABLE IF NOT EXISTS "system_sms_channel" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "signature" varchar(10) NOT NULL, - "code" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "api_key" varchar(63) NOT NULL, - "api_secret" varchar(63) DEFAULT NULL, - "callback_url" varchar(255) DEFAULT 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 '短信渠道'; - -CREATE TABLE IF NOT EXISTS "system_sms_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL, - "status" tinyint NOT NULL, - "code" varchar(63) NOT NULL, - "name" varchar(63) NOT NULL, - "content" varchar(255) NOT NULL, - "params" varchar(255) NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "api_template_id" varchar(63) NOT NULL, - "channel_id" bigint NOT NULL, - "channel_code" varchar(63) 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 '短信模板'; - -CREATE TABLE IF NOT EXISTS "system_sms_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "channel_id" bigint NOT NULL, - "channel_code" varchar(63) NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar(63) NOT NULL, - "template_type" tinyint NOT NULL, - "template_content" varchar(255) NOT NULL, - "template_params" varchar(255) NOT NULL, - "api_template_id" varchar(63) NOT NULL, - "mobile" varchar(11) NOT NULL, - "user_id" bigint DEFAULT '0', - "user_type" tinyint DEFAULT '0', - "send_status" tinyint NOT NULL DEFAULT '0', - "send_time" timestamp DEFAULT NULL, - "send_code" int DEFAULT NULL, - "send_msg" varchar(255) DEFAULT NULL, - "api_send_code" varchar(63) DEFAULT NULL, - "api_send_msg" varchar(255) DEFAULT NULL, - "api_request_id" varchar(255) DEFAULT NULL, - "api_serial_no" varchar(255) DEFAULT NULL, - "receive_status" tinyint NOT NULL DEFAULT '0', - "receive_time" timestamp DEFAULT NULL, - "api_receive_code" varchar(63) DEFAULT NULL, - "api_receive_msg" varchar(255) DEFAULT 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 '短信日志'; - -CREATE TABLE IF NOT EXISTS "system_sms_code" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "mobile" varchar(11) NOT NULL, - "code" varchar(11) NOT NULL, - "scene" bigint NOT NULL, - "create_ip" varchar NOT NULL, - "today_index" int NOT NULL, - "used" bit NOT NULL DEFAULT FALSE, - "used_time" timestamp DEFAULT NULL, - "used_ip" varchar 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 '短信日志'; - -CREATE TABLE IF NOT EXISTS "system_social_client" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(255) NOT NULL, - "social_type" int NOT NULL, - "user_type" int NOT NULL, - "client_id" varchar(255) NOT NULL, - "client_secret" varchar(255) NOT NULL, - "agent_id" varchar(255) NOT NULL, - "status" int 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 NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '社交客户端表'; - -CREATE TABLE IF NOT EXISTS "system_social_user" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL, - "openid" varchar(64) NOT NULL, - "token" varchar(256) DEFAULT NULL, - "raw_token_info" varchar(1024) NOT NULL, - "nickname" varchar(32) NOT NULL, - "avatar" varchar(255) DEFAULT NULL, - "raw_user_info" varchar(1024) NOT NULL, - "code" varchar(64) NOT NULL, - "state" varchar(64), - "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 '社交用户'; - -CREATE TABLE IF NOT EXISTS "system_social_user_bind" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "social_type" tinyint NOT NULL, - "social_user_id" number 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 '社交用户的绑定'; - -CREATE TABLE IF NOT EXISTS "system_tenant" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "contact_user_id" bigint NOT NULL DEFAULT '0', - "contact_name" varchar(255) NOT NULL, - "contact_mobile" varchar(255), - "status" tinyint NOT NULL, - "website" varchar(63) DEFAULT '', - "package_id" bigint NOT NULL, - "expire_time" timestamp NOT NULL, - "account_count" int 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 '租户'; - -CREATE TABLE IF NOT EXISTS "system_tenant_package" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(256), - "menu_ids" varchar(2048) 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 NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '租户套餐表'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_client" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "client_id" varchar NOT NULL, - "secret" varchar NOT NULL, - "name" varchar NOT NULL, - "logo" varchar NOT NULL, - "description" varchar, - "status" int NOT NULL, - "access_token_validity_seconds" int NOT NULL, - "refresh_token_validity_seconds" int NOT NULL, - "redirect_uris" varchar NOT NULL, - "authorized_grant_types" varchar NOT NULL, - "scopes" varchar NOT NULL DEFAULT '', - "auto_approve_scopes" varchar NOT NULL DEFAULT '', - "authorities" varchar NOT NULL DEFAULT '', - "resource_ids" varchar NOT NULL DEFAULT '', - "additional_information" varchar NOT NULL DEFAULT '', - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 客户端表'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_approve" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "client_id" varchar NOT NULL, - "scope" varchar NOT NULL, - "approved" bit NOT NULL DEFAULT FALSE, - "expires_time" datetime NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 批准表'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_access_token" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "user_info" varchar NOT NULL, - "access_token" varchar NOT NULL, - "refresh_token" varchar NOT NULL, - "client_id" varchar NOT NULL, - "scopes" varchar NOT NULL, - "approved" bit NOT NULL DEFAULT FALSE, - "expires_time" datetime NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 访问令牌'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_refresh_token" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "refresh_token" varchar NOT NULL, - "client_id" varchar NOT NULL, - "scopes" varchar NOT NULL, - "approved" bit NOT NULL DEFAULT FALSE, - "expires_time" datetime NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 刷新令牌'; - -CREATE TABLE IF NOT EXISTS "system_oauth2_code" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL, - "code" varchar NOT NULL, - "client_id" varchar NOT NULL, - "scopes" varchar NOT NULL, - "expires_time" datetime NOT NULL, - "redirect_uri" varchar NOT NULL, - "state" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'OAuth2 刷新令牌'; - -CREATE TABLE IF NOT EXISTS "system_mail_account" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "mail" varchar NOT NULL, - "username" varchar NOT NULL, - "password" varchar NOT NULL, - "host" varchar NOT NULL, - "port" int NOT NULL, - "ssl_enable" bit NOT NULL, - "starttls_enable" bit NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '邮箱账号表'; - -CREATE TABLE IF NOT EXISTS "system_mail_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "code" varchar NOT NULL, - "account_id" bigint NOT NULL, - "nickname" varchar, - "title" varchar NOT NULL, - "content" varchar NOT NULL, - "params" varchar NOT NULL, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '邮件模版表'; - -CREATE TABLE IF NOT EXISTS "system_mail_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint, - "user_type" varchar, - "to_mail" varchar NOT NULL, - "account_id" bigint NOT NULL, - "from_mail" varchar NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar NOT NULL, - "template_nickname" varchar, - "template_title" varchar NOT NULL, - "template_content" varchar NOT NULL, - "template_params" varchar NOT NULL, - "send_status" varchar NOT NULL, - "send_time" datetime, - "send_message_id" varchar, - "send_exception" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '邮件日志表'; - --- 将该建表 SQL 语句,添加到 yudao-module-system-biz 模块的 test/resources/sql/create_tables.sql 文件里 -CREATE TABLE IF NOT EXISTS "system_notify_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "code" varchar NOT NULL, - "nickname" varchar NOT NULL, - "content" varchar NOT NULL, - "type" varchar NOT NULL, - "params" varchar, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '站内信模板表'; - -CREATE TABLE IF NOT EXISTS "system_notify_message" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" varchar NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar NOT NULL, - "template_nickname" varchar NOT NULL, - "template_content" varchar NOT NULL, - "template_type" int NOT NULL, - "template_params" varchar NOT NULL, - "read_status" bit NOT NULL, - "read_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '站内信消息表';