| @@ -0,0 +1,421 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>yqzj</artifactId> | |||
| <packaging>pom</packaging> | |||
| <version>1.0</version> | |||
| <modules> | |||
| <module>yqzj-mybatis</module> | |||
| <module>yqzjService</module> | |||
| <module>yqzjAdmin</module> | |||
| <module>yqzjCApi</module> | |||
| <module>yqzjSchedule</module> | |||
| <module>yqzj-swagger</module> | |||
| </modules> | |||
| <parent> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-parent</artifactId> | |||
| <version>2.2.5.RELEASE</version> | |||
| <relativePath/> | |||
| </parent> | |||
| <properties> | |||
| <weixin-java-common.version>3.7.0.B</weixin-java-common.version> | |||
| <weixin-java-mp.version>3.7.0.B</weixin-java-mp.version> | |||
| <weixin-java-miniapp.version>3.7.0.B</weixin-java-miniapp.version> | |||
| <weixin-java-pay.version>3.7.0.B</weixin-java-pay.version> | |||
| <weixin-java-open.version>3.7.0.B</weixin-java-open.version> | |||
| <quartz.version>2.3.0</quartz.version> | |||
| <log4j2.version>2.15.0</log4j2.version> | |||
| </properties> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-web</artifactId> | |||
| <exclusions> | |||
| <exclusion> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-tomcat</artifactId> | |||
| </exclusion> | |||
| </exclusions> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-undertow</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-aop</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-amqp</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-cache</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-data-redis</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-configuration-processor</artifactId> | |||
| <optional>true</optional> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-web-services</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-mail</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.flowable</groupId> | |||
| <artifactId>flowable-spring-boot-starter-process</artifactId> | |||
| <version>6.4.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>mysql</groupId> | |||
| <artifactId>mysql-connector-java</artifactId> | |||
| <version>8.0.19</version> | |||
| <scope>runtime</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.baomidou</groupId> | |||
| <artifactId>mybatis-plus-boot-starter</artifactId> | |||
| <version>3.2.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.mybatis.spring.boot</groupId> | |||
| <artifactId>mybatis-spring-boot-starter</artifactId> | |||
| <version>2.1.2</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.pagehelper</groupId> | |||
| <artifactId>pagehelper-spring-boot-starter</artifactId> | |||
| <version>1.2.13</version> | |||
| <exclusions> | |||
| <exclusion> | |||
| <groupId>org.mybatis</groupId> | |||
| <artifactId>mybatis</artifactId> | |||
| </exclusion> | |||
| <exclusion> | |||
| <groupId>org.mybatis</groupId> | |||
| <artifactId>mybatis-spring</artifactId> | |||
| </exclusion> | |||
| </exclusions> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.alibaba</groupId> | |||
| <artifactId>druid</artifactId> | |||
| <version>1.1.22</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework</groupId> | |||
| <artifactId>spring-context-support</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-test</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <!-- rocketmq --> | |||
| <dependency> | |||
| <groupId>org.rocketmq.spring.boot</groupId> | |||
| <artifactId>rocketmq-spring-boot-starter</artifactId> | |||
| <version>1.0.0.RELEASE</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.apache.commons</groupId> | |||
| <artifactId>commons-lang3</artifactId> | |||
| <version>3.8</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.google.guava</groupId> | |||
| <artifactId>guava</artifactId> | |||
| <version>26.0-jre</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.alibaba</groupId> | |||
| <artifactId>fastjson</artifactId> | |||
| <version>1.2.68</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.quartz-scheduler</groupId> | |||
| <artifactId>quartz</artifactId> | |||
| <version>${quartz.version}</version> | |||
| <exclusions> | |||
| <exclusion> | |||
| <groupId>com.mchange</groupId> | |||
| <artifactId>c3p0</artifactId> | |||
| </exclusion> | |||
| <exclusion> | |||
| <groupId>com.zaxxer</groupId> | |||
| <artifactId>HikariCP-java6</artifactId> | |||
| </exclusion> | |||
| </exclusions> | |||
| </dependency> | |||
| <!-- Swagger --> | |||
| <!-- <dependency>--> | |||
| <!-- <groupId>io.springfox</groupId>--> | |||
| <!-- <artifactId>springfox-swagger2</artifactId>--> | |||
| <!-- <version>2.8.0</version>--> | |||
| <!-- </dependency>--> | |||
| <!-- <dependency>--> | |||
| <!-- <groupId>io.springfox</groupId>--> | |||
| <!-- <artifactId>springfox-swagger-ui</artifactId>--> | |||
| <!-- <version>2.8.0</version>--> | |||
| <!-- </dependency>--> | |||
| <!-- <dependency>--> | |||
| <!-- <groupId>io.springfox</groupId>--> | |||
| <!-- <artifactId>springfox-spring-web</artifactId>--> | |||
| <!-- <version>2.8.0</version>--> | |||
| <!-- </dependency>--> | |||
| <dependency> | |||
| <groupId>com.fasterxml.jackson.core</groupId> | |||
| <artifactId>jackson-core</artifactId> | |||
| <version>2.10.3</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.fasterxml.jackson.core</groupId> | |||
| <artifactId>jackson-databind</artifactId> | |||
| <version>2.10.3</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>javax.xml.bind</groupId> | |||
| <artifactId>jaxb-api</artifactId> | |||
| <version>2.3.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.projectlombok</groupId> | |||
| <artifactId>lombok</artifactId> | |||
| <version>1.18.10</version> | |||
| <scope>provided</scope> | |||
| </dependency> | |||
| <!-- </dependencyManagement> --> | |||
| <!-- <dependencies> --> | |||
| <!-- <dependency> --> | |||
| <!-- <groupId>com.iformall</groupId> --> | |||
| <!-- <artifactId>base</artifactId> --> | |||
| <!-- <version>1.0</version> --> | |||
| <!-- </dependency> --> | |||
| <!-- <dependency> --> | |||
| <!-- <groupId>com.iformall</groupId> --> | |||
| <!-- <artifactId>freemarker</artifactId> --> | |||
| <!-- <version>1.0</version> --> | |||
| <!-- </dependency> --> | |||
| <dependency> | |||
| <groupId>org.apache.shiro</groupId> | |||
| <artifactId>shiro-core</artifactId> | |||
| <version>1.4.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.apache.shiro</groupId> | |||
| <artifactId>shiro-spring</artifactId> | |||
| <version>1.4.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.crazycake</groupId> | |||
| <artifactId>shiro-redis</artifactId> | |||
| <version>3.1.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.jdom</groupId> | |||
| <artifactId>jdom2</artifactId> | |||
| <version>2.0.6</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.bouncycastle</groupId> | |||
| <artifactId>bcprov-jdk15on</artifactId> | |||
| <version>1.60</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.bouncycastle</groupId> | |||
| <artifactId>bcpkix-jdk15on</artifactId> | |||
| <version>1.60</version> | |||
| </dependency> | |||
| <!-- <dependency> --> | |||
| <!-- <groupId>net.coobird</groupId> --> | |||
| <!-- <artifactId>thumbnailator</artifactId> --> | |||
| <!-- <version>0.4.8</version> --> | |||
| <!-- </dependency> --> | |||
| <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> | |||
| <dependency> | |||
| <groupId>commons-io</groupId> | |||
| <artifactId>commons-io</artifactId> | |||
| <version>2.6</version> | |||
| </dependency> | |||
| <!--easypoi--> | |||
| <dependency> | |||
| <groupId>cn.afterturn</groupId> | |||
| <artifactId>easypoi-spring-boot-starter</artifactId> | |||
| <version>4.1.3.A</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> | |||
| <dependency> | |||
| <groupId>org.apache.httpcomponents</groupId> | |||
| <artifactId>httpclient</artifactId> | |||
| <version>4.5.3</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp --> | |||
| <dependency> | |||
| <groupId>com.squareup.okhttp3</groupId> | |||
| <artifactId>okhttp</artifactId> | |||
| <version>3.14.0</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/org.dom4j/dom4j --> | |||
| <dependency> | |||
| <groupId>org.dom4j</groupId> | |||
| <artifactId>dom4j</artifactId> | |||
| <version>2.1.1</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson --> | |||
| <dependency> | |||
| <groupId>com.google.code.gson</groupId> | |||
| <artifactId>gson</artifactId> | |||
| <version>2.8.5</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream --> | |||
| <dependency> | |||
| <groupId>com.thoughtworks.xstream</groupId> | |||
| <artifactId>xstream</artifactId> | |||
| <version>1.4.10</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.binarywang</groupId> | |||
| <artifactId>weixin-java-common</artifactId> | |||
| <version>${weixin-java-common.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.binarywang</groupId> | |||
| <artifactId>weixin-java-miniapp</artifactId> | |||
| <version>${weixin-java-miniapp.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.binarywang</groupId> | |||
| <artifactId>weixin-java-mp</artifactId> | |||
| <version>${weixin-java-mp.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.binarywang</groupId> | |||
| <artifactId>weixin-java-pay</artifactId> | |||
| <version>${weixin-java-pay.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.binarywang</groupId> | |||
| <artifactId>weixin-java-open</artifactId> | |||
| <version>${weixin-java-open.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.ulisesbocchio</groupId> | |||
| <artifactId>jasypt-spring-boot</artifactId> | |||
| <version>2.1.0</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.belerweb/pinyin4j --> | |||
| <dependency> | |||
| <groupId>com.belerweb</groupId> | |||
| <artifactId>pinyin4j</artifactId> | |||
| <version>2.5.0</version> | |||
| </dependency> | |||
| <!--阿里云的短信服务SDK--> | |||
| <dependency> | |||
| <groupId>com.aliyun</groupId> | |||
| <artifactId>aliyun-java-sdk-core</artifactId> | |||
| <version>4.5.2</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.aliyun</groupId> | |||
| <artifactId>aliyun-java-sdk-dysmsapi</artifactId> | |||
| <version>2.1.0</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss --> | |||
| <dependency> | |||
| <groupId>com.aliyun.oss</groupId> | |||
| <artifactId>aliyun-sdk-oss</artifactId> | |||
| <version>3.10.2</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload --> | |||
| <dependency> | |||
| <groupId>commons-fileupload</groupId> | |||
| <artifactId>commons-fileupload</artifactId> | |||
| <version>1.4</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-jpeg --> | |||
| <dependency> | |||
| <groupId>com.twelvemonkeys.imageio</groupId> | |||
| <artifactId>imageio-jpeg</artifactId> | |||
| <version>3.6</version> | |||
| </dependency> | |||
| <!-- <dependency> | |||
| <groupId>com.sun</groupId> | |||
| <artifactId>tools</artifactId> | |||
| <version>1.8.0</version> | |||
| <scope>system</scope> | |||
| <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath> | |||
| </dependency> --> | |||
| </dependencies> | |||
| <!-- | |||
| <build> | |||
| <plugins> | |||
| <plugin> | |||
| <groupId>org.apache.maven.plugins</groupId> | |||
| <artifactId>maven-compiler-plugin</artifactId> | |||
| <version>3.1</version> | |||
| <configuration> | |||
| <source>1.8</source> | |||
| <target>1.8</target> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| --> | |||
| </project> | |||
| @@ -0,0 +1,78 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>yqzj-mybatis</artifactId> | |||
| <version>1.0</version> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.github.jsqlparser</groupId> | |||
| <artifactId>jsqlparser</artifactId> | |||
| <version>2.0</version> | |||
| <scope>compile</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.baomidou</groupId> | |||
| <artifactId>mybatis-plus-core</artifactId> | |||
| <version>3.2.0</version> | |||
| </dependency> | |||
| <!--测试期间依赖--> | |||
| <dependency> | |||
| <scope>test</scope> | |||
| <groupId>junit</groupId> | |||
| <artifactId>junit</artifactId> | |||
| <version>4.12</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>mysql</groupId> | |||
| <artifactId>mysql-connector-java</artifactId> | |||
| <version>8.0.19</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.alibaba</groupId> | |||
| <artifactId>druid</artifactId> | |||
| <version>1.1.22</version> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| <plugins> | |||
| <plugin> | |||
| <groupId>org.apache.maven.plugins</groupId> | |||
| <artifactId>maven-compiler-plugin</artifactId> | |||
| <version>2.3.2</version> | |||
| <configuration> | |||
| <source>1.8</source> | |||
| <target>1.8</target> | |||
| <encoding>utf-8</encoding> | |||
| </configuration> | |||
| </plugin> | |||
| <plugin> | |||
| <artifactId>maven-source-plugin</artifactId> | |||
| <version>2.4</version> | |||
| <executions> | |||
| <execution> | |||
| <phase>package</phase> | |||
| <goals> | |||
| <goal>jar-no-fork</goal> | |||
| </goals> | |||
| </execution> | |||
| </executions> | |||
| </plugin> | |||
| <plugin> | |||
| <artifactId>maven-surefire-plugin</artifactId> | |||
| <version>2.9</version> | |||
| <configuration> | |||
| <!--跳过单元测试--> | |||
| <skip>false</skip> | |||
| <!--单元测试乱码--> | |||
| <forkMode>once</forkMode> | |||
| <argLine>-Dfile.encoding=UTF-8</argLine> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| </project> | |||
| @@ -0,0 +1,69 @@ | |||
| package com.iformall.plugin; | |||
| import org.apache.ibatis.executor.statement.StatementHandler; | |||
| import org.apache.ibatis.plugin.*; | |||
| import org.apache.ibatis.session.ResultHandler; | |||
| import com.iformall.plugin.entity.ChainValue; | |||
| import java.sql.Connection; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| *共享数据库的多租户系统实现 | |||
| * Created by Stormeye on 2018/10/22. | |||
| */ | |||
| @Intercepts({ | |||
| //@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}), | |||
| //@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}) | |||
| @Signature( method = "prepare", type = StatementHandler.class,args = {Connection.class, Integer.class}), | |||
| @Signature(method = "query", type = StatementHandler.class, args = {java.sql.Statement.class, ResultHandler.class}) | |||
| }) | |||
| public class MyBatisItercepters implements Interceptor { | |||
| private List<MyBatisPlus> plugins; | |||
| public MyBatisItercepters(){ | |||
| } | |||
| public void setPlugins(List<MyBatisPlus> plugins) { | |||
| this.plugins = plugins; | |||
| } | |||
| public Object intercept(Invocation invocation) throws Throwable { | |||
| if (null != plugins && plugins.size() > 0 ) { | |||
| // 能从cookie或者session获取到tenantId | |||
| Map<String,ChainValue> chainValues = new HashMap<String,ChainValue>(); | |||
| for (int i = 0 ; i < plugins.size() ; i++) { | |||
| MyBatisPlus plug = plugins.get(i); | |||
| invokeIntercept(plug, invocation, chainValues); | |||
| } | |||
| } | |||
| return invocation.proceed(); | |||
| } | |||
| private void invokeIntercept(MyBatisPlus plug,Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable { | |||
| Map<String,ChainValue> resultMap = plug.intercept(invocation, chainMap); | |||
| if (null != resultMap) { | |||
| chainMap.putAll(resultMap); | |||
| } | |||
| } | |||
| /** | |||
| * 生成代理对象 | |||
| * | |||
| * @param target | |||
| * @return | |||
| */ | |||
| @Override | |||
| public Object plugin(Object target) { | |||
| if (target instanceof StatementHandler) { | |||
| return Plugin.wrap(target, this); | |||
| } else { | |||
| return target; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,18 @@ | |||
| package com.iformall.plugin; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import org.apache.ibatis.plugin.Invocation; | |||
| import com.iformall.plugin.entity.ChainValue; | |||
| public interface MyBatisPlus { | |||
| /** | |||
| * @param invocation | |||
| * @return Map<coloumn,value> | |||
| * @throws Throwable | |||
| */ | |||
| public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable; | |||
| } | |||
| @@ -0,0 +1,662 @@ | |||
| package com.iformall.plugin.autoTenantId; | |||
| import net.sf.jsqlparser.JSQLParserException; | |||
| import net.sf.jsqlparser.expression.Expression; | |||
| import net.sf.jsqlparser.expression.Parenthesis; | |||
| import net.sf.jsqlparser.expression.StringValue; | |||
| import net.sf.jsqlparser.expression.operators.conditional.AndExpression; | |||
| import net.sf.jsqlparser.expression.operators.conditional.OrExpression; | |||
| import net.sf.jsqlparser.expression.operators.relational.EqualsTo; | |||
| import net.sf.jsqlparser.expression.operators.relational.ExpressionList; | |||
| import net.sf.jsqlparser.expression.operators.relational.ItemsList; | |||
| import net.sf.jsqlparser.expression.operators.relational.MultiExpressionList; | |||
| import net.sf.jsqlparser.parser.CCJSqlParserUtil; | |||
| import net.sf.jsqlparser.schema.Column; | |||
| import net.sf.jsqlparser.schema.Table; | |||
| import net.sf.jsqlparser.statement.Statement; | |||
| import net.sf.jsqlparser.statement.create.table.ColDataType; | |||
| import net.sf.jsqlparser.statement.create.table.ColumnDefinition; | |||
| import net.sf.jsqlparser.statement.create.table.CreateTable; | |||
| import net.sf.jsqlparser.statement.delete.Delete; | |||
| import net.sf.jsqlparser.statement.insert.Insert; | |||
| import net.sf.jsqlparser.statement.select.*; | |||
| import net.sf.jsqlparser.statement.update.Update; | |||
| import net.sf.jsqlparser.util.TablesNamesFinder; | |||
| import org.apache.ibatis.executor.statement.StatementHandler; | |||
| import org.apache.ibatis.mapping.BoundSql; | |||
| import org.apache.ibatis.mapping.MappedStatement; | |||
| import org.apache.ibatis.mapping.SqlCommandType; | |||
| import org.apache.ibatis.plugin.*; | |||
| import org.apache.ibatis.reflection.MetaObject; | |||
| import org.apache.ibatis.reflection.SystemMetaObject; | |||
| import org.apache.ibatis.session.Configuration; | |||
| import org.apache.ibatis.session.ResultHandler; | |||
| import com.iformall.plugin.MyBatisPlus; | |||
| import com.iformall.plugin.entity.ChainValue; | |||
| import java.sql.Connection; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| /** | |||
| *共享数据库的多租户系统实现 | |||
| * Created by Stormeye on 2018/10/22. | |||
| */ | |||
| public class MultiTenancy implements MyBatisPlus { | |||
| //获取tenantId的接口 | |||
| private TenantInfo tenantInfo; | |||
| private String tenantIdColumn = "tenant_id"; | |||
| private String parentTenantIdColumn = "parent_tenant_id"; | |||
| private String dialect = "mysql"; | |||
| public TenantInfo getTenantInfo() { | |||
| return tenantInfo; | |||
| } | |||
| public void setTenantInfo(TenantInfo tenantInfo) { | |||
| this.tenantInfo = tenantInfo; | |||
| } | |||
| public String getTenantIdColumn() { | |||
| return tenantIdColumn; | |||
| } | |||
| public void setTenantIdColumn(String tenantIdColumn) { | |||
| this.tenantIdColumn = tenantIdColumn; | |||
| } | |||
| public String getParentTenantIdColumn() { | |||
| return parentTenantIdColumn; | |||
| } | |||
| public void setParentTenantIdColumn(String parentTenantIdColumn) { | |||
| this.parentTenantIdColumn = parentTenantIdColumn; | |||
| } | |||
| public String getDialect() { | |||
| return dialect; | |||
| } | |||
| public void setDialect(String dialect) { | |||
| this.dialect = dialect; | |||
| } | |||
| //属性参数信息 | |||
| private Properties properties; | |||
| public MultiTenancy(){ | |||
| } | |||
| @Override | |||
| public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable { | |||
| if (getTenantInfo().getTenantId() != null || getTenantInfo().getParentTenantId() != null) { | |||
| // 能从cookie或者session获取到tenantId | |||
| //Map<String,Object> resultMap = new HashMap<String,Object>(); | |||
| //resultMap.put(tenantIdColumn, getTenantInfo().getTenantId()); | |||
| //resultMap.put(parentTenantIdColumn, getTenantInfo().getParentTenantId()); | |||
| return mod(invocation); | |||
| } | |||
| return null; | |||
| } | |||
| /** | |||
| * 更改MappedStatement为新的 | |||
| * @param invocation | |||
| * @throws Throwable | |||
| */ | |||
| public Map<String,ChainValue> mod(Invocation invocation) throws Throwable { | |||
| StatementHandler statementHandler = (StatementHandler) invocation.getTarget(); | |||
| MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler); | |||
| Configuration configuration = (Configuration) metaStatementHandler.getValue("delegate.configuration"); | |||
| MappedStatement ms = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement"); | |||
| if (getTenantInfo().doMappedStatementFIlter(ms)) | |||
| return null; | |||
| SqlCommandType type = ms.getSqlCommandType(); | |||
| BoundSql boundSql = statementHandler.getBoundSql(); | |||
| String newSQL = addWhere(boundSql.getSql()); | |||
| if (newSQL != null) { | |||
| metaStatementHandler.setValue("delegate.boundSql.sql", newSQL); | |||
| } | |||
| Map<String,ChainValue> newchainMap = new HashMap<String,ChainValue>(); | |||
| ChainValue tenantIdChain = new ChainValue(); | |||
| tenantIdChain.setColumn(tenantIdColumn); | |||
| tenantIdChain.setValue(getTenantInfo().getTenantId()); | |||
| tenantIdChain.setIgnoreTables(getTenantInfo().filterTables()); | |||
| newchainMap.put(tenantIdColumn,tenantIdChain); | |||
| ChainValue parentTenantIdChain = new ChainValue(); | |||
| parentTenantIdChain.setColumn(parentTenantIdColumn); | |||
| parentTenantIdChain.setValue(getTenantInfo().getParentTenantId()); | |||
| parentTenantIdChain.setIgnoreTables(getTenantInfo().filterSubTables()); | |||
| newchainMap.put(parentTenantIdColumn,parentTenantIdChain); | |||
| return newchainMap; | |||
| } | |||
| /** | |||
| * 添加租户id条件 | |||
| * @param sql | |||
| * @return | |||
| * @throws JSQLParserException | |||
| */ | |||
| private String addWhere(String sql) throws Exception { | |||
| Statement stmt = CCJSqlParserUtil.parse(sql); | |||
| if (stmt instanceof Insert) { | |||
| return processInsert((Insert) stmt); | |||
| } | |||
| if (stmt instanceof Delete) { | |||
| return processDelete((Delete) stmt); | |||
| } | |||
| if (stmt instanceof Update) { | |||
| return processUpdate(sql, stmt); | |||
| } | |||
| if (stmt instanceof Select) { | |||
| return processSelect(stmt); | |||
| } | |||
| if (stmt instanceof CreateTable) { | |||
| return processCreateTable((CreateTable) stmt); | |||
| } | |||
| throw new RuntimeException("非法sql语句,请检查"+sql); | |||
| } | |||
| private String processCreateTable(CreateTable stmt) { | |||
| CreateTable createTable = stmt; | |||
| ColDataType colDataType = new ColDataType(); | |||
| colDataType.setDataType("varchar(10)"); | |||
| // add tenant_id | |||
| ColumnDefinition columnDefinition = new ColumnDefinition(); | |||
| columnDefinition.setColumnName(getTenantIdColumn()); | |||
| columnDefinition.setColDataType(colDataType); | |||
| createTable.getColumnDefinitions().add(columnDefinition); | |||
| // add parent_tenant_id | |||
| ColumnDefinition subColumnDefinition = new ColumnDefinition(); | |||
| subColumnDefinition.setColumnName(getParentTenantIdColumn()); | |||
| subColumnDefinition.setColDataType(colDataType); | |||
| createTable.getColumnDefinitions().add(subColumnDefinition); | |||
| return createTable.toString(); | |||
| } | |||
| private String processSelect(Statement stmt) throws Exception { | |||
| //获得Select对象 | |||
| Select select = (Select) stmt; | |||
| PlainSelect ps = (PlainSelect) select.getSelectBody(); | |||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||
| List<String> tableList = tablesNamesFinder.getTableList(select); | |||
| if (tableList.size() == 0) { | |||
| return select.toString(); | |||
| } | |||
| for (String table : tableList) { | |||
| if (getTenantInfo().doTableFilter(table)) | |||
| continue; | |||
| if (ps.getWhere() != null) { | |||
| AndExpression where = addAndExpression(stmt, table, ps.getWhere()); | |||
| // form 和 join 中加载的表 | |||
| if (where != null) { | |||
| ps.setWhere(where); | |||
| } else { | |||
| //子查询中的表 | |||
| findSubSelect(stmt, ps.getWhere()); | |||
| } | |||
| } else { | |||
| String aliasName = getTableAlias(stmt, table); | |||
| EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); | |||
| ps.setWhere(equalsTo); | |||
| } | |||
| } | |||
| return select.toString(); | |||
| } | |||
| private String processUpdate(String sql, Statement stmt) throws Exception { | |||
| //获得Update对象 | |||
| Update updateStatement = (Update) stmt; | |||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||
| List<String> tableList = tablesNamesFinder.getTableList(stmt); | |||
| if (tableList.size() == 0) { | |||
| return updateStatement.toString(); | |||
| } | |||
| //获得where条件表达式 | |||
| Expression where = updateStatement.getWhere(); | |||
| for (String table: tableList) { | |||
| if (getTenantInfo().doTableFilter(table)) | |||
| continue; | |||
| if (where != null) { | |||
| AndExpression andE = addAndExpression(stmt, table, updateStatement.getWhere()); | |||
| if (andE != null) { | |||
| updateStatement.setWhere(andE); | |||
| } | |||
| } else { | |||
| throw new Exception("update语句不能没有where条件:" + sql + Arrays.toString(Thread.currentThread().getStackTrace())); | |||
| } | |||
| } | |||
| return updateStatement.toString(); | |||
| } | |||
| private String processDelete(Delete deleteStatement) { | |||
| //获得Delete对象 | |||
| if (getTenantInfo().doTableFilter(deleteStatement.getTable().getName())) | |||
| return deleteStatement.toString(); | |||
| Expression where = deleteStatement.getWhere(); | |||
| EqualsTo equalsTo = new EqualsTo(); | |||
| if (getTenantInfo().getTenantId() != null) { | |||
| equalsTo.setLeftExpression(new Column(getTenantIdColumn())); | |||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); | |||
| } | |||
| if (!getTenantInfo().doTableFilterSub(deleteStatement.getTable().getName())) { | |||
| if (getTenantInfo().getParentTenantId() != null) { | |||
| equalsTo.setLeftExpression(new Column(getParentTenantIdColumn())); | |||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getParentTenantId())); | |||
| } | |||
| } | |||
| if (null != where) { | |||
| if (where instanceof OrExpression) { | |||
| AndExpression andExpression = new AndExpression(equalsTo, new Parenthesis(where)); | |||
| deleteStatement.setWhere(andExpression); | |||
| } else { | |||
| AndExpression andExpression = new AndExpression(equalsTo, where); | |||
| deleteStatement.setWhere(andExpression); | |||
| } | |||
| } | |||
| return deleteStatement.toString(); | |||
| } | |||
| /** | |||
| * 插入处理 | |||
| * @param insertStatement | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| private String processInsert(Insert insertStatement) throws Exception { | |||
| // 非tenant表,直接返回 | |||
| if (getTenantInfo().doTableFilter(insertStatement.getTable().getName())) { | |||
| return insertStatement.toString(); | |||
| } | |||
| boolean bExist = insertStatement.getColumns().stream().anyMatch(col -> col.getColumnName().equalsIgnoreCase(getTenantIdColumn())); | |||
| if (!bExist) { | |||
| if (getTenantInfo().getTenantId() != null) { | |||
| insertStatement.getColumns().add(new Column(getTenantIdColumn())); | |||
| } | |||
| if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { | |||
| if (getTenantInfo().getParentTenantId() != null) { | |||
| insertStatement.getColumns().add(new Column(getParentTenantIdColumn())); | |||
| } | |||
| } | |||
| ItemsList itemsList = insertStatement.getItemsList(); | |||
| if (itemsList instanceof MultiExpressionList){ | |||
| ((MultiExpressionList) itemsList).getExprList().forEach(el -> { | |||
| el.getExpressions().add(new StringValue(getTenantInfo().getTenantId())); | |||
| if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { | |||
| if (getTenantInfo().getParentTenantId() != null) { | |||
| el.getExpressions().add(new StringValue(getTenantInfo().getParentTenantId())); | |||
| } | |||
| } | |||
| }); | |||
| }else { | |||
| ((ExpressionList) itemsList).getExpressions().add(new StringValue(getTenantInfo().getTenantId())); | |||
| if (!getTenantInfo().doTableFilterSub(insertStatement.getTable().getName())) { | |||
| if (getTenantInfo().getParentTenantId() != null) { | |||
| ((ExpressionList) itemsList).getExpressions().add(new StringValue(getTenantInfo().getParentTenantId())); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return insertStatement.toString(); | |||
| } | |||
| /** | |||
| * 获取配置信息 | |||
| * {dialect=mysql, tenantInfo=org.xue.test.TenantInfoImpl, tenantIdColumn=tenant_id, parentTenantIdColumn=parent_tenant_id} | |||
| * @param properties | |||
| */ | |||
| public void setProperties(Properties properties) { | |||
| this.properties=properties; | |||
| try { | |||
| Class onwClass=Class.forName(this.properties.getProperty("tenantInfo")); | |||
| this.tenantInfo = (TenantInfo)onwClass.newInstance(); | |||
| this.tenantIdColumn = this.properties.getProperty("tenantIdColumn"); | |||
| this.parentTenantIdColumn = this.properties.getProperty("parentTenantIdColumn"); | |||
| this.dialect = this.properties.getProperty("dialect"); | |||
| } catch (ClassNotFoundException e) { | |||
| throw new RuntimeException(e); | |||
| } catch (InstantiationException e) { | |||
| throw new RuntimeException(e); | |||
| } catch (IllegalAccessException e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| /** | |||
| * 多条件情况下,使用AndExpression给where条件加上tenantid条件 | |||
| * | |||
| * @param table | |||
| * @param where | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| public AndExpression addAndExpression(Statement stmt, String table, Expression where) throws Exception { | |||
| String aliasName = getTableAlias(stmt, table); | |||
| EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); | |||
| if (equalsTo != null) { | |||
| AndExpression right = new AndExpression(equalsTo, where); | |||
| if (!getTenantInfo().doTableFilterSub(table)) { | |||
| EqualsTo equalsToSub = addEqualsToForParentTenantId(stmt, table, aliasName); | |||
| if (equalsToSub != null) { | |||
| return new AndExpression(equalsToSub, right); | |||
| } else { | |||
| return right; | |||
| } | |||
| } else { | |||
| return right; | |||
| } | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| * 创建一个 EqualsTo相同判断 条件 | |||
| * | |||
| * @param stmt 查询对象 | |||
| * @param table 表名 | |||
| * @return “A=B” 单个where条件表达式 | |||
| * @throws Exception | |||
| */ | |||
| public EqualsTo addEqualsTo(Statement stmt, String table, String aliasName) throws Exception { | |||
| if (aliasName != null) { | |||
| if (getTenantInfo().getTenantId() != null) { | |||
| EqualsTo equalsTo = new EqualsTo(); | |||
| equalsTo.setLeftExpression(new Column(aliasName + '.' + getTenantIdColumn())); | |||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getTenantId())); | |||
| return equalsTo; | |||
| } | |||
| return null; | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| * 创建一个 EqualsTo相同判断 条件 | |||
| * | |||
| * @param stmt 查询对象 | |||
| * @param table 表名 | |||
| * @return “A=B” 单个where条件表达式 | |||
| * @throws Exception | |||
| */ | |||
| public EqualsTo addEqualsToForParentTenantId(Statement stmt, String table, String aliasName) throws Exception { | |||
| if (aliasName != null) { | |||
| if (getTenantInfo().getParentTenantId() != null) { | |||
| EqualsTo equalsTo = new EqualsTo(); | |||
| equalsTo.setLeftExpression(new Column(aliasName + '.' + getParentTenantIdColumn())); | |||
| equalsTo.setRightExpression(new StringValue(getTenantInfo().getParentTenantId())); | |||
| return equalsTo; | |||
| } else { | |||
| return null; | |||
| } | |||
| } else { | |||
| return null; | |||
| } | |||
| } | |||
| /** | |||
| * 获取sql送指定表的别名你,没有别名则返回原表名 如果表名不存在返回null | |||
| * 【仅查询from和join 不含 IN 子查询中的表 】 | |||
| * | |||
| * @param stmt | |||
| * @param tableName | |||
| * @return | |||
| */ | |||
| public String getTableAlias(Statement stmt, String tableName) { | |||
| String alias = null; | |||
| // 插入不做处理 | |||
| if (stmt instanceof Insert) { | |||
| return tableName; | |||
| } | |||
| if (stmt instanceof Delete) { | |||
| //获得Delete对象 | |||
| Delete deleteStatement = (Delete) stmt; | |||
| if ((deleteStatement.getTable()).getName().equalsIgnoreCase(tableName)) { | |||
| alias = deleteStatement.getTable().getAlias() != null ? deleteStatement.getTable().getAlias().getName() : tableName; | |||
| } | |||
| } | |||
| if (stmt instanceof Update) { | |||
| //获得Update对象 | |||
| Update updateStatement = (Update) stmt; | |||
| if ((updateStatement.getTables().get(0)).getName().equalsIgnoreCase(tableName)) { | |||
| alias = updateStatement.getTables().get(0).getAlias() != null ? updateStatement.getTables().get(0).getAlias().getName() : tableName; | |||
| } | |||
| } | |||
| if (stmt instanceof Select) { | |||
| Select select = (Select) stmt; | |||
| PlainSelect ps = (PlainSelect) select.getSelectBody(); | |||
| FromItem item = ps.getFromItem(); | |||
| // 判断主表的别名 | |||
| if (item instanceof Table) { | |||
| if (((Table) item).getName().equalsIgnoreCase(tableName)) { | |||
| alias = item.getAlias() != null ? item.getAlias().getName() : tableName; | |||
| } | |||
| } else { | |||
| } | |||
| } | |||
| return alias; | |||
| } | |||
| /** | |||
| * 针对子查询中的表别名查询 | |||
| * | |||
| * @param subSelect | |||
| * @param tableName | |||
| * @return | |||
| */ | |||
| public String getTableAlias(SubSelect subSelect, String tableName) { | |||
| PlainSelect ps = (PlainSelect) subSelect.getSelectBody(); | |||
| // 判断主表的别名 | |||
| String alias = null; | |||
| FromItem item = ps.getFromItem(); | |||
| if (item instanceof Table) { | |||
| if (((Table) item).getName().equalsIgnoreCase(tableName)){ | |||
| if (item.getAlias() != null) { | |||
| alias = item.getAlias().getName(); | |||
| } else { | |||
| alias = tableName; | |||
| } | |||
| } | |||
| } | |||
| return alias; | |||
| } | |||
| /** | |||
| * 递归处理 子查询中的tenantid-where | |||
| * | |||
| * @param stmt sql查询对象 | |||
| * @param where 当前sql的where条件 where为AndExpression或OrExpression的实例,解析其中的rightExpression,然后检查leftExpression是否为空, | |||
| * 不为空则是AndExpression或OrExpression,再次解析其中的rightExpression | |||
| * 注意tenantid-where是加在子查询上的 | |||
| */ | |||
| void findSubSelect(Statement stmt, Expression where) throws Exception { | |||
| // and 表达式 | |||
| if (where instanceof AndExpression) { | |||
| AndExpression andExpression = (AndExpression) where; | |||
| if (andExpression.getRightExpression() instanceof SubSelect) { | |||
| SubSelect subSelect = (SubSelect) andExpression.getRightExpression(); | |||
| doSelect(stmt, subSelect); | |||
| } | |||
| if (andExpression.getLeftExpression() != null) { | |||
| findSubSelect(stmt, andExpression.getLeftExpression()); | |||
| } | |||
| } else if (where instanceof OrExpression) { | |||
| // or表达式 | |||
| OrExpression orExpression = (OrExpression) where; | |||
| if (orExpression.getRightExpression() instanceof SubSelect) { | |||
| SubSelect subSelect = (SubSelect) orExpression.getRightExpression(); | |||
| doSelect(stmt, subSelect); | |||
| } | |||
| if (orExpression.getLeftExpression() != null) { | |||
| findSubSelect(stmt, orExpression.getLeftExpression()); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 处理select 和 subSelect | |||
| * | |||
| * @param stmt 查询对象 | |||
| * @param select | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| Expression doSelect(Statement stmt, Expression select) throws Exception { | |||
| PlainSelect ps = null; | |||
| boolean hasSubSelect = false; | |||
| if (select instanceof SubSelect) { | |||
| ps = (PlainSelect) ((SubSelect) select).getSelectBody(); | |||
| } | |||
| if (select instanceof Select) { | |||
| ps = (PlainSelect) ((Select) select).getSelectBody(); | |||
| } | |||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||
| List<String> tableList = tablesNamesFinder.getTableList(select); | |||
| if (tableList.size() == 0) { | |||
| return select; | |||
| } | |||
| for (String table : tableList) { | |||
| // sql 包含 where 条件的情况 使用 addAndExpression 连接 已有的条件和新条件 | |||
| if (ps.getWhere() == null) { | |||
| AndExpression where = addAndExpression(stmt, table, ps.getWhere()); | |||
| // form 和 join 中加载的表 | |||
| if (where != null) { | |||
| ps.setWhere(where); | |||
| } else { | |||
| // 如果在Statement中不存在这个表名,则存在于子查询中 | |||
| hasSubSelect = true; | |||
| } | |||
| } else { | |||
| // sql 不含 where条件 新建一个EqualsTo设置为where条件 | |||
| String aliasName = getTableAlias(stmt, table); | |||
| EqualsTo equalsTo = addEqualsTo(stmt, table, aliasName); | |||
| ps.setWhere(equalsTo); | |||
| } | |||
| } | |||
| if (hasSubSelect) { | |||
| //子查询中的表 | |||
| findSubSelect(stmt, ps.getWhere()); | |||
| } | |||
| return select; | |||
| } | |||
| private void processSelectBody(SelectBody selectBody) { | |||
| if (selectBody instanceof PlainSelect) { | |||
| processPlainSelect((PlainSelect) selectBody); | |||
| } else if (selectBody instanceof WithItem) { | |||
| WithItem withItem = (WithItem) selectBody; | |||
| if (withItem.getSelectBody() != null) { | |||
| processSelectBody(withItem.getSelectBody()); | |||
| } | |||
| } else { | |||
| SetOperationList operationList = (SetOperationList) selectBody; | |||
| if (operationList.getOperations() != null && operationList.getSelects().size() > 0) { | |||
| List<SelectBody> plainSelects = operationList.getSelects(); | |||
| for (SelectBody sub: plainSelects) { | |||
| processSelectBody(sub); | |||
| } | |||
| } | |||
| if (!orderByHashParameters(operationList.getOrderByElements())) { | |||
| operationList.setOrderByElements(null); | |||
| } | |||
| } | |||
| } | |||
| private void processPlainSelect(PlainSelect plainSelect) { | |||
| if (!orderByHashParameters(plainSelect.getOrderByElements())) { | |||
| plainSelect.setOrderByElements(null); | |||
| } | |||
| if (plainSelect.getFromItem() != null) { | |||
| processFromItem(plainSelect.getFromItem()); | |||
| } | |||
| if (plainSelect.getJoins() != null && plainSelect.getJoins().size() > 0) { | |||
| List<Join> joins = plainSelect.getJoins(); | |||
| for (Join join : joins) { | |||
| if (join.getRightItem() != null) { | |||
| processFromItem(join.getRightItem()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| public void processFromItem(FromItem fromItem) { | |||
| if (fromItem instanceof SubJoin) { | |||
| SubJoin subJoin = (SubJoin) fromItem; | |||
| if (subJoin.getJoinList() != null) { | |||
| for(Join tjoin: subJoin.getJoinList()) { | |||
| if (tjoin.getRightItem() != null) { | |||
| processFromItem(tjoin.getRightItem()); | |||
| } | |||
| } | |||
| } | |||
| } else if (fromItem instanceof SubSelect) { | |||
| SubSelect subSelect = (SubSelect) fromItem; | |||
| if (subSelect.getSelectBody() != null) { | |||
| processSelectBody(subSelect.getSelectBody()); | |||
| } | |||
| } else if (fromItem instanceof ValuesList) { | |||
| } else if (fromItem instanceof LateralSubSelect) { | |||
| LateralSubSelect lateralSubSelect = (LateralSubSelect) fromItem; | |||
| if (lateralSubSelect.getSubSelect() != null) { | |||
| SubSelect subSelect = (SubSelect) (lateralSubSelect.getSubSelect()); | |||
| if (subSelect.getSelectBody() != null) { | |||
| processSelectBody(subSelect.getSelectBody()); | |||
| } | |||
| } | |||
| } | |||
| //Table时不用处理 | |||
| } | |||
| public boolean orderByHashParameters(List<OrderByElement> orderByElements) { | |||
| if (orderByElements == null) { | |||
| return false; | |||
| } | |||
| for (OrderByElement orderByElement : orderByElements) { | |||
| if (orderByElement.toString().toUpperCase().contains("?")) { | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.iformall.plugin.autoTenantId; | |||
| import java.util.List; | |||
| import org.apache.ibatis.mapping.MappedStatement; | |||
| /** | |||
| * 需要实现该接口用于获取租户id | |||
| * Created by Stormeye on 2018/10/22. | |||
| */ | |||
| public interface TenantInfo { | |||
| String getTenantId(); | |||
| String getParentTenantId(); | |||
| boolean doTableFilter(String tableName); | |||
| List<String> filterTables(); | |||
| boolean doTableFilterSub(String tableName); | |||
| List<String> filterSubTables(); | |||
| boolean doMappedStatementFIlter(MappedStatement ms); | |||
| } | |||
| @@ -0,0 +1,41 @@ | |||
| package com.iformall.plugin.entity; | |||
| import java.io.Serializable; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.Set; | |||
| /** | |||
| * 链里的值 | |||
| * @author alascor | |||
| * {column:"tennat_id", value:"789", ignoreTables:"wx_c_user","wx_c_user_basic_info"...} | |||
| * | |||
| */ | |||
| public class ChainValue implements Serializable{ | |||
| private static final long serialVersionUID = 6290377774649358950L; | |||
| private String column; | |||
| private Object value; | |||
| private List<String> ignoreTables; | |||
| public String getColumn() { | |||
| return column; | |||
| } | |||
| public void setColumn(String column) { | |||
| this.column = column; | |||
| } | |||
| public Object getValue() { | |||
| return value; | |||
| } | |||
| public void setValue(Object value) { | |||
| this.value = value; | |||
| } | |||
| public List<String> getIgnoreTables() { | |||
| return ignoreTables; | |||
| } | |||
| public void setIgnoreTables(List<String> ignoreTables) { | |||
| this.ignoreTables = ignoreTables; | |||
| } | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package com.iformall.plugin.entity; | |||
| import java.util.Map; | |||
| public class ChainValueHelper { | |||
| public static Object getValue(String table,String column,Map<String,ChainValue> parentChainMap) { | |||
| if (null != parentChainMap && parentChainMap.containsKey(column)) { | |||
| ChainValue chainvalue = parentChainMap.get(column); | |||
| if (null != chainvalue) { | |||
| if (null != chainvalue.getIgnoreTables()) { | |||
| if (!chainvalue.getIgnoreTables().contains(table)) { | |||
| Object o = chainvalue.getValue(); | |||
| if (null != o) { | |||
| return o; | |||
| } | |||
| } | |||
| }else { | |||
| Object o = chainvalue.getValue(); | |||
| if (null != o) { | |||
| return o; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| package com.iformall.plugin.shard.annotation; | |||
| 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; | |||
| /** | |||
| * 在mapper方法上面用 | |||
| */ | |||
| @Documented | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Target(ElementType.METHOD) | |||
| public @interface IgnoreSharding { | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package com.iformall.plugin.shard.impl; | |||
| public enum EnumShardingRule { | |||
| HASH(1,"哈希值分表"); | |||
| private Integer code; | |||
| private String name; | |||
| private EnumShardingRule(Integer code, String name) { | |||
| this.code = code; | |||
| this.name = name; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(Integer code) { | |||
| this.code = code; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| package com.iformall.plugin.shard.impl; | |||
| import java.util.Map; | |||
| import java.util.concurrent.ConcurrentHashMap; | |||
| import com.alibaba.druid.util.StringUtils; | |||
| import com.iformall.plugin.shard.impl.rule.ShardingRuleDefaultService; | |||
| import com.iformall.plugin.shard.impl.rule.ShardingRuleService; | |||
| public class ShardingRuleExcuter { | |||
| private static Map<Integer,ShardingRuleService> serviceMap = null; | |||
| private static Map<Integer,ShardingRuleService> getServiceMap() { | |||
| if (null == serviceMap) { | |||
| serviceMap = new ConcurrentHashMap<Integer, ShardingRuleService>(); | |||
| serviceMap.put(EnumShardingRule.HASH.getCode(), new ShardingRuleDefaultService()); | |||
| } | |||
| return serviceMap; | |||
| } | |||
| public static String getTableIndex(Integer rule,Object value,int tableCount) { | |||
| String index = getServiceMap().get(rule).getTableIndex(value, tableCount); | |||
| if (StringUtils.isEmpty(index)) { | |||
| throw new RuntimeException("Sharding Rule["+rule+"] not support. column value:"+value+" tableCount:"+tableCount) ; | |||
| } | |||
| return index; | |||
| } | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| package com.iformall.plugin.shard.impl; | |||
| public class ShardingSphere { | |||
| public static final String TABLE_SUFFIX = "_"; | |||
| /*表名,不用带下划线**/ | |||
| private String tableName; | |||
| /*分表列名**/ | |||
| private String column; | |||
| /*分表规则**/ | |||
| private Integer rule; | |||
| /*表数量**/ | |||
| private Integer count; | |||
| public String getTableName() { | |||
| return tableName; | |||
| } | |||
| public void setTableName(String tableName) { | |||
| this.tableName = tableName; | |||
| } | |||
| public String getColumn() { | |||
| return column; | |||
| } | |||
| public void setColumn(String column) { | |||
| this.column = column; | |||
| } | |||
| public Integer getRule() { | |||
| return rule; | |||
| } | |||
| public void setRule(Integer rule) { | |||
| this.rule = rule; | |||
| } | |||
| public Integer getCount() { | |||
| return count; | |||
| } | |||
| public void setCount(Integer count) { | |||
| this.count = count; | |||
| } | |||
| } | |||
| @@ -0,0 +1,33 @@ | |||
| package com.iformall.plugin.shard.impl; | |||
| import java.util.Map; | |||
| import java.util.concurrent.ConcurrentHashMap; | |||
| public class ShardingTableExcuter { | |||
| private static Map<String,ShardingSphere> tableMap = new ConcurrentHashMap<String, ShardingSphere>(); | |||
| public static Map<String,ShardingSphere> setTableSharding(String table ,ShardingSphere ss) { | |||
| tableMap.put(table, ss); | |||
| return tableMap; | |||
| } | |||
| public static ShardingSphere getShardingSphere(String table) { | |||
| return tableMap.get(table); | |||
| } | |||
| public static boolean isShardingTable(String table) { | |||
| ShardingSphere ss = getShardingSphere(table); | |||
| if (null == ss) { | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| public static boolean hasShardingConfig() { | |||
| if (null == tableMap || tableMap.size() <= 0) { | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| package com.iformall.plugin.shard.impl.rule; | |||
| public class ShardingRuleDefaultService implements ShardingRuleService { | |||
| @Override | |||
| public String getTableIndex(Object value, int count) { | |||
| if (null == value || count <= 0 ) { | |||
| return null; | |||
| } | |||
| int hash = 9999999; | |||
| //如果是整数,则直接变为Long,好查询 | |||
| if (value instanceof String) { | |||
| try { | |||
| Long lvalue = Long.parseLong((String)value); | |||
| hash = getHashCode(lvalue); | |||
| }catch(Exception e) { | |||
| hash = getHashCode(value); | |||
| } | |||
| }else { | |||
| hash = getHashCode(value); | |||
| } | |||
| return String.valueOf(hash%count); | |||
| } | |||
| private int getHashCode(Object value) { | |||
| int hash = value.hashCode(); | |||
| if (hash < 0 ) { | |||
| hash = Math.abs(hash); | |||
| } | |||
| return hash; | |||
| } | |||
| } | |||
| @@ -0,0 +1,6 @@ | |||
| package com.iformall.plugin.shard.impl.rule; | |||
| public interface ShardingRuleService { | |||
| public String getTableIndex(Object value,int count); | |||
| } | |||
| @@ -0,0 +1,301 @@ | |||
| package com.iformall.plugin.shard.plugin; | |||
| import net.sf.jsqlparser.JSQLParserException; | |||
| import net.sf.jsqlparser.parser.CCJSqlParserUtil; | |||
| import net.sf.jsqlparser.schema.Table; | |||
| import net.sf.jsqlparser.statement.Statement; | |||
| import net.sf.jsqlparser.statement.create.table.CreateTable; | |||
| import net.sf.jsqlparser.statement.delete.Delete; | |||
| import net.sf.jsqlparser.statement.insert.Insert; | |||
| import net.sf.jsqlparser.statement.select.*; | |||
| import net.sf.jsqlparser.statement.update.Update; | |||
| import net.sf.jsqlparser.util.TablesNamesFinder; | |||
| import org.apache.ibatis.executor.statement.StatementHandler; | |||
| import org.apache.ibatis.logging.LogFactory; | |||
| import org.apache.ibatis.mapping.BoundSql; | |||
| import org.apache.ibatis.mapping.MappedStatement; | |||
| import org.apache.ibatis.mapping.StatementType; | |||
| import org.apache.ibatis.plugin.*; | |||
| import org.apache.ibatis.reflection.MetaObject; | |||
| import org.apache.ibatis.reflection.SystemMetaObject; | |||
| import com.alibaba.druid.wall.violation.ErrorCode; | |||
| import com.iformall.plugin.MyBatisPlus; | |||
| import com.iformall.plugin.entity.ChainValue; | |||
| import com.iformall.plugin.entity.ChainValueHelper; | |||
| import com.iformall.plugin.shard.annotation.IgnoreSharding; | |||
| import com.iformall.plugin.shard.impl.ShardingRuleExcuter; | |||
| import com.iformall.plugin.shard.impl.ShardingSphere; | |||
| import com.iformall.plugin.shard.impl.ShardingTableExcuter; | |||
| import java.lang.reflect.Method; | |||
| import java.math.BigDecimal; | |||
| import java.sql.Date; | |||
| import java.sql.Time; | |||
| import java.sql.Timestamp; | |||
| import java.util.HashMap; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| /** | |||
| *分表 | |||
| */ | |||
| public class ShardingSpherePlugin implements MyBatisPlus { | |||
| public ShardingSpherePlugin(){ | |||
| } | |||
| //属性参数信息 | |||
| private Properties properties; | |||
| private String dialect = "mysql"; | |||
| private List<ShardingSphere> ShardingSpheres; | |||
| public String getDialect() { | |||
| return dialect; | |||
| } | |||
| public void setDialect(String dialect) { | |||
| this.dialect = dialect; | |||
| } | |||
| public List<ShardingSphere> getShardingSpheres() { | |||
| return ShardingSpheres; | |||
| } | |||
| public void setShardingSpheres(List<ShardingSphere> shardingSpheres) { | |||
| ShardingSpheres = shardingSpheres; | |||
| } | |||
| /** | |||
| * 获取配置信息 | |||
| * {dialect=mysql, tenantInfo=org.xue.test.TenantInfoImpl, tenantIdColumn=tenant_id, parentTenantIdColumn=parent_tenant_id} | |||
| * @param properties | |||
| */ | |||
| public void setProperties(Properties properties) { | |||
| this.properties=properties; | |||
| this.dialect = this.properties.getProperty("dialect"); | |||
| if (null != this.ShardingSpheres) { | |||
| for (ShardingSphere ss : this.ShardingSpheres) { | |||
| ShardingTableExcuter.setTableSharding(ss.getTableName(), ss); | |||
| } | |||
| } | |||
| } | |||
| public Map<String,ChainValue> intercept(Invocation invocation,Map<String,ChainValue> chainMap) throws Throwable { | |||
| if (!ShardingTableExcuter.hasShardingConfig()) { | |||
| return null; | |||
| } | |||
| StatementHandler statementHandler = (StatementHandler) invocation.getTarget(); | |||
| MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler); | |||
| MappedStatement ms = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement"); | |||
| if(ms.getStatementType().equals(StatementType.CALLABLE)){ | |||
| return chainMap; | |||
| } | |||
| //String id = ms.getId(); | |||
| //String className = id.substring(0, id.lastIndexOf(".")); | |||
| //String methodName = id.substring(id.lastIndexOf(".") + 1); | |||
| //Class<?> clazz = Class.forName(className); | |||
| //Method method = getMethodFromAllParent(clazz, methodName); | |||
| //if (method != null) { | |||
| // IgnoreSharding ignore = method.getAnnotation(IgnoreSharding.class); | |||
| // if (null == ignore) { | |||
| Object parameterObject = metaStatementHandler.getValue("delegate.boundSql.parameterObject"); | |||
| BoundSql boundSql = statementHandler.getBoundSql(); | |||
| String newSQL = buildTable(boundSql,parameterObject,chainMap); | |||
| metaStatementHandler.setValue("delegate.boundSql.sql", newSQL); | |||
| // } | |||
| //} | |||
| //没有添加字段,只是根据字段分表,没有别的需要返回 | |||
| return chainMap; | |||
| } | |||
| private String buildTable(BoundSql boundSql,Object parameterObject,Map<String,ChainValue> chainMap) throws JSQLParserException { | |||
| String oldSql = boundSql.getSql(); | |||
| Statement stmt = CCJSqlParserUtil.parse(oldSql); | |||
| if (stmt instanceof Insert) { | |||
| return buildInsert((Insert) stmt,oldSql,parameterObject,chainMap); | |||
| } | |||
| if (stmt instanceof Delete) { | |||
| return buildDelete((Delete) stmt,oldSql,parameterObject,chainMap); | |||
| } | |||
| if (stmt instanceof Update) { | |||
| return buildUpdate((Update) stmt,oldSql,parameterObject,chainMap); | |||
| } | |||
| if (stmt instanceof Select) { | |||
| return buildSelect((Select) stmt,oldSql,parameterObject,chainMap); | |||
| } | |||
| if (stmt instanceof CreateTable) { | |||
| return oldSql; | |||
| } | |||
| throw new RuntimeException("非法sql语句,请检查"+oldSql); | |||
| } | |||
| private String buildInsert(Insert stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| return buildTable(stmt.getTable(), oldSql, parameterObject,chainMap); | |||
| } | |||
| private String buildDelete(Delete stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| return buildTable(stmt.getTable(), oldSql, parameterObject,chainMap); | |||
| } | |||
| private String buildUpdate(Update stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| return buildListTables(stmt.getTables(), oldSql, parameterObject,chainMap); | |||
| } | |||
| private String buildSelect(Select stmt,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); | |||
| List<String> tableList = tablesNamesFinder.getTableList(stmt); | |||
| return buildByListTableNames(tableList, oldSql, parameterObject,chainMap); | |||
| } | |||
| private String buildTable(Table table,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| return buildByTableName(table.getName(), oldSql, parameterObject,chainMap); | |||
| } | |||
| private String buildByTableName(String table,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| if (!ShardingTableExcuter.isShardingTable(table)) { | |||
| return oldSql; | |||
| } | |||
| String newtable = getShareTable(table,parameterObject,chainMap); | |||
| //此处处理前缀相似的表,如wx_c_user, wx_c_user_basic_info, 直接替换wx_c_user会有问题 | |||
| return oldSql.replaceAll(table+"_", "########").replaceAll(table, newtable).replaceAll("########", table+"_"); | |||
| } | |||
| private String buildListTables(List<Table> tables,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| for (Table t : tables) { | |||
| oldSql = buildTable(t,oldSql,parameterObject,chainMap); | |||
| } | |||
| return oldSql; | |||
| } | |||
| private String buildByListTableNames(List<String> tables,String oldSql,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| for (String t : tables) { | |||
| oldSql = buildByTableName(t,oldSql,parameterObject,chainMap); | |||
| } | |||
| return oldSql; | |||
| } | |||
| private String getShareTable(String table,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| ShardingSphere ss = ShardingTableExcuter.getShardingSphere(table); | |||
| return ss.getTableName()+ShardingSphere.TABLE_SUFFIX+ShardingRuleExcuter.getTableIndex(ss.getRule(), getValue(table,ss.getColumn(),parameterObject,chainMap), ss.getCount()); | |||
| } | |||
| private Object getValue(String table,String column,Object parameterObject,Map<String,ChainValue> parentChainMap) { | |||
| Object ov = ChainValueHelper.getValue(table, column, parentChainMap); | |||
| if (null != ov ) { | |||
| return ov; | |||
| } | |||
| if (parameterObject instanceof Map) { | |||
| String field = getField(column); | |||
| field = field.substring(0,1).toLowerCase()+field.substring(1); | |||
| Object o = parameterObject; | |||
| if (((Map) parameterObject).containsKey("et")) { | |||
| o = ((Map) parameterObject).get("et"); | |||
| }else if(((Map) parameterObject).containsKey("ew")) { | |||
| Object ew = ((Map) parameterObject).get("ew"); | |||
| if (ew instanceof com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) { | |||
| o = ((com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ew).getEntity(); | |||
| } | |||
| }else if(((Map) parameterObject).containsKey(column)) { | |||
| o = ((Map) parameterObject).get(column); | |||
| }else if (((Map) parameterObject).containsKey(field)) { | |||
| o = ((Map) parameterObject).get(field); | |||
| }else { | |||
| Map m = (Map) parameterObject; | |||
| for (Iterator it = m.keySet().iterator();it.hasNext();) { | |||
| Object ito = it.next(); | |||
| Object value = m.get(ito); | |||
| if(isBasicTypeValue(value)) { | |||
| if (ito instanceof String) { | |||
| String itoStr = (String) ito; | |||
| if( itoStr.equals(column) || itoStr.equals(field)) { | |||
| return value; | |||
| }else { | |||
| continue; | |||
| } | |||
| }else { | |||
| continue; | |||
| } | |||
| } | |||
| Object v = getValue(table,column,value,parentChainMap); | |||
| if (null != v) { | |||
| return v; | |||
| } | |||
| } | |||
| } | |||
| return getValue(table,column,o,parentChainMap); | |||
| }else if (isBasicTypeValue(parameterObject)) { | |||
| return parameterObject; | |||
| //认为是实体 | |||
| }else { | |||
| return getEntityValue(column, parameterObject, parentChainMap); | |||
| } | |||
| } | |||
| private String getField(String column) { | |||
| if (null == column) { | |||
| throw new RuntimeException("table sharinding error column is null"); | |||
| } | |||
| try { | |||
| if (column.contains("_") && (!column.endsWith("_")) && (!column.startsWith("_"))) { | |||
| String[] field = column.split("_"); | |||
| String fieldName = ""; | |||
| if (null != field && field.length > 0) { | |||
| for (String f : field) { | |||
| fieldName = fieldName + f.substring(0,1).toUpperCase()+f.substring(1); | |||
| } | |||
| }else { | |||
| fieldName = column.substring(0,1).toUpperCase()+column.substring(1); | |||
| } | |||
| return fieldName; | |||
| }else { | |||
| return column.substring(0,1).toUpperCase()+column.substring(1); | |||
| } | |||
| }catch(Exception e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| private boolean isBasicTypeValue(Object parameterObject) { | |||
| if( parameterObject instanceof Integer || parameterObject instanceof Long || parameterObject instanceof Short || parameterObject instanceof Float | |||
| || parameterObject instanceof Double || parameterObject instanceof BigDecimal || parameterObject instanceof Character || parameterObject instanceof String | |||
| || parameterObject instanceof Byte || parameterObject instanceof Date || parameterObject instanceof Time || parameterObject instanceof Timestamp ) { | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| private Object getEntityValue(String column,Object parameterObject,Map<String,ChainValue> chainMap) { | |||
| try { | |||
| Method method = getMethodFromAllParent(parameterObject.getClass(),"get"+getField(column)); | |||
| Object o = method.invoke(parameterObject); | |||
| return o; | |||
| }catch(Exception e) { | |||
| e.printStackTrace(); | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| private Method getMethodFromAllParent(Class<?> currentClazz,String methodName) { | |||
| Method method = null; | |||
| for(Class<?> clazz = currentClazz ; clazz != Object.class ; clazz = clazz.getSuperclass()) { | |||
| try { | |||
| method = clazz.getDeclaredMethod(methodName) ; | |||
| } catch (Exception e) { | |||
| //这里甚么都不要做!并且这里的异常必须这样写,不能抛出去。 | |||
| //如果这里的异常打印或者往外抛,则就不会执行clazz = clazz.getSuperclass(),最后就不会进入到父类中了 | |||
| } | |||
| } | |||
| if (null == method) { | |||
| throw new RuntimeException(currentClazz+" has no method:"+methodName+"()"); | |||
| } | |||
| return method; | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <parent> | |||
| <artifactId>yqzj</artifactId> | |||
| <groupId>com.iformall</groupId> | |||
| <version>1.0</version> | |||
| </parent> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <artifactId>yqzj-swagger</artifactId> | |||
| <dependencies> | |||
| <!--swagger 相关依赖--> | |||
| <dependency> | |||
| <groupId>io.springfox</groupId> | |||
| <artifactId>springfox-swagger2</artifactId> | |||
| <version>2.9.2</version> | |||
| </dependency> | |||
| <!--doc.html模式--> | |||
| <dependency> | |||
| <groupId>com.github.xiaoymin</groupId> | |||
| <artifactId>swagger-bootstrap-ui</artifactId> | |||
| <version>1.9.3</version> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -0,0 +1,19 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.ElementType; | |||
| import java.lang.annotation.Retention; | |||
| import java.lang.annotation.RetentionPolicy; | |||
| import java.lang.annotation.Target; | |||
| @Target(ElementType.METHOD) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| public @interface ApiVersion { | |||
| /** | |||
| * 接口版本号(对应swagger中的group) | |||
| * | |||
| * @return String[] | |||
| */ | |||
| String[] group(); | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.annotation; | |||
| import com.iformall.config.SwaggerConfiguration; | |||
| import org.springframework.context.annotation.Import; | |||
| import java.lang.annotation.*; | |||
| @Target({ElementType.TYPE}) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Documented | |||
| @Inherited | |||
| @Import({SwaggerConfiguration.class}) | |||
| public @interface BaseEnableSwagger { | |||
| } | |||
| @@ -0,0 +1,94 @@ | |||
| package com.iformall.config; | |||
| import com.google.common.base.Predicate; | |||
| import com.google.common.base.Predicates; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import springfox.documentation.builders.ApiInfoBuilder; | |||
| import springfox.documentation.builders.PathSelectors; | |||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||
| import springfox.documentation.service.ApiInfo; | |||
| import springfox.documentation.service.Contact; | |||
| import springfox.documentation.spi.DocumentationType; | |||
| import springfox.documentation.spring.web.plugins.Docket; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| import javax.servlet.ServletContext; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| @Configuration | |||
| @EnableSwagger2 | |||
| @EnableAutoConfiguration | |||
| @EnableConfigurationProperties(SwaggerProperties.class) | |||
| @ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true) | |||
| public class SwaggerConfiguration { | |||
| private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error"); | |||
| private static final String BASE_PATH = "/**"; | |||
| @Autowired | |||
| private SwaggerProperties swaggerProperties; | |||
| /** | |||
| * 1、分组 | |||
| * 2、切换分组,修改访问/v2/api-docs/ 接口的路径 | |||
| * https://admintest.malls.iformall.com/v2/api-docs/ | |||
| * https://admintest.malls.iformall.com/B/v2/api-docs/ | |||
| * | |||
| * @param servletContext | |||
| * @return {@link Docket} | |||
| */ | |||
| @Bean | |||
| public Docket docket(ServletContext servletContext) { | |||
| // base-path处理 | |||
| if (swaggerProperties.getBasePath().isEmpty()) { | |||
| swaggerProperties.getBasePath().add(BASE_PATH); | |||
| } | |||
| List<Predicate<String>> basePath = new ArrayList<>(swaggerProperties.getBasePath().size()); | |||
| swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path))); | |||
| // exclude-path处理 | |||
| if (swaggerProperties.getExcludePath().isEmpty()) { | |||
| swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); | |||
| } | |||
| List<Predicate<String>> excludePath = new ArrayList<>(); | |||
| swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); | |||
| return new Docket(DocumentationType.SWAGGER_2) | |||
| .host(swaggerProperties.getHost()) | |||
| .apiInfo(apiInfo(swaggerProperties)).select() | |||
| .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) | |||
| .apis(input -> { | |||
| ApiVersion apiVersion = input.getHandlerMethod().getMethodAnnotation(ApiVersion.class); | |||
| return apiVersion != null && Arrays.asList(apiVersion.group()).contains(SwaggerConstant.V_1_0_0); | |||
| }) | |||
| .paths( | |||
| Predicates.and( | |||
| Predicates.not(Predicates.or(excludePath)), | |||
| Predicates.or(basePath) | |||
| ) | |||
| ) | |||
| .build(); | |||
| } | |||
| private ApiInfo apiInfo(SwaggerProperties swaggerProperties) { | |||
| return new ApiInfoBuilder() | |||
| .title(swaggerProperties.getTitle()) | |||
| .description(swaggerProperties.getDescription()) | |||
| .license(swaggerProperties.getLicense()) | |||
| .licenseUrl(swaggerProperties.getLicenseUrl()) | |||
| .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) | |||
| .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) | |||
| .version(swaggerProperties.getVersion()) | |||
| .build(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,123 @@ | |||
| package com.iformall.config; | |||
| import lombok.Data; | |||
| import lombok.NoArgsConstructor; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @Data | |||
| @ConfigurationProperties("swagger") | |||
| public class SwaggerProperties { | |||
| private Map<String, String> services; | |||
| private String prePath; | |||
| /** | |||
| * 是否开启swagger | |||
| */ | |||
| private Boolean enabled; | |||
| /** | |||
| * swagger会解析的包路径 | |||
| **/ | |||
| private String basePackage = ""; | |||
| /** | |||
| * swagger会解析的url规则 | |||
| **/ | |||
| private List<String> basePath = new ArrayList<>(); | |||
| /** | |||
| * 在basePath基础上需要排除的url规则 | |||
| **/ | |||
| private List<String> excludePath = new ArrayList<>(); | |||
| /** | |||
| * 标题 | |||
| **/ | |||
| private String title = ""; | |||
| /** | |||
| * 描述 | |||
| **/ | |||
| private String description = ""; | |||
| /** | |||
| * 版本 | |||
| **/ | |||
| private String version = ""; | |||
| /** | |||
| * 许可证 | |||
| **/ | |||
| private String license = ""; | |||
| /** | |||
| * 许可证URL | |||
| **/ | |||
| private String licenseUrl = ""; | |||
| /** | |||
| * 服务条款URL | |||
| **/ | |||
| private String termsOfServiceUrl = ""; | |||
| /** | |||
| * host信息 | |||
| **/ | |||
| private String host = ""; | |||
| /** | |||
| * 联系人信息 | |||
| */ | |||
| private Contact contact = new Contact(); | |||
| /** | |||
| * 全局统一鉴权配置 | |||
| **/ | |||
| private Authorization authorization = new Authorization(); | |||
| @Data | |||
| public static class Contact { | |||
| /** | |||
| * 联系人 | |||
| **/ | |||
| private String name = ""; | |||
| /** | |||
| * 联系人url | |||
| **/ | |||
| private String url = ""; | |||
| /** | |||
| * 联系人email | |||
| **/ | |||
| private String email = ""; | |||
| } | |||
| @Data | |||
| @NoArgsConstructor | |||
| public static class Authorization { | |||
| /** | |||
| * 鉴权策略ID,需要和SecurityReferences ID保持一致 | |||
| */ | |||
| private String name = ""; | |||
| /** | |||
| * 需要开启鉴权URL的正则 | |||
| */ | |||
| private String authRegex = "^.*$"; | |||
| /** | |||
| * 鉴权作用域列表 | |||
| */ | |||
| private List<AuthorizationScope> authorizationScopeList = new ArrayList<>(); | |||
| private List<String> tokenUrlList = new ArrayList<>(); | |||
| } | |||
| @Data | |||
| @NoArgsConstructor | |||
| public static class AuthorizationScope { | |||
| /** | |||
| * 作用域名称 | |||
| */ | |||
| private String scope = ""; | |||
| /** | |||
| * 作用域描述 | |||
| */ | |||
| private String description = ""; | |||
| } | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| package com.iformall.constant; | |||
| public interface SwaggerConstant { | |||
| /** | |||
| * | |||
| */ | |||
| String V_1_0_0 = "v1.0.0"; | |||
| } | |||
| @@ -0,0 +1,187 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <parent> | |||
| <artifactId>yqzj</artifactId> | |||
| <groupId>com.iformall</groupId> | |||
| <version>1.0</version> | |||
| </parent> | |||
| <artifactId>yqzjAdmin</artifactId> | |||
| <properties> | |||
| <weixin-java-mp.version>3.7.0.B</weixin-java-mp.version> | |||
| <weixin-java-open.version>3.7.0.B</weixin-java-open.version> | |||
| </properties> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>yqzjService</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>commons-fileupload</groupId> | |||
| <artifactId>commons-fileupload</artifactId> | |||
| <version>1.3.3</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.google.zxing</groupId> | |||
| <artifactId>core</artifactId> | |||
| <version>3.3.3</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.axet</groupId> | |||
| <artifactId>kaptcha</artifactId> | |||
| <version>0.0.9</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.flywaydb</groupId> | |||
| <artifactId>flyway-core</artifactId> | |||
| <version>5.2.4</version> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| <plugins> | |||
| <plugin> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-maven-plugin</artifactId> | |||
| <configuration> | |||
| <executable>true</executable> | |||
| <layout>ZIP</layout> | |||
| <excludeGroupIds> | |||
| antlr, | |||
| ch.qos.logback, | |||
| com.alibaba, | |||
| com.amazonaws, | |||
| com.baomidou, | |||
| com.mchange, | |||
| com.fasterxml.jackson.core, | |||
| com.fasterxml.jackson.dataformat, | |||
| com.fasterxml.jackson.datatype, | |||
| com.fasterxml.jackson.module, | |||
| com.fasterxml.uuid, | |||
| com.fasterxml, | |||
| com.github.axet, | |||
| com.github.jsqlparser, | |||
| com.github.pagehelper, | |||
| com.github.ulisesbocchio, | |||
| com.github.virtuald, | |||
| com.google.code.findbugs, | |||
| com.google.code.gson, | |||
| com.google.errorprone, | |||
| com.google.guava, | |||
| com.google.protobuf, | |||
| com.google.zxing, | |||
| com.jayway.jsonpath, | |||
| com.jhlabs, | |||
| com.puppycrawl.tools, | |||
| com.rabbitmq, | |||
| com.squareup.okhttp3, | |||
| com.squareup.okio, | |||
| com.sun, | |||
| com.sun.mail, | |||
| com.thoughtworks.xstream, | |||
| com.zaxxer, | |||
| commons-beanutils, | |||
| commons-cli, | |||
| commons-codec, | |||
| commons-collections, | |||
| commons-fileupload, | |||
| commons-io, | |||
| commons-logging, | |||
| io.lettuce, | |||
| io.netty, | |||
| io.projectreactor, | |||
| io.springfox, | |||
| io.swagger, | |||
| io.undertow, | |||
| javax.activation, | |||
| javax.annotation, | |||
| javax.mail, | |||
| javax.persistence, | |||
| javax.servlet, | |||
| javax.validation, | |||
| javax.xml.bind, | |||
| javax.xml.soap, | |||
| javax.xml.ws, | |||
| joda-time, | |||
| junit, | |||
| mysql, | |||
| net.bytebuddy, | |||
| net.minidev, | |||
| net.sf.dozer, | |||
| net.sf.saxon, | |||
| ognl, | |||
| org.antlr, | |||
| org.apache.commons, | |||
| org.apache.httpcomponents, | |||
| org.apache.logging.log4j, | |||
| org.apache.poi, | |||
| org.apache.poi.wso2, | |||
| org.apache.rocketmq, | |||
| org.apache.shiro, | |||
| org.apache.tomcat.embed, | |||
| org.apache.xmlbeans, | |||
| org.aspectj, | |||
| org.assertj, | |||
| org.bouncycastle, | |||
| org.checkerframework, | |||
| org.codehaus.mojo, | |||
| org.crazycake, | |||
| org.dom4j, | |||
| org.flowable, | |||
| org.flywaydb, | |||
| org.glassfish, | |||
| org.hibernate.validator, | |||
| org.jasypt, | |||
| org.javassist, | |||
| org.jboss.logging, | |||
| org.jboss.spec.javax.annotation, | |||
| org.jboss.spec.javax.websocket, | |||
| org.jboss.xnio, | |||
| org.jdom, | |||
| org.jodd, | |||
| org.jvnet.mimepull, | |||
| org.jvnet.staxex, | |||
| org.mapstruct, | |||
| org.mockito, | |||
| org.mybatis, | |||
| org.mybatis.generator, | |||
| org.mybatis.spring.boot, | |||
| org.ow2.asm, | |||
| org.projectlombok, | |||
| org.quartz-scheduler, | |||
| org.reactivestreams, | |||
| org.reflections, | |||
| org.rocketmq.spring.boot, | |||
| org.slf4j, | |||
| org.springframework, | |||
| org.springframework.amqp, | |||
| org.springframework.boot, | |||
| org.springframework.data, | |||
| org.springframework.retry, | |||
| org.springframework.ws, | |||
| org.yaml, | |||
| redis.clients, | |||
| software.amazon.ion, | |||
| tk.mybatis, | |||
| xmlpull, | |||
| xpp3 | |||
| </excludeGroupIds> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| </project> | |||
| @@ -0,0 +1,80 @@ | |||
| package com.iformall; | |||
| import com.iformall.annotation.BaseEnableSwagger; | |||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||
| import org.mybatis.spring.annotation.MapperScan; | |||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.boot.SpringApplication; | |||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.EnableAspectJAutoProxy; | |||
| import org.springframework.scheduling.annotation.EnableAsync; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| /** | |||
| * @author chenkx | |||
| * @date 2017-12-26 | |||
| */ | |||
| @SpringBootApplication | |||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||
| @BaseEnableSwagger | |||
| @EnableEncryptableProperties | |||
| @EnableAsync | |||
| @EnableRocketMQ | |||
| @EnableAspectJAutoProxy(exposeProxy = true) | |||
| public class AdminApplication { | |||
| @Value("${fm.exception}") | |||
| private boolean fmException; | |||
| @Value("${fm.exception_emails}") | |||
| private String fmExceptionEmails; | |||
| @Value("${fm.open}") | |||
| private boolean fmOpen; | |||
| @Value("${fm.upload_dir}") | |||
| private String uploadDir; | |||
| @Value("${fm.ocr_data}") | |||
| private String ocrData; | |||
| @Value("${fm.videoType}") | |||
| private String videoType; | |||
| @Bean | |||
| public boolean isFmException() { | |||
| return fmException; | |||
| } | |||
| @Bean | |||
| public String fmExceptionEmails() { | |||
| return fmExceptionEmails; | |||
| } | |||
| @Bean | |||
| public boolean isFmOpen() { | |||
| return fmOpen; | |||
| } | |||
| @Bean | |||
| public String fmUploadDir() { | |||
| return uploadDir; | |||
| } | |||
| @Bean | |||
| public String ocrData() { | |||
| return ocrData; | |||
| } | |||
| @Bean | |||
| public String videoType() { | |||
| return videoType; | |||
| } | |||
| public static void main(String[] args) { | |||
| SpringApplication.run(AdminApplication.class, args); | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.*; | |||
| @Target({ElementType.PARAMETER, ElementType.METHOD}) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Documented | |||
| public @interface SystemControllerLog { | |||
| String description() default ""; | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.*; | |||
| @Target({ElementType.PARAMETER, ElementType.METHOD}) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Documented | |||
| public @interface SystemServiceLog { | |||
| String description() default ""; | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.*; | |||
| /** | |||
| * api接口,忽略Token验证 | |||
| * @author stormeye.wu | |||
| * @email wuguoqiang@iformall.com | |||
| * @date 2017-03-23 15:44 | |||
| */ | |||
| @Target(ElementType.METHOD) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Documented | |||
| public @interface TenantIgnore { | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @Target({ElementType.METHOD}) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Documented | |||
| public @interface UserDataRuleAnnotation { | |||
| String value() default ""; | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| import org.springframework.stereotype.Component; | |||
| /** | |||
| * @author Stormeye | |||
| */ | |||
| @Component | |||
| @ConfigurationProperties(prefix = "aws") | |||
| public class AwsProperty { | |||
| // AWS ACCESS KEY | |||
| private String access; | |||
| private String secret; | |||
| private String clientRegion; | |||
| private String bucketName; | |||
| public String getAccess() { | |||
| return access; | |||
| } | |||
| public void setAccess(String access) { | |||
| this.access = access; | |||
| } | |||
| public String getSecret() { | |||
| return secret; | |||
| } | |||
| public void setSecret(String secret) { | |||
| this.secret = secret; | |||
| } | |||
| public String getClientRegion() { | |||
| return clientRegion; | |||
| } | |||
| public void setClientRegion(String clientRegion) { | |||
| this.clientRegion = clientRegion; | |||
| } | |||
| public String getBucketName() { | |||
| return bucketName; | |||
| } | |||
| public void setBucketName(String bucketName) { | |||
| this.bucketName = bucketName; | |||
| } | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| package com.iformall.config; | |||
| import com.google.code.kaptcha.impl.DefaultKaptcha; | |||
| import com.google.code.kaptcha.util.Config; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import java.util.Properties; | |||
| /** | |||
| * 生成验证码配置 | |||
| * | |||
| * @author stormeye.wu | |||
| * @email wugq@mippoint.com | |||
| * @date 2017-04-20 19:22 | |||
| */ | |||
| @Configuration | |||
| public class KaptchaConfig { | |||
| @Bean | |||
| public DefaultKaptcha producer() { | |||
| Properties properties = new Properties(); | |||
| properties.put("kaptcha.border", "no"); | |||
| properties.put("kaptcha.textproducer.font.color", "black"); | |||
| properties.put("kaptcha.textproducer.char.space", "5"); | |||
| Config config = new Config(properties); | |||
| DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); | |||
| defaultKaptcha.setConfig(config); | |||
| return defaultKaptcha; | |||
| } | |||
| } | |||
| @@ -0,0 +1,55 @@ | |||
| package com.iformall.config; | |||
| import org.apache.shiro.authc.AuthenticationToken; | |||
| public class MyAuthenticationToken implements AuthenticationToken{ | |||
| private Integer projectType; | |||
| private String username; | |||
| private char[] password; | |||
| public Integer getProjectType() { | |||
| return projectType; | |||
| } | |||
| public void setProjectType(Integer projectType) { | |||
| this.projectType = projectType; | |||
| } | |||
| public String getUsername() { | |||
| return username; | |||
| } | |||
| public void setUsername(String username) { | |||
| this.username = username; | |||
| } | |||
| public char[] getPassword() { | |||
| return password; | |||
| } | |||
| public void setPassword(char[] password) { | |||
| this.password = password; | |||
| } | |||
| @Override | |||
| public Object getPrincipal() { | |||
| return getUsername(); | |||
| } | |||
| @Override | |||
| public Object getCredentials() { | |||
| return getPassword(); | |||
| } | |||
| public MyAuthenticationToken() { | |||
| } | |||
| public MyAuthenticationToken(Integer projectType, String username, char[] password) { | |||
| this.projectType = projectType; | |||
| this.username = username; | |||
| this.password = password; | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.config; | |||
| import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; | |||
| import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; | |||
| import com.iformall.plugin.MyBatisItercepters; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.transaction.annotation.EnableTransactionManagement; | |||
| @EnableTransactionManagement | |||
| @Configuration | |||
| public class MyBatisConfiguration extends BaseMyBatisConfiguration{ | |||
| @Bean | |||
| public MyBatisItercepters intercepters() { | |||
| return allIntercepters(); | |||
| } | |||
| @Bean | |||
| public PaginationInterceptor paginationInterceptor() { | |||
| PaginationInterceptor page = new PaginationInterceptor(); | |||
| page.setDialectType("mysql"); | |||
| return page; | |||
| } | |||
| @Bean | |||
| public OptimisticLockerInterceptor optimisticLockerInterceptor() { | |||
| return new OptimisticLockerInterceptor(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.core.task.AsyncTaskExecutor; | |||
| import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | |||
| import java.util.concurrent.ThreadPoolExecutor; | |||
| @Configuration | |||
| public class MyExecutorConfig { | |||
| /** | |||
| * 自定义异步线程池 | |||
| * | |||
| * @return | |||
| */ | |||
| @Bean | |||
| public AsyncTaskExecutor taskExecutor() { | |||
| ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | |||
| executor.setThreadNamePrefix("Anno-Executor"); | |||
| executor.setMaxPoolSize(100); | |||
| executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); | |||
| return executor; | |||
| } | |||
| } | |||
| @@ -0,0 +1,347 @@ | |||
| package com.iformall.config; | |||
| import com.fasterxml.jackson.annotation.JsonAutoDetect; | |||
| import com.fasterxml.jackson.annotation.PropertyAccessor; | |||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.cache.CacheManager; | |||
| import org.springframework.cache.annotation.CachingConfigurerSupport; | |||
| import org.springframework.cache.annotation.EnableCaching; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.data.redis.cache.RedisCacheConfiguration; | |||
| import org.springframework.data.redis.cache.RedisCacheManager; | |||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | |||
| import org.springframework.data.redis.serializer.StringRedisSerializer; | |||
| import java.time.Duration; | |||
| import java.util.*; | |||
| /** | |||
| * Created by Stormeye on 2018/10/1. | |||
| */ | |||
| @Configuration | |||
| @EnableCaching | |||
| public class RedisConfig extends CachingConfigurerSupport { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| //缓存管理器 | |||
| @Bean | |||
| public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||
| /* | |||
| //user信息缓存配置 | |||
| RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||
| Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||
| redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||
| //初始化一个RedisCacheWriter | |||
| RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||
| // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||
| // ClassLoader loader = this.getClass().getClassLoader(); | |||
| // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||
| // RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||
| // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||
| RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||
| //设置默认超过期时间是30秒 | |||
| defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||
| //初始化RedisCacheManager | |||
| RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||
| return cacheManager; | |||
| */ | |||
| RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); // 生成一个默认配置,通过config对象即可对缓存进行自定义配置 | |||
| config = config.entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置 | |||
| .disableCachingNullValues(); // 不缓存空值 | |||
| // 设置一个初始化的缓存空间set集合 | |||
| Set<String> cacheNames = new HashSet<>(); | |||
| cacheNames.add("my-redis-cache1"); | |||
| cacheNames.add("my-redis-cache2"); | |||
| // 对每个缓存空间应用不同的配置 | |||
| Map<String, RedisCacheConfiguration> configMap = new HashMap<>(); | |||
| configMap.put("my-redis-cache1", config); | |||
| configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120))); | |||
| RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory) // 使用自定义的缓存配置初始化一个cacheManager | |||
| .initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置 | |||
| .withInitialCacheConfigurations(configMap) | |||
| .build(); | |||
| return cacheManager; | |||
| } | |||
| @Bean("pushLimitRedisTemplate") | |||
| public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>(); | |||
| Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("scoreRuleRedisTemplate") | |||
| public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>(); | |||
| Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("openRedisTemplate") | |||
| public RedisTemplate<String, String> getWeChatOpen(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, String> template = new RedisTemplate<String, String>(); | |||
| // value值的序列化 | |||
| template.setValueSerializer(new StringRedisSerializer()); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("cuserTokenRedisTemplate") | |||
| public RedisTemplate<String, WxCUser> getCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxCUser> template = new RedisTemplate<String, WxCUser>(); | |||
| Jackson2JsonRedisSerializer<WxCUser> j = new Jackson2JsonRedisSerializer<WxCUser>(WxCUser.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("baseCUserTokenRedisTemplate") | |||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("subMallListRedisTemplate") | |||
| public RedisTemplate<String, List<WxMall>> getSubMallListRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, List<WxMall>> template = new RedisTemplate<String, List<WxMall>>(); | |||
| Jackson2JsonRedisSerializer<List> j = new Jackson2JsonRedisSerializer<List>(List.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("couponChannelRedisTemplate") | |||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("buserTokenRedisTemplate") | |||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | |||
| Jackson2JsonRedisSerializer<WxBuser> j = new Jackson2JsonRedisSerializer(WxBuser.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("couponDetailRedisTemplate") | |||
| public RedisTemplate<String, WxCouponCVo> getCouponDetailRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxCouponCVo> template = new RedisTemplate<String, WxCouponCVo>(); | |||
| Jackson2JsonRedisSerializer<WxCouponCVo> j = new Jackson2JsonRedisSerializer<WxCouponCVo>(WxCouponCVo.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("cUserBasicInfoRedisTemplate") | |||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | |||
| Jackson2JsonRedisSerializer<WxCUserBasicInfo> j = new Jackson2JsonRedisSerializer<WxCUserBasicInfo>(WxCUserBasicInfo.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| @Bean("objectCommonRedisTemplate") | |||
| public RedisTemplate<String, Object> getObjectValueOperations(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, Object> template = new RedisTemplate<>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<Object> j = new Jackson2JsonRedisSerializer<Object>(Object.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -0,0 +1,58 @@ | |||
| package com.iformall.config; | |||
| import java.io.IOException; | |||
| import java.util.Optional; | |||
| import javax.servlet.Filter; | |||
| import javax.servlet.FilterChain; | |||
| import javax.servlet.FilterConfig; | |||
| import javax.servlet.ServletException; | |||
| import javax.servlet.ServletRequest; | |||
| import javax.servlet.ServletResponse; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| /** | |||
| * 前后端分离RESTful接口过滤器 | |||
| * | |||
| * @author xuguoqin | |||
| * | |||
| */ | |||
| public class RestFilter implements Filter { | |||
| @Override | |||
| public void init(FilterConfig filterConfig) throws ServletException { | |||
| } | |||
| @Override | |||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||
| throws IOException, ServletException { | |||
| HttpServletRequest req = null; | |||
| if (request instanceof HttpServletRequest) { | |||
| req = (HttpServletRequest) request; | |||
| } | |||
| HttpServletResponse res = null; | |||
| if (response instanceof HttpServletResponse) { | |||
| res = (HttpServletResponse) response; | |||
| } | |||
| if (req != null && res != null) { | |||
| //设置允许传递的参数 | |||
| res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); | |||
| //设置允许带上cookie | |||
| res.setHeader("Access-Control-Allow-Credentials", "true"); | |||
| String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer")); | |||
| //设置允许的请求来源 | |||
| res.setHeader("Access-Control-Allow-Origin", origin); | |||
| //设置允许的请求方法 | |||
| res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS"); | |||
| } | |||
| chain.doFilter(request, response); | |||
| } | |||
| @Override | |||
| public void destroy() { | |||
| } | |||
| } | |||
| @@ -0,0 +1,24 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.http.client.ClientHttpRequestFactory; | |||
| import org.springframework.http.client.SimpleClientHttpRequestFactory; | |||
| import org.springframework.web.client.RestTemplate; | |||
| @Configuration | |||
| public class RestTemplateConfig { | |||
| @Bean | |||
| public RestTemplate restTemplate(ClientHttpRequestFactory factory) { | |||
| return new RestTemplate(factory); | |||
| } | |||
| @Bean | |||
| public ClientHttpRequestFactory simpleClientHttpRequestFactory() { | |||
| SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | |||
| factory.setReadTimeout(5000);//ms | |||
| factory.setConnectTimeout(10000);//ms | |||
| return factory; | |||
| } | |||
| } | |||
| @@ -0,0 +1,319 @@ | |||
| package com.iformall.config; | |||
| import com.iformall.service.MallPermissionService; | |||
| import com.iformall.shiro.MyRetryLimitCredentialsMatcher; | |||
| import com.iformall.shiro.MyShiroRealm; | |||
| import org.apache.shiro.mgt.SecurityManager; | |||
| import org.apache.shiro.spring.LifecycleBeanPostProcessor; | |||
| import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; | |||
| import org.apache.shiro.spring.web.ShiroFilterFactoryBean; | |||
| import org.apache.shiro.web.mgt.DefaultWebSecurityManager; | |||
| import org.apache.shiro.web.servlet.SimpleCookie; | |||
| import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; | |||
| import org.crazycake.shiro.RedisCacheManager; | |||
| import org.crazycake.shiro.RedisManager; | |||
| import org.crazycake.shiro.RedisSessionDAO; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import javax.servlet.Filter; | |||
| import javax.servlet.ServletRequest; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.LinkedHashMap; | |||
| import java.util.Map; | |||
| /** | |||
| * Created by yangqj on 2017/4/23. | |||
| */ | |||
| @Configuration | |||
| public class ShiroConfig { | |||
| @Value("${spring.redis.host}") | |||
| private String host; | |||
| @Value("${spring.redis.port}") | |||
| private int port; | |||
| @Value("${spring.redis.timeout}") | |||
| private int timeout; | |||
| @Value("${spring.redis.expire}") | |||
| private int expire; | |||
| @Value("${spring.redis.password}") | |||
| private String password; | |||
| @Bean | |||
| public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() { | |||
| return new LifecycleBeanPostProcessor(); | |||
| } | |||
| /** | |||
| * ShiroDialect,为了在thymeleaf里使用shiro的标签的bean | |||
| * @return | |||
| */ | |||
| // @Bean | |||
| // public ShiroDialect shiroDialect() { | |||
| // return new ShiroDialect(); | |||
| // } | |||
| /** | |||
| * ShiroFilterFactoryBean 处理拦截资源文件问题。 | |||
| * 注意:单独一个ShiroFilterFactoryBean配置是或报错的,因为在 | |||
| * 初始化ShiroFilterFactoryBean的时候需要注入:SecurityManager | |||
| * <p> | |||
| * Filter Chain定义说明 | |||
| * 1、一个URL可以配置多个Filter,使用逗号分隔 | |||
| * 2、当设置多个过滤器时,全部验证通过,才视为通过 | |||
| * 3、部分过滤器可指定参数,如perms,roles | |||
| */ | |||
| @Bean | |||
| public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { | |||
| System.out.println("ShiroConfiguration.shirFilter()"); | |||
| ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); | |||
| // 必须设置 SecurityManager | |||
| shiroFilterFactoryBean.setSecurityManager(securityManager); | |||
| Map<String, Filter> filters = new LinkedHashMap<String, Filter>(); | |||
| filters.put("token", new ShiroLoginFilter()); | |||
| filters.put("corsFilter", new RestFilter()); | |||
| //filters.put("authc", new MyFormAuthenticationFilter()); | |||
| shiroFilterFactoryBean.setFilters(filters); | |||
| // 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面 | |||
| shiroFilterFactoryBean.setLoginUrl("/#/"); | |||
| // 登录成功后要跳转的链接 | |||
| shiroFilterFactoryBean.setSuccessUrl("/usersPage"); | |||
| //未授权界面; | |||
| shiroFilterFactoryBean.setUnauthorizedUrl("/403"); | |||
| //拦截器. | |||
| Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>(); | |||
| //filterChainDefinitionMap.put("/ue/**", "anon"); | |||
| //filterChainDefinitionMap.put("/config.json", "anon"); | |||
| // login | |||
| filterChainDefinitionMap.put("/doLogin/**", "anon"); | |||
| filterChainDefinitionMap.put("/bHidLogin/**", "anon"); | |||
| filterChainDefinitionMap.put("/sendLoginPhoneCode/**", "anon"); | |||
| filterChainDefinitionMap.put("/doLoginByPhone/**", "anon"); | |||
| filterChainDefinitionMap.put("/wechat/login", "anon"); // 微信第三方登录callback | |||
| filterChainDefinitionMap.put("/wechat/callback", "anon"); // 微信网页登录回调 | |||
| filterChainDefinitionMap.put("/wechat/weChatUserLogin", "anon"); // 微信第三方登录 | |||
| // 验证码 | |||
| filterChainDefinitionMap.put("/captcha.jpg", "anon"); | |||
| // 官网 | |||
| filterChainDefinitionMap.put("/wxMallApply/add", "anon"); | |||
| // callback | |||
| filterChainDefinitionMap.put("/wxPay/notify/**", "anon"); // 支付回调 | |||
| filterChainDefinitionMap.put("/wxPayBill/notify/**", "anon"); | |||
| filterChainDefinitionMap.put("/wxMsgCallback/**", "anon"); | |||
| filterChainDefinitionMap.put("/user/sendvalidationcode", "anon"); | |||
| filterChainDefinitionMap.put("/user/updatepwd", "anon"); | |||
| filterChainDefinitionMap.put("/carCallback/**", "anon"); | |||
| filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode", "anon"); | |||
| // 补发消息 | |||
| filterChainDefinitionMap.put("/wxCoupon/updateStokeAndValidDate", "anon"); | |||
| // static files | |||
| filterChainDefinitionMap.put("/css/**", "anon"); | |||
| filterChainDefinitionMap.put("/js/**", "anon"); | |||
| filterChainDefinitionMap.put("/img/**", "anon"); | |||
| filterChainDefinitionMap.put("/font-awesome/**", "anon"); | |||
| //<!-- 过滤链定义,从上向下顺序执行,一般将 /**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了; | |||
| //<!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问--> | |||
| //自定义加载权限资源关系 | |||
| // Map<String,Object> map = new HashMap<>(); | |||
| // List<SysPermission> resourcesList = resourcesService.list(map); | |||
| // for(SysPermission resources:resourcesList){ | |||
| // | |||
| // if (StringUtil.isNotEmpty(resources.getUrl())) { | |||
| // String permission = "perms[" + resources.getUrl()+ "]"; | |||
| // filterChainDefinitionMap.put(resources.getUrl(),permission); | |||
| // } | |||
| // } | |||
| // swagger-ui | |||
| filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | |||
| filterChainDefinitionMap.put("/doc.html", "anon"); | |||
| filterChainDefinitionMap.put("/v2/**", "anon"); | |||
| filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | |||
| filterChainDefinitionMap.put("/webjars/**", "anon"); | |||
| filterChainDefinitionMap.put("/version", "anon"); | |||
| //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||
| filterChainDefinitionMap.put("/logout", "authc"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| return shiroFilterFactoryBean; | |||
| } | |||
| public static boolean isAjax(ServletRequest request) { | |||
| String header = ((HttpServletRequest) request).getHeader("X-Requested-With"); | |||
| if ("XMLHttpRequest".equalsIgnoreCase(header)) { | |||
| System.out.println("当前请求为Ajax请求"); | |||
| return Boolean.TRUE; | |||
| } | |||
| System.out.println("当前请求非Ajax请求"); | |||
| return Boolean.FALSE; | |||
| } | |||
| @Bean | |||
| public SecurityManager securityManager() { | |||
| DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||
| //设置realm. | |||
| securityManager.setRealm(myShiroRealm()); | |||
| // 自定义缓存实现 使用redis | |||
| //securityManager.setCacheManager(cacheManager()); | |||
| // 自定义session管理 使用redis | |||
| securityManager.setSessionManager(sessionManager()); | |||
| return securityManager; | |||
| } | |||
| @Bean | |||
| public MyShiroRealm myShiroRealm() { | |||
| MyShiroRealm myShiroRealm = new MyShiroRealm(); | |||
| myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); | |||
| return myShiroRealm; | |||
| } | |||
| /** | |||
| * 密码匹配凭证管理器 凭证匹配器 | |||
| * (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了 | |||
| * 所以我们需要修改下doGetAuthenticationInfo中的代码; | |||
| * ) | |||
| * | |||
| * @return | |||
| */ | |||
| public MyRetryLimitCredentialsMatcher hashedCredentialsMatcher() { | |||
| MyRetryLimitCredentialsMatcher hashedCredentialsMatcher = new MyRetryLimitCredentialsMatcher(); | |||
| hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法; | |||
| hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5("")); | |||
| return hashedCredentialsMatcher; | |||
| } | |||
| /** | |||
| * 开启shiro aop注解支持. | |||
| * 使用代理方式;所以需要开启代码支持; | |||
| * | |||
| * @param securityManager | |||
| * @return | |||
| */ | |||
| @Bean | |||
| public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { | |||
| AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); | |||
| authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); | |||
| return authorizationAttributeSourceAdvisor; | |||
| } | |||
| /** | |||
| * 配置shiro redisManager | |||
| * 使用的是shiro-redis开源插件 | |||
| * | |||
| * @return | |||
| */ | |||
| public RedisManager redisManager() { | |||
| RedisManager redisManager = new RedisManager(); | |||
| redisManager.setHost(host); | |||
| redisManager.setPort(port); | |||
| //redisManager.setExpire(expire);// 配置缓存过期时间 | |||
| redisManager.setTimeout(timeout); | |||
| redisManager.setPassword(password); | |||
| return redisManager; | |||
| } | |||
| /** | |||
| * cacheManager 缓存 redis实现 | |||
| * 使用的是shiro-redis开源插件 | |||
| * | |||
| * @return | |||
| */ | |||
| public RedisCacheManager cacheManager() { | |||
| RedisCacheManager redisCacheManager = new RedisCacheManager(); | |||
| redisCacheManager.setRedisManager(redisManager()); | |||
| return redisCacheManager; | |||
| } | |||
| /** | |||
| * RedisSessionDAO shiro sessionDao层的实现 通过redis | |||
| * 使用的是shiro-redis开源插件 | |||
| */ | |||
| @Bean | |||
| public RedisSessionDAO redisSessionDAO() { | |||
| RedisSessionDAO redisSessionDAO = new RedisSessionDAO(); | |||
| redisSessionDAO.setRedisManager(redisManager()); | |||
| return redisSessionDAO; | |||
| } | |||
| /** | |||
| * shiro session的管理 | |||
| */ | |||
| @Bean | |||
| public DefaultWebSessionManager sessionManager() { | |||
| DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); | |||
| //设置session过期时间为1小时(单位:毫秒),默认为30分钟 | |||
| sessionManager.setGlobalSessionTimeout(60 * 60 * 1000); | |||
| sessionManager.setSessionValidationSchedulerEnabled(true); | |||
| sessionManager.setSessionIdUrlRewritingEnabled(false); | |||
| sessionManager.setSessionDAO(redisSessionDAO()); | |||
| sessionManager.setSessionIdCookie(simpleCookie()); | |||
| return sessionManager; | |||
| } | |||
| @Bean | |||
| public SimpleCookie simpleCookie() { | |||
| SimpleCookie simpleCookie = new SimpleCookie("SSIDS"); | |||
| simpleCookie.setDomain(""); | |||
| return simpleCookie; | |||
| } | |||
| // @Bean | |||
| // public SimpleCookie rememberMeCookie(){ | |||
| // //System.out.println("ShiroConfiguration.rememberMeCookie()"); | |||
| // //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe | |||
| // SimpleCookie simpleCookie = new SimpleCookie("rememberMe"); | |||
| // //<!-- 记住我cookie生效时间30天 ,单位秒;--> | |||
| // simpleCookie.setMaxAge(60*30); | |||
| // return simpleCookie; | |||
| // } | |||
| // @Bean | |||
| // public CookieRememberMeManager rememberMeManager(){ | |||
| // //System.out.println("ShiroConfiguration.rememberMeManager()"); | |||
| // CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); | |||
| // cookieRememberMeManager.setCookie(rememberMeCookie()); | |||
| // //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位) | |||
| // cookieRememberMeManager.setCipherKey(Base64.decodeBytes("2AvVhdsgUs0FSA3SDFAdag==")); | |||
| // return cookieRememberMeManager; | |||
| // } | |||
| // @Bean(name = "securityManager") | |||
| // public DefaultWebSecurityManager defaultWebSecurityManager(MyShiroRealm realm){ | |||
| // DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||
| // //设置realm | |||
| // securityManager.setRealm(realm); | |||
| // //用户授权/认证信息Cache, 采用EhCache缓存 | |||
| // securityManager.setCacheManager(cacheManager()); | |||
| // //注入记住我管理器 | |||
| // securityManager.setRememberMeManager(rememberMeManager()); | |||
| // return securityManager; | |||
| // } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.config; | |||
| import javax.servlet.ServletRequest; | |||
| import javax.servlet.ServletResponse; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import org.apache.shiro.web.filter.authc.FormAuthenticationFilter; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.iformall.common.ResultData; | |||
| public class ShiroLoginFilter extends FormAuthenticationFilter { | |||
| @Override | |||
| protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { | |||
| response.setCharacterEncoding("UTF-8"); | |||
| response.setContentType("application/json"); | |||
| ResultData resultData = new ResultData(ResultData.UNLOGIN,"用户未登录"); | |||
| response.getWriter().write(JSON.toJSONString(resultData)); | |||
| return false; | |||
| } | |||
| /** | |||
| * 判断ajax请求 | |||
| * @param request | |||
| * @return | |||
| */ | |||
| boolean isAjax(HttpServletRequest request){ | |||
| return (request.getHeader("X-Requested-With") != null && "XMLHttpRequest".equals( request.getHeader("X-Requested-With").toString()) ) ; | |||
| } | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| //package com.iformall.config; | |||
| // | |||
| //import org.springframework.beans.factory.annotation.Autowired; | |||
| //import org.springframework.context.annotation.Bean; | |||
| //import org.springframework.context.annotation.Configuration; | |||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||
| //import springfox.documentation.builders.ParameterBuilder; | |||
| //import springfox.documentation.builders.PathSelectors; | |||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||
| //import springfox.documentation.schema.ModelRef; | |||
| //import springfox.documentation.service.ApiInfo; | |||
| //import springfox.documentation.service.Parameter; | |||
| //import springfox.documentation.spi.DocumentationType; | |||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| //import springfox.documentation.spring.web.plugins.Docket; | |||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| // | |||
| //import javax.servlet.ServletContext; | |||
| //import java.util.ArrayList; | |||
| //import java.util.List; | |||
| // | |||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| //@Configuration | |||
| //@EnableSwagger2 | |||
| //public class Swagger2Config { | |||
| // | |||
| // @Autowired | |||
| // private ServletContext servletContext; | |||
| // | |||
| // @Bean | |||
| // public Docket createRestApi() { | |||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||
| // //增加一个request的header参数 | |||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| // pars.add(tokenPar.build()); | |||
| // return new Docket(DocumentationType.SWAGGER_2) | |||
| // .apiInfo(apiInfo()) | |||
| // .select() | |||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| // .paths(PathSelectors.any()) | |||
| // .build() | |||
| // .globalOperationParameters(pars) | |||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||
| // @Override | |||
| // public String getApplicationBasePath() { | |||
| // return "/api"; | |||
| // } | |||
| // }); | |||
| // } | |||
| // | |||
| // private ApiInfo apiInfo() { | |||
| // return new ApiInfoBuilder() | |||
| // .title("a端 api") | |||
| // .description("a api") | |||
| // .termsOfServiceUrl("http://localhost:7000") | |||
| // .version("2.0") | |||
| // .build(); | |||
| // } | |||
| // | |||
| //} | |||
| @@ -0,0 +1,166 @@ | |||
| package com.iformall.config; | |||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||
| import com.fasterxml.jackson.databind.DeserializationConfig; | |||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.fasterxml.jackson.databind.module.SimpleModule; | |||
| import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| import com.iformall.interceptor.CurrentTenantInterceptor; | |||
| import com.iformall.interceptor.HttpServletRequestWrapperFilter; | |||
| import com.iformall.interceptor.RequestInterceptor; | |||
| import com.iformall.service.MallResourceService; | |||
| import com.iformall.ueditor.ActionEnter; | |||
| import com.iformall.ueditor.ConfigManager; | |||
| import com.iformall.ueditor.UEditorConfig; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||
| import org.springframework.boot.web.servlet.FilterRegistrationBean; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.http.converter.HttpMessageConverter; | |||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||
| import org.springframework.web.cors.CorsConfiguration; | |||
| import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | |||
| import org.springframework.web.filter.CharacterEncodingFilter; | |||
| import org.springframework.web.filter.CorsFilter; | |||
| import org.springframework.web.servlet.config.annotation.*; | |||
| import javax.servlet.Filter; | |||
| import java.math.BigDecimal; | |||
| import java.math.BigInteger; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.List; | |||
| @Configuration | |||
| @EnableWebMvc | |||
| @EnableConfigurationProperties({UEditorConfig.class, AwsProperty.class}) | |||
| public class WebConfig implements WebMvcConfigurer { | |||
| @Autowired | |||
| private UEditorConfig uEditorConfig; | |||
| @Autowired | |||
| private AwsProperty awsProperty; | |||
| @Autowired | |||
| private RequestInterceptor requestInterceptor; | |||
| @Autowired | |||
| private CurrentTenantInterceptor tenantInterceptor; | |||
| @Autowired | |||
| private MallResourceService mallResourceService; | |||
| @Autowired | |||
| private AliyunOSS aliyunOSS; | |||
| @Bean | |||
| @ConditionalOnMissingBean(ActionEnter.class) | |||
| public ActionEnter actionEnter() { | |||
| ActionEnter actionEnter = new ActionEnter(ConfigManager.getInstance(uEditorConfig, awsProperty, mallResourceService, aliyunOSS)); | |||
| return actionEnter; | |||
| } | |||
| @Bean | |||
| public CorsFilter corsFilter() { | |||
| final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); | |||
| final CorsConfiguration corsConfiguration = new CorsConfiguration(); | |||
| // 允许cookies跨域 | |||
| corsConfiguration.setAllowCredentials(true); | |||
| // 允许向该服务器提交请求的URI, *表示全部允许 | |||
| corsConfiguration.addAllowedOrigin("*"); | |||
| // 允许访问的头信息,*表示全部 | |||
| corsConfiguration.addAllowedHeader("*"); | |||
| // 允许提交请求的方法, *表示全部允许 | |||
| corsConfiguration.addAllowedMethod("*"); | |||
| urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); | |||
| return new CorsFilter(urlBasedCorsConfigurationSource); | |||
| } | |||
| /** | |||
| * 用于处理编码问题 | |||
| * | |||
| * @return | |||
| */ | |||
| @Bean("myCharacterEncodingFilter") | |||
| public Filter characterEncodingFilter() { | |||
| CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); | |||
| characterEncodingFilter.setEncoding("UTF-8"); | |||
| characterEncodingFilter.setForceEncoding(true); | |||
| return characterEncodingFilter; | |||
| } | |||
| @Override | |||
| public void addInterceptors(InterceptorRegistry registry) { | |||
| registry.addInterceptor(requestInterceptor).addPathPatterns("/**"); | |||
| registry.addInterceptor(tenantInterceptor).addPathPatterns("/**"); | |||
| } | |||
| @Override | |||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||
| // registry.addResourceHandler("swagger-ui.html") | |||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("doc.html") | |||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("/webjars/**") | |||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||
| // ueditor | |||
| registry.addResourceHandler("/upload/**") | |||
| .addResourceLocations("file:" + uEditorConfig.getUploadPath()); | |||
| registry.addResourceHandler("/config.json").addResourceLocations("classpath:/config.json"); | |||
| } | |||
| @Override | |||
| public void addCorsMappings(CorsRegistry registry) { | |||
| registry.addMapping("/**") | |||
| .allowedOrigins("*") | |||
| .allowCredentials(true) | |||
| .allowedMethods("GET", "POST", "DELETE", "PUT") | |||
| .maxAge(3600); | |||
| } | |||
| @Override | |||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||
| MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||
| //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||
| ObjectMapper objectMapper = new ObjectMapper(); | |||
| SimpleModule simpleModule = new SimpleModule(); | |||
| //不显示为null的字段 | |||
| objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||
| DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||
| // 设置反序列化日期格式、忽略不存在get、set的属性 | |||
| objectMapper.setConfig( | |||
| dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||
| .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||
| ); | |||
| //序列化将Long转String类型 | |||
| simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||
| simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||
| SimpleModule bigIntegerModule = new SimpleModule(); | |||
| //序列化将BigInteger转String类型 | |||
| bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||
| SimpleModule bigDecimalModule = new SimpleModule(); | |||
| //序列化将BigDecimal转String类型 | |||
| bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||
| objectMapper.registerModule(simpleModule); | |||
| objectMapper.registerModule(bigDecimalModule); | |||
| objectMapper.registerModule(bigIntegerModule); | |||
| jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||
| converters.add(jackson2HttpMessageConverter); | |||
| } | |||
| @Bean | |||
| public FilterRegistrationBean<HttpServletRequestWrapperFilter> Filters() { | |||
| FilterRegistrationBean<HttpServletRequestWrapperFilter> registrationBean = new FilterRegistrationBean<HttpServletRequestWrapperFilter>(); | |||
| registrationBean.setFilter(new HttpServletRequestWrapperFilter()); | |||
| registrationBean.addUrlPatterns("/*"); | |||
| registrationBean.setName("koalaSignFilter"); | |||
| return registrationBean; | |||
| } | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| package com.iformall.config; | |||
| import me.chanjar.weixin.mp.api.WxMpService; | |||
| import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; | |||
| import me.chanjar.weixin.mp.config.WxMpConfigStorage; | |||
| import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.stereotype.Component; | |||
| @Component | |||
| public class WechatMpConfig { | |||
| @Autowired | |||
| private WechatWebProperties wechatWebProperties; | |||
| @Bean | |||
| public WxMpService wxMpService() { | |||
| //创建WxMpService实例并设置appid和sectret | |||
| WxMpService wxMpService = new WxMpServiceImpl(); | |||
| //这里的设置方式是跟着这个sdk的文档写的 | |||
| wxMpService.setWxMpConfigStorage(wxConfigProvider()); | |||
| return wxMpService; | |||
| } | |||
| public WxMpConfigStorage wxConfigProvider(){ | |||
| WxMpDefaultConfigImpl wxConfigProvider = new WxMpDefaultConfigImpl(); | |||
| wxConfigProvider.setAppId(wechatWebProperties.getAppId()); | |||
| wxConfigProvider.setSecret(wechatWebProperties.getSecret()); | |||
| return wxConfigProvider; | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| package com.iformall.config; | |||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| import org.springframework.stereotype.Component; | |||
| /** | |||
| * Stormeye | |||
| */ | |||
| @Component | |||
| @ConfigurationProperties(prefix = "wechat.web") | |||
| public class WechatWebProperties { | |||
| /** | |||
| * 设置微信第三方平台-微信登录的web应用appid | |||
| */ | |||
| private String appId; | |||
| /** | |||
| * 设置微信第三方平台-微信登录的web应用app secret | |||
| */ | |||
| private String secret; | |||
| /** | |||
| * 网页URL | |||
| * @return | |||
| */ | |||
| private String url; | |||
| public String getAppId() { | |||
| return appId; | |||
| } | |||
| public void setAppId(String appId) { | |||
| this.appId = appId; | |||
| } | |||
| public String getSecret() { | |||
| return secret; | |||
| } | |||
| public void setSecret(String secret) { | |||
| this.secret = secret; | |||
| } | |||
| public String getUrl() { | |||
| return url; | |||
| } | |||
| public void setUrl(String url) { | |||
| this.url = url; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return ToStringBuilder.reflectionToString(this, | |||
| ToStringStyle.MULTI_LINE_STYLE); | |||
| } | |||
| } | |||
| @@ -0,0 +1,88 @@ | |||
| package com.iformall.controller.base; | |||
| import java.beans.PropertyEditorSupport; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.shiro.UserSession; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.IPUtil; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.SecurityUtils; | |||
| import org.apache.shiro.session.Session; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.context.request.RequestContextHolder; | |||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @RestController | |||
| public class BaseController { | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||
| public void setAsText(String value) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||
| } catch(ParseException e) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||
| } catch (ParseException e1) { | |||
| setValue(null); | |||
| } | |||
| } | |||
| } | |||
| public String getAsText() { | |||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||
| } | |||
| }); | |||
| } | |||
| public MallUserInfo getUser(){ | |||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| // MallUserInfo user = new MallUserInfo(); | |||
| // user.setId(2L); | |||
| // user.setName("localtest"); | |||
| // user.setIsAdmin(1); | |||
| return user; | |||
| } | |||
| public Long getUserId(){ | |||
| Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId); | |||
| // Long userId = 463627091581734912L; | |||
| return userId; | |||
| } | |||
| // @Deprecated | |||
| // public String getTenantId(){ | |||
| // String tenantId = (String)SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId); | |||
| // return tenantId; | |||
| // } | |||
| /** | |||
| * 返回租户信息 | |||
| * @return | |||
| */ | |||
| public TenantEntity getTenantInfo(){ | |||
| Session session = SecurityUtils.getSubject().getSession(); | |||
| String tenantId = (String)session.getAttribute(UserSession.tenantId); | |||
| String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.setTenantId(tenantId); | |||
| tenantEntity.setParentTenantId(parentTenantId); | |||
| return tenantEntity; | |||
| } | |||
| public String getIpAddr() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| return ipaddress; | |||
| } | |||
| } | |||
| @@ -0,0 +1,56 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.lang.reflect.Method; | |||
| import java.util.*; | |||
| @RestController | |||
| @RequestMapping("enum") | |||
| @Api(description="枚举接口") | |||
| public class EnumController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @SystemControllerLog(description = "会员管理-标签获取") | |||
| @ApiOperation(value="获取枚举对象", notes="根据获取枚举类名获取枚举对象") | |||
| @GetMapping("/getEnum/{type}") | |||
| public ResultData getEnum(@PathVariable("type") String type) { | |||
| if(StringUtils.isBlank(type)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| String className = "com.iformall.enums." + type; | |||
| List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | |||
| try { | |||
| // 1.得到枚举类对象 | |||
| Class<Enum> clz = (Class<Enum>) Class.forName(className); | |||
| // 2.得到所有枚举常量 | |||
| Object[] objects = clz.getEnumConstants(); | |||
| Method getCode = clz.getMethod("getCode"); | |||
| Method getMessage = clz.getMethod("getMessage"); | |||
| Map<String, String> map = null; | |||
| for (Object obj : objects) { | |||
| map = new HashMap<String, String>(); | |||
| map.put("code", getCode.invoke(obj).toString()); | |||
| map.put("message", getMessage.invoke(obj).toString()); | |||
| list.add(map); | |||
| } | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"数据不存在"); | |||
| } | |||
| if(list.size() == 0){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"数据不存在"); | |||
| } | |||
| return new ResultData(list); | |||
| } | |||
| } | |||
| @@ -0,0 +1,72 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.service.TtGoodsCategoryService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("goodsCategory") | |||
| public class TtGoodsCategoryController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private TtGoodsCategoryService ttGoodsCategoryService; | |||
| @TenantIgnore | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("treeList") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData treeList() { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::treeList"); | |||
| return new ResultData(ttGoodsCategoryService.findTreeList()); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询类目") | |||
| @GetMapping("get") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData categoryGet(Integer categoryId) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::categoryGet"); | |||
| if(categoryId == null){ | |||
| categoryId = 0; | |||
| } | |||
| return new ResultData(ttGoodsCategoryService.categoryGet(categoryId)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询抖音类目") | |||
| @GetMapping("syncGet/{token}") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData syncGet(@PathVariable String token) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get"); | |||
| if(StringUtils.isBlank(token)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| String systemTime = DateUtils.getSystemTime("MMdd")+"syncgc"; | |||
| if(!systemTime.equals(token)){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| ttGoodsCategoryService.syncGet(); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,321 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.controller.mem.AsyncTask; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.BufferedInputStream; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("merchantPoi") | |||
| public class TtMerchantPoiController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private TtMerchantPoiService ttMerchantPoiService; | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private AsyncTask asyncTask; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData list(@ModelAttribute TtMerchantPoi record, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::list"); | |||
| if (null == record) record = new TtMerchantPoi(); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||
| final PageInfo<TtMerchantPoi> page = ttMerchantPoiService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findById"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| TtMerchantPoi record = ttMerchantPoiService.getById(id); | |||
| return new ResultData(record); | |||
| } | |||
| @ApiOperation("更新商户接口") | |||
| @PostMapping("updateById") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData updateById(@RequestBody TtMerchantPoi record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateById"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| TtMerchantPoi merchantPoi = ttMerchantPoiService.getById(record.getId()); | |||
| if(merchantPoi == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到修改的数据"); | |||
| } | |||
| if(!EnumSupplierMathStatus.match_update.getCode().equals(merchantPoi.getMatchStatus()) | |||
| && !EnumSupplierMathStatus.match_fail.getCode().equals(merchantPoi.getMatchStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该状态不允许修改"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setMatchStatus(EnumSupplierMathStatus.match_update.getCode()); | |||
| ttMerchantPoiService.updateById(record); | |||
| return new ResultData(record); | |||
| } | |||
| @ApiOperation("新建匹配任务") | |||
| @PostMapping("match") | |||
| @SystemControllerLog(description = "新建匹配任务") | |||
| public ResultData match(@RequestBody List<Long> ids) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::match"); | |||
| if(ids == null || ids.isEmpty()){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return ttMerchantPoiService.match(getTenantInfo(),ids); | |||
| } | |||
| @ApiOperation("重新匹配任务") | |||
| @PostMapping("matchAgain") | |||
| @SystemControllerLog(description = "重新匹配任务") | |||
| public ResultData matchAgain(@RequestBody Map<String, Long> param) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::matchAgain"); | |||
| Long id = param.get("id"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return ttMerchantPoiService.matchAgain(getTenantInfo(),id); | |||
| } | |||
| @ApiOperation("商铺同步") | |||
| @PostMapping("merchantSync") | |||
| @SystemControllerLog(description = "商铺同步") | |||
| public ResultData merchantSync(@RequestBody Map<String, Long> param) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantSync"); | |||
| Long id = param.get("id"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return ttMerchantPoiService.merchantSync(getTenantInfo(),id); | |||
| } | |||
| @ApiOperation("商铺同步结果") | |||
| @GetMapping("merchantQuery") | |||
| @SystemControllerLog(description = "商铺同步") | |||
| public ResultData merchantQuery(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantQuery"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return ttMerchantPoiService.supplierQuery(getTenantInfo(),id); | |||
| } | |||
| // @ApiOperation("获取商品可用的POI") | |||
| // @GetMapping("/findPoi") | |||
| // @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| // @SystemControllerLog(description = "查询") | |||
| // public ResultData findPoi(Long couponChannelId) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId); | |||
| // } | |||
| // @ApiOperation("商品同步") | |||
| // @PostMapping("spuSync") | |||
| // @SystemControllerLog(description = "商品同步") | |||
| // public ResultData spuSync(@RequestBody Map<String, String> param) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync"); | |||
| // String couponChannelIdStr = param.get("couponChannelId"); | |||
| // Long couponChannelId = null; | |||
| // try{ | |||
| // couponChannelId = Long.parseLong(couponChannelIdStr); | |||
| // }catch(Exception e){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||
| // } | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| //// String merchantIdStr = param.get("merchantIds"); | |||
| //// List<Long> merchantIds = new ArrayList<>(); | |||
| //// try{ | |||
| //// List<String> strings = Arrays.asList(merchantIdStr.split(",")); | |||
| //// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); | |||
| //// }catch(Exception e){ | |||
| //// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||
| //// } | |||
| //// if(merchantIds == null || merchantIds.size() == 0){ | |||
| //// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| //// } | |||
| // return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null); | |||
| // } | |||
| // @ApiOperation("商品同步查询") | |||
| // @GetMapping("spuGet") | |||
| // @SystemControllerLog(description = "商品同步查询") | |||
| // public ResultData spuGet(Long couponChannelId) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId); | |||
| // } | |||
| // | |||
| // @ApiOperation("商品状态同步") | |||
| // @PostMapping("spuStatusSync") | |||
| // @SystemControllerLog(description = "商品状态同步") | |||
| // public ResultData spuStatusSync(@RequestBody Map<String, Long> param) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync"); | |||
| // Long couponChannelId = param.get("couponChannelId"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId); | |||
| // } | |||
| // | |||
| // @ApiOperation("商品库存同步") | |||
| // @PostMapping("spuStockSync") | |||
| // @SystemControllerLog(description = "商品库存同步") | |||
| // public ResultData spuStockSync(@RequestBody Map<String, Long> param) { | |||
| // logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync"); | |||
| // Long couponChannelId = param.get("couponChannelId"); | |||
| // if(couponChannelId == null){ | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| // } | |||
| // return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId); | |||
| // } | |||
| @TenantIgnore | |||
| @PostMapping(value = "/importPoi", consumes = "multipart/*") | |||
| @SystemControllerLog(description = "poi-导入数据") | |||
| public ResultData importPoi(@RequestParam("file") MultipartFile mFile) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::importPoi"); | |||
| if (mFile.isEmpty()) { | |||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| } | |||
| //得到当前用户ID | |||
| final MallUserInfo user = getUser(); | |||
| String userId = "" + user.getId(); | |||
| String importKey = Constant.importMemPrev + userId; | |||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||
| if (allCount) { | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||
| stringRedisTemplate.expire(importKey,30, TimeUnit.MINUTES); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||
| String fpath = fmUploadDir; | |||
| File targetFile = new File(fpath); | |||
| if (!targetFile.exists()) { | |||
| targetFile.mkdirs(); | |||
| } | |||
| String fileName = "poi" + Math.round(Math.random() * 100000000000L); | |||
| int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||
| fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||
| File lFile = new File(fpath + File.separator + fileName); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| try { | |||
| fos = new FileOutputStream(lFile); | |||
| fs = (BufferedInputStream) mFile.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| } catch (Exception e) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } finally { | |||
| if (fos != null) { | |||
| try { | |||
| fos.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| if (fs != null) { | |||
| try { | |||
| fs.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| } | |||
| asyncTask.importExcelPoiData(lFile, user, importKey); | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,317 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.TtPoiTakeRate; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumCpsPlanContentType; | |||
| import com.iformall.enums.EnumCpsPlanStatus; | |||
| import com.iformall.enums.EnumCpsPlanType; | |||
| import com.iformall.service.TtCouponGoodsService; | |||
| import com.iformall.service.WxCouponService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * @author | |||
| */ | |||
| @RestController | |||
| @RequestMapping("poiPlan") | |||
| public class TtPoiPlanController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private TtCouponGoodsService ttCouponGoodsService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("takeRateList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData takeRateList(@ModelAttribute TtPoiTakeRate record, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::list"); | |||
| if (null == record) record = new TtPoiTakeRate(); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||
| final PageInfo<TtPoiTakeRate> page = ttCouponGoodsService.takeRateListAsPage(record, pageNum, pageSize); | |||
| if(page.getList() != null && !page.getList().isEmpty()){ | |||
| List<Long> couponIds = page.getList().stream().map(cc -> cc.getCouponId()).collect(Collectors.toList()); | |||
| Map<Long, WxCoupon> couponMap = wxCouponService.getCouponMap(couponIds, getTenantInfo()); | |||
| for (TtPoiTakeRate takeRate:page.getList()) { | |||
| takeRate.setCoupon(couponMap.get(takeRate.getCouponId())); | |||
| } | |||
| } | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("通过id获取") | |||
| @GetMapping("getTakeRate") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData getTakeRate(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getTakeRate"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| TtPoiTakeRate takeRateById = ttCouponGoodsService.getTakeRateById(getTenantInfo(), id); | |||
| return new ResultData(takeRateById); | |||
| } | |||
| // @TenantIgnore | |||
| @ApiOperation("通用计划分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData list(Long couponId,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] TtPoiPlanController::list"); | |||
| if(couponId == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(pageNum == null){ | |||
| pageNum = 1; | |||
| } | |||
| if(pageSize == null){ | |||
| pageSize = 100; | |||
| } | |||
| return ttCouponGoodsService.poiPlanList(getTenantInfo(),couponId,pageNum,pageSize); | |||
| } | |||
| @ApiOperation("定向计划分页列表接口") | |||
| @GetMapping("orientedList") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData orientedList(Long couponId,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] TtPoiPlanController::orientedList"); | |||
| if(couponId == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(pageNum == null){ | |||
| pageNum = 1; | |||
| } | |||
| if(pageSize == null){ | |||
| pageSize = 100; | |||
| } | |||
| return ttCouponGoodsService.poiOrientedPlanList(getTenantInfo(),couponId,pageNum,pageSize); | |||
| } | |||
| @ApiOperation("发布修改通用佣金计划") | |||
| @PostMapping("save") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData save(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::save"); | |||
| if(record.getTakeRate() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空"); | |||
| } | |||
| if(record.getTakeRate() < 100 || record.getTakeRate() > 2900){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位100-2900之间"); | |||
| } | |||
| if(record.getContentType() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空"); | |||
| } | |||
| if(record.getCouponId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.poiPlanSave(record); | |||
| } | |||
| @ApiOperation("发布修改定向佣金计划") | |||
| @PostMapping("saveOrientedPlan") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::saveOrientedPlan"); | |||
| if(StringUtils.isBlank(record.getName())){//不可修改 | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划名称为空"); | |||
| } | |||
| if(StringUtils.isBlank(record.getMerchantPhone())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划联系人为空"); | |||
| } | |||
| if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"定向达人抖音号为空"); | |||
| } | |||
| //达人去重 | |||
| List<String> collect = record.getDouyinIdList().stream().distinct().collect(Collectors.toList()); | |||
| record.setDouyinIdList(collect); | |||
| if(record.getCouponId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||
| } | |||
| if(record.getContentType() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空"); | |||
| } | |||
| EnumCpsPlanContentType planType = EnumCpsPlanContentType.getEnum(record.getContentType()); | |||
| if(planType == null || (!planType.equals(EnumCpsPlanContentType.VIDEO) && !planType.equals(EnumCpsPlanContentType.LIVE))){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景错误"); | |||
| } | |||
| if(planType.equals(EnumCpsPlanContentType.VIDEO)){ | |||
| if(record.getStartTime() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划开始时间为空"); | |||
| } | |||
| if(record.getEndTime() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划结束时间为空"); | |||
| } | |||
| if(record.getCommissionDuration() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"佣金有效期为空"); | |||
| } | |||
| } | |||
| if(record.getTakeRate() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空"); | |||
| } | |||
| if(record.getTakeRate() < 0 || record.getTakeRate() > 2900){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位0-2900之间"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.saveOrientedPlan(record); | |||
| } | |||
| @ApiOperation("新增定向佣金达人合作") | |||
| @PostMapping("addOrientedPlanDouyin") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData addOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::addOrientedPlanDouyin"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空"); | |||
| } | |||
| if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"添加定向达人抖音号为空"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.addOrientedPlanDouyin(record); | |||
| } | |||
| @ApiOperation("取消定向佣金达人合作") | |||
| @PostMapping("cancelOrientedPlanDouyin") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData cancelOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::cancelOrientedPlanDouyin"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空"); | |||
| } | |||
| if(StringUtils.isBlank(record.getDouyinId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"取消定向达人抖音号为空"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.cancelOrientedPlanDouyin(record); | |||
| } | |||
| @ApiOperation("修改通用佣金计划状态") | |||
| @PostMapping("updateStatus") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData updateStatus(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateStatus"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划ID为空"); | |||
| } | |||
| if(record.getStatus() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态值为空"); | |||
| } | |||
| EnumCpsPlanStatus planStatus = EnumCpsPlanStatus.getEnum(record.getStatus()); | |||
| if(planStatus == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态不合法"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.poiPlanUpdateStatus(record); | |||
| } | |||
| @ApiOperation("修改定向佣金计划状态") | |||
| @PostMapping("updateOrientedStatus") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData updateOrientedStatus(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::updateOrientedStatus"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划ID为空"); | |||
| } | |||
| if(record.getStatus() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态值为空"); | |||
| } | |||
| EnumCpsPlanStatus planStatus = EnumCpsPlanStatus.getEnum(record.getStatus()); | |||
| if(!EnumCpsPlanStatus.OFF.equals(planStatus)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"状态不合法"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.poiOrientedPlanUpdateStatus(record); | |||
| } | |||
| @ApiOperation("获取佣金范围") | |||
| @PostMapping("getRateScope") | |||
| @SystemControllerLog(description = "获取") | |||
| public ResultData getRateScope(@RequestBody Map<String, Object> param) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getRateScope"); | |||
| String couponIdStr = (String) param.get("couponId"); | |||
| Integer planType = (Integer) param.get("planType"); | |||
| if(StringUtils.isBlank(couponIdStr)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||
| } | |||
| Long couponId = Long.parseLong(couponIdStr); | |||
| EnumCpsPlanType anEnum = EnumCpsPlanType.getEnum(planType); | |||
| if(anEnum == null){ | |||
| anEnum = EnumCpsPlanType.COMMON; | |||
| } | |||
| return ttCouponGoodsService.getRateScope(getTenantInfo(),couponId,anEnum); | |||
| } | |||
| @ApiOperation("设置总分佣率") | |||
| @PostMapping("setUpRateAll") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData setUpAll(@RequestBody Map<String, Object> param) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::setUpAll"); | |||
| String couponIdStr = (String) param.get("couponId"); | |||
| if(StringUtils.isBlank(couponIdStr)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||
| } | |||
| Long couponId = Long.parseLong(couponIdStr); | |||
| Integer mallRate = (Integer) param.get("mallRate"); | |||
| if(mallRate == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"总分佣率为空"); | |||
| } | |||
| return ttCouponGoodsService.setUpAll(getTenantInfo(),couponId,mallRate); | |||
| } | |||
| @ApiOperation("获取总分佣率及范围") | |||
| @PostMapping("getRateAll") | |||
| @SystemControllerLog(description = "获取") | |||
| public ResultData getAll(@RequestBody Map<String, Object> param) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::getAll"); | |||
| String couponIdStr = (String) param.get("couponId"); | |||
| if(StringUtils.isBlank(couponIdStr)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); | |||
| } | |||
| Long couponId = Long.parseLong(couponIdStr); | |||
| return ttCouponGoodsService.getAll(getTenantInfo(),couponId); | |||
| } | |||
| } | |||
| @@ -0,0 +1,135 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxBrand; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.enums.EnumDelFlag; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxBrandService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxBrand") | |||
| public class WxBrandController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxBrandService wxBrandService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "品牌-列表") | |||
| public ResultData list(@ModelAttribute WxBrand wxBrand,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxBrandController::list"); | |||
| if (null == wxBrand) { | |||
| wxBrand = new WxBrand(); | |||
| } | |||
| wxBrand.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxBrand.setSortColumns(BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxBrand> page = wxBrandService.listAsPage(wxBrand, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "品牌-增加") | |||
| public ResultData add(@RequestBody WxBrand wxBrand) { | |||
| logger.debug("[" + getIpAddr() + "] WxBrandController::add"); | |||
| wxBrand.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| return wxBrandService.save(wxBrand); | |||
| } | |||
| @TenantIgnore | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "品牌-更新") | |||
| public ResultData update(@RequestBody WxBrand wxBrand) { | |||
| logger.debug("[" + getIpAddr() + "] WxBrandController::update"); | |||
| if(wxBrand.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(EnumDelFlag.YES.getCode().equals(wxBrand.getIsDel())){ | |||
| //判断是否解绑商户 | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| // wxMerchant.updateTenantInfo(wxBrand); | |||
| wxMerchant.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| wxMerchant.setBrand(wxBrand.getId()); | |||
| List<WxMerchant> merchantList = wxMerchantService.findList(wxMerchant); | |||
| if(CollectionUtils.isNotEmpty(merchantList)){ | |||
| return new ResultData(Result.ERROR, "请先删除已绑定该品牌的商户。"); | |||
| } | |||
| } | |||
| wxBrandService.update(wxBrand); | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "品牌-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBrandController::del"); | |||
| wxBrandService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "品牌-查找") | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxBrandService.getById(id)); | |||
| } | |||
| @GetMapping("/queryBrand") | |||
| @SystemControllerLog(description = "品牌-租户-全部") | |||
| public ResultData queryBrand() { | |||
| List<Map<String,Object>> brandList = wxBrandService.queryBrand(getTenantInfo()); | |||
| return new ResultData(brandList); | |||
| } | |||
| @ApiOperation("查询品牌名称是否存在") | |||
| @GetMapping("hasBrand") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "name", value = "name", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query")}) | |||
| @SystemControllerLog(description = "品牌-名称是否存在") | |||
| public ResultData hasBrand(String name, Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBrandController::hasBrand"); | |||
| WxBrand wxBrand = new WxBrand(); | |||
| wxBrand.setId(id); | |||
| wxBrand.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxBrand.setName(name); | |||
| return wxBrandService.hasBrand(wxBrand); | |||
| } | |||
| } | |||
| @@ -0,0 +1,239 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCustomizeModule; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumThemeType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCustomizeModuleService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @Api(description = "CustomizeModule相关接口") | |||
| @RequestMapping("wxCustomizeModule") | |||
| public class WxCustomizeModuleController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxCustomizeModuleService wxCustomizeModuleService; | |||
| @Autowired | |||
| WxAppinfoService wxAppinfoService; | |||
| @ApiOperation("查询CustomizeModule列表") | |||
| @GetMapping(value = "/getDesc") | |||
| @SystemControllerLog(description = "查询CustomizeModule列表") | |||
| public ResultData getDesc(Integer themeType) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getDesc"); | |||
| try { | |||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| if(themeType == null){ | |||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||
| } | |||
| wxCustomizeModule.setIsUsing(EnumYesOrNo.YES.getCode()); | |||
| List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModule); | |||
| String msg = ""; | |||
| if(list == null || list.size() == 0){ | |||
| msg = "注:当前自定义配置无数据,如须使用自定义配置,建议先同步默认配置,再进行修改"; | |||
| }else if(list.size() < 4 || list.size() > 8){ | |||
| msg = "注:功能按钮配置达到4个方可生效,最多可添加8个功能按钮"; | |||
| }else{ | |||
| msg = "注:配置已生效,请在2分钟后重新登入小程序查看"; | |||
| } | |||
| return new ResultData(msg); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("查询CustomizeModule列表") | |||
| @GetMapping(value = "/list") | |||
| @SystemControllerLog(description = "查询CustomizeModule列表") | |||
| public ResultData getList(@ModelAttribute WxCustomizeModule wxCustomizeModule, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList"); | |||
| try { | |||
| if(wxCustomizeModule == null){ | |||
| wxCustomizeModule = new WxCustomizeModule(); | |||
| } | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| if(wxCustomizeModule.getThemeType() == null){ | |||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||
| } | |||
| PageInfo<WxCustomizeModule> page = wxCustomizeModuleService.listAsPage(wxCustomizeModule, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("查询CustomizeModule列表") | |||
| @GetMapping(value = "/findDefault") | |||
| @SystemControllerLog(description = "查询CustomizeModule列表") | |||
| public ResultData findDefault(@ModelAttribute WxCustomizeModule wxCustomizeModule) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList"); | |||
| try { | |||
| if(wxCustomizeModule == null){ | |||
| wxCustomizeModule = new WxCustomizeModule(); | |||
| } | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| if(wxCustomizeModule.getThemeType() == null){ | |||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||
| } | |||
| WxAppinfo cAppInfo = null; | |||
| if(EnumThemeType.C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序"); | |||
| } | |||
| }else if(EnumThemeType.TT_C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序"); | |||
| } | |||
| } | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到C端小程序"); | |||
| } | |||
| List<WxCustomizeModule> aDefault = wxCustomizeModuleService.findDefault(wxCustomizeModule,cAppInfo); | |||
| PageInfo<WxCustomizeModule> page = new PageInfo(aDefault); | |||
| return new ResultData(page); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("恢复主题默认") | |||
| @PostMapping("/updateDefault") | |||
| @SystemControllerLog(description = "恢复主题默认") | |||
| public ResultData updateDefault(@RequestBody WxCustomizeModule wxCustomizeModule) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::updateDefault"); | |||
| if(wxCustomizeModule == null){ | |||
| wxCustomizeModule = new WxCustomizeModule(); | |||
| } | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| if(wxCustomizeModule.getThemeType() == null){ | |||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||
| } | |||
| WxAppinfo cAppInfo = null; | |||
| if(EnumThemeType.C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序"); | |||
| } | |||
| }else if(EnumThemeType.TT_C.getCode().equals(wxCustomizeModule.getThemeType())){ | |||
| cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序"); | |||
| } | |||
| } | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到C端小程序"); | |||
| } | |||
| return wxCustomizeModuleService.updateDefault(wxCustomizeModule,cAppInfo); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/getById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "-查询") | |||
| public ResultData getById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getById"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| wxCustomizeModule.setId(id); | |||
| wxCustomizeModule = wxCustomizeModuleService.getById(wxCustomizeModule); | |||
| return new ResultData(wxCustomizeModule); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| wxCustomizeModule.setId(id); | |||
| wxCustomizeModuleService.updateDel(wxCustomizeModule); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/isNew") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "-置顶") | |||
| public ResultData isNew(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCustomizeModule wxCustomizeModule = new WxCustomizeModule(); | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| wxCustomizeModule.setId(id); | |||
| wxCustomizeModule.setSort(0); | |||
| wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule); | |||
| return new ResultData(Result.SUCCESS, "置顶成功", null); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "-添加") | |||
| public ResultData add(@RequestBody WxCustomizeModule wxCustomizeModule) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::add"); | |||
| if(wxCustomizeModule == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| if(wxCustomizeModule.getThemeType() == null){ | |||
| wxCustomizeModule.setThemeType(EnumThemeType.C.getCode()); | |||
| } | |||
| WxCustomizeModule wxCustomizeModuleQ = new WxCustomizeModule(); | |||
| wxCustomizeModuleQ.updateTenantInfo(wxCustomizeModule); | |||
| wxCustomizeModuleQ.setThemeType(wxCustomizeModule.getThemeType()); | |||
| wxCustomizeModuleQ.setIsUsing(EnumYesOrNo.YES.getCode()); | |||
| List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModuleQ); | |||
| if(list != null && list.size() >= 8){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"当前已超限,最多可添加8条"); | |||
| } | |||
| wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData update(@RequestBody WxCustomizeModule wxCustomizeModule) { | |||
| logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::update"); | |||
| if(wxCustomizeModule == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxCustomizeModule.updateTenantInfo(getTenantInfo()); | |||
| wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,73 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxGroup; | |||
| import com.iformall.service.WxGroupService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxGroup") | |||
| public class WxGroupController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxGroupService wxGroupService; | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "集团-列表") | |||
| public ResultData list(@ModelAttribute WxGroup wxGroup, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxGroupController::list"); | |||
| if (null == wxGroup) wxGroup = new WxGroup(); | |||
| final PageInfo<WxGroup> page = wxGroupService.listAsPage(wxGroup, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "集团-添加") | |||
| public ResultData add(@RequestBody WxGroup wxGroup) { | |||
| logger.debug("[" + getIpAddr() + "] WxGroupController::add"); | |||
| //Assert.notNull(wxGroup.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxGroupService.saveOrUpdate(wxGroup); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "集团-更新") | |||
| public ResultData update(@RequestBody WxGroup wxGroup) { | |||
| logger.debug("[" + getIpAddr() + "] WxGroupController::update"); | |||
| wxGroupService.saveOrUpdate(wxGroup); | |||
| return new ResultData(); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "集团-删除") | |||
| public ResultData delete(String id) { | |||
| logger.debug("[" + getIpAddr() + "] WxGroupController::delete"); | |||
| wxGroupService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "集团-查询") | |||
| public ResultData findById(String id) { | |||
| logger.debug("[" + getIpAddr() + "] WxGroupController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxGroupService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,88 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMallBuilding; | |||
| import com.iformall.domain.po.WxMallFloor; | |||
| import com.iformall.service.WxMallBuildingService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxMallBuilding") | |||
| public class WxMallBuildingController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallBuildingService wxMallBuildingService; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||
| @ApiOperation("获取楼层楼座数据") | |||
| @GetMapping("getbuildingfloorlist") | |||
| @SystemControllerLog(description = "商城-楼座-获取楼层楼座数据") | |||
| public ResultData getbuildingfloorlist() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::getbuildingfloorlist"); | |||
| return wxMallBuildingService.getBuildingFloorList(getTenantInfo()); | |||
| } | |||
| @ApiOperation("保存楼层楼座地图") | |||
| @PostMapping("saveFloorImg") | |||
| @SystemControllerLog(description = "商城-楼座/楼层-保存地图") | |||
| public ResultData saveFloorImg(@RequestBody List<WxMallBuilding> record) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor"); | |||
| if(record == null && record.size() > 0) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| for (WxMallBuilding building: record) { | |||
| List<WxMallFloor> floors = building.getFloors(); | |||
| if(floors != null && floors.size() > 0){ | |||
| for (WxMallFloor floor:floors) { | |||
| if (floor.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| floor.updateTenantInfo(getTenantInfo()); | |||
| wxMallBuildingService.saveFloorImg(floor); | |||
| } | |||
| } | |||
| } | |||
| String key = Constant.mallBuildingPrev + getTenantInfo().getTenantId(); | |||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("保存楼层楼座面积") | |||
| @PostMapping("saveFloorArea") | |||
| @SystemControllerLog(description = "商城-楼座/楼层-保存面积") | |||
| public ResultData saveFloorArea(@RequestBody WxMallFloor record) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor"); | |||
| if(record == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if (record.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if (record.getTotalArea() == null && record.getOperatingArea() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| wxMallBuildingService.saveFloorArea(record); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,100 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.google.code.kaptcha.Constants; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.enums.EnumGroupSupport; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.utils.ShiroUtils; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.io.IOUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.imageio.ImageIO; | |||
| import javax.servlet.ServletException; | |||
| import javax.servlet.ServletOutputStream; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.IOException; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxMall") | |||
| public class WxMallController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "商城-更新") | |||
| public ResultData update(@RequestBody WxMall wxMall) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::update"); | |||
| wxMallService.update(wxMall); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/mallinfoExt") | |||
| @SystemControllerLog(description = "商城-查询") | |||
| public ResultData mallinfoExt() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfoExt"); | |||
| return new ResultData(wxMallService.getByTenantInfoExt(getTenantInfo())); | |||
| } | |||
| @ApiOperation("查询当前mall的信息") | |||
| @GetMapping("/mallinfo") | |||
| @SystemControllerLog(description = "商城-当前查询") | |||
| public ResultData mallinfo() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); | |||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||
| if(mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if (wxMallService.isgroupSupport(mall)) { | |||
| mall.setSubMalls(wxMallService.getSubByParentTenantId(mall.getTenantId())); | |||
| } | |||
| mall.setValidPrompt(wxMallService.mallValid(getUserId(),mall)); | |||
| return new ResultData(mall); | |||
| } | |||
| @ApiOperation("查询当前mall的子广场") | |||
| @GetMapping("/childMall") | |||
| @SystemControllerLog(description = "商城-当前查询") | |||
| public ResultData childMall() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::childMall"); | |||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||
| if(mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if (wxMallService.isgroupSupport(mall)) { | |||
| List<WxMall> childMall = wxMallService.getSubByParentTenantId(mall.getTenantId()); | |||
| return new ResultData(childMall); | |||
| } | |||
| return new ResultData(Result.ERROR, "未查询到子广场"); | |||
| } | |||
| @ApiOperation("验证码") | |||
| @GetMapping("/imgUrlH") | |||
| public ResultData imgUrlH(){ | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::imgUrlH"); | |||
| WxMall mall = wxMallService.getByTenantInfo(getUser()); | |||
| if(mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| return new ResultData(mall.getImgUrlH()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantBUser") | |||
| public class WxMerchantBUserController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantBUserService wxMerchantBUserService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("listVo") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData listVo(@ModelAttribute WxMerchantBUser wxMerchantBUser, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::list"); | |||
| if (null == wxMerchantBUser) wxMerchantBUser = new WxMerchantBUser(); | |||
| wxMerchantBUser.updateTenantInfo(getTenantInfo()); | |||
| wxMerchantBUser.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxMerchantBUser> page = wxMerchantBUserService.listAsPage(wxMerchantBUser, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("手机号是否存在") | |||
| @GetMapping("/hasphone") | |||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | |||
| public ResultData hasPhone(String phone) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::hasphone"); | |||
| boolean has = wxMerchantBUserService.hasPhone(getTenantInfo(), phone); | |||
| return new ResultData(Result.SUCCESS, "查询成功", has); | |||
| } | |||
| } | |||
| @@ -0,0 +1,445 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.domain.vo.WxMerchantTradeDetailVo; | |||
| import com.iformall.domain.vo.WxMerchantTradeVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.douyin.pay.enums.AppAddSubMerchantUrlType; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxMerchant") | |||
| public class WxMerchantController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private QrCodeService qrCodeService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxPayAccountService payAccountService; | |||
| @Autowired | |||
| private WxProfitSharingReceiverService wxProfitSharingReceiverService; | |||
| @UserDataRuleAnnotation("merchant_list") | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("listVo") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData listVo(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode()); | |||
| final PageInfo<WxMerchant> page = wxMerchantService.listVoAsPage(wxMerchant, pageNum, pageSize,true); | |||
| return new ResultData(page); | |||
| } | |||
| @UserDataRuleAnnotation("merchant_list") | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("listVo2") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData listVo2(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode()); | |||
| final PageInfo<WxMerchant> page = wxMerchantService.listVoAsPage(wxMerchant, pageNum, pageSize,false); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData list(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode()); | |||
| final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("parentList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData parentList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::parentList"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| String tenantId = getUser().getTenantId(); | |||
| // wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setParentTenantId(tenantId); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode()); | |||
| final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("获取商管商户") | |||
| @GetMapping("adminMerchantOne") | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData adminMerchantOne() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::adminMerchantOne"); | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| wxMerchant.setIsAdmin(EnumMerchantAdmin.PUBLIC_ADMIN.getCode()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| List<WxMerchant> list = wxMerchantService.findList(wxMerchant); | |||
| if(list == null || list.isEmpty()){ | |||
| return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到商管商户"); | |||
| } | |||
| return new ResultData(list.get(0)); | |||
| } | |||
| @ApiOperation("获取商户ID,名称接口") | |||
| @GetMapping("IdAndNamelist") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "type", value = "类型", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||
| }) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData IdAndNamelist(Integer type,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| WxMerchant wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| wxMerchant.setType(type); | |||
| wxMerchant.setCarVendorType(0); | |||
| return new ResultData(wxMerchantService.queryIdAndNames(wxMerchant)); | |||
| } | |||
| @ApiOperation("ETCP商户列表") | |||
| @GetMapping("etcplist") | |||
| @SystemControllerLog(description = "商户-ETCP商户列表") | |||
| public ResultData etcpList(@ModelAttribute WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::etcpList"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| final List<WxMerchant> merchantList = wxMerchantService.etcpList(wxMerchant); | |||
| return new ResultData(merchantList); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::delete"); | |||
| wxMerchantService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::findById"); | |||
| WxMerchant wxMerchant = wxMerchantService.getById(id); | |||
| return new ResultData(wxMerchant); | |||
| } | |||
| @ApiOperation("停用") | |||
| @GetMapping("disable") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-停用") | |||
| public ResultData disable(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::disable"); | |||
| wxMerchantService.disable(id); | |||
| return new ResultData(Result.SUCCESS, "停用成功"); | |||
| } | |||
| @ApiOperation("新增商户接口") | |||
| @PostMapping("addMerchant") | |||
| @SystemControllerLog(description = "商户-新增") | |||
| public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| ResultData resultData = wxMerchantService.addMerchant(wxMerchant, getUserId()); | |||
| if(resultData.code == 200){ | |||
| wxMerchantService.updateQrCode(wxMerchant,wxMerchant.getId()); | |||
| } | |||
| return resultData; | |||
| } | |||
| @ApiOperation("更新商户接口") | |||
| @PostMapping("updateMerchant") | |||
| @SystemControllerLog(description = "商户-更新") | |||
| public ResultData updateMerchant(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchant"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchant(wxMerchant); | |||
| } | |||
| // @ApiOperation("更新账户接口") | |||
| // @PostMapping("updateMerchantAccount") | |||
| // @SystemControllerLog(description = "商户-更新账户") | |||
| // public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { | |||
| // logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); | |||
| // wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| // return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); | |||
| // } | |||
| @ApiOperation("更新管理员接口") | |||
| @PostMapping("updateMerchantAdmin") | |||
| @SystemControllerLog(description = "商户-更新管理员") | |||
| public ResultData updateMerchantAdmin(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAdmin"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantAdmin(wxMerchant); | |||
| } | |||
| @ApiOperation("更新法人接口") | |||
| @PostMapping("updateMerchantCorp") | |||
| @SystemControllerLog(description = "商户-更新法人") | |||
| public ResultData updateMerchantCopr(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantCorp"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantCorp(wxMerchant); | |||
| } | |||
| @ApiOperation("更新税务接口") | |||
| @PostMapping("updateMerchantTax") | |||
| @SystemControllerLog(description = "商户-更新税务") | |||
| public ResultData updateMerchantTax(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantTax"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantTax(wxMerchant); | |||
| } | |||
| @ApiOperation("商户信息设置接口") | |||
| @PostMapping("updateMerchantLevel") | |||
| @SystemControllerLog(description = "商户-更新会员等级权益") | |||
| public ResultData updateMerchantLevel(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantLevel"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantLevel(wxMerchant); | |||
| } | |||
| @ApiOperation("查询当前租户下商户名称列表") | |||
| @GetMapping("/name_list") | |||
| @SystemControllerLog(description = "查询当前租户下商户名称列表") | |||
| public ResultData nameList() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::name_list"); | |||
| return new ResultData(wxMerchantService.findList(getTenantInfo())); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findMerchantById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-查询") | |||
| public ResultData findMerchantById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::findMerchantById"); | |||
| WxMerchantVo wxMerchant = wxMerchantService.findMerchantById(getTenantInfo(),id); | |||
| return new ResultData(wxMerchant); | |||
| } | |||
| @UserDataRuleAnnotation("merchant_list") | |||
| @ApiOperation("商户数据导出") | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "商户-商户数据导出") | |||
| public void exportData(@ModelAttribute WxMerchant wxMerchant, HttpServletRequest request, HttpServletResponse response) { | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| wxMerchant.setIsPrivate(EnumYesOrNo.NO.getCode()); | |||
| wxMerchantService.exportData(wxMerchant,request,response); | |||
| } | |||
| @ApiOperation("置顶") | |||
| @PostMapping("top") | |||
| @SystemControllerLog(description = "商户-置顶") | |||
| public ResultData top(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::top"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.top(wxMerchant); | |||
| } | |||
| // @ApiOperation("更新收款账户状态") | |||
| // @PostMapping("useAccount") | |||
| // @SystemControllerLog(description = "商户-更新收款账户状态") | |||
| // public ResultData useAccount(@RequestBody WxProfitSharingReceiver wxProfitSharingReceiver) { | |||
| // logger.debug("[" + getIpAddr() + "] WxMerchantController::useAccount"); | |||
| // wxProfitSharingReceiver.updateTenantInfo(getTenantInfo()); | |||
| // return wxMerchantService.useAccount(wxProfitSharingReceiver); | |||
| // } | |||
| @ApiOperation("查看是否存在商户名称相同记录") | |||
| @GetMapping("/hasMerchant") | |||
| @SystemControllerLog(description = "商户-查看是否存在商户名称相同记录") | |||
| public ResultData hasMerchant(@ModelAttribute WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::hasMerchant"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| boolean has = wxMerchantService.hasMerchant(wxMerchant); | |||
| return new ResultData(has); | |||
| } | |||
| @ApiOperation("查看是否存在商户名称相同记录") | |||
| @GetMapping("/hasMerchantEncode") | |||
| @SystemControllerLog(description = "商户-查看是否存在商户编码相同记录") | |||
| @TenantIgnore | |||
| public ResultData hasMerchantEncode(@ModelAttribute WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::hasMerchantEncode{}"+wxMerchant.toString()); | |||
| boolean has = wxMerchantService.hasMerchantEncode(wxMerchant); | |||
| return new ResultData(has); | |||
| } | |||
| @ApiOperation("商户会员消费分页列表接口") | |||
| @GetMapping("userTradeList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-消费列表") | |||
| public ResultData userTradeList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchant.setSortColumns(BaseEntity.SortField.TopTime_DESC); | |||
| final PageInfo<WxMerchantTradeVo> page = wxMerchantService.userTradeList(wxMerchant, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("商户会员消费明细列表接口") | |||
| @GetMapping("userTradeDetailList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-商户会员消费明细列表接口") | |||
| public ResultData userTradeDetailList(@ModelAttribute WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxMerchantTradeDetailVo> page = wxMerchantService.userTradeDetailList(wxMerchant, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("导出商户会员消费分页列表") | |||
| @GetMapping("exportUserTradeDetailList") | |||
| @SystemControllerLog(description = "导出商户会员消费分页列表") | |||
| public void exportUserTradeList(@ModelAttribute WxMerchant wxMerchant,HttpServletRequest request, HttpServletResponse response) throws Exception{ | |||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::exportUserTradeDetailList"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| wxMerchantService.exportUserTradeList(wxMerchant, request,response); | |||
| } | |||
| @ApiOperation("刷新进件页面") | |||
| @GetMapping("/updateTtReceiver") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-删除") | |||
| public ResultData updateTtReceiver(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateTtReceiver"); | |||
| WxMerchant merchant = wxMerchantService.selectById(id); | |||
| if(merchant == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); | |||
| } | |||
| return wxProfitSharingReceiverService.updateTtReceiver(merchant); | |||
| } | |||
| @ApiOperation("获取进件/余额页面") | |||
| @GetMapping("/getTtReceiverUrl") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData getTtReceiver(Long id,Integer urlType) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::getTtReceiver"); | |||
| if(urlType == null || id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请检查传递参数"); | |||
| } | |||
| WxMerchant merchant = wxMerchantService.selectById(id); | |||
| if(merchant == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); | |||
| } | |||
| AppAddSubMerchantUrlType anEnum = AppAddSubMerchantUrlType.getEnum(urlType); | |||
| if(anEnum == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); | |||
| } | |||
| if(anEnum.equals(AppAddSubMerchantUrlType.improt_URL)){ | |||
| return wxProfitSharingReceiverService.getTtReceiverImprotURL(merchant); | |||
| }else if(anEnum.equals(AppAddSubMerchantUrlType.Balance_URL)){ | |||
| return wxProfitSharingReceiverService.getTtReceiverBalanceURL(merchant); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); | |||
| } | |||
| } | |||
| @ApiOperation("修改可用状态") | |||
| @GetMapping("/updateTtReceiverIsUse") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-删除") | |||
| public ResultData updateTtReceiverIsUse(Long id) { | |||
| WxMerchant merchant = wxMerchantService.selectById(id); | |||
| if(merchant == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请检查传递参数"); | |||
| } | |||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||
| if(appInfo == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| WxPayAccount payAcount = payAccountService.getById(appInfo.getPayId()); | |||
| if(payAcount == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| return wxProfitSharingReceiverService.updateTtReceiverIsUse(merchant); | |||
| } | |||
| } | |||
| @@ -0,0 +1,40 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMerchantShop; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.service.WxMerchantShopService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantShop") | |||
| public class WxMerchantShopController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantShopService wxMerchantShopService; | |||
| @ApiOperation("获取关联商铺信息") | |||
| @GetMapping("queryShopList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户商铺--获取关联商铺信息") | |||
| public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::queryShopList"); | |||
| if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); | |||
| wxMerchantShop.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -0,0 +1,168 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @Api(description = "MiniappTheme相关接口") | |||
| @RequestMapping("wxMiniappTheme") | |||
| public class WxMiniappThemeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMiniappThemeService wxMiniappThemeService; | |||
| @Autowired | |||
| WxAppinfoService wxAppinfoService; | |||
| @ApiOperation("查询MiniappTheme列表") | |||
| @GetMapping(value = "/list") | |||
| @SystemControllerLog(description = "查询MiniappTheme列表") | |||
| @TenantIgnore | |||
| public ResultData getList(@ModelAttribute WxMiniappTheme wxMiniappTheme, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::getList"); | |||
| try { | |||
| if(wxMiniappTheme == null){ | |||
| wxMiniappTheme = new WxMiniappTheme(); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| if(wxMiniappTheme.getType() == null){ | |||
| wxMiniappTheme.setType(EnumThemeType.C.getCode()); | |||
| } | |||
| if(EnumThemeType.C.getCode().equals(wxMiniappTheme.getType())){ | |||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.WX); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到微信C端小程序"); | |||
| } | |||
| wxMiniappTheme.setMouldType(cAppInfo.getMouldType()); | |||
| }else if(EnumThemeType.TT_C.getCode().equals(wxMiniappTheme.getType())){ | |||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumAppPlat.TOUTIAO); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到抖音C端小程序"); | |||
| } | |||
| wxMiniappTheme.setMouldType(cAppInfo.getMouldType()); | |||
| } | |||
| if(wxMiniappTheme.getMouldType() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请先确认模板类型"); | |||
| } | |||
| PageInfo<WxMiniappTheme> page = wxMiniappThemeService.listAsPage(wxMiniappTheme, pageNum, pageSize); | |||
| if(page.getList() != null && page.getList().size() > 0){ | |||
| WxThemeMall wxThemeMall = new WxThemeMall(); | |||
| wxThemeMall.setTenantId(getTenantInfo().getTenantId()); | |||
| wxThemeMall.setThemeType(wxMiniappTheme.getType()); | |||
| wxThemeMall.setMouldType(wxMiniappTheme.getMouldType()); | |||
| WxThemeMall themeMall = wxMiniappThemeService.findThemeMall(wxThemeMall); | |||
| boolean updateStatus = true; | |||
| if(themeMall != null){ | |||
| for (WxMiniappTheme theme:page.getList()) { | |||
| if(theme.getId().equals(themeMall.getThemeId())){ | |||
| theme.setStatus(0); | |||
| updateStatus = false; | |||
| }else{ | |||
| theme.setStatus(1); | |||
| } | |||
| } | |||
| } | |||
| if(updateStatus){ | |||
| page.getList().get(0).setStatus(0); | |||
| } | |||
| } | |||
| return new ResultData(page); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("根据id使之生效") | |||
| @PostMapping("/updateEffect") | |||
| @ApiImplicitParam(name = "themeId", value = "themeId", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "根据id使之生效") | |||
| @TenantIgnore | |||
| public ResultData updateEffect(@RequestBody WxThemeMall wxThemeMall) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::updateEffect"); | |||
| if(wxThemeMall == null || wxThemeMall.getThemeId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxMiniappTheme miniappTheme = new WxMiniappTheme(); | |||
| miniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| miniappTheme.setId(wxThemeMall.getThemeId()); | |||
| WxMiniappTheme theme = wxMiniappThemeService.selectById(miniappTheme); | |||
| if(theme == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| wxThemeMall.setTenantId(getTenantInfo().getTenantId()); | |||
| wxThemeMall.setMouldType(theme.getMouldType()); | |||
| wxThemeMall.setThemeType(theme.getType()); | |||
| wxMiniappThemeService.updateEffect(wxThemeMall); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "-删除") | |||
| @TenantIgnore | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::delete"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappThemeService.updateDel(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "-添加") | |||
| @TenantIgnore | |||
| public ResultData add(@RequestBody WxMiniappTheme wxMiniappTheme) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::add"); | |||
| if(wxMiniappTheme == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| if(wxMiniappTheme.getType() == null){ | |||
| wxMiniappTheme.setType(EnumThemeType.C.getCode()); | |||
| } | |||
| if(wxMiniappTheme.getMouldType() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请确认模板类型"); | |||
| } | |||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "-更新") | |||
| public ResultData update(@RequestBody WxMiniappTheme wxMiniappTheme) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::update"); | |||
| if(wxMiniappTheme == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,130 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.domain.po.WxProfitSharingReceiverApply; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxMerchantReceiverApplyVo; | |||
| import com.iformall.douyin.pay.enums.MerchantImportStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxProfitSharingReceiverApplyService; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.codec.binary.Base64; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.ByteArrayInputStream; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("sharingReceiverApply") | |||
| @Api(description = "进件相关接口") | |||
| @Slf4j | |||
| public class WxProfitSharingReceiverApplyController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxProfitSharingReceiverApplyService wxProfitSharingReceiverApplyService; | |||
| @Autowired | |||
| private WxProfitSharingReceiverService wxProfitSharingReceiverService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private AliyunOSS aliyunOSS; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("listVo") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData listVo(WxMerchantReceiverApplyVo receiver, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::listVo"); | |||
| if (null == receiver) receiver = new WxMerchantReceiverApplyVo(); | |||
| receiver.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxMerchantReceiverApplyVo> page = wxProfitSharingReceiverApplyService.listVoAsPage(receiver, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("tenantListVo") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| @SystemControllerLog(description = "商户-列表") | |||
| public ResultData tenantListVo(WxMerchantReceiverApplyVo receiver, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::tenantListVo"); | |||
| if (null == receiver) receiver = new WxMerchantReceiverApplyVo(); | |||
| final PageInfo<WxMerchantReceiverApplyVo> page = wxProfitSharingReceiverApplyService.listVoAsPage(receiver, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("修改功能状态") | |||
| @PostMapping("/updateFunctionState") | |||
| @SystemControllerLog(description = "修改") | |||
| public ResultData updateFunctionState(@RequestBody WxProfitSharingReceiverApply receiverAdd) { | |||
| log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::updateFunctionState"); | |||
| if(receiverAdd.getId() == null || receiverAdd.getFunctionState() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxProfitSharingReceiverApply receiverApply = wxProfitSharingReceiverApplyService.selectById(receiverAdd.getId()); | |||
| if(receiverApply == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到进件数据"); | |||
| } | |||
| if(!EnumSharingReceiverApplymentState.APPLYMENT_STATE_FINISHED.getCode().equals(receiverApply.getApplymentState())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "进件还未完成"); | |||
| } | |||
| receiverAdd.updateTenantInfo(receiverApply); | |||
| return wxProfitSharingReceiverApplyService.updateFunctionState(receiverAdd); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("刷新审核状态") | |||
| @GetMapping("/syncApplymentStates") | |||
| @SystemControllerLog(description = "刷新") | |||
| public ResultData syncApplymentStates(Long id) { | |||
| log.debug("[" + getIpAddr() + "] merchantProfitSharingReceiver::syncApplymentStates"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "ID不能为空"); | |||
| } | |||
| WxProfitSharingReceiverApply receiverApply = wxProfitSharingReceiverApplyService.findResultStateById(id); | |||
| if(receiverApply == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到进件数据"); | |||
| } | |||
| return wxProfitSharingReceiverApplyService.handApplymentStates(receiverApply); | |||
| } | |||
| } | |||
| @@ -0,0 +1,209 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.service.WxShopService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxShop") | |||
| public class WxShopController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxShopService wxShopService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "店铺管理-列表") | |||
| public ResultData list(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::list"); | |||
| if (null == wxShop){ | |||
| wxShop = new WxShop(); | |||
| } | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<Map<String, Object>> page = wxShopService.listMapAsPage(wxShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "店铺管理-新增") | |||
| public ResultData add(@RequestBody WxShop wxShop) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::add"); | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| return wxShopService.saveOrUpdate(wxShop); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "店铺管理-更新") | |||
| public ResultData update(@RequestBody WxShop wxShop) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::update"); | |||
| if (null == wxShop){ | |||
| wxShop = new WxShop(); | |||
| } | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| return wxShopService.saveOrUpdate(wxShop); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @SystemControllerLog(description = "店铺管理-删除") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::delete"); | |||
| Integer isAdmin = getUser().getIsAdmin(); | |||
| return wxShopService.deleteById(id, isAdmin); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "店铺管理-id查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxShopService.getById(id)); | |||
| } | |||
| @ApiOperation("获取商铺数据") | |||
| @GetMapping("getShopListByShopNumber") | |||
| @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "店铺管理-获取商铺数据") | |||
| public ResultData getShoplist(String shopNumber) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::getbshoplist"); | |||
| return wxShopService.getShopList(getTenantInfo(), shopNumber); | |||
| } | |||
| @ApiOperation("获取商户商铺数据") | |||
| @GetMapping("getMerchantShopByShopId") | |||
| @ApiImplicitParam(name = "shopId", value = "shopId", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "店铺管理-获取商户商铺数据") | |||
| public ResultData getMerchantShopByShopId(String shopId) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::getMerchantShopByShopId"); | |||
| return wxShopService.getMerchantShopByShopId(getTenantInfo(), shopId); | |||
| } | |||
| @ApiOperation("查询商铺号是否存在") | |||
| @GetMapping("hasShopNumber") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query"), | |||
| @ApiImplicitParam(name = "type", value = "type", dataType = "Integer", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "店铺管理-查询商铺号是否存在") | |||
| public ResultData hasShopNumber(String shopNumber, Long id, Integer type) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::hasShopNumber"); | |||
| WxShop wxShop = new WxShop(); | |||
| wxShop.setShopNumber(shopNumber); | |||
| wxShop.setType(type); | |||
| wxShop.setId(id); | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| return wxShopService.hasShopNumber(wxShop); | |||
| } | |||
| @ApiOperation("查询商铺地图sid是否存在") | |||
| @GetMapping("hasShopSid") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query"), | |||
| @ApiImplicitParam(name = "type", value = "type", dataType = "Integer", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "店铺管理-查询商铺号是否存在") | |||
| public ResultData hasShopSid(String shopSid, Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::hasShopSid"); | |||
| WxShop wxShop = new WxShop(); | |||
| wxShop.setSid(shopSid); | |||
| wxShop.setId(id); | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| return wxShopService.hasShopSid(wxShop); | |||
| } | |||
| @ApiOperation("分页列表接品-合同访问") | |||
| @GetMapping("listShopFromContract") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "店铺管理-合同访问") | |||
| public ResultData listShopFromContract(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::listShopFromContract"); | |||
| if (null == wxShop){ | |||
| wxShop = new WxShop(); | |||
| } | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<Map<String, Object>> page = wxShopService.listShopFromContract(wxShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("导出店铺") | |||
| @GetMapping("/exportShop") | |||
| @SystemControllerLog(description = "店铺管理-导出店铺") | |||
| public void exportShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::exportShop"); | |||
| if (null == wxShop){ | |||
| wxShop = new WxShop(); | |||
| } | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| wxShop.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Id_DESC); | |||
| wxShopService.exportShop(wxShop, request, response); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("导出未出租店铺") | |||
| @GetMapping("/exportNotRentShop") | |||
| @SystemControllerLog(description = "商铺出租数据-未出租商铺列表-导出") | |||
| public void exportNotRentShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::exportNotRentShop"); | |||
| if (null == wxShop){ | |||
| wxShop = new WxShop(); | |||
| } | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| wxShop.setSortColumns(BaseEntity.SortField.SCreateDate_DESC,BaseEntity.SortField.SId_DESC); | |||
| wxShopService.exportNotRentShop(wxShop, request, response); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("未出租商铺分页列表接口") | |||
| @GetMapping("notRentShopList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "未出租商铺分页列表接口") | |||
| public ResultData notRentShopList(@ModelAttribute WxShop wxShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxShopController::notRentShopList"); | |||
| if (null == wxShop){ | |||
| wxShop = new WxShop(); | |||
| } | |||
| wxShop.updateTenantInfo(getTenantInfo()); | |||
| wxShop.setSortColumns(BaseEntity.SortField.SCreateDate_DESC,BaseEntity.SortField.SId_DESC); | |||
| final PageInfo<Map<String, Object>> page = wxShopService.notRentListMapAsPage(wxShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -0,0 +1,124 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.MarkingCouponDataReportDto; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.service.MarkingDataReportService; | |||
| import com.iformall.service.WxMallService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.List; | |||
| /** | |||
| * Created by syf on 2018/8/29. | |||
| */ | |||
| @RestController | |||
| @RequestMapping("markingDataReport") | |||
| @Api(description = "营销报表接口") | |||
| public class MarkingDataReportController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private MarkingDataReportService markingDataReportService; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @TenantIgnore | |||
| @ApiOperation("查询券数据") | |||
| @GetMapping("/couponData") | |||
| @SystemControllerLog(description = "券数据-查询券数据") | |||
| public ResultData findCouponData() { | |||
| logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findCouponData"); | |||
| return new ResultData(markingDataReportService.getCouponData(getTenantInfo())); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询券数据列表") | |||
| @GetMapping("/couponDataList") | |||
| @SystemControllerLog(description = "券数据-查询券数据列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findCouponDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findCouponDataList"); | |||
| return new ResultData(markingDataReportService.getCouponDataList(getTenantInfo(), markingCouponDataReportDto, pageNum, pageSize)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询场景投放券数据") | |||
| @GetMapping("/sceneData") | |||
| @SystemControllerLog(description = "券数据-查询场景投放券数据") | |||
| public ResultData findSceneData() { | |||
| logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findSceneData"); | |||
| return new ResultData(markingDataReportService.getSceneData(getTenantInfo())); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询场景营销数据列表") | |||
| @GetMapping("/sceneDataList") | |||
| @SystemControllerLog(description = "券数据-查询场景营销数据列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findSceneDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MarkingDataReportController::findSceneDataList"); | |||
| return new ResultData(markingDataReportService.getSceneDataList(getTenantInfo(), markingCouponDataReportDto, pageNum, pageSize)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询触达用户数数据") | |||
| @GetMapping("/touchUsersData") | |||
| @SystemControllerLog(description = "券数据-查询触达用户数数据") | |||
| public ResultData touchUsersData() { | |||
| logger.debug("[" + getIpAddr() + "] MarkingDataReportController::touchUsersData"); | |||
| return new ResultData(markingDataReportService.getTouchUsersReportData(getTenantInfo())); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询触达用户数数据列表") | |||
| @GetMapping("/touchUsersDataList") | |||
| @SystemControllerLog(description = "券数据-查询触达用户数数据列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData touchUsersDataList(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MarkingDataReportController::touchUsersDataList"); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| //List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantInfo); | |||
| //markingCouponDataReportDto.setTenantEntitys(tenantEntitys); | |||
| markingCouponDataReportDto.updateTenantInfo(tenantInfo); | |||
| markingCouponDataReportDto.setTenantEntity(tenantInfo); | |||
| return new ResultData(markingDataReportService.getTouchUsersReportList(markingCouponDataReportDto, pageNum, pageSize)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("触达用户数数据导出") | |||
| @GetMapping("/exportTouchUsersData") | |||
| @SystemControllerLog(description = "券数据-触达用户数数据导出") | |||
| public void exportTouchUsersData(@ModelAttribute MarkingCouponDataReportDto markingCouponDataReportDto, HttpServletRequest request, HttpServletResponse response) { | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| //List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantInfo); | |||
| //markingCouponDataReportDto.setTenantEntitys(tenantEntitys); | |||
| markingCouponDataReportDto.updateTenantInfo(tenantInfo); | |||
| markingCouponDataReportDto.setTenantEntity(tenantInfo); | |||
| markingDataReportService.exportTouchUsersData(request, response, markingCouponDataReportDto); | |||
| } | |||
| } | |||
| @@ -0,0 +1,42 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.service.PushLimitService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("pushLimit") | |||
| @Api(description = "疲劳度相关接口") | |||
| public class PushLimitController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private PushLimitService pushLimitService; | |||
| @ApiOperation("疲劳度配置") | |||
| @GetMapping("setting") | |||
| @SystemControllerLog(description = "疲劳度-配置获取") | |||
| public ResultData list() { | |||
| logger.debug("[" + getIpAddr() + "] PushLimitController::list"); | |||
| PushLimit pushLimit = pushLimitService.getPushLimit(getTenantInfo()); | |||
| return new ResultData(pushLimit); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "疲劳度-配置更新") | |||
| public ResultData update(@RequestBody PushLimit pushLimit) { | |||
| logger.debug("[" + getIpAddr() + "] PushLimitController::update"); | |||
| pushLimit.updateTenantInfo(getTenantInfo()); | |||
| pushLimitService.saveOrUpdate(pushLimit); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,189 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.vo.TtCouponChannelVo; | |||
| import com.iformall.domain.vo.TtCouponVo; | |||
| import com.iformall.douyin.web.bean.GoodsTemplateGet; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("ttgoods") | |||
| @Api(description = "抖音商品库") | |||
| public class TtCouponGoodsController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @Autowired | |||
| private TtCouponGoodsService ttCouponGoodsService; | |||
| @Autowired | |||
| private TtMerchantPoiService ttMerchantPoiService; | |||
| @Autowired | |||
| private TtGoodsCategoryService ttGoodsCategoryService; | |||
| // @ApiOperation("分页列表接口") | |||
| // @GetMapping("couponList") | |||
| // @ApiImplicitParams({ | |||
| // @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| // @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| // @SystemControllerLog(description = "-列表") | |||
| // public ResultData couponList(@ModelAttribute TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { | |||
| // logger.debug("[" + getIpAddr() + "] WxCouponController::couponList"); | |||
| // if (ttCouponVo == null) ttCouponVo = new TtCouponVo(); | |||
| // ttCouponVo.updateTenantInfo(getTenantInfo()); | |||
| // ttCouponVo.setType(EnumCouponType.COUPON_DOUYIN.getCode()); | |||
| // if(StringUtils.isNotBlank(ttCouponVo.getSortColumn())){ | |||
| // String coryColumn = "c."+ttCouponVo.getSortColumns(); | |||
| // ttCouponVo.setSortColumns(coryColumn); | |||
| // ttCouponVo.setSortColumn(null); | |||
| // }else{ | |||
| // ttCouponVo.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC); | |||
| // } | |||
| // if (ttCouponVo.getStatus() != null && ttCouponVo.getStatus() == -1) | |||
| // ttCouponVo.setStatus(null); | |||
| // return ttCouponGoodsService.couponList(ttCouponVo, pageNum, pageSize); | |||
| // } | |||
| // | |||
| // @ApiOperation("分页列表接口") | |||
| // @GetMapping("channelList") | |||
| // @ApiImplicitParams({ | |||
| // @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| // @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| // @SystemControllerLog(description = "-列表") | |||
| // public ResultData channelList(@ModelAttribute TtCouponChannelVo ttChannelVo, Integer pageNum, Integer pageSize) { | |||
| // logger.debug("[" + getIpAddr() + "] WxCouponController::channelList"); | |||
| // if (ttChannelVo == null) ttChannelVo = new TtCouponChannelVo(); | |||
| // ttChannelVo.updateTenantInfo(getTenantInfo()); | |||
| // ttChannelVo.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); | |||
| // if(null == ttChannelVo.getSourceType()){ | |||
| // ttChannelVo.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| // } | |||
| // | |||
| // if(StringUtils.isNotBlank(ttChannelVo.getSortColumn())){ | |||
| // String coryColumn = "cc."+ttChannelVo.getSortColumns(); | |||
| // ttChannelVo.setSortColumns(coryColumn); | |||
| // ttChannelVo.setSortColumn(null); | |||
| // }else{ | |||
| // ttChannelVo.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | |||
| // } | |||
| // | |||
| // return ttCouponGoodsService.channelList(ttChannelVo, pageNum, pageSize); | |||
| // } | |||
| @ApiOperation("根据类目获取商品模板") | |||
| @GetMapping("getTemplate") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "根据类目获取商品模板") | |||
| public ResultData getGoodsTemplate(Long couponId,Integer categoryId,Integer productType) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::getGoodsTemplate"); | |||
| if(productType == null){ | |||
| productType = 1; | |||
| } | |||
| if(couponId == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCoupon coupon = wxCouponService.getAttrsById(couponId, getTenantInfo().getTenantId()); | |||
| if(coupon == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| try { | |||
| GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtWebService(getTenantInfo()).getGoodsService().templateGet(categoryId, productType); | |||
| ttGoodsCategoryService.adminIsShow(goodsTemplateGet); | |||
| ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon); | |||
| return new ResultData(goodsTemplateGet); | |||
| } catch (WxErrorException e) { | |||
| e.printStackTrace(); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("提交审核") | |||
| @PostMapping("product/save") | |||
| @SystemControllerLog(description = "提交审核") | |||
| public ResultData productSave(@RequestBody WxCoupon wxCoupon) { | |||
| if (wxCoupon.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(), getTenantInfo().getTenantId()); | |||
| if(coupon == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(coupon.getSalePrice() == null || coupon.getSalePrice().intValue() == 0){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"免费券无需提审"); | |||
| } | |||
| try { | |||
| return ttCouponGoodsService.productSave(coupon); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("实时查询审核状态") | |||
| @GetMapping("product/draft") | |||
| @SystemControllerLog(description = "实时查询审核状态") | |||
| public ResultData productDraft(Long id) { | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return ttCouponGoodsService.productDraftGet(getTenantInfo(),id); | |||
| } | |||
| @ApiOperation("实时查询线上商品状态") | |||
| @GetMapping("product/online") | |||
| @SystemControllerLog(description = "实时查询审核状态") | |||
| public ResultData productOnline(Long id) { | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return ttCouponGoodsService.productOnlineGet(getTenantInfo(),id); | |||
| } | |||
| @ApiOperation("实时同步上下架状态") | |||
| @GetMapping("product/operate") | |||
| @SystemControllerLog(description = "实时同步上下架状态") | |||
| public ResultData productOperate(Long id) { | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return ttCouponGoodsService.productOperate(getTenantInfo(),id); | |||
| } | |||
| @ApiOperation("实时同步库存") | |||
| @GetMapping("product/stock/sync") | |||
| @SystemControllerLog(description = "实时同步库存") | |||
| public ResultData productStockSync(Long id) { | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return ttCouponGoodsService.productStockSync(getTenantInfo(),id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.ueditor.ActionEnter; | |||
| import io.swagger.annotations.Api; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @RestController | |||
| @RequestMapping("/ue") | |||
| @Api(description = "网页bannner图接口") | |||
| public class UeditorController { | |||
| @Autowired | |||
| private ActionEnter actionEnter; | |||
| @ResponseBody | |||
| @RequestMapping("/ueditor/exec") | |||
| public Object exe(HttpServletRequest request){ | |||
| return actionEnter.exec(request); | |||
| } | |||
| } | |||
| @@ -0,0 +1,132 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxActivity; | |||
| import com.iformall.enums.EnumActivityStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxActivityService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxActivity") | |||
| @Api(description = "活动") | |||
| public class WxActivityController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxActivityService wxActivityService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "活动-列表") | |||
| public ResultData list(@ModelAttribute WxActivity wxActivity, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::list"); | |||
| if (null == wxActivity) wxActivity = new WxActivity(); | |||
| if (wxActivity.getStatus() != null && wxActivity.getStatus() == -1) { | |||
| wxActivity.setStatus(null); | |||
| } | |||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||
| wxActivity.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxActivity> page = wxActivityService.listAsPage(wxActivity, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "活动-新增") | |||
| public ResultData add(@RequestBody WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::add"); | |||
| wxActivity.setStatus(EnumActivityStatus.STATUS_THROW_IN.getCode()); | |||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| return wxActivityService.saveOrUpdate(wxActivity); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "活动-id更新") | |||
| public ResultData update(@RequestBody WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::update"); | |||
| try { | |||
| return wxActivityService.saveOrUpdate(wxActivity); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("updateStatus") | |||
| @SystemControllerLog(description = "活动-更新状态") | |||
| public ResultData updateStatus(@RequestBody WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus"); | |||
| try { | |||
| return wxActivityService.updateStatus(wxActivity); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "活动-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::findById"); | |||
| WxActivity wxActivity = wxActivityService.getById(id); | |||
| return new ResultData(wxActivity); | |||
| } | |||
| @ApiOperation("投放到宣传页") | |||
| @GetMapping("/sendToCampaign") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "活动-投放到宣传页") | |||
| public ResultData sendToCampaign(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::sendToCampaign"); | |||
| return wxActivityService.sendToCampaign(id); | |||
| } | |||
| @ApiOperation("从宣传页下线") | |||
| @PostMapping("offLineCampaign") | |||
| @SystemControllerLog(description = "活动-更新状态") | |||
| public ResultData offLineCampaign(@RequestBody WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus"); | |||
| return wxActivityService.offLineCampaign(wxActivity); | |||
| } | |||
| @ApiOperation("删除") | |||
| @PostMapping("deleteById") | |||
| @SystemControllerLog(description = "活动-删除") | |||
| public ResultData deleteById(@RequestBody WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::deleteById"); | |||
| if(wxActivity.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return wxActivityService.deleteById(wxActivity.getId(),getTenantInfo().getTenantId()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,114 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxActivityJoin; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxActivityJoinService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxActivityJoin") | |||
| @Api(description = "活动参与信息") | |||
| public class WxActivityJoinController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxActivityJoinService wxActivityJoinService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "活动参与信息-列表") | |||
| public ResultData list(@ModelAttribute WxActivityJoin wxActivityJoin, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::list"); | |||
| if (null == wxActivityJoin) { | |||
| wxActivityJoin = new WxActivityJoin(); | |||
| } | |||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||
| wxActivityJoin.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxActivityJoin> page = wxActivityJoinService.listAsPage(wxActivityJoin, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("确认或取消报名") | |||
| @PostMapping("modifyStatus") | |||
| @SystemControllerLog(description = "活动参与信息-确认或取消报名") | |||
| public ResultData modifyStatus(@RequestBody WxActivityJoin wxActivityJoin) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::modifyStatus"); | |||
| if (wxActivityJoin.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); | |||
| } | |||
| if (wxActivityJoin.getActivityId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||
| } | |||
| if (wxActivityJoin.getStatus() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "status不能为空"); | |||
| } | |||
| try { | |||
| return wxActivityJoinService.modifyStatus(wxActivityJoin); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("导出报名表") | |||
| @RequestMapping("/exportData") | |||
| @SystemControllerLog(description = "活动参与信息-导出报名表") | |||
| public void exportData(@ModelAttribute WxActivityJoin wxActivityJoin, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::exportData"); | |||
| if (wxActivityJoin.getActivityId() == null) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||
| } | |||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||
| wxActivityJoinService.exportData(request, response, wxActivityJoin); | |||
| } | |||
| @ApiOperation("查询报名总数") | |||
| @GetMapping("queryJoinInfo") | |||
| @SystemControllerLog(description = "活动参与信息-查询报名总数") | |||
| public ResultData queryJoinInfo(@ModelAttribute WxActivityJoin wxActivityJoin) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::queryJoinInfo"); | |||
| if (wxActivityJoin.getActivityId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||
| } | |||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||
| return wxActivityJoinService.queryJoinInfo(wxActivityJoin); | |||
| } | |||
| @ApiOperation("发送短信") | |||
| @GetMapping("sendMsg") | |||
| @SystemControllerLog(description = "活动参与信息-发送短信") | |||
| public ResultData sendMsg(@ModelAttribute WxActivityJoin wxActivityJoin) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityJoinController::confirmCompletion"); | |||
| if (wxActivityJoin.getActivityId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "activityId不能为空"); | |||
| } | |||
| wxActivityJoin.updateTenantInfo(getTenantInfo()); | |||
| return wxActivityJoinService.sendMsg(wxActivityJoin); | |||
| } | |||
| } | |||
| @@ -0,0 +1,216 @@ | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.service.WxCampaignService; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxCampaign") | |||
| @Api(description = "促销和banner接口") | |||
| public class WxCampaignController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCampaignService wxCampaignService; | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "宣传页-列表") | |||
| public ResultData list(@ModelAttribute WxCampaign wxCampaign, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::list"); | |||
| if (null == wxCampaign) wxCampaign = new WxCampaign(); | |||
| if (wxCampaign.getStatus() != null && wxCampaign.getStatus() == -1) { | |||
| wxCampaign.setStatus(null); | |||
| } | |||
| if(wxCampaign.getPlat() == null){ | |||
| wxCampaign.setPlat(EnumAppPlat.WX.getCode()); | |||
| } | |||
| wxCampaign.updateTenantInfo(getTenantInfo()); | |||
| wxCampaign.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxCampaign> page = wxCampaignService.listAsPage(wxCampaign, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "宣传页-新增") | |||
| public ResultData add(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::add"); | |||
| if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | |||
| String[] arys = wxCampaign.getCouponIds().split(","); | |||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | |||
| } else { | |||
| wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0])); | |||
| } | |||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||
| wxCampaign.updateTenantInfo(getTenantInfo()); | |||
| if(wxCampaign.getPlat() == null){ | |||
| wxCampaign.setPlat(EnumAppPlat.WX.getCode()); | |||
| } | |||
| return wxCampaignService.saveOrUpdate(wxCampaign); | |||
| } | |||
| @ApiOperation(value = "新增接口-小程序路径", notes = "produceType,produceId,pagePath,pageScene必填") | |||
| @PostMapping("addByPath") | |||
| @SystemControllerLog(description = "宣传页-新增") | |||
| public ResultData addByPath(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::addByPath"); | |||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||
| wxCampaign.updateTenantInfo(getTenantInfo()); | |||
| if(wxCampaign.getPlat() == null){ | |||
| wxCampaign.setPlat(EnumAppPlat.WX.getCode()); | |||
| } | |||
| return wxCampaignService.addForPath(wxCampaign); | |||
| } | |||
| @ApiOperation(value = "新增接口-小程序路径", notes = "produceType,produceId,pagePath,pageScene必填") | |||
| @PostMapping("addByAPPPath") | |||
| @SystemControllerLog(description = "宣传页-新增") | |||
| public ResultData addByAPPPath(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::addByAPPPath"); | |||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||
| wxCampaign.updateTenantInfo(getTenantInfo()); | |||
| if(wxCampaign.getPlat() == null){ | |||
| wxCampaign.setPlat(EnumAppPlat.WX.getCode()); | |||
| } | |||
| return wxCampaignService.addByAPPPath(wxCampaign); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "宣传页-id更新") | |||
| public ResultData update(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::update"); | |||
| if (StringUtils.isNotBlank(wxCampaign.getCouponIds())) { | |||
| String[] arys = wxCampaign.getCouponIds().split(","); | |||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | |||
| } else { | |||
| wxCampaign.setCouponIds(JSONArray.toJSONString(new String[0])); | |||
| } | |||
| if(wxCampaign.getPlat() == null){ | |||
| wxCampaign.setPlat(EnumAppPlat.WX.getCode()); | |||
| } | |||
| return wxCampaignService.saveOrUpdate(wxCampaign); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("updateStatus") | |||
| @SystemControllerLog(description = "宣传页-更新状态") | |||
| public ResultData updateStatus(@RequestBody WxCampaign wxCampaign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::updateStatus"); | |||
| WxCampaign campaign = wxCampaignService.getById(wxCampaign.getId()); | |||
| // check coupon 状态 | |||
| if (campaign.getType().equals(EnumCampaignType.STABLE.getCode())) { | |||
| if (campaign.getStatus().equals(EnumCampaignStatus.STATUS_THROW_IN.getCode()) | |||
| && !wxCampaign.getStatus().equals(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode())) { | |||
| // 宣传页 - 下架不检查状态 | |||
| List<String> ids = JSONArray.parseArray(campaign.getCouponIds(), String.class); | |||
| for (String couponIdStr : ids) { | |||
| Long couponId = Long.parseLong(couponIdStr); | |||
| WxCoupon wxCoupon = wxCouponService.getById(couponId,campaign.getTenantId()); | |||
| if (wxCoupon == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| } | |||
| if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| wxCampaign.setPlat(campaign.getPlat()); | |||
| return wxCampaignService.updateStatus(wxCampaign); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "宣传页-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::delete"); | |||
| wxCampaignService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "宣传页-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::findById"); | |||
| WxCampaign wxCampaign = wxCampaignService.getById(id); | |||
| if (wxCampaign != null) { | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.updateTenantInfo(wxCampaign); | |||
| wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); | |||
| wxCouponChannel.setSubTargetId(wxCampaign.getId()); | |||
| wxCouponChannel.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||
| List<WxCouponChannelVo> voList = wxCouponChannelService.newfindListVo(wxCouponChannel); | |||
| wxCampaign.setCoupons(voList); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCampaign); | |||
| } | |||
| @ApiOperation("调整顺序") | |||
| @GetMapping("/move") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "sourceId", value = "", dataType = "Long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "targetId", value = "", dataType = "Long", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "宣传页-调整顺序") | |||
| public ResultData move(Long sourceId, Long targetId) { | |||
| logger.debug("[" + getIpAddr() + "] WxCampaignController::move"); | |||
| WxCampaign source = wxCampaignService.getById(sourceId); | |||
| WxCampaign target = wxCampaignService.getById(targetId); | |||
| if (source == null || target == null) { | |||
| return new ResultData(Result.ERROR, "调整顺序失败", null); | |||
| } | |||
| int temp = source.getSortNum(); | |||
| source.setSortNum(target.getSortNum()); | |||
| target.setSortNum(temp); | |||
| wxCampaignService.saveOrUpdate(source); | |||
| wxCampaignService.saveOrUpdate(target); | |||
| return new ResultData(Result.SUCCESS, "调整顺序成功", null); | |||
| } | |||
| } | |||
| @@ -0,0 +1,104 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.enums.EnumCashOutStatus; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * 提现。微信需要小程序开通“企业付款到零钱”功能。 | |||
| * @author alascor | |||
| * | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/cashout") | |||
| @Api(description = "提现相关接口") | |||
| public class WxCashOutController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCashOutService wxCashOutService; | |||
| @Autowired | |||
| WxCUserService wxCUserService; | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| WxMallService wxMallService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute WxCashOut wxCashOut, Integer pageNum, Integer pageSize) { | |||
| if (null == wxCashOut) wxCashOut = new WxCashOut(); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCashOut.updateTenantInfo(tenantInfo); | |||
| if (null != wxCashOut.getStatus() && wxCashOut.getStatus().intValue()>0) { | |||
| //提现中 | |||
| List<Integer> statusList = new ArrayList<Integer>(); | |||
| if (wxCashOut.getStatus().intValue()==99) { | |||
| statusList.add(EnumCashOutStatus.DOING.getCode()); | |||
| statusList.add(EnumCashOutStatus.WAITING.getCode()); | |||
| wxCashOut.setStatusList(statusList); | |||
| wxCashOut.setStatus(null); | |||
| //提现成功 | |||
| }else if (wxCashOut.getStatus().intValue()==98) { | |||
| statusList.add(EnumCashOutStatus.SUCCESS.getCode()); | |||
| wxCashOut.setStatusList(statusList); | |||
| wxCashOut.setStatus(null); | |||
| //提现失败 | |||
| }else if (wxCashOut.getStatus().intValue()==97) { | |||
| statusList.add(EnumCashOutStatus.FAIL.getCode()); | |||
| statusList.add(EnumCashOutStatus.BACK.getCode()); | |||
| wxCashOut.setStatusList(statusList); | |||
| wxCashOut.setStatus(null); | |||
| //提现拒绝 | |||
| }else if (wxCashOut.getStatus().intValue()==96) { | |||
| statusList.add(EnumCashOutStatus.REJECT.getCode()); | |||
| wxCashOut.setStatusList(statusList); | |||
| wxCashOut.setStatus(null); | |||
| //审批中 | |||
| }else if (wxCashOut.getStatus().intValue()==95) { | |||
| statusList.add(EnumCashOutStatus.AUDIOING.getCode()); | |||
| wxCashOut.setStatusList(statusList); | |||
| wxCashOut.setStatus(null); | |||
| } | |||
| }else { | |||
| wxCashOut.setStatus(null); | |||
| } | |||
| wxCashOut.setSortColumns(SortField.CreateDate_DESC); | |||
| final PageInfo<WxCashOut> page = wxCashOutService.listAsPage(wxCashOut, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("查询当前提现信息") | |||
| @GetMapping("getInfo") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", paramType = "query", required = true)}) | |||
| public ResultData getCurrentCashOutData(Long id) { | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| WxCashOut out = wxCashOutService.getById(id, tenantInfo.getTenantId()); | |||
| return new ResultData(out); | |||
| } | |||
| } | |||
| @@ -0,0 +1,81 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCouponActionLog; | |||
| import com.iformall.service.WxCouponActionLogService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxCouponActionLog") | |||
| @Api(description = "发券行为记录接口") | |||
| public class WxCouponActionLogController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponActionLogService wxCouponActionLogService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "注券记录-图表") | |||
| public ResultData list(@ModelAttribute WxCouponActionLog wxCouponActionLog, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::list"); | |||
| if (null == wxCouponActionLog) wxCouponActionLog = new WxCouponActionLog(); | |||
| final PageInfo<WxCouponActionLog> page = wxCouponActionLogService.listAsPage(wxCouponActionLog, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "注券记录-新增") | |||
| public ResultData add(@RequestBody WxCouponActionLog wxCouponActionLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::add"); | |||
| //Assert.notNull(wxCouponActionLog.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponActionLogService.saveOrUpdate(wxCouponActionLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "注券记录-更新") | |||
| public ResultData update(@RequestBody WxCouponActionLog wxCouponActionLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::update"); | |||
| wxCouponActionLogService.saveOrUpdate(wxCouponActionLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "注券记录-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::delete"); | |||
| wxCouponActionLogService.deleteById(id,getTenantInfo().getTenantId()); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "注券记录-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponActionLogController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponActionLogService.getById(id,getTenantInfo().getTenantId())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,71 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCouponCar; | |||
| import com.iformall.service.WxCouponCarService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxCouponCar") | |||
| @Api(description = "停车券接口") | |||
| public class WxCouponCarController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponCarService wxCouponCarService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "停车券-列表") | |||
| public ResultData list(@ModelAttribute WxCouponCar wxCouponCar, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::list"); | |||
| if (null == wxCouponCar) wxCouponCar = new WxCouponCar(); | |||
| final PageInfo<WxCouponCar> page = wxCouponCarService.listAsPage(wxCouponCar, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "停车券-新增") | |||
| public ResultData add(@RequestBody WxCouponCar wxCouponCar) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::add"); | |||
| //Assert.notNull(wxCouponCar.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponCarService.save(wxCouponCar); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "停车券-更新") | |||
| public ResultData update(@RequestBody WxCouponCar wxCouponCar) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::update"); | |||
| wxCouponCarService.update(wxCouponCar); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "停车券-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponCarController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponCarService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,275 @@ | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.WxCouponChannelDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.EnumCouponSourceType; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.service.util.CouponCacheUtils; | |||
| import com.iformall.utils.RedisLock; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxCouponChannel") | |||
| @Api(description = "优惠券投放接口") | |||
| public class WxCouponChannelController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "券投放-列表") | |||
| public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::list"); | |||
| if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); | |||
| if (wxCouponChannel.getStatus() != null && wxCouponChannel.getStatus() == -1) { | |||
| wxCouponChannel.setStatus(null); | |||
| } | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| if(null == wxCouponChannel.getSourceType()){ | |||
| wxCouponChannel.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| } | |||
| if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){ | |||
| // | |||
| }else{ | |||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | |||
| } | |||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "券投放-更新") | |||
| public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::update"); | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| ResultData resultData = wxCouponChannelService.saveOrUpdate(wxCouponChannel); | |||
| WxCouponChannel couponChannel = (WxCouponChannel)resultData.data; | |||
| //生成二维码 | |||
| if(couponChannel!=null){ | |||
| wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType()); | |||
| } | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | |||
| CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null); | |||
| return resultData; | |||
| } | |||
| @ApiOperation("预审核上架") | |||
| @PostMapping("updateOnline") | |||
| @SystemControllerLog(description = "预审核上架") | |||
| public ResultData updateOnline(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| if (wxCouponChannel.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| ResultData resultData = wxCouponChannelService.updateOnline(wxCouponChannel); | |||
| if(resultData.code == 200){ | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | |||
| CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null); | |||
| } | |||
| return resultData; | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponChannelService.getById(id,getTenantInfo().getTenantId())); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("批量新增") | |||
| @PostMapping("/addbatch") | |||
| @SystemControllerLog(description = "券投放-批量新增") | |||
| public ResultData addbatch(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::addbatch"); | |||
| String[] ids = wxCouponChannelDto.getCouponIds().split(","); | |||
| String[] channelId = wxCouponChannelDto.getChannelId().split(","); | |||
| ResultData resultData = wxCouponChannelService.addBatch(wxCouponChannelDto.getType(),ids, channelId, getTenantInfo(), | |||
| wxCouponChannelDto.getShowBeginTime(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime(),wxCouponChannelDto.getChannelPrice(),wxCouponChannelDto.getChannelStock()); | |||
| if (null != channelId && channelId.length > 0 ) { | |||
| for (String chId: channelId) { | |||
| if (!StringUtils.isBlank(chId)) { | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, Long.parseLong(chId)); | |||
| } | |||
| } | |||
| } | |||
| CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, this.getTenantInfo().getTenantId(), null, null); | |||
| return resultData; | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findChannelByCouponId") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-查询") | |||
| public ResultData findChannelByCouponId(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::findChannelByCouponId"); | |||
| List<Integer> channellist = new ArrayList<>(); | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| wxCouponChannel.setStatus(0); | |||
| wxCouponChannel.setCouponId(id); | |||
| List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel, 1, 5).getList(); | |||
| if (list.isEmpty()) { | |||
| return new ResultData(Result.SUCCESS, "查询成功", ""); | |||
| } | |||
| for (WxCouponChannel temp : list) { | |||
| channellist.add(temp.getTargetAd()); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "查询成功", JSON.toJSONString(channellist)); | |||
| } | |||
| @ApiOperation("设置库存") | |||
| @PostMapping("/setChannelStock") | |||
| @SystemControllerLog(description = "设置渠道库存") | |||
| public ResultData setChannelStock(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| if (null == wxCouponChannel.getChannelStock() || wxCouponChannel.getChannelStock() <= 0) { | |||
| return new ResultData(Result.ERROR, "库存未设置或者库存小于0, 如不需要可点击解除锁定库存."); | |||
| } | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(), wxCouponChannel.getTenantId()); | |||
| if (coupon.getRemainInventory().intValue() < wxCouponChannel.getChannelStock().intValue()) { | |||
| return new ResultData(Result.ERROR, "渠道库存不能大于券剩余总库存."); | |||
| } | |||
| try { | |||
| wxCouponChannelService.setChannelStock(wxCouponChannel, wxCouponChannel.getChannelStock()); | |||
| redisLock.setCouponStock(wxCouponChannel.getCouponId(), coupon.getRemainInventory()); | |||
| redisLock.setCouponChannelStock(wxCouponChannel.getId(), wxCouponChannel.getChannelStock()); | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | |||
| return new ResultData(Result.SUCCESS, "设置成功", ""); | |||
| }catch(MallinkException e) { | |||
| logger.error("setChannelStock error.",e); | |||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||
| }catch(Exception e){ | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("解除锁定库存") | |||
| @PostMapping("/releaseChannelStock") | |||
| @SystemControllerLog(description = "释放渠道锁定库存") | |||
| public ResultData releaseChannelStock(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| wxCouponChannelService.releaseChannelStock(wxCouponChannel); | |||
| redisLock.removeCouponStock(wxCouponChannel.getCouponId()); | |||
| redisLock.removeCouponChannelStock(wxCouponChannel.getId()); | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | |||
| return new ResultData(Result.SUCCESS, "设置成功", ""); | |||
| }catch(MallinkException e) { | |||
| logger.error("releaseChannelStock error.",e); | |||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||
| }catch(Exception e){ | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("设置价格") | |||
| @PostMapping("/setChannelPrice") | |||
| @SystemControllerLog(description = "设置渠道价格") | |||
| public ResultData setChannelPrice(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| if (null == wxCouponChannel.getChannelPrice() || wxCouponChannel.getChannelPrice() < 0) { | |||
| return new ResultData(Result.ERROR, "价格未设置或者价格小于0, 如不需要可点击解除价格设置."); | |||
| } | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| //免费券不能设置有价 | |||
| WxCouponChannel cc = wxCouponChannelService.getById(wxCouponChannel.getId(), wxCouponChannel.getTenantId()); | |||
| if (null == cc ) { | |||
| return new ResultData(Result.ERROR, "id无效."); | |||
| } | |||
| WxCoupon coupon = wxCouponService.getById(cc.getCouponId(), wxCouponChannel.getTenantId()); | |||
| if (null == coupon ) { | |||
| return new ResultData(Result.ERROR, "优惠券不存在."); | |||
| } | |||
| if (coupon.getSalePrice() <= 0) { | |||
| return new ResultData(Result.ERROR, "免费券不能设置渠道价格."); | |||
| } | |||
| try { | |||
| wxCouponChannelService.setChannelPrice(wxCouponChannel); | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | |||
| return new ResultData(Result.SUCCESS, "设置成功", ""); | |||
| }catch(MallinkException e) { | |||
| logger.error("setChannelPrice error.",e); | |||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||
| }catch(Exception e){ | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("解除价格设置") | |||
| @PostMapping("/releaseSetChannelPrice") | |||
| @SystemControllerLog(description = "设置渠道价格") | |||
| public ResultData releaseSetChannelPrice(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| wxCouponChannel.setChannelPrice(null); | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| wxCouponChannelService.setChannelPrice(wxCouponChannel); | |||
| CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); | |||
| return new ResultData(Result.SUCCESS, "设置成功", ""); | |||
| }catch(MallinkException e) { | |||
| logger.error("releaseSetChannelPrice error.",e); | |||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||
| }catch(Exception e){ | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,739 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.TtCouponVo; | |||
| import com.iformall.domain.vo.WxCouponStatisVo; | |||
| import com.iformall.douyin.web.bean.GoodsTemplateGet; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.WxCouponChannelMapper; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.util.CouponCacheUtils; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisLock; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.*; | |||
| @RestController | |||
| @RequestMapping("wxCoupon") | |||
| @Api(description = "优惠券接口") | |||
| public class WxCouponController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @Autowired | |||
| private WxCouponPasswordService couponPasswordService; | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| @Autowired | |||
| private WxFlowService wxFlowService; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Autowired | |||
| private WxCouponMallService wxCouponMallService; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||
| if (wxCoupon == null) wxCoupon = new WxCoupon(); | |||
| wxCoupon.updateTenantInfo(getTenantInfo()); | |||
| return couponList(wxCoupon, pageNum, pageSize, isList); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("父券分页列表接口") | |||
| @GetMapping("parentCouponList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData parentCouponList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||
| if (wxCoupon == null) wxCoupon = new WxCoupon(); | |||
| TenantEntity mallTenantEntity = getTenantInfo(); | |||
| wxCoupon.setTenantId(mallTenantEntity.getParentTenantId()); | |||
| wxCoupon.setParentTenantId(null); | |||
| //平台券 | |||
| if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == wxCoupon.getType()) { | |||
| //查询已经分配了的parentCouponList | |||
| WxCouponMall couponMall = new WxCouponMall(); | |||
| couponMall.updateTenantInfo(wxCoupon); | |||
| couponMall.setMallTenantId(mallTenantEntity.getTenantId()); | |||
| List<Long> couponIds = wxCouponMallService.listCouponIds(couponMall); | |||
| if (null != couponIds && couponIds.size() > 0 ) { | |||
| wxCoupon.setIds(couponIds); | |||
| }else { | |||
| wxCoupon.setId(-1L); | |||
| } | |||
| } | |||
| return couponList(wxCoupon, pageNum, pageSize, isList); | |||
| } | |||
| private ResultData couponList(WxCoupon wxCoupon, Integer pageNum, Integer pageSize,Boolean isList) { | |||
| //默认A端建券 | |||
| if(null == wxCoupon.getSourceType()){ | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| } | |||
| //排序处理 | |||
| if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ | |||
| String coryColumn = "c."+wxCoupon.getSortColumns(); | |||
| wxCoupon.setSortColumns(coryColumn); | |||
| wxCoupon.setSortColumn(null); | |||
| } | |||
| //isList true 查全部 / 否则 只查询主动领取和定向投放的。 | |||
| if(wxCoupon.getSendType() == null && !(isList == null?false:isList)){ | |||
| Integer[] sendTypeArray = { | |||
| EnumCouponSendType.ACTIVE.getCode(), | |||
| EnumCouponSendType.PASSIVE.getCode(),}; | |||
| wxCoupon.setSendTypes(Arrays.asList(sendTypeArray)); | |||
| } | |||
| return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 | |||
| } | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("listWithTypePress") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "券投放-列表") | |||
| public ResultData listWithTypePress(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||
| if (wxCoupon == null) wxCoupon = new WxCoupon(); | |||
| wxCoupon.updateTenantInfo(getTenantInfo()); | |||
| Integer[] typeArray = { | |||
| EnumCouponType.COUPON_MANJIAN.getCode(), | |||
| EnumCouponType.COUPON_DAIJIN.getCode(), | |||
| // EnumCouponType.COUPON_TUANGOU.getCode(), | |||
| EnumCouponType.COUPON_LIPIN.getCode(), | |||
| EnumCouponType.COUPON_TINGCHE.getCode(), | |||
| EnumCouponType.COUPON_MULTIMCH.getCode(), | |||
| EnumCouponType.COUPON_DOUYIN.getCode(), | |||
| EnumCouponType.COUPON_PRESS.getCode(), | |||
| EnumCouponType.COUPON_PREORDER.getCode()}; | |||
| wxCoupon.setTypes(Arrays.asList(typeArray)); | |||
| Integer[] sendTypeArray = { | |||
| EnumCouponSendType.ACTIVE.getCode(), | |||
| EnumCouponSendType.PASSIVE.getCode(),}; | |||
| wxCoupon.setSendTypes(Arrays.asList(sendTypeArray)); | |||
| if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ | |||
| String coryColumn = "c."+wxCoupon.getSortColumns(); | |||
| wxCoupon.setSortColumns(coryColumn); | |||
| wxCoupon.setSortColumn(null); | |||
| } | |||
| return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "券投放-新增") | |||
| public ResultData add(@RequestBody WxCoupon wxCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::add"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxCoupon.updateTenantInfo(tenantEntity); | |||
| if(null == wxCoupon.getContentType()){ | |||
| wxCoupon.setContentType(EnumCouponContentType.NORMAL.getCode()); | |||
| } | |||
| if(null == wxCoupon.getSourceType()){ | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| } | |||
| ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon); | |||
| if (resultData.code != 200) { | |||
| return resultData; | |||
| } | |||
| redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); | |||
| //启动投放审批 | |||
| if(wxCoupon.getFlowParams() !=null && wxCoupon.getFlowParams().size()>0) { | |||
| wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); | |||
| wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), tenantEntity); | |||
| //修改coupon applyStatus状态为审核中 | |||
| wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| } | |||
| return resultData; | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "券投放-更新") | |||
| public ResultData update(@RequestBody WxCoupon wxCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::update"); | |||
| if (wxCoupon.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| wxCoupon.updateTenantInfo(getTenantInfo()); | |||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId()); | |||
| if (null == coupon) { | |||
| return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); | |||
| } | |||
| if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){ | |||
| if(!EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(coupon.getStatus())){ | |||
| return new ResultData(ResultData.ERROR, "请先作废,再进行删除。"); | |||
| } | |||
| wxCouponService.deleteById(wxCoupon.getId(),wxCoupon.getTenantId()); | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | |||
| CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId()); | |||
| return new ResultData(); | |||
| } | |||
| //启动审批流 | |||
| if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { | |||
| logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType")); | |||
| wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); | |||
| wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantInfo()); | |||
| //作废审批 | |||
| if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) { | |||
| wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| return new ResultData(wxCoupon); | |||
| } else { | |||
| //投放审批 | |||
| wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| } | |||
| } | |||
| ResultData result = null; | |||
| if(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){ | |||
| result = wxCouponService.disable(wxCoupon, wxCoupon.getId()); | |||
| }else{ | |||
| result = wxCouponService.saveOrUpdate(wxCoupon); | |||
| if(wxCoupon.getRemainInventory() != null){ | |||
| redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); | |||
| } | |||
| } | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | |||
| CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId()); | |||
| return result; | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("continueAdd") | |||
| @SystemControllerLog(description = "继续添加") | |||
| public ResultData continueAdd(@RequestBody WxCoupon wxCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::update"); | |||
| if (wxCoupon.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| if(wxCoupon.getProductType() == null || wxCoupon.getCategoryId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "缺少必要参数"); | |||
| } | |||
| wxCoupon.updateTenantInfo(getTenantInfo()); | |||
| WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId()); | |||
| if (null == coupon) { | |||
| return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); | |||
| } | |||
| coupon.setProductType(wxCoupon.getProductType()); | |||
| coupon.setCategoryId(wxCoupon.getCategoryId()); | |||
| coupon.setProductAttrs(wxCoupon.getProductAttrs()); | |||
| coupon.setSkuAttrs(wxCoupon.getSkuAttrs()); | |||
| ResultData result = wxCouponService.updateTtProduct(coupon); | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | |||
| CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId()); | |||
| return result; | |||
| } | |||
| @ApiOperation("根据id更新库存及有效期接口") | |||
| @PostMapping("updateStokeAndValidDate") | |||
| @SystemControllerLog(description = "券投放-库存/有效期更新") | |||
| public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); | |||
| if (wxCoupon.getId() == null) { | |||
| logger.error("缺少id"); | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| if (wxCoupon.getType() == null) { | |||
| logger.error("缺少type"); | |||
| return new ResultData(ResultData.ERROR, "缺少type"); | |||
| } | |||
| if (wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) { | |||
| logger.error("库存错误1"); | |||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR); | |||
| } | |||
| if (wxCoupon.getRemainInventory() > wxCoupon.getInventory()) { | |||
| logger.error("库存错误2"); | |||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR); | |||
| } | |||
| if (wxCoupon.getValidType() == null) { | |||
| logger.error("库存错误3"); | |||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | |||
| } | |||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { | |||
| if (wxCoupon.getValidEndDate() == null) { | |||
| logger.error("有效期错误1"); | |||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | |||
| } | |||
| } else { | |||
| if (wxCoupon.getValidDays() == null) { | |||
| logger.error("有效期错误2"); | |||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | |||
| } | |||
| } | |||
| if (wxCoupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode()) || | |||
| wxCoupon.getType().equals(EnumCouponType.COUPON_CREDIT_PARK.getCode())) { | |||
| logger.error("券库存有效期不支持停车券"); | |||
| return new ResultData(ErrorCode.COUPON_STOCK_DATE_NO_CAR); | |||
| } | |||
| wxCoupon.updateTenantInfo(getTenantInfo()); | |||
| WxCoupon coupon = wxCouponService.findById(wxCoupon); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if(EnumCouponSendType.GIFT.getCode().equals(coupon.getSendType())){ | |||
| return new ResultData(ErrorCode.COUPON_GIFT_NOTUPD_INVENTORY); | |||
| } | |||
| if ((wxCoupon.getValidEndDate() != null && coupon.getValidEndDate() != null && DateUtils.format(wxCoupon.getValidEndDate()).equals(DateUtils.format(coupon.getValidEndDate())) | |||
| && wxCoupon.getInventory().equals(coupon.getInventory())) | |||
| || | |||
| (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getInventory().equals(coupon.getInventory()) && | |||
| wxCoupon.getValidDays().equals(coupon.getValidDays())) | |||
| ) { | |||
| return new ResultData(ErrorCode.COUPON_STOCK_VALID_DATE_SETTING_ERR); | |||
| } | |||
| if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(coupon.getValidEndDate())) { | |||
| return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); | |||
| } | |||
| if (wxCoupon.getInventory() != null && wxCoupon.getInventory().intValue() < coupon.getInventory().intValue()) { | |||
| return new ResultData(ErrorCode.COUPON_STOCK_INV_ERR); | |||
| } | |||
| if (wxCoupon.getValidDays() != null && coupon.getValidDays() != null && wxCoupon.getValidDays().intValue() < coupon.getValidDays().intValue()) { | |||
| return new ResultData(ErrorCode.COUPON_STOCK_ENDTIME_ERR); | |||
| } | |||
| wxCoupon.setSalePrice(coupon.getSalePrice()); | |||
| if(!wxCouponService.validCouponDate(wxCoupon)) { | |||
| return new ResultData(ResultData.ERROR,"券有效结束日期必须在30天以内。"); | |||
| } | |||
| wxCoupon.setSalePrice(null); | |||
| //启动审批流 | |||
| if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { | |||
| List<Map<String, Object>> variables = (List) wxCoupon.getFlowParams().get("variables"); | |||
| Map<String, Object> map = new HashedMap(); | |||
| map.put("key", "inventory"); | |||
| map.put("value", wxCoupon.getInventory()); | |||
| variables.add(map); | |||
| map = new HashedMap(); | |||
| map.put("key", "remainInventory"); | |||
| map.put("value", wxCoupon.getRemainInventory()); | |||
| variables.add(map); | |||
| map = new HashedMap(); | |||
| map.put("key", "type"); | |||
| map.put("value", wxCoupon.getType()); | |||
| variables.add(map); | |||
| map = new HashedMap(); | |||
| map.put("key", "validEndDate"); | |||
| map.put("value", wxCoupon.getValidEndDate()); | |||
| map = new HashedMap(); | |||
| map.put("key", "validStartDate"); | |||
| map.put("value", wxCoupon.getValidStartDate()); | |||
| map = new HashedMap(); | |||
| map.put("key", "validType"); | |||
| map.put("value", wxCoupon.getValidType()); | |||
| variables.add(map); | |||
| map = new HashedMap(); | |||
| map.put("key", "validDays"); | |||
| map.put("value", wxCoupon.getValidDays()); | |||
| variables.add(map); | |||
| wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); | |||
| wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), wxCoupon); | |||
| //更新状态 | |||
| WxCoupon updateCoupon = new WxCoupon(); | |||
| updateCoupon.updateTenantInfo(wxCoupon); | |||
| updateCoupon.setId(wxCoupon.getId()); | |||
| updateCoupon.setStockApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| updateCoupon.setUpdateDate(new Date()); | |||
| wxCouponService.update(updateCoupon); | |||
| redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); | |||
| } else { | |||
| redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); | |||
| return wxCouponService.updateCouponStockAndEndTime(wxCoupon); | |||
| } | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); | |||
| wxCouponService.deleteById(id,getTenantInfo().getTenantId()); | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, id); | |||
| CouponCacheUtils.removeCouponMerchantCache(redisTemplate, id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-查询") | |||
| public ResultData findById(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| return new ResultData(wxCouponService.getVoById(id,tenantEntity.getTenantId(),tenantEntity)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findParentCouponById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-查询") | |||
| public ResultData findParentCouponById(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| return new ResultData(wxCouponService.getVoById(id,getTenantInfo().getParentTenantId(),tenantEntity)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("卡营销列表接口") | |||
| @GetMapping("findCardCountList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "券投放-卡营销列表") | |||
| public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| //默认时间本月第一天,截止到当天 | |||
| Map<String, Object> result = new HashedMap(); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| if (wxCoupon.getStartdate() == null) { | |||
| wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | |||
| } | |||
| if (wxCoupon.getEnddate() == null) { | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| } | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCountData(wxCoupon,tenantEntitys, pageNum, pageSize); | |||
| for (WxCouponStatisVo coupon : pageInfo.getList()) { | |||
| if (coupon.getSaleAmount() == null) { | |||
| coupon.setSaleAmount(0); | |||
| } | |||
| if (coupon.getSumPayment() == null) { | |||
| coupon.setSumPayment(0); | |||
| } | |||
| if (coupon.getSumSubsidy() == null) { | |||
| coupon.setSumSubsidy(0); | |||
| } | |||
| } | |||
| result.put("list", pageInfo); | |||
| return new ResultData(result); | |||
| } | |||
| @ApiOperation("卡营销列表记录导出") | |||
| @GetMapping("/cardCountExportData") | |||
| @SystemControllerLog(description = "营销统计-卡营销数据导出") | |||
| public void cardCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) { | |||
| //默认时间本月第一天,截止到当天 | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| if (wxCoupon.getStartdate() == null) { | |||
| wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | |||
| } | |||
| if (wxCoupon.getEnddate() == null) { | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| } | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| wxCouponService.exportCardData(wxCoupon,tenantEntitys, request, response); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("券营销列表接口") | |||
| @GetMapping("findCouponCountList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "券投放-券营销列表") | |||
| public ResultData findCouponCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| //默认时间本月第一天,截止到当天 | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| Map<String, Object> result = new HashedMap(); | |||
| if (wxCoupon.getStartdate() == null) { | |||
| wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | |||
| } | |||
| if (wxCoupon.getEnddate() == null) { | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| } | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| PageInfo<WxCouponStatisVo> pageInfo = wxCouponService.findCouponData(wxCoupon, tenantEntitys, pageNum, pageSize); | |||
| for (WxCouponStatisVo coupon : pageInfo.getList()) { | |||
| if (coupon.getSumSubsidy() == null) { | |||
| coupon.setSumSubsidy(0); | |||
| } | |||
| if (coupon.getSumSubsidy() == null) { | |||
| coupon.setSumSubsidy(0); | |||
| } | |||
| } | |||
| return new ResultData(pageInfo); | |||
| } | |||
| @ApiOperation("券营销列表记录导出") | |||
| @GetMapping("/couponCountExportData") | |||
| @SystemControllerLog(description = "营销统计-券营销数据导出") | |||
| public void couponCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) { | |||
| //默认时间本月第一天,截止到当天 | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| if (wxCoupon.getStartdate() == null) { | |||
| wxCoupon.setStartdate(DateUtils.getFirstDayForCurrMonth()); | |||
| } | |||
| if (wxCoupon.getEnddate() == null) { | |||
| wxCoupon.setEnddate(DateUtils.stringToDate(DateUtils.getSystemTime("yyyy-MM-dd") + " 23:59:59")); | |||
| } | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| wxCouponService.exportCouponData(wxCoupon,tenantEntitys, request, response); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("砍价营销列表接口") | |||
| @GetMapping("findPressCountList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "券投放-砍价营销列表") | |||
| public ResultData findPressCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| wxCoupon.updateTenantInfo(tenantEntity); | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| PageInfo<WxCouponStatisVo> pages = wxCouponService.findPressData(wxCoupon,tenantEntitys,pageNum,pageSize); | |||
| return new ResultData(pages); | |||
| } | |||
| @ApiOperation("砍价营销列表记录导出") | |||
| @GetMapping("/pressCountExportData") | |||
| @SystemControllerLog(description = "营销统计-券营销数据导出") | |||
| public void pressCountExportData(@ModelAttribute WxCoupon wxCoupon, HttpServletRequest request, HttpServletResponse response) { | |||
| //默认时间本月第一天,截止到当天 | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| wxCoupon.updateTenantInfo(tenantEntity); | |||
| wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); | |||
| wxCouponService.exportPressData(wxCoupon,tenantEntitys, request, response); | |||
| } | |||
| @GetMapping("exportCouponPassword") | |||
| @SystemControllerLog(description = "卡券兑换码-导出数据") | |||
| public void exportCouponPassword(@ModelAttribute WxCouponPassword wxCouponPassword, HttpServletRequest request, HttpServletResponse response) { | |||
| wxCouponPassword.updateTenantInfo(getTenantInfo()); | |||
| if (wxCouponPassword.getCouponId() == null) { | |||
| wxCouponPassword.setCouponId(0L); | |||
| } | |||
| couponPasswordService.exportData(request, response, wxCouponPassword); | |||
| if (null != wxCouponPassword.getCouponId()) { | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCouponPassword.getCouponId()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id获取富文本接口") | |||
| @GetMapping("/getHtml") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-富文本获取") | |||
| public ResultData getHtml(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | |||
| return new ResultData(wxCouponService.getHtmlById(id,getTenantInfo().getTenantId())); | |||
| } | |||
| @ApiOperation("卡延期") | |||
| @PostMapping("/cardDefer") | |||
| @SystemControllerLog(description = "卡延期") | |||
| public ResultData cardDefer(@RequestBody WxCoupon wxCoupon) { | |||
| if (wxCoupon.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| if (wxCoupon.getValidEndDate() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少validEndDate"); | |||
| } | |||
| ResultData result = wxCouponService.cardDefer(wxCoupon.getId(),getTenantInfo().getTenantId(),wxCoupon.getValidEndDate()); | |||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | |||
| return result; | |||
| } | |||
| @ApiOperation("集团查询:查询平台券商场列表") | |||
| @GetMapping("/getPlatMallList") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData getPlatMallList(@RequestParam Long id) { | |||
| WxCouponMall wxCouponMall = new WxCouponMall(); | |||
| wxCouponMall.updateTenantInfo(getTenantInfo()); | |||
| wxCouponMall.setProductId(id); | |||
| return new ResultData(wxCouponMallService.list(wxCouponMall,true)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("平台券商场列表") | |||
| @GetMapping("/getCouponMall") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) | |||
| public ResultData getCouponMall(Long id) { | |||
| //如果是集团查询,则查询所有的,如果是商场查询,则只查询商场的 | |||
| WxCouponMall wxCouponMall = new WxCouponMall(); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if (null == tenantEntity.getParentTenantId()) { | |||
| wxCouponMall.updateTenantInfo(tenantEntity); | |||
| wxCouponMall.setProductId(id); | |||
| }else { | |||
| wxCouponMall.setTenantId(tenantEntity.getParentTenantId()); | |||
| //一个商场,每个平台券只有一条记录 | |||
| wxCouponMall.setMallTenantId(tenantEntity.getTenantId()); | |||
| wxCouponMall.setProductId(id); | |||
| } | |||
| List<WxCouponMall> mallList= wxCouponMallService.list(wxCouponMall,false); | |||
| if (null != mallList && mallList.size() > 0 ) { | |||
| boolean isComplete = true; | |||
| for (int i = 0 ; i < mallList.size(); i ++) { | |||
| WxCouponMall cm = mallList.get(i); | |||
| if (EnumCouponMallStatus.UNFINISED.getCode() == cm.getStatus()) { | |||
| isComplete = false; | |||
| break; | |||
| } | |||
| } | |||
| if (isComplete) { | |||
| return new ResultData("{\"isCompleted\":1}"); | |||
| }else { | |||
| return new ResultData("{\"isCompleted\":0}"); | |||
| } | |||
| }else { | |||
| return new ResultData("{\"isCompleted\":0}"); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("商场设置平台券商户") | |||
| @PostMapping("/setParentCouponMerchants") | |||
| public ResultData setMallMerchants(@RequestBody WxCoupon wxCoupon) { | |||
| try { | |||
| wxCouponService.setParentCouponMallMerchants(getTenantInfo(),wxCoupon); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("自己券商户是否自动分账") | |||
| @PostMapping("/couponMerchantAutoShare") | |||
| public ResultData couponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) { | |||
| wxCoupon.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(wxCoupon,wxCoupon); | |||
| return new ResultData(map); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("父券商户是否自动分账") | |||
| @PostMapping("/parentCouponMerchantAutoShare") | |||
| public ResultData parentCouponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxCoupon.setTenantId(tenantEntity.getParentTenantId()); | |||
| wxCoupon.setParentTenantId(null); | |||
| try { | |||
| Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(tenantEntity,wxCoupon); | |||
| return new ResultData(map); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("商场设置平台券已完成") | |||
| @PostMapping("/setPlatCouponFinished") | |||
| public ResultData setPlatCouponFinished(@RequestBody WxCoupon wxCoupon) { | |||
| try { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| String mallTenantId = tenantEntity.getTenantId(); | |||
| String tenantId = tenantEntity.getTenantId(); | |||
| if (null != tenantEntity.getParentTenantId()) { | |||
| tenantId = tenantEntity.getParentTenantId(); | |||
| } | |||
| wxCouponMallService.finised(tenantId, wxCoupon.getId(), mallTenantId); | |||
| return new ResultData(); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("商场设置平台券未完成") | |||
| @PostMapping("/setPlatCouponUnFinished") | |||
| public ResultData setPlatCouponUnFinished(@RequestBody WxCoupon wxCoupon) { | |||
| try { | |||
| if (null == wxCoupon.getType()) { | |||
| return new ResultData(Result.ERROR,"缺少参数"); | |||
| } | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| String mallTenantId = tenantEntity.getTenantId(); | |||
| String tenantId = tenantEntity.getTenantId(); | |||
| if (null != tenantEntity.getParentTenantId()) { | |||
| tenantId = tenantEntity.getParentTenantId(); | |||
| } | |||
| wxCouponMallService.unfinised(tenantId, wxCoupon.getId(),wxCoupon.getType(), mallTenantId); | |||
| return new ResultData(); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,83 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxCouponPassword; | |||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||
| import com.iformall.service.WxCouponPasswordService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("couponPassword") | |||
| @Api(description = "免费卡接口") | |||
| public class WxCouponPasswordController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponPasswordService wxCouponPasswordService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData list(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::list"); | |||
| wxCouponPassword.updateTenantInfo(getTenantInfo()); | |||
| wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxCouponPassword> page = wxCouponPasswordService.listAsPage(wxCouponPassword, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("可发送卡数据") | |||
| @GetMapping("/findCouponList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "可发送卡数据") | |||
| public ResultData findCouponList(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::findCouponList"); | |||
| wxCouponPassword.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCouponPasswordCountInfoVO> page = wxCouponPasswordService.findCouponList(wxCouponPassword, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation(value = "卡密延期", notes = "{\"couponId\":\"string\", \"expireDate\":\"string\"}") | |||
| @PostMapping("/postpone") | |||
| @SystemControllerLog(description = "卡密延期") | |||
| public ResultData postpone(@RequestBody WxCouponPassword wxCouponPassword) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::postpone"); | |||
| if (wxCouponPassword.getCouponId() == null) { | |||
| logger.error("couponId不能为空: "); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponPassword couponPassword = new WxCouponPassword(); | |||
| couponPassword.updateTenantInfo(getTenantInfo()); | |||
| couponPassword.setCouponId(wxCouponPassword.getCouponId()); | |||
| couponPassword.setExpireDate(wxCouponPassword.getExpireDate()); | |||
| try { | |||
| wxCouponPasswordService.postpone(couponPassword); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.COUPON_PASSWORD_POSTPONE_ERR); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,145 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumCouponPasswordStatus; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.enums.EnumCouponValidType; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.PushLimitService; | |||
| import com.iformall.service.WxCouponPasswordService; | |||
| import com.iformall.service.WxCouponPresentService; | |||
| import com.iformall.service.WxCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.HashSet; | |||
| import java.util.List; | |||
| import java.util.Set; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("couponPresent") | |||
| @Api(description = "卡投放接口") | |||
| public class WxCouponPresentController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponPresentService wxCouponPresentService; | |||
| @Autowired | |||
| PushLimitService pushLimitService; | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Autowired | |||
| WxCouponPasswordService wxCouponPasswordService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData list(@ModelAttribute WxCouponPresent wxCouponPresent, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponPresentController::list"); | |||
| wxCouponPresent.updateTenantInfo(getTenantInfo()); | |||
| wxCouponPresent.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxCouponPresent> page = wxCouponPresentService.listAsPage(wxCouponPresent, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "查询") | |||
| public ResultData findById(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponPresentController::findById"); | |||
| return new ResultData(wxCouponPresentService.findById(id)); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "新增") | |||
| public ResultData add(@RequestBody WxCouponPresent wxCouponPresent) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponInjectController::add"); | |||
| if (wxCouponPresent.getCouponId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请选择卡"); | |||
| } | |||
| if (wxCouponPresent.getPhones().isEmpty()) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写手机号"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxCouponPresent.setUserId(user.getId()); | |||
| wxCouponPresent.updateTenantInfo(user); | |||
| try { | |||
| pushLimitService.checkSendTime(user); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponPresent.getCouponId(),wxCouponPresent.getTenantId()); | |||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { //时间范围 | |||
| if (new Date().after(wxCoupon.getValidEndDate())) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | |||
| } | |||
| } | |||
| if (!wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode())) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| } | |||
| //获取手机号 | |||
| String phones = wxCouponPresent.getPhones(); | |||
| String[] phoneSplit = phones.split(","); | |||
| Set<String> phoneSet = new HashSet<>(phoneSplit.length); | |||
| for (String phone : phoneSplit) { | |||
| if (!phone.isEmpty()) { | |||
| phoneSet.add(phone); | |||
| } | |||
| } | |||
| //查询有效券数量 | |||
| WxCouponPassword wxCouponPassword = new WxCouponPassword(); | |||
| wxCouponPassword.updateTenantInfo(user); | |||
| wxCouponPassword.setCouponId(wxCouponPresent.getCouponId()); | |||
| wxCouponPassword.setStatus(EnumCouponPasswordStatus.INIT.getCode()); | |||
| List<WxCouponPassword> list = wxCouponPasswordService.findList(wxCouponPassword); | |||
| if (phoneSet.size() > list.size()) { | |||
| logger.info(ErrorCode.REMAIN_IS_EMPTY.getMessage()); | |||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| wxCouponPresent.setCouponName(wxCoupon.getTitle()); | |||
| //只需要给一端发就可以了。默认给微信小程序发 | |||
| wxCouponPresentService.add(wxCouponPresent, list, phoneSet,EnumPayWay.PAY_WAY_WECHAT); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("ttttttt") | |||
| @SystemControllerLog(description = "新增") | |||
| public ResultData tttttt(@RequestBody WxCouponPresent wxCouponPresent) { | |||
| //只需要给一端发就可以了。默认给微信小程序发 | |||
| wxCouponPresentService.tttttttttttttt(); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,74 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCouponSendConfig; | |||
| import com.iformall.enums.EnumCouponSendSendType; | |||
| import com.iformall.enums.EnumValidStatus; | |||
| import com.iformall.service.WxCouponSendConfigService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| @RestController | |||
| @RequestMapping("wxCouponSendConfig") | |||
| @Api(description = "注劵配置接口") | |||
| public class WxCouponSendConfigController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponSendConfigService wxCouponSendConfigService; | |||
| @ApiOperation("获取开关") | |||
| @GetMapping("get") | |||
| @SystemControllerLog(description = "发券开关-获取") | |||
| public ResultData getCouponSendConfig(@ModelAttribute WxCouponSendConfig wxCouponSendConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::getCouponSendConfig"); | |||
| if (wxCouponSendConfig == null || wxCouponSendConfig.getSendType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| wxCouponSendConfig.updateTenantInfo(getTenantInfo()); | |||
| PageInfo<WxCouponSendConfig> page = wxCouponSendConfigService.listAsPage(wxCouponSendConfig, 1, 1); | |||
| if (page.getSize() > 0) { | |||
| return new ResultData(page.getList().get(0)); | |||
| } else { | |||
| //配置不存在,添加默认配置(停用) | |||
| wxCouponSendConfig.setRemark(EnumCouponSendSendType.getEnum(wxCouponSendConfig.getSendType()).getMessage() + "开关"); | |||
| wxCouponSendConfig.setValue(1); | |||
| wxCouponSendConfigService.saveOrUpdate(wxCouponSendConfig); | |||
| return new ResultData(wxCouponSendConfig); | |||
| } | |||
| } | |||
| @PostMapping("update") | |||
| @ApiOperation("修改开关") | |||
| @SystemControllerLog(description = "发券开关-修改开关") | |||
| public ResultData updateCouponSendConfig(@RequestBody WxCouponSendConfig wxCouponSendConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallConfigController::updateStopCarConpon"); | |||
| if (wxCouponSendConfig == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxCouponSendConfig.getId() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxCouponSendConfig.getSendType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxCouponSendConfig.getValue() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| wxCouponSendConfig.updateTenantInfo(getTenantInfo()); | |||
| wxCouponSendConfig.setUpdateTime(new Date()); | |||
| wxCouponSendConfigService.update(wxCouponSendConfig); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,175 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponSend; | |||
| import com.iformall.domain.vo.WxCouponSendVo; | |||
| import com.iformall.enums.EnumCouponSendSendType; | |||
| import com.iformall.enums.EnumCouponSendType; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCouponActionLogService; | |||
| import com.iformall.service.WxCouponSendService; | |||
| import com.iformall.service.WxCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.Objects; | |||
| @RestController | |||
| @RequestMapping("wxCouponSend") | |||
| @Api(description = "注劵接口") | |||
| public class WxCouponSendController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponSendService wxCouponSendService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @Autowired | |||
| private WxCouponActionLogService wxCouponActionLogService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "merchantName", value = "商户名,模糊查询", dataType = "String", paramType = "query"), | |||
| @ApiImplicitParam(name = "merchantId", value = "商户Id", dataType = "String", paramType = "query"), | |||
| }) | |||
| @SystemControllerLog(description = "注券-列表") | |||
| public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::list"); | |||
| if (null == wxCouponSend) wxCouponSend = new WxCouponSend(); | |||
| wxCouponSend.updateTenantInfo(getTenantInfo()); | |||
| // if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSend.getSendType())) { | |||
| // if (Objects.nonNull(wxCouponSend.getStatus())) { | |||
| // valid = wxCouponSend.getStatus(); | |||
| // } else { | |||
| // wxCouponSend.setStatus(null); | |||
| // } | |||
| // } | |||
| PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("注券-添加配置") | |||
| @GetMapping("config/add") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "beforeDays", value = "提前n天发券", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "sendType", value = "注券类型(生日券=8)", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| @SystemControllerLog(description = "注券-添加或更新配置") | |||
| public ResultData addConfig(Integer beforeDays, Integer sendType) { | |||
| if (!Objects.equals(sendType, EnumCouponSendSendType.BIRTHDAY.getCode())) { | |||
| return new ResultData(ErrorCode.COUPON_VALID_NOT_SUPPORTED); | |||
| } | |||
| try { | |||
| wxCouponSendService.saveOrUpdateConfig(beforeDays, sendType, getTenantInfo()); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("注券-获取配置") | |||
| @GetMapping("config/get") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "sendType", value = "注券类型(生日券=8)", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "注券-获取配置") | |||
| public ResultData getConfig(Integer sendType) { | |||
| WxCouponSend wxCouponSend = wxCouponSendService.getConfig(sendType, getTenantInfo()); | |||
| return new ResultData(Objects.isNull(wxCouponSend) ? null : wxCouponSend.getConditions()); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "注券-新增") | |||
| public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::add"); | |||
| if (null == wxCouponSend) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId(),getTenantInfo().getTenantId()); | |||
| if (!EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(wxCoupon.getStatus())) { | |||
| return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| } | |||
| if (!EnumCouponSendType.PASSIVE.getCode().equals(wxCoupon.getSendType())) { | |||
| return new ResultData(ErrorCode.COUPON_TYPE_IS_NOT_PASSIVE); | |||
| } | |||
| wxCouponSend.updateTenantInfo(wxCoupon); | |||
| wxCouponSend.setTitle(wxCoupon.getTitle()); | |||
| wxCouponSend.setCreateDate(new Date()); | |||
| wxCouponSend.setUpdateDate(new Date()); | |||
| try { | |||
| wxCouponSend.setOperatorId(getUserId()); | |||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| // @ApiOperation("根据id更新接口") | |||
| // @PostMapping("update") | |||
| // @SystemControllerLog(description = "注券-更新") | |||
| // public ResultData update(@RequestBody WxCouponSend wxCouponSend) { | |||
| // logger.debug("[" + getIpAddr() + "] WxCouponSendController::update"); | |||
| // wxCouponSend.updateTenantInfo(getTenantInfo()); | |||
| // wxCouponSendService.saveOrUpdate(wxCouponSend); | |||
| // return new ResultData(); | |||
| // } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "sendType", value = "注券类型(会员生日券时必传)", dataType = "int", paramType = "query") | |||
| }) | |||
| @SystemControllerLog(description = "注券-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::delete"); | |||
| WxCouponSend wxCouponSend = wxCouponSendService.getById(id,getTenantInfo().getTenantId()); | |||
| if (wxCouponSend == null) { | |||
| return new ResultData(ErrorCode.COUPON_SEND_IS_INVALID); | |||
| } | |||
| try { | |||
| wxCouponSendService.updateInvalid(wxCouponSend); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "注券-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponSendService.getById(id,getTenantInfo().getTenantId())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,92 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxFloatingLayer; | |||
| import com.iformall.domain.vo.WxFloatingLayerVO; | |||
| import com.iformall.enums.EnumFloatingLayerStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxFloatingLayerService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxFloatingLayer") | |||
| @Api(description = "首页浮层展示") | |||
| public class WxFloatingLayerController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxFloatingLayerService wxFloatingLayerService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData list(@ModelAttribute WxFloatingLayer wxFloatingLayer, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::list"); | |||
| wxFloatingLayer.updateTenantInfo(getTenantInfo()); | |||
| wxFloatingLayer.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxFloatingLayerVO> page = wxFloatingLayerService.listAsPage(wxFloatingLayer, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("/add") | |||
| @SystemControllerLog(description = "新增") | |||
| public ResultData add(@RequestBody WxFloatingLayer wxFloatingLayer) { | |||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::add"); | |||
| wxFloatingLayer.updateTenantInfo(getTenantInfo()); | |||
| wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_THROW_IN.getCode()); | |||
| try { | |||
| return wxFloatingLayerService.saveOrUpdate(wxFloatingLayer); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("/updateStatus") | |||
| @SystemControllerLog(description = "id更新") | |||
| public ResultData updateStatus(@RequestBody WxFloatingLayer wxFloatingLayer) { | |||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::updateStatus"); | |||
| if (wxFloatingLayer.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); | |||
| } | |||
| try { | |||
| wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_TAKE_OFFF.getCode()); | |||
| return wxFloatingLayerService.updateStatus(wxFloatingLayer); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "活动-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::findById"); | |||
| WxFloatingLayer wxFloatingLayer = wxFloatingLayerService.getById(id); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxFloatingLayer); | |||
| } | |||
| } | |||
| @@ -0,0 +1,113 @@ | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxGame; | |||
| import com.iformall.enums.EnumGameStatus; | |||
| import com.iformall.service.WxGameService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxGame") | |||
| @Api(description = "游戏接口") | |||
| public class WxGameController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxGameService wxGameService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "游戏-列表") | |||
| public ResultData list(@ModelAttribute WxGame wxGame, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameController::list"); | |||
| if (null == wxGame) wxGame = new WxGame(); | |||
| wxGame.updateTenantInfo(getTenantInfo()); | |||
| wxGame.setSortColumns(BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxGame> page = wxGameService.listAsPage(wxGame, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "游戏-新增") | |||
| public ResultData add(@RequestBody WxGame wxGame) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameController::add"); | |||
| //Assert.notNull(wxGame.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| if (StringUtils.isBlank(wxGame.getCouponIds())) { | |||
| wxGame.setCouponIds(JSONArray.toJSONString(new String[0])); | |||
| } | |||
| if(wxGame.getPlayCreditLimit() != null && wxGame.getPlayCreditLimit() >= 0){ | |||
| if(wxGame.getPlayCredit() == null || wxGame.getPlayCredit() <= 0){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"游戏消耗积分不能为空或为0"); | |||
| } | |||
| if(wxGame.getPlayLimit() == null || wxGame.getPlayLimit() == 0){ | |||
| wxGame.setPlayLimit(-1); | |||
| } | |||
| } | |||
| wxGame.setStatus(EnumGameStatus.STATUS_THROW_IN.getCode()); | |||
| wxGame.updateTenantInfo(getTenantInfo()); | |||
| wxGameService.saveOrUpdate(wxGame); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "游戏-更新") | |||
| public ResultData update(@RequestBody WxGame wxGame) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameController::update"); | |||
| if (StringUtils.isBlank(wxGame.getCouponIds())) { | |||
| wxGame.setCouponIds(JSONArray.toJSONString(new String[0])); | |||
| } | |||
| if(wxGame.getPlayCreditLimit() != null && wxGame.getPlayCreditLimit() >= 0){ | |||
| if(wxGame.getPlayCredit() == null || wxGame.getPlayCredit() <= 0){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"游戏消耗积分不能为空或为0"); | |||
| } | |||
| if(wxGame.getPlayLimit() == null || wxGame.getPlayLimit() == 0){ | |||
| wxGame.setPlayLimit(-1); | |||
| } | |||
| } | |||
| wxGame.updateTenantInfo(getTenantInfo()); | |||
| wxGameService.saveOrUpdate(wxGame); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "游戏-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameController::delete"); | |||
| wxGameService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "游戏-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxGameService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,93 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxGameTemplate; | |||
| import com.iformall.service.WxGameTemplateService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxGameTemplate") | |||
| @Api(description = "游戏模板接口") | |||
| public class WxGameTemplateController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxGameTemplateService wxGameTemplateService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("listPage") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "游戏模板-分页列表") | |||
| public ResultData listPage(@ModelAttribute WxGameTemplate wxGameTemplate, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::listPage"); | |||
| if (null == wxGameTemplate) wxGameTemplate = new WxGameTemplate(); | |||
| final PageInfo<WxGameTemplate> page = wxGameTemplateService.listAsPage(wxGameTemplate, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("列表接口") | |||
| @GetMapping("list") | |||
| @SystemControllerLog(description = "游戏模板-列表") | |||
| public ResultData list(@ModelAttribute WxGameTemplate wxGameTemplate) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::list"); | |||
| if (null == wxGameTemplate) wxGameTemplate = new WxGameTemplate(); | |||
| final List<WxGameTemplate> page = wxGameTemplateService.getList(wxGameTemplate); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "游戏模板-新增") | |||
| public ResultData add(@RequestBody WxGameTemplate wxGameTemplate) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::add"); | |||
| //Assert.notNull(wxGameTemplate.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxGameTemplateService.saveOrUpdate(wxGameTemplate); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "游戏模板-更新") | |||
| public ResultData update(@RequestBody WxGameTemplate wxGameTemplate) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::update"); | |||
| wxGameTemplateService.saveOrUpdate(wxGameTemplate); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "游戏模板-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::delete"); | |||
| wxGameTemplateService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "游戏模板-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxGameTemplateController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxGameTemplateService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,73 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.WxOrderReportDto; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxMerchantMicroPayVo; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.service.MarkingDataReportService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantMicroPay") | |||
| @Api(description = "B端收银台相关接口") | |||
| public class WxMerchantMicroPayController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private MarkingDataReportService markingDataReportService; | |||
| @TenantIgnore | |||
| @ApiOperation("获得商场近30日刷卡") | |||
| @GetMapping("/listMonth") | |||
| @SystemControllerLog(description = "收银台-近30日刷卡列表") | |||
| public ResultData listMonth() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::listMonth"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| WxOrderReportDto wxOrderReportDto = new WxOrderReportDto(); | |||
| wxOrderReportDto.updateTenantInfo(tenantEntity); | |||
| wxOrderReportDto.setType(EnumOrderType.MICROPAY.getCode()); | |||
| wxOrderReportDto.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| return new ResultData(markingDataReportService.listOrderReportByDate(wxOrderReportDto)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("获商户得近30日刷卡") | |||
| @GetMapping("/detail") | |||
| @SystemControllerLog(description = "收银台-近30日刷卡列表详情") | |||
| public ResultData detail(@RequestParam Long merchantId) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::detail"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| WxOrderReportDto wxOrderReportDto = new WxOrderReportDto(); | |||
| wxOrderReportDto.updateTenantInfo(tenantEntity); | |||
| wxOrderReportDto.setMerchantId(merchantId); | |||
| return new ResultData(markingDataReportService.listMicroPayOrderReportByDateAndMerchant(wxOrderReportDto)); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("获得昨日刷卡列表") | |||
| @GetMapping("/listYesterday") | |||
| @SystemControllerLog(description = "收银台-获得昨日刷卡列表") | |||
| public ResultData listYesterday(@ModelAttribute WxOrderReportDto wxOrderReportDto, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listYesterday"); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if (wxOrderReportDto == null) | |||
| wxOrderReportDto = new WxOrderReportDto(); | |||
| wxOrderReportDto.updateTenantInfo(tenantEntity); | |||
| final PageInfo<WxMerchantMicroPayVo> page = markingDataReportService.listMerchantMicroPayOrderReportByDate(wxOrderReportDto, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -0,0 +1,85 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxMerchantPowerBillConfig; | |||
| import com.iformall.service.WxMerchantPowerBillConfigService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxMerchantPowerBillConfig") | |||
| @Api(description = "商户电费生成配置") | |||
| public class WxMerchantPowerBillConfigController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantPowerBillConfigService wxMerchantPowerBillConfigService; | |||
| @ApiOperation("查询数据列表") | |||
| @GetMapping("/list") | |||
| @SystemControllerLog(description = "查询数据列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findCouponDataList(@ModelAttribute WxMerchantPowerBillConfig wxMerchantPowerBillConfig, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::list"); | |||
| wxMerchantPowerBillConfig.updateTenantInfo(getTenantInfo()); | |||
| wxMerchantPowerBillConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxMerchantPowerBillConfig> page = wxMerchantPowerBillConfigService.listAsPage(wxMerchantPowerBillConfig, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增") | |||
| @PostMapping("/add") | |||
| @SystemControllerLog(description = "新增") | |||
| public ResultData add(@RequestBody WxMerchantPowerBillConfig wxMerchantPowerBillConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::add"); | |||
| return wxMerchantPowerBillConfigService.saveOrUpdate(wxMerchantPowerBillConfig); | |||
| } | |||
| @ApiOperation("更新") | |||
| @PostMapping("/update") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData update(@RequestBody WxMerchantPowerBillConfig wxMerchantPowerBillConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::update"); | |||
| return wxMerchantPowerBillConfigService.saveOrUpdate(wxMerchantPowerBillConfig); | |||
| } | |||
| @ApiOperation("删除") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::delete"); | |||
| wxMerchantPowerBillConfigService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "id查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantPowerBillConfigController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxMerchantPowerBillConfigService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,152 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.vo.WxMerchantSubsidyVo; | |||
| import com.iformall.enums.EnumMerchantSubsidyStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxMerchantSubsidyService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("subsidy") | |||
| @Api(description = "商户补贴接口") | |||
| public class WxMerchantSubsidyController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMerchantSubsidyService wxMerchantSubsidyService; | |||
| @ApiOperation("补贴记录汇总") | |||
| @GetMapping("sum") | |||
| @SystemControllerLog(description = "商户-补贴记录-汇总") | |||
| public ResultData count(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("subsidy/sum: " + ipStr + " :" + wxMerchantSubsidy.toString()); | |||
| if (wxMerchantSubsidy == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| for(String status: statusAttr) { | |||
| tmpList.add(Integer.valueOf(status)); | |||
| } | |||
| if(!tmpList.isEmpty()) { | |||
| wxMerchantSubsidy.setStatusS(tmpList); | |||
| } | |||
| } | |||
| List<Map<String, Object>> retMap = wxMerchantSubsidyService.sumForSubsidy(wxMerchantSubsidy); | |||
| return new ResultData(retMap); | |||
| } | |||
| @ApiOperation("补贴记录") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-补贴记录-列表") | |||
| public ResultData listMonth(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("subsidy/list: " + ipStr + " :" + wxMerchantSubsidy.toString()); | |||
| if (wxMerchantSubsidy == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| for(String status: statusAttr) { | |||
| tmpList.add(Integer.valueOf(status)); | |||
| } | |||
| if(!tmpList.isEmpty()) { | |||
| wxMerchantSubsidy.setStatusS(tmpList); | |||
| } | |||
| } | |||
| wxMerchantSubsidy.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxMerchantSubsidyVo> page = wxMerchantSubsidyService.listAsPage(wxMerchantSubsidy, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("交易列表") | |||
| @GetMapping("summary") | |||
| @SystemControllerLog(description = "结算-总计") | |||
| public ResultData summary(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy) { | |||
| logger.debug("[" + getIpAddr() + "] subsidy::summary"); | |||
| if (null == wxMerchantSubsidy) { | |||
| wxMerchantSubsidy = new WxMerchantSubsidyVo(); | |||
| } | |||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||
| Map<String, Long> data = wxMerchantSubsidyService.summary(wxMerchantSubsidy); | |||
| return new ResultData(data); | |||
| } | |||
| @ApiOperation("更新补贴记录") | |||
| @PostMapping("updateSubsidied") | |||
| @SystemControllerLog(description = "商户-更新补贴记录") | |||
| public ResultData updateSubsidied(@RequestBody WxMerchantSubsidyVo wxMerchantSubsidy) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("subsidy/update: " + ipStr + " :" + wxMerchantSubsidy.toString()); | |||
| if (wxMerchantSubsidy == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||
| wxMerchantSubsidy.setStatus(EnumMerchantSubsidyStatus.MANUAL_SUBSIDIED.getCode()); | |||
| wxMerchantSubsidy.setUpdateDate(new Date()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getIdStr())) { | |||
| String [] idArr = wxMerchantSubsidy.getIdStr().split(","); | |||
| List<Long> tmpList = new ArrayList<Long>(); | |||
| for(String id: idArr) { | |||
| tmpList.add(Long.valueOf(id)); | |||
| } | |||
| if(!tmpList.isEmpty()) { | |||
| wxMerchantSubsidy.setIds(tmpList); | |||
| } | |||
| } | |||
| return wxMerchantSubsidyService.update(wxMerchantSubsidy); | |||
| } | |||
| @ApiOperation("补贴记录导出") | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "商户-补贴记录-导出") | |||
| public void exportData(@ModelAttribute WxMerchantSubsidyVo wxMerchantSubsidy, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.info("[" + getIpAddr() + "] subsidy/exportData"); | |||
| if (wxMerchantSubsidy == null) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件不能为空"); | |||
| } | |||
| wxMerchantSubsidy.updateTenantInfo(getTenantInfo()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| for(String status: statusAttr) { | |||
| tmpList.add(Integer.valueOf(status)); | |||
| } | |||
| if(!tmpList.isEmpty()) { | |||
| wxMerchantSubsidy.setStatusS(tmpList); | |||
| } | |||
| } | |||
| wxMerchantSubsidy.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| wxMerchantSubsidyService.exportData(wxMerchantSubsidy, request, response); | |||
| } | |||
| } | |||
| @@ -0,0 +1,75 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxOpinion; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxOpinionService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxOpinion") | |||
| @Api(description="投诉建议") | |||
| public class WxOpinionController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxOpinionService wxOpinionService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||
| }) | |||
| @SystemControllerLog(description = "投诉建议-列表") | |||
| public ResultData list(@ModelAttribute WxOpinion record, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::list"); | |||
| if (null == record) { | |||
| record = new WxOpinion(); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxOpinion> page = wxOpinionService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/getById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "问券调查--查询") | |||
| public ResultData getById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::getById"); | |||
| return new ResultData(wxOpinionService.getById(id)); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "问券调查--更新") | |||
| public ResultData update(@RequestBody WxOpinion record) { | |||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::update"); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| wxOpinionService.saveOrUpdate(record); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,70 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxOrderGroupMarketing; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxOrderGroupService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import java.util.List; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @RestController | |||
| @RequestMapping("/orderGroup") | |||
| @Api(description = "拼团相关接口") | |||
| public class WxOrderGroupController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxOrderGroupService wxOrderGroupService; | |||
| @Autowired | |||
| WxMallService wxMallService; | |||
| @TenantIgnore | |||
| @ApiOperation(value = "拼团营销分析") | |||
| @GetMapping("queryOrderGroupMarketingList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query"), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| @SystemControllerLog(description = "订单管理-拼团营销分析") | |||
| public ResultData queryOrderGroupMarketingList(@ModelAttribute WxOrderGroupMarketing wxOrderGroupMarketing, Integer pageNum, Integer pageSize) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| wxOrderGroupMarketing.updateTenantInfo(tenantEntity); | |||
| final PageInfo<WxOrderGroupMarketing> page = wxOrderGroupService.queryOrderGroupMarketingList(wxOrderGroupMarketing,tenantEntitys, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation(value = "拼团营销数据导出") | |||
| @GetMapping("exportOrderGroupMarketingList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query") | |||
| }) | |||
| @SystemControllerLog(description = "营销统计-拼团营销数据导出") | |||
| public void exportOrderGroupMarketingList(@ModelAttribute WxOrderGroupMarketing wxOrderGroupMarketing, HttpServletRequest request, HttpServletResponse response) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| List<TenantEntity> tenantEntitys = wxMallService.getTenantEntitys(tenantEntity); | |||
| wxOrderGroupMarketing.updateTenantInfo(tenantEntity); | |||
| wxOrderGroupService.exportOrderGroupMarketingList(wxOrderGroupMarketing,tenantEntitys, request, response); | |||
| } | |||
| } | |||
| @@ -0,0 +1,67 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxPowerBillAutoConfig; | |||
| import com.iformall.service.WxPowerBillAutoConfigService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxPowerBillAutoConfig") | |||
| @Api(description = "电费自动生成配置") | |||
| public class WxPowerBillAutoConfigController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxPowerBillAutoConfigService wxPowerBillAutoConfigService; | |||
| @ApiOperation("查询数据列表") | |||
| @GetMapping("/list") | |||
| @SystemControllerLog(description = "查询数据列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findCouponDataList(@ModelAttribute WxPowerBillAutoConfig wxPowerBillAutoConfig, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::list"); | |||
| wxPowerBillAutoConfig.updateTenantInfo(getTenantInfo()); | |||
| wxPowerBillAutoConfig.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxPowerBillAutoConfig> page = wxPowerBillAutoConfigService.listAsPage(wxPowerBillAutoConfig, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("修改") | |||
| @PostMapping("/modify") | |||
| @SystemControllerLog(description = "修改") | |||
| public ResultData add(@RequestBody WxPowerBillAutoConfig wxPowerBillAutoConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::modify"); | |||
| return wxPowerBillAutoConfigService.modify(wxPowerBillAutoConfig); | |||
| } | |||
| @ApiOperation("得到配置信息") | |||
| @GetMapping("/getConfig") | |||
| @SystemControllerLog(description = "id查询") | |||
| public ResultData getConfig() { | |||
| logger.debug("[" + getIpAddr() + "] WxPowerBillAutoConfigController::getConfig"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxPowerBillAutoConfigService.getConfig(getTenantInfo())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,91 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxPrepayment; | |||
| import com.iformall.domain.po.WxPrepaymentHistory; | |||
| import com.iformall.enums.EnumUserType; | |||
| import com.iformall.service.WxPrepaymentService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("prepayment") | |||
| @Api(description = "预付费") | |||
| public class WxPrepaymentController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxPrepaymentService wxPrepaymentService; | |||
| @ApiOperation("列表查询") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "预付费-列表查询") | |||
| public ResultData list(@ModelAttribute WxPrepayment wxPrepayment, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("prepayment/list: " + ipStr); | |||
| if (wxPrepayment == null) { | |||
| wxPrepayment = new WxPrepayment(); | |||
| } | |||
| final PageInfo<WxPrepayment> page = wxPrepaymentService.listAsPage(wxPrepayment, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("列表查询历史") | |||
| @GetMapping("listHistory") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "预付费-列表查询历史") | |||
| public ResultData listHistory(@ModelAttribute WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("prepayment/listHistory: " + ipStr); | |||
| if (wxPrepaymentHistory == null) { | |||
| wxPrepaymentHistory = new WxPrepaymentHistory(); | |||
| } | |||
| final PageInfo<WxPrepaymentHistory> page = wxPrepaymentService.listHistoryAsPage(wxPrepaymentHistory, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("首次充值") | |||
| @PostMapping("payFirst") | |||
| @SystemControllerLog(description = "预付费-交费") | |||
| public ResultData payFirst(@RequestBody WxPrepayment wxPrepayment) { | |||
| logger.debug("[" + getIpAddr() + "] prepayment::add"); | |||
| wxPrepayment.updateTenantInfo(getTenantInfo()); | |||
| wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode()); | |||
| wxPrepayment.setOperator(getUserId()); | |||
| wxPrepaymentService.payFirst(wxPrepayment); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("再次充值") | |||
| @PostMapping("payAgain") | |||
| @SystemControllerLog(description = "预付费-交费或扣费") | |||
| public ResultData payAgain(@RequestBody WxPrepayment wxPrepayment) { | |||
| logger.debug("[" + getIpAddr() + "] prepayment::update"); | |||
| wxPrepayment.updateTenantInfo(getTenantInfo()); | |||
| wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode()); | |||
| wxPrepayment.setOperator(getUserId()); | |||
| wxPrepaymentService.payAgain(wxPrepayment); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,276 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.po.WxPressBatch; | |||
| import com.iformall.domain.po.WxPressBatchItem; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCouponChannelStatus; | |||
| import com.iformall.enums.EnumCouponChannelType; | |||
| import com.iformall.enums.EnumCouponContentType; | |||
| import com.iformall.enums.EnumCouponSourceType; | |||
| import com.iformall.enums.EnumCouponType; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.service.WxPressBatchService; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||
| 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.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("pressBatch") | |||
| public class WxPressBatchController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxPressBatchService wxPressBatchService; | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Autowired | |||
| WxCouponChannelService wxCouponChannelService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),}) | |||
| public ResultData list(@ModelAttribute WxPressBatch record, Integer pageNum, Integer pageSize) { | |||
| if (null == record) { | |||
| record = new WxPressBatch(); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||
| final PageInfo<WxPressBatch> page = wxPressBatchService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增&修改接口") | |||
| @PostMapping("saveOrUpdate") | |||
| public ResultData saveOrUpdate(@RequestBody WxPressBatch record) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| record.updateTenantInfo(tenantEntity); | |||
| wxPressBatchService.saveOrUpdate(record); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("详情接口") | |||
| @GetMapping("detail") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) | |||
| public ResultData detail(Long id) { | |||
| if (null == id) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| WxPressBatch order = wxPressBatchService.getById(id, getTenantInfo().getTenantId()); | |||
| return new ResultData(order); | |||
| } | |||
| @ApiOperation("砍价券接口") | |||
| @GetMapping("itemList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData itemList(Long id, Integer pageNum, Integer pageSize) { | |||
| if (null == id) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| PageInfo<WxPressBatchItem> itemPage = wxPressBatchService.getItemPage(id, tenantEntity.getTenantId(),pageNum,pageSize); | |||
| List<WxPressBatchItem> items = itemPage.getList(); | |||
| if (null != items && items.size() > 0 ) { | |||
| List<Long> couponIdList = wxPressBatchService.getItemCouponIdList(id, tenantEntity.getTenantId()); | |||
| WxCoupon record = new WxCoupon(); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| if (null != couponIdList && couponIdList.size() > 0 ) { | |||
| record.setIds(couponIdList); | |||
| }else { | |||
| record.setId(0L); | |||
| } | |||
| List<WxCoupon> list = wxCouponService.list(record); | |||
| Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); | |||
| if (null != list && list.size() > 0 ) { | |||
| for (WxCoupon c : list) { | |||
| couponMap.put(c.getId(), c); | |||
| } | |||
| } | |||
| for (WxPressBatchItem pbi : items) { | |||
| WxCoupon coupon = couponMap.get(pbi.getCouponId()); | |||
| pbi.setCoupon(coupon); | |||
| } | |||
| } | |||
| return new ResultData(itemPage); | |||
| } | |||
| @ApiOperation("删除接口") | |||
| @PostMapping("delete") | |||
| public ResultData delete(@RequestBody WxPressBatch record) { | |||
| if (null == record.getId()) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| wxPressBatchService.deleteBatch(record.getId(), getTenantInfo().getTenantId()); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("已投放砍价券列表接口") | |||
| @GetMapping("couponList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true),}) | |||
| public ResultData couponList(@ModelAttribute WxCoupon record, Integer pageNum, Integer pageSize) { | |||
| WxCouponChannel couponChannelQ = new WxCouponChannel(); | |||
| couponChannelQ.updateTenantInfo(getTenantInfo()); | |||
| couponChannelQ.setType(EnumCouponType.COUPON_PRESS.getCode()); | |||
| couponChannelQ.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()); | |||
| couponChannelQ.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| List<Long> couponIds = wxCouponChannelService.findCouponIdList(couponChannelQ); | |||
| if (null == record) { | |||
| record = new WxCoupon(); | |||
| } | |||
| record.updateTenantInfo(couponChannelQ); | |||
| if (null != couponIds && couponIds.size() > 0 ) { | |||
| record.setIds(couponIds); | |||
| }else { | |||
| record.setId(0L); | |||
| } | |||
| PageInfo<WxCoupon> page = wxCouponService.simplelistAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增items") | |||
| @PostMapping("addItems") | |||
| public ResultData addItems(@RequestBody WxPressBatch record) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| record.updateTenantInfo(tenantEntity); | |||
| if (null == record.getId()) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| String cidstr = record.getCouponIds(); | |||
| if (StringUtils.isBlank(cidstr)) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| String[] cids = cidstr.split(","); | |||
| if (null == cids || cids.length <= 0 ) { | |||
| return new ResultData(Result.ERROR,"请选择砍价券"); | |||
| } | |||
| List<Long> rcids = new ArrayList<Long>(); | |||
| for (String cid: cids) { | |||
| rcids.add(Long.parseLong(cid)); | |||
| } | |||
| //已经存在了的不能再加入 | |||
| List<Long> arrayCouponIds = wxPressBatchService.getCouponIds(tenantEntity.getTenantId()); | |||
| if (null != arrayCouponIds && arrayCouponIds.size() > 0 ) { | |||
| if (arrayCouponIds.containsAll(rcids)) { | |||
| return new ResultData(Result.ERROR,"所选择的券已经加入了一个批次,不能再加"); | |||
| } | |||
| List<Long> extraCouponIds = new ArrayList<Long>(); | |||
| extraCouponIds.addAll(rcids); | |||
| extraCouponIds.removeAll(arrayCouponIds); | |||
| List<Long> sameCouponIds = new ArrayList<Long>(); | |||
| sameCouponIds.addAll(rcids); | |||
| sameCouponIds.removeAll(extraCouponIds); | |||
| if (sameCouponIds.size() > 0) { | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.updateTenantInfo(tenantEntity); | |||
| couponQ.setIds(sameCouponIds); | |||
| List<WxCoupon> couponList = wxCouponService.list(couponQ); | |||
| if (null == couponList || couponList.size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"未查询到这些券"); | |||
| } | |||
| Map<Long,String> couponNameMap = new HashMap<Long,String>(); | |||
| for (WxCoupon c: couponList) { | |||
| couponNameMap.put(c.getId(),c.getTitle()); | |||
| } | |||
| StringBuffer sb = new StringBuffer("已经存在一个批次的券:"); | |||
| for (Long _cid: sameCouponIds) { | |||
| sb.append(couponNameMap.get(_cid)).append(","); | |||
| } | |||
| return new ResultData(Result.ERROR,sb.toString()); | |||
| } | |||
| } | |||
| List<Long> batchCids = wxPressBatchService.getItemCouponIdList(record.getId(), tenantEntity.getTenantId()); | |||
| if (null != cids && cids.length > 0 ) { | |||
| if (null != batchCids && batchCids.size() > 0 ) { | |||
| rcids.removeAll(batchCids); | |||
| } | |||
| WxPressBatch order = wxPressBatchService.getById(record.getId(), tenantEntity.getTenantId()); | |||
| wxPressBatchService.saveItems(order, rcids); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("详情接口") | |||
| @PostMapping("deleteItem") | |||
| public ResultData deleteItem(@RequestBody WxPressBatchItem record) { | |||
| if (null == record.getId()) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| wxPressBatchService.deleteItemById(record.getId(), getTenantInfo().getTenantId()); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("详情接口") | |||
| @PostMapping("updateStatus") | |||
| public ResultData updateStatus(@RequestBody WxPressBatch record) { | |||
| if (null == record.getId() || null == record.getStatus()) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| wxPressBatchService.updateStatus(record); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("详情接口") | |||
| @PostMapping("setRules") | |||
| public ResultData setRules(@RequestBody WxPressBatch record) { | |||
| if (null == record.getId()) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| WxPressBatch record1 = wxPressBatchService.getById(record.getId(), getTenantInfo().getTenantId()); | |||
| record1.setPromoterLimitRule(record.getPromoterLimitRule()); | |||
| record1.setPromoterAllowCount(record.getPromoterAllowCount()); | |||
| record1.setBargainerAllowCount(record.getBargainerAllowCount()); | |||
| record1.setBargainerAllowSame(record.getBargainerAllowSame()); | |||
| wxPressBatchService.saveOrUpdate(record1); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,87 @@ | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxQuestion; | |||
| import com.iformall.domain.po.WxQuestionConfig; | |||
| import com.iformall.enums.EnumQuestionConfigStatus; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxQuestion") | |||
| @Api(description="问券调查") | |||
| public class WxQuestionController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxQuestionService wxQuestionService; | |||
| @ApiOperation("查寻问券配置") | |||
| @GetMapping("getConfig") | |||
| @SystemControllerLog(description = "营销-问券调查-配置获取") | |||
| public Result getQuestionConfig() { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionController::getQuestionConfig"); | |||
| WxQuestionConfig wxQuestionConfig = new WxQuestionConfig(); | |||
| wxQuestionConfig.updateTenantInfo(getTenantInfo()); | |||
| WxQuestion wxQuestion = new WxQuestion(); | |||
| wxQuestion.updateTenantInfo(wxQuestionConfig); | |||
| List<WxQuestionConfig> list = wxQuestionService.findConfigList(wxQuestionConfig); | |||
| if (list.size() > 0) { | |||
| list.get(0).setQuestions(wxQuestionService.findList(wxQuestion)); | |||
| return new ResultData(list.get(0)); | |||
| } | |||
| wxQuestionConfig.setQuestions(wxQuestionService.findList(wxQuestion)); | |||
| wxQuestionConfig.setQuestionList(""); | |||
| wxQuestionConfig.setCouponTypeList(""); | |||
| wxQuestionConfig.setStatus(EnumQuestionConfigStatus.OFF.getCode()); | |||
| return new ResultData(wxQuestionConfig); | |||
| } | |||
| @ApiOperation("设置问券配置") | |||
| @PostMapping("setConfig") | |||
| @SystemControllerLog(description = "营销-问券调查-设置") | |||
| public Result setQuestionConfig(@RequestBody WxQuestionConfig wxQuestionConfig) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionController::setQuestionConfig"); | |||
| if (wxQuestionConfig == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if (wxQuestionConfig.getQuestionList() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if (wxQuestionConfig.getCouponTypeList() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| String[] arys1 = wxQuestionConfig.getQuestionList().split(","); | |||
| List<Long> qs = new ArrayList<>(); | |||
| for (int i = 0; i < arys1.length; i++) { | |||
| if (!arys1[i].isEmpty()) | |||
| qs.add(Long.parseLong(arys1[i])); | |||
| } | |||
| String[] arys2 = wxQuestionConfig.getCouponTypeList().split(","); | |||
| List<Long> ct = new ArrayList<>(); | |||
| for (int i = 0; i < arys2.length; i++) { | |||
| if (!arys2[i].isEmpty()) | |||
| ct.add(Long.parseLong(arys2[i])); | |||
| } | |||
| wxQuestionConfig.setQuestionList(JSONObject.toJSONString(qs)); | |||
| wxQuestionConfig.setCouponTypeList(JSONObject.toJSONString(ct)); | |||
| wxQuestionConfig.updateTenantInfo(getTenantInfo()); | |||
| wxQuestionService.saveOrUpdateConfig(wxQuestionConfig); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,176 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxQuestionOneself; | |||
| import com.iformall.domain.po.WxQuestionOneselfUser; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumQuestionOneselfStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxQuestionOneselfService; | |||
| import com.iformall.service.WxQuestionOneselfUserService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @RestController | |||
| @RequestMapping("wxQuestionOneself") | |||
| @Api(description="问券调查") | |||
| public class WxQuestionOneselfController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxQuestionOneselfService wxQuestionOneselfService; | |||
| @Autowired | |||
| private WxQuestionOneselfUserService wxQuestionOneselfUserService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||
| }) | |||
| @SystemControllerLog(description = "问券调查-列表") | |||
| public ResultData list(@ModelAttribute WxQuestionOneself record, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::list"); | |||
| if (null == record) { | |||
| record = new WxQuestionOneself(); | |||
| } | |||
| if (record.getStatus() != null && record.getStatus() == -1) { | |||
| record.setStatus(null); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC,BaseEntity.SortField.Sort_DESC); | |||
| final PageInfo<WxQuestionOneself> page = wxQuestionOneselfService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "问券调查-新增") | |||
| public ResultData add(@RequestBody WxQuestionOneself record) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::add"); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| wxQuestionOneselfService.saveOrUpdate(record); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "问券调查--更新") | |||
| public ResultData update(@RequestBody WxQuestionOneself record) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::update"); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| try { | |||
| wxQuestionOneselfService.saveOrUpdate(record); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("updateStatus") | |||
| @SystemControllerLog(description = "问券调查--更新状态") | |||
| public ResultData updateStatus(@RequestBody WxQuestionOneself record) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::updateStatus"); | |||
| if(record == null || record.getStatus() == null || record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(!record.getStatus().equals(EnumQuestionOneselfStatus.STATUS_TAKE_OFFF.getCode()) | |||
| && !record.getStatus().equals(EnumQuestionOneselfStatus.INJECT_ONLINE.getCode())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| return wxQuestionOneselfService.updateStatus(record); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/detailsById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "问券调查--查询") | |||
| public ResultData detailsById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::detailsById"); | |||
| return new ResultData(wxQuestionOneselfService.detailsById(id)); | |||
| } | |||
| @ApiOperation("投放到宣传页") | |||
| @GetMapping("/sendToCampaign") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "问券调查--投放到宣传页") | |||
| public ResultData sendToCampaign(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::sendToCampaign"); | |||
| return wxQuestionOneselfService.sendToCampaign(id); | |||
| } | |||
| @ApiOperation("从宣传页下线") | |||
| @GetMapping("offLineCampaign") | |||
| @SystemControllerLog(description = "问券调查--从宣传页下线") | |||
| public ResultData offLineCampaign(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::offLineCampaign"); | |||
| return wxQuestionOneselfService.offLineCampaign(id); | |||
| } | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("userList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true) | |||
| }) | |||
| @SystemControllerLog(description = "userList-列表") | |||
| public ResultData userList(@ModelAttribute WxQuestionOneselfUser record, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::userList"); | |||
| if (null == record) { | |||
| record = new WxQuestionOneselfUser(); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxQuestionOneselfUser> page = wxQuestionOneselfUserService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/userDetails") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "问券调查--查询") | |||
| public ResultData userDetails(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxQuestionOneselfController::userDetails"); | |||
| return new ResultData(wxQuestionOneselfUserService.userDetailsById(id)); | |||
| } | |||
| @ApiOperation("导出") | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "导出") | |||
| public void exportData(@ModelAttribute WxQuestionOneselfUser record, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.info("[" + getIpAddr() + "] WxQuestionOneselfController/exportData"); | |||
| if (null == record || record.getQuestionId() == null) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| wxQuestionOneselfUserService.exportData(record, request, response); | |||
| } | |||
| } | |||
| @@ -0,0 +1,84 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import io.swagger.annotations.Api; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxRefundOrder; | |||
| import com.iformall.service.WxRefundOrderService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("/refund") | |||
| @Api(description = "微信退款订单接口") | |||
| public class WxRefundOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "退款-列表") | |||
| public ResultData list(@ModelAttribute WxRefundOrder wxRefundOrder, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxRefundOrderController::list"); | |||
| if (null == wxRefundOrder) wxRefundOrder = new WxRefundOrder(); | |||
| final PageInfo<WxRefundOrder> page = wxRefundOrderService.listAsPage(wxRefundOrder, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "退款-新增") | |||
| public ResultData add(@RequestBody WxRefundOrder wxRefundOrder) { | |||
| logger.debug("[" + getIpAddr() + "] WxRefundOrderController::add"); | |||
| //Assert.notNull(wxRefundOrder.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxRefundOrderService.saveOrUpdate(wxRefundOrder); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "退款-更新") | |||
| public ResultData update(@RequestBody WxRefundOrder wxRefundOrder) { | |||
| logger.debug("[" + getIpAddr() + "] WxRefundOrderController::update"); | |||
| wxRefundOrderService.saveOrUpdate(wxRefundOrder); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "退款-根据id删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxRefundOrderController::delete"); | |||
| wxRefundOrderService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "退款-id查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxRefundOrderController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxRefundOrderService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,110 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.utils.PayUtil; | |||
| import io.swagger.annotations.Api; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxSubsidy; | |||
| import com.iformall.service.WxSubsidyService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import javax.imageio.ImageIO; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.awt.image.BufferedImage; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxSubsidy") | |||
| @Api(description = "商城补贴支付接口") | |||
| public class WxSubsidyController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxSubsidyService wxSubsidyService; | |||
| // @ApiOperation("补贴扫码支付发起") | |||
| // @GetMapping("prePay") | |||
| // @ApiImplicitParams({ | |||
| // @ApiImplicitParam(name = "amount", value = "金额", dataType = "String", paramType = "query", required = true)}) | |||
| // @SystemControllerLog(description = "商城补贴-补贴扫码支付发起") | |||
| // public void subsidyPrepay(String amount, HttpServletResponse response) throws Exception { | |||
| // String ipStr = getIpAddr(); | |||
| // logger.info("subsidyPrepay: " + ipStr + "-" + amount); | |||
| // MallUserInfo userInfo = getUser(); | |||
| // ResultData resultData = wxSubsidyService.createSubsidy(userInfo, ipStr, amount); | |||
| // if (resultData.code == 200) { | |||
| // String codeUrl = ((Map<String, String>) resultData.data).get("code_url"); | |||
| // BufferedImage image = PayUtil.getQRCodeImge(codeUrl); | |||
| // | |||
| // response.setContentType("image/jpeg"); | |||
| // response.setHeader("Pragma", "no-cache"); | |||
| // response.setHeader("Cache-Control", "no-cache"); | |||
| // response.setIntHeader("Expires", -1); | |||
| // ImageIO.write(image, "JPEG", response.getOutputStream()); | |||
| // } else { | |||
| // throw new MallinkException(resultData.code, resultData.message); | |||
| // } | |||
| // } | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商城补贴-列表") | |||
| public ResultData list(@ModelAttribute WxSubsidy wxSubsidy, Integer pageNum, Integer pageSize) { | |||
| if (null == wxSubsidy) wxSubsidy = new WxSubsidy(); | |||
| final PageInfo<WxSubsidy> page = wxSubsidyService.listAsPage(wxSubsidy, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "商城补贴-新增接口") | |||
| public ResultData add(@RequestBody WxSubsidy wxSubsidy) { | |||
| //Assert.notNull(wxSubsidy.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxSubsidyService.saveOrUpdate(wxSubsidy); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "商城补贴-更新") | |||
| public ResultData update(@RequestBody WxSubsidy wxSubsidy) { | |||
| wxSubsidyService.saveOrUpdate(wxSubsidy); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商城补贴-删除") | |||
| public ResultData delete(Long id) { | |||
| wxSubsidyService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商城补贴-查询") | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxSubsidyService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,107 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumWxTopicStatus; | |||
| import com.iformall.enums.EnumWxTopicType; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| @RestController | |||
| @RequestMapping("topic") | |||
| @Api(description = "专题相关接口") | |||
| public class WxTopicController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxTopicService wxTopicService; | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "专题-列表") | |||
| public ResultData list(WxTopic wxTopic, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxTopicController::list"); | |||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||
| wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode()); | |||
| PageInfo<WxTopic> page = wxTopicService.listAsPage(wxTopic, pageNum, pageSize); | |||
| //可投放、已上线,时间区间查的是活动开始时间 | |||
| //已下线、已作为,时间区间查的是活动结束时间 | |||
| //设置正在上架的专题 | |||
| Date now = new Date(); | |||
| page.getList().stream().forEach(cc->{ | |||
| if (cc.getStatus().equals(EnumWxTopicStatus.VAILD.getCode()) && | |||
| cc.getEndTime()!=null && cc.getBeginTime()!=null && | |||
| now.getTime() >= cc.getBeginTime().getTime() && | |||
| now.getTime() <= cc.getEndTime().getTime()) { | |||
| cc.setIsOnline(1); | |||
| } | |||
| }); | |||
| return new ResultData(page); | |||
| } | |||
| @GetMapping("findById") | |||
| @SystemControllerLog(description = "专题-获取详情") | |||
| public ResultData findById(WxTopic wxTopic) { | |||
| logger.debug("[" + getIpAddr() + "] WxTopicController::findById"); | |||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||
| WxTopic queryTopic = wxTopicService.findById(wxTopic); | |||
| return new ResultData(queryTopic); | |||
| } | |||
| @PostMapping("saveOrUpdate") | |||
| @SystemControllerLog(description = "专题-保存更新") | |||
| public ResultData saveOrUpdate(@RequestBody WxTopic wxTopic) { | |||
| logger.debug("[" + getIpAddr() + "] WxTopicController::saveOrUpdate"); | |||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||
| if(wxTopic.getTopicType() == null){ | |||
| wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode()); | |||
| } | |||
| return wxTopicService.saveOrUpdate(wxTopic); | |||
| } | |||
| @GetMapping("findByType") | |||
| @SystemControllerLog(description = "专题-获取详情") | |||
| public ResultData findByType(Integer topicType) { | |||
| logger.debug("[" + getIpAddr() + "] WxTopicController::findByType"); | |||
| if(topicType == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxTopic wxTopic = new WxTopic(); | |||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||
| wxTopic.setTopicType(topicType); | |||
| WxTopic queryTopic = wxTopicService.findByType(wxTopic); | |||
| return new ResultData(queryTopic); | |||
| } | |||
| @PostMapping("updateByType") | |||
| @SystemControllerLog(description = "专题-保存更新") | |||
| public ResultData updateByType(@RequestBody WxTopic wxTopic) { | |||
| logger.debug("[" + getIpAddr() + "] WxTopicController::updateByType"); | |||
| wxTopic.updateTenantInfo(getTenantInfo()); | |||
| if(wxTopic.getTopicType() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxTopic.setName(EnumWxTopicType.getEnum(wxTopic.getTopicType()).getMessage()); | |||
| if(StringUtils.isBlank(wxTopic.getName())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| return wxTopicService.saveOrUpdate(wxTopic); | |||
| } | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.WxUserCouponDto; | |||
| import com.iformall.service.WxUserCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| 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; | |||
| /** | |||
| * Created by syf on 2018/8/10. | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxUserCoupon") | |||
| @Api(description = "会员卡券查询接口") | |||
| public class WxUserCouponController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxUserCouponService wxUserCouponService; | |||
| @ApiOperation("查询用户卡券接口") | |||
| @PostMapping("findByStatus") | |||
| @SystemControllerLog(description = "会员管理-查询用户卡券接口") | |||
| public ResultData findByStatus(@RequestBody WxUserCouponDto wxUserCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxUserCouponController::findByStatus"); | |||
| //根据用户id,用户卡券状态查找 | |||
| if(wxUserCoupon==null||wxUserCoupon.getCUserId()==null||wxUserCoupon.getCouponStatus()==null){ | |||
| return new ResultData(Result.ERROR,"查询失败"); | |||
| } | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(getTenantInfo(),wxUserCoupon.getCUserId(),wxUserCoupon.getCouponStatus())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,198 @@ | |||
| package com.iformall.controller.mem; | |||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxTags; | |||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||
| import com.iformall.domain.vo.MerchantPoiT; | |||
| import com.iformall.service.TtMerchantPoiService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxTagsService; | |||
| import org.apache.shiro.session.UnknownSessionException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Component; | |||
| import java.io.File; | |||
| import java.util.List; | |||
| import java.util.concurrent.TimeUnit; | |||
| @Component | |||
| public class AsyncTask { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private TtMerchantPoiService ttMerchantPoiService; | |||
| @Autowired | |||
| private WxTagsService wxTagsService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||
| @Override | |||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private class PoiExcelHandler extends ExcelDataHandlerDefaultImpl<MerchantPoiT> { | |||
| @Override | |||
| public Object importHandler(MerchantPoiT obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if(fail) { | |||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @Async | |||
| public void importExcelData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "成长值", "积分"}); | |||
| IExcelDataHandler<CUserBaseInfoT> handler = new AsyncTask.UserExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"手机号*"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if(datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int total = successList.size() + failList.size(); | |||
| int all_success = successList.size(); | |||
| int all_fail = failList.size(); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if(successList.size() > 0) { | |||
| WxTags wxTagsQ = new WxTags(); | |||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||
| try { | |||
| successList.parallelStream().forEach(uBase -> { | |||
| try { | |||
| wxCUserBasicInfoService.importOneMem(importKey, tagList, uBase, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:"+e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @Async | |||
| public void importExcelPoiData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", | |||
| "已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息"}); | |||
| IExcelDataHandler<MerchantPoiT> handler = new AsyncTask.PoiExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"服务商POI_ID","已匹配POI_ID"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<MerchantPoiT> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiT.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if(datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<MerchantPoiT> successList = datalist.getList(); | |||
| List<MerchantPoiT> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int total = successList.size() + failList.size(); | |||
| int all_success = successList.size(); | |||
| int all_fail = failList.size(); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if(successList.size() > 0) { | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| ttMerchantPoiService.importOneMem(user,importKey, poiBase); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:"+e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,169 @@ | |||
| package com.iformall.controller.mem; | |||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxBillDailyVo; | |||
| import com.iformall.enums.EnumDelStatus; | |||
| import com.iformall.enums.EnumShopStatus; | |||
| import com.iformall.mapper.WxShopMapper; | |||
| import com.iformall.service.WxBillDailyService; | |||
| import org.apache.shiro.session.UnknownSessionException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Component; | |||
| import java.io.File; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.concurrent.TimeUnit; | |||
| @Component | |||
| public class BillDailyAsyncTask { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxBillDailyService wxBillDailyService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| WxShopMapper wxShopMapper; | |||
| private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> { | |||
| @Override | |||
| public Object importHandler(WxBillDailyVo obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if (fail) { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @Async | |||
| public void importExcelData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||
| IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillDailyVo> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillDailyVo.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillDailyVo> successList = datalist.getList(); | |||
| List<WxBillDailyVo> failList = datalist.getFailList(); | |||
| List<WxBillDailyVo> processList = new ArrayList<>(); | |||
| int fail = 0; | |||
| for (WxBillDailyVo vo : successList) { | |||
| //店铺 | |||
| WxShop shop = new WxShop(); | |||
| shop.setShopNumber(vo.getShopNumber()); | |||
| shop.updateTenantInfo(user); | |||
| shop.setType(vo.getRentShopType()); | |||
| shop.setStatus(EnumShopStatus.RENT.getCode()); | |||
| shop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| WxShop wxShop = wxShopMapper.selectOne(new QueryWrapper(shop)); | |||
| if (wxShop == null) { | |||
| logger.error("店铺不存在", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| String receivePayStr = vo.getReceivePayStr(); | |||
| long receivePay = new BigDecimal(receivePayStr).multiply(new BigDecimal(100)).longValue(); | |||
| if (receivePay <= 0) { | |||
| logger.error("实际应收金额小于等于0", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| String payStr = vo.getPayStr(); | |||
| long pay = new BigDecimal(payStr).multiply(new BigDecimal(100)).longValue(); | |||
| if (pay < 0) { | |||
| logger.error("实收金额小于0", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| if (receivePay < pay) { | |||
| logger.error("实际应收金额小于实收金额", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| vo.setReceivePay(receivePay); | |||
| vo.setPay(pay); | |||
| vo.updateTenantInfo(user); | |||
| vo.setShopId(wxShop.getId()); | |||
| vo.setRentShopType(wxShop.getType()); | |||
| processList.add(vo); | |||
| } | |||
| logger.info("验证通过的数量: " + processList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int all_success = processList.size(); | |||
| int all_fail = failList.size() + fail; | |||
| int total = processList.size() + all_fail; | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (processList.size() > 0) { | |||
| try { | |||
| processList.parallelStream().forEach(billDaily -> { | |||
| try { | |||
| //插入数据 | |||
| wxBillDailyService.insertData(billDaily, importKey, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,342 @@ | |||
| package com.iformall.controller.mem; | |||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxTags; | |||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||
| import com.iformall.domain.vo.WxBillExcelTemplate; | |||
| import com.iformall.domain.vo.WxBillExcelTemplateOther; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.service.WxBillAllService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxTagsService; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.session.UnknownSessionException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Component; | |||
| import java.io.File; | |||
| import java.math.BigDecimal; | |||
| import java.util.*; | |||
| import java.util.concurrent.TimeUnit; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @Component | |||
| public class ImportTemplateTask { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private WxTagsService wxTagsService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private WxBillAllService wxBillAllService; | |||
| @Autowired | |||
| private WxMerchantMapper wxMerchantMapper; | |||
| @Async | |||
| public void importBillData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商户名*", "费用类型*", "费用属性*", "费用所属期-开始时间*", "费用所属期-结束时间*", "收款金额(元)*", "收款日期*", "截止缴款日*", "收款方式"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillExcelTemplate> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplate.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillExcelTemplate> successList = datalist.getList(); | |||
| List<WxBillExcelTemplate> failList = datalist.getFailList(); | |||
| //此处判断商户是否存在 | |||
| //1 过滤重复商户名 | |||
| Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||
| .map(s -> StringUtils.trim(s.getMerchantName())) | |||
| .collect(Collectors.toSet()); | |||
| //2 查询商户名是否存在 | |||
| Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||
| merchantSet.parallelStream().forEach(merchantName -> { | |||
| WxMerchant wxMerchantQuery = new WxMerchant(); | |||
| wxMerchantQuery.updateTenantInfo(user); | |||
| wxMerchantQuery.setName(merchantName); | |||
| wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||
| if (wxMerchant != null) { | |||
| merchantMap.put(merchantName, wxMerchant); | |||
| } | |||
| }); | |||
| //3 计失败条数 | |||
| List<WxBillExcelTemplate> billSuccessList = new ArrayList<>(); | |||
| successList.parallelStream().forEach(s -> { | |||
| if (StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||
| && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||
| && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||
| && null != s.getPayDate() && null != s.getReceiveDate()) { | |||
| WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||
| if (wxMerchant != null) { | |||
| Long merchantId = wxMerchant.getId(); | |||
| if (merchantId != null) { | |||
| s.setMerchantId(merchantId); | |||
| Integer type = wxMerchant.getType(); | |||
| s.setMerchantType(type); | |||
| billSuccessList.add(s); | |||
| } | |||
| } | |||
| } | |||
| }); | |||
| int billSuccessSize = billSuccessList.size(); | |||
| int successSize = successList.size(); | |||
| int failSize = failList.size(); | |||
| int total = successSize + failSize; | |||
| int failCount = successSize - billSuccessSize; | |||
| int all_success = billSuccessSize; | |||
| int all_fail = failSize + failCount; | |||
| logger.info("验证通过的数量: " + billSuccessSize); | |||
| logger.info("验证未通过的数量: " + failSize); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (billSuccessSize > 0) { | |||
| try { | |||
| billSuccessList.stream().forEach(bill -> { | |||
| try { | |||
| wxBillAllService.importBill(importKey, bill, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| public void importBillDataOther(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期", "截止缴款日*", "收款方式"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillExcelTemplateOther> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplateOther.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillExcelTemplateOther> successList = datalist.getList(); | |||
| List<WxBillExcelTemplateOther> failList = datalist.getFailList(); | |||
| //此处判断商户是否存在 | |||
| //1 过滤重复商户名 | |||
| Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||
| .map(s -> StringUtils.trim(s.getMerchantName())) | |||
| .collect(Collectors.toSet()); | |||
| //2 查询商户名是否存在 | |||
| Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||
| merchantSet.parallelStream().forEach(merchantName -> { | |||
| WxMerchant wxMerchantQuery = new WxMerchant(); | |||
| wxMerchantQuery.updateTenantInfo(user); | |||
| wxMerchantQuery.setName(merchantName); | |||
| wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||
| if (wxMerchant != null) { | |||
| merchantMap.put(merchantName, wxMerchant); | |||
| } | |||
| }); | |||
| //3 计失败条数 | |||
| List<WxBillExcelTemplateOther> billSuccessList = new ArrayList<>(); | |||
| successList.parallelStream().forEach(s -> { | |||
| boolean flag = StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||
| && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||
| && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||
| && null != s.getReceiveDate() && StringUtils.isNotEmpty(s.getReceivePayStr()); | |||
| if (flag) { | |||
| double pay = new BigDecimal(s.getPayStr()).doubleValue(); | |||
| //付款大于0且付款日期不为空说明是更新账单 或者 付款为0且付款日期为空是新增账单 满足其一即可继续 | |||
| flag = (pay > 0 && null != s.getPayDate()) || (pay == 0 && null == s.getPayDate()); | |||
| if (flag) { | |||
| WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||
| if (wxMerchant != null) { | |||
| Long merchantId = wxMerchant.getId(); | |||
| if (merchantId != null) { | |||
| s.setMerchantId(merchantId); | |||
| Integer type = wxMerchant.getType(); | |||
| s.setMerchantType(type); | |||
| billSuccessList.add(s); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| }); | |||
| int billSuccessSize = billSuccessList.size(); | |||
| int successSize = successList.size(); | |||
| int failSize = failList.size(); | |||
| int total = successSize + failSize; | |||
| int failCount = successSize - billSuccessSize; | |||
| int all_success = billSuccessSize; | |||
| int all_fail = failSize + failCount; | |||
| logger.info("验证通过的数量: " + billSuccessSize); | |||
| logger.info("验证未通过的数量: " + failSize); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (billSuccessSize > 0) { | |||
| try { | |||
| billSuccessList.stream().forEach(bill -> { | |||
| try { | |||
| wxBillAllService.importBillOther(importKey, bill, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||
| @Override | |||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if (fail) { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @Async | |||
| public void importMemberData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值", "积分"}); | |||
| IExcelDataHandler<CUserBaseInfoT> handler = new ImportTemplateTask.UserExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"手机号*"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int total = successList.size() + failList.size(); | |||
| int all_success = successList.size(); | |||
| int all_fail = failList.size(); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (successList.size() > 0) { | |||
| WxTags wxTagsQ = new WxTags(); | |||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||
| try { | |||
| successList.parallelStream().forEach(uBase -> { | |||
| try { | |||
| wxCUserBasicInfoService.importOneMem(importKey, tagList, uBase, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,192 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.EnumCouponChannelStatus; | |||
| import com.iformall.enums.EnumCouponChannelType; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("memCoupon") | |||
| @Api(description = "会员券相关接口") | |||
| public class MemCouponController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponChannelService couponChannelService; | |||
| @Autowired | |||
| private MemCouponFromDspService memCouponFromDspService; | |||
| @Autowired | |||
| private WxCouponService couponService; | |||
| @ApiOperation("已投放券列表接口") | |||
| @GetMapping("couponChannelList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "会员券管理-已投放列表") | |||
| public ResultData couponChannelList(Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MemCouponController::list"); | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| if (null == wxCouponChannel) { | |||
| wxCouponChannel = new WxCouponChannel(); | |||
| } | |||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||
| wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_H5.getCode()); | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){ | |||
| // String coryColumn = "c."+wxCouponChannel.getSortColumns(); | |||
| // wxCouponChannel.setSortColumns(coryColumn); | |||
| // wxCouponChannel.setSortColumn(null); | |||
| }else{ | |||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | |||
| } | |||
| final PageInfo<WxCouponChannelVo> page = couponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("已发放券列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "会员券管理-列表") | |||
| public ResultData list(@ModelAttribute MemCouponFromDsp memCouponFromDsp, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MemCouponController::list"); | |||
| if (null == memCouponFromDsp) { | |||
| memCouponFromDsp = new MemCouponFromDsp(); | |||
| } else { | |||
| if (StringUtils.isBlank(memCouponFromDsp.getPhone())) { | |||
| memCouponFromDsp.setPhone(null); | |||
| } | |||
| } | |||
| memCouponFromDsp.updateTenantInfo(getTenantInfo()); | |||
| memCouponFromDsp.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| PageInfo<MemCouponFromDsp> page = memCouponFromDspService.listAsPage(memCouponFromDsp, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("检查用户购买券是否可用") | |||
| @PostMapping("checkMemCoupon") | |||
| @SystemControllerLog(description = "会员券管理-检查") | |||
| public ResultData checkMemCoupon(@RequestBody MemCouponFromDsp memCouponFromDsp) { | |||
| logger.debug("[" + getIpAddr() + "] MemCouponController::add"); | |||
| if (StringUtils.isBlank(memCouponFromDsp.getPhone())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "phone必填"); | |||
| } | |||
| if (memCouponFromDsp.getCouponChannelId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId必填"); | |||
| } | |||
| memCouponFromDsp.updateTenantInfo(getTenantInfo()); | |||
| WxCouponChannel couponChannel = couponChannelService.getById(memCouponFromDsp.getCouponChannelId(),getTenantInfo().getTenantId()); | |||
| if (memCouponFromDsp.getCouponId() == null) { | |||
| memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | |||
| } | |||
| // 1. 检查券是否已超限, 无剩余库存 | |||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),memCouponFromDsp.getTenantId()); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | |||
| } | |||
| MemCouponFromDsp couponQ = new MemCouponFromDsp(); | |||
| couponQ.updateTenantInfo(memCouponFromDsp); | |||
| couponQ.setCouponId(memCouponFromDsp.getCouponId()); | |||
| couponQ.setStatus(0); | |||
| Integer couponCount = memCouponFromDspService.countByInfo(couponQ); | |||
| if (coupon.getRemainInventory() <= couponCount) { | |||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| // 2. 检查此会员是否已超限, 达到券购买限制 | |||
| couponQ = new MemCouponFromDsp(); | |||
| couponQ.updateTenantInfo(memCouponFromDsp); | |||
| couponQ.setPhone(memCouponFromDsp.getPhone()); | |||
| couponQ.setCouponId(memCouponFromDsp.getCouponId()); | |||
| couponCount = memCouponFromDspService.countByInfo(couponQ); | |||
| if (coupon.getUseLimitQuantity() <= couponCount) { | |||
| return new ResultData(ErrorCode.ORDER_IS_LIMITED); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "会员券管理-添加") | |||
| public ResultData add(@RequestBody MemCouponFromDsp memCouponFromDsp) { | |||
| logger.debug("[" + getIpAddr() + "] MemCouponController::add"); | |||
| if (StringUtils.isBlank(memCouponFromDsp.getPhone())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "phone必填"); | |||
| } | |||
| if (memCouponFromDsp.getCouponChannelId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId必填"); | |||
| } | |||
| memCouponFromDsp.updateTenantInfo(getTenantInfo()); | |||
| WxCouponChannel couponChannel = couponChannelService.getById(memCouponFromDsp.getCouponChannelId(),getTenantInfo().getTenantId()); | |||
| if (memCouponFromDsp.getCouponId() == null) { | |||
| memCouponFromDsp.setCouponId(couponChannel.getCouponId()); | |||
| } | |||
| // 1. 检查券是否已超限, 无剩余库存 | |||
| WxCoupon coupon = couponService.getById(memCouponFromDsp.getCouponId(),couponChannel.getTenantId()); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券不存在:" + memCouponFromDsp.getCouponId()); | |||
| } | |||
| MemCouponFromDsp couponQ = new MemCouponFromDsp(); | |||
| couponQ.updateTenantInfo(memCouponFromDsp); | |||
| couponQ.setCouponId(memCouponFromDsp.getCouponId()); | |||
| couponQ.setStatus(0); | |||
| Integer couponCount = memCouponFromDspService.countByInfo(couponQ); | |||
| if (coupon.getRemainInventory() <= couponCount) { | |||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| // 2. 检查此会员是否已超限, 达到券购买限制 | |||
| couponQ = new MemCouponFromDsp(); | |||
| couponQ.updateTenantInfo(memCouponFromDsp); | |||
| couponQ.setPhone(memCouponFromDsp.getPhone()); | |||
| couponQ.setCouponId(memCouponFromDsp.getCouponId()); | |||
| couponCount = memCouponFromDspService.countByInfo(couponQ); | |||
| if (coupon.getUseLimitQuantity() <= couponCount) { | |||
| return new ResultData(ErrorCode.ORDER_IS_LIMITED); | |||
| } | |||
| // 3. 保存 | |||
| memCouponFromDsp.setStatus(0); | |||
| memCouponFromDspService.saveOrUpdate(memCouponFromDsp); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据手机号查询接口") | |||
| @GetMapping("/findByPhone") | |||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "会员券管理-根据手机号查询接口") | |||
| public ResultData findByPhone(String phone) { | |||
| logger.debug("[" + getIpAddr() + "] MemCouponController::findByPhone"); | |||
| if (StringUtils.isEmpty(phone)) { | |||
| return new ResultData(new ArrayList<MemCouponFromDsp>()); | |||
| } | |||
| MemCouponFromDsp memQ = new MemCouponFromDsp(); | |||
| memQ.updateTenantInfo(getTenantInfo()); | |||
| memQ.setPhone(phone); | |||
| List<MemCouponFromDsp> memCouponFromDsps = memCouponFromDspService.getList(memQ); | |||
| return new ResultData(memCouponFromDsps); | |||
| } | |||
| } | |||
| @@ -0,0 +1,111 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("userBasicInfoAddress") | |||
| @Api(description = "会员地址相关接口") | |||
| public class UserBasicInfoAddressController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private UserBasicInfoAddressService userBasicInfoAddressService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "会员地址-列表") | |||
| public ResultData list(@ModelAttribute UserBasicInfoAddress userBasicInfoAddress, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] UserBasicInfoAddressController::list"); | |||
| if (null == userBasicInfoAddress) { | |||
| userBasicInfoAddress = new UserBasicInfoAddress(); | |||
| } | |||
| if(userBasicInfoAddress.getUserId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "用户ID为空"); | |||
| } | |||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||
| PageInfo<UserBasicInfoAddress> page = userBasicInfoAddressService.listAsPage(userBasicInfoAddress, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("saveOrUpdate") | |||
| @SystemControllerLog(description = "会员地址-保存更新") | |||
| public ResultData saveOrUpdate(@RequestBody UserBasicInfoAddress userBasicInfoAddress) { | |||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::saveOrUpdate"); | |||
| if(userBasicInfoAddress == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(userBasicInfoAddress.getUserId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||
| userBasicInfoAddressService.saveOrUpdate(userBasicInfoAddress); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("setUpDefault") | |||
| @SystemControllerLog(description = "会员地址-默认") | |||
| public ResultData setUpDefault(@RequestBody UserBasicInfoAddress userBasicInfoAddress) { | |||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::setUpDefault"); | |||
| if(userBasicInfoAddress == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if(userBasicInfoAddress.getId() == null || userBasicInfoAddress.getUserId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "用户ID或者Id为空"); | |||
| } | |||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||
| userBasicInfoAddressService.updateDefault(userBasicInfoAddress); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("消息模板-删除") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "消息验证模板-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::delete"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "Id为空"); | |||
| } | |||
| UserBasicInfoAddress userBasicInfoAddress = new UserBasicInfoAddress(); | |||
| userBasicInfoAddress.setId(id); | |||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||
| userBasicInfoAddressService.deleteById(userBasicInfoAddress); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("消息模板-查询") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "消息验证模板-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] userBasicInfoAddress::findById"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "Id为空"); | |||
| } | |||
| UserBasicInfoAddress userBasicInfoAddress = new UserBasicInfoAddress(); | |||
| userBasicInfoAddress.setId(id); | |||
| userBasicInfoAddress.undateFinalTenantId(getTenantInfo()); | |||
| userBasicInfoAddressService.findById(userBasicInfoAddress); | |||
| return new ResultData(Result.SUCCESS, "查询成功", null); | |||
| } | |||
| } | |||
| @@ -0,0 +1,82 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCUserCar; | |||
| import com.iformall.service.WxCUserCarService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxCUserCar") | |||
| public class WxCUserCarController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserCarService wxCUserCarService; | |||
| @TenantIgnore | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "停车-列表") | |||
| public ResultData list(@ModelAttribute WxCUserCar wxCUserCar, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::list"); | |||
| if (null == wxCUserCar) wxCUserCar = new WxCUserCar(); | |||
| wxCUserCar.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserCar> page = wxCUserCarService.listAsPage(wxCUserCar, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "停车-新增") | |||
| public ResultData add(@RequestBody WxCUserCar wxCUserCar) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::add"); | |||
| //Assert.notNull(wxCUserCar.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCUserCarService.saveOrUpdate(wxCUserCar); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "停车-更新") | |||
| public ResultData update(@RequestBody WxCUserCar wxCUserCar) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::update"); | |||
| wxCUserCarService.saveOrUpdate(wxCUserCar); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "停车-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::delete"); | |||
| wxCUserCarService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "停车-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCUserCarService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,81 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.service.WxCUserService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxCUser") | |||
| public class WxCUserController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserService wxCUserService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "用户管理-列表") | |||
| public ResultData list(@ModelAttribute WxCUser wxCUser, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserController::list"); | |||
| if (null == wxCUser) wxCUser = new WxCUser(); | |||
| final PageInfo<WxCUser> page = wxCUserService.listAsPage(wxCUser, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "用户管理-新增") | |||
| public ResultData add(@RequestBody WxCUser wxCUser) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserController::add"); | |||
| //Assert.notNull(wxCUser.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCUserService.saveOrUpdate(wxCUser); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "用户管理-更新") | |||
| public ResultData update(@RequestBody WxCUser wxCUser) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserController::update"); | |||
| wxCUserService.saveOrUpdate(wxCUser); | |||
| return new ResultData(); | |||
| } | |||
| // @ApiOperation("根据id删除接口") | |||
| // @GetMapping("/del") | |||
| // @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| // @SystemControllerLog(description = "用户管理-删除") | |||
| // public ResultData delete(Long id) { | |||
| // logger.debug("[" + getIpAddr() + "] WxCUserController::delete"); | |||
| // wxCUserService.deleteById(id); | |||
| // return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| // } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "用户管理-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCUserService.getById(id,getTenantInfo().getTenantId())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,79 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCUserFrom; | |||
| import com.iformall.domain.vo.WxCUserFromVo; | |||
| import com.iformall.enums.EnumCUserFrom; | |||
| import com.iformall.service.WxCUserFromService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @RestController | |||
| @RequestMapping("wxCUserFrom") | |||
| public class WxCUserFromController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserFromService wxCUserFromService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "分享-列表") | |||
| public ResultData list(@ModelAttribute WxCUserFrom wxCUserFrom, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::list"); | |||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserFrom> page = wxCUserFromService.listAsPage(wxCUserFrom, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/visits") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "分享-列表") | |||
| public ResultData visits(@ModelAttribute WxCUserFromVo wxCUserFromVo,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById"); | |||
| if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo(); | |||
| if(wxCUserFromVo.getFromType() == null){ | |||
| wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||
| } | |||
| wxCUserFromVo.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserFromVo> page = wxCUserFromService.listAsVisitsPage(wxCUserFromVo, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "导出数据") | |||
| public void exportData(@ModelAttribute WxCUserFrom wxCUserFrom, HttpServletRequest request, HttpServletResponse response) { | |||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||
| wxCUserFromService.exportData(request, response, wxCUserFrom); | |||
| } | |||
| @GetMapping("/exportDataVisits") | |||
| @SystemControllerLog(description = "导出数据") | |||
| public void exportDataVisits(@ModelAttribute WxCUserFromVo wxCUserFromVo, HttpServletRequest request, HttpServletResponse response) { | |||
| if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo(); | |||
| wxCUserFromVo.updateTenantInfo(getTenantInfo()); | |||
| if(wxCUserFromVo.getFromType() == null){ | |||
| wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||
| } | |||
| wxCUserFromService.exportDataVisits(request, response, wxCUserFromVo); | |||
| } | |||
| } | |||
| @@ -0,0 +1,200 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.MerchantCreditRankingVo; | |||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.enums.EnumUserType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCreditHistoryService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Map; | |||
| import java.util.Objects; | |||
| @RestController | |||
| @RequestMapping("wxCreditHistory") | |||
| public class WxCreditHistoryController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxCreditHistoryService wxCreditHistoryService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "积分历史-列表") | |||
| public ResultData list(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::list"); | |||
| if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory(); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCreditHistory.updateTenantInfo(tenantInfo); | |||
| final PageInfo<WxCreditHistoryVo> page = wxCreditHistoryService.listAsPageMore(wxCreditHistory, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据商户ID和消费金额获取所增加积分 取data里credit的值") | |||
| @GetMapping("findByMerchantIdAndSpend") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "merchantId", value = "商户ID", dataType = "long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "spend", value = "消费金额", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "userId", value = "会员Id", dataType = "long", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "积分历史-根据商户ID和消费金额获取所增加积分") | |||
| public ResultData findByMerchantIdAndSpend(Long merchantId, String spendStr,Long userId) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findByMerchantIdAndSpend"); | |||
| if(Objects.isNull(merchantId)|| StringUtils.isEmpty(spendStr)||Objects.isNull(userId)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ; | |||
| } | |||
| try { | |||
| Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId) ; | |||
| return new ResultData(result); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "积分历史-新增接口") | |||
| public ResultData add(@RequestBody WxCreditHistory wxCreditHistory) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::add"); | |||
| MallUserInfo user = getUser(); | |||
| wxCreditHistory.setTenantId(user.getFinalTenantId()); | |||
| wxCreditHistory.setFinalTenantId(user.getFinalTenantId()); | |||
| wxCreditHistory.setOperatorId(user.getId()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.MALLUSER.getCode()); | |||
| String desc = ""; | |||
| if(wxCreditHistory.getCreditType().equals(EnumScoreType.SPEND_CREDIT.getCode())){ | |||
| WxMerchant byId = wxMerchantService.getById(wxCreditHistory.getMerchantId()); | |||
| desc = "管理端手动积分:消费商户["+byId.getName()+"] 消费金额["+wxCreditHistory.getSpendStr()+"元]"; | |||
| }else if(wxCreditHistory.getCreditType().equals(EnumScoreType.REDUCE_CREDIT.getCode())){ | |||
| desc = "管理端手动扣减积分"; | |||
| if(StringUtils.isNotBlank(wxCreditHistory.getChangePurpose())){ | |||
| desc = desc + "["+wxCreditHistory.getChangePurpose()+"]"; | |||
| } | |||
| }else{ | |||
| desc = "管理端("+user.getUsername()+")操作未知积分来源"; | |||
| } | |||
| wxCreditHistory.setChangePurpose(desc); | |||
| try { | |||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),getTenantInfo()) ; | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,getTenantInfo().getTenantId()); | |||
| return new ResultData(Result.SUCCESS, "操作成功", credit); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "积分历史-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCreditHistoryService.getById(id,getTenantInfo().getFinalTenantId())); | |||
| } | |||
| /** | |||
| * 根据A端设置的【每自然年末扣除前N年用户积分】规则,扣减用户积分 | |||
| * | |||
| * @return | |||
| */ | |||
| public ResultData clearCreditByYear() { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::clearCreditByYear"); | |||
| wxCreditHistoryService.clearCreditByYear(); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @GetMapping("exportData") | |||
| @SystemControllerLog(description = "积分历史-导出数据") | |||
| public void exportData(@ModelAttribute WxCreditHistory wxCreditHistory, HttpServletRequest request, HttpServletResponse response) { | |||
| wxCreditHistory.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCreditHistory.setFinalTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCreditHistoryService.exportData(request, response, wxCreditHistory); | |||
| } | |||
| @ApiOperation("积分统计概览") | |||
| @GetMapping("getCreditSummary") | |||
| @SystemControllerLog(description = "积分历史-积分统计概览") | |||
| public ResultData getCreditSummary(@ModelAttribute WxCreditHistory wxCreditHistory) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::getCreditSummary"); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCreditHistory.updateTenantInfo(tenantInfo); | |||
| return wxCreditHistoryService.getCreditSummary(wxCreditHistory); | |||
| } | |||
| @ApiOperation("积分清零计划") | |||
| @PostMapping("clearCreditByYear") | |||
| @SystemControllerLog(description = "积分清零计划") | |||
| @TenantIgnore | |||
| public ResultData clearCreditByYear(@RequestBody WxCreditHistory wxCreditHistory) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::clearCreditByYear"); | |||
| if(wxCreditHistory == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ; | |||
| } | |||
| if(StringUtils.isBlank(wxCreditHistory.getFinalTenantId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ; | |||
| } | |||
| wxCreditHistoryService.clearCreditByYear(wxCreditHistory); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @ApiOperation("积分清零计划 刷新商圈积分") | |||
| @PostMapping("syncClearCredit") | |||
| @SystemControllerLog(description = "刷新商圈积分") | |||
| @TenantIgnore | |||
| public ResultData syncClearCredit() { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::syncClearCredit"); | |||
| wxCreditHistoryService.syncClearCredit(getTenantInfo()); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @ApiOperation("门店排行榜") | |||
| @GetMapping("merchantCreditRanking") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "、-列表") | |||
| public ResultData merchantCreditRanking(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::merchantCreditRanking"); | |||
| if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory(); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCreditHistory.updateTenantInfo(tenantInfo); | |||
| final PageInfo<MerchantCreditRankingVo> page = wxCreditHistoryService.listAsPageMcrv(wxCreditHistory, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||