项目首次添加
This commit is contained in:
commit
540ead801e
5
.idea/.gitignore
vendored
Normal file
5
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
38
.idea/compiler.xml
Normal file
38
.idea/compiler.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="mall-admin" />
|
||||
<module name="mall-search" />
|
||||
<module name="mall-auth" />
|
||||
<module name="mall-account" />
|
||||
<module name="mall-im" />
|
||||
<module name="mall-common" />
|
||||
<module name="mall-shop" />
|
||||
<module name="mall-cms" />
|
||||
<module name="mall-gateway" />
|
||||
<module name="mall-pay" />
|
||||
<module name="mall-sns" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="mall-account" options="-parameters" />
|
||||
<module name="mall-admin" options="-parameters" />
|
||||
<module name="mall-auth" options="-parameters" />
|
||||
<module name="mall-cms" options="-parameters" />
|
||||
<module name="mall-common" options="-parameters" />
|
||||
<module name="mall-gateway" options="-parameters" />
|
||||
<module name="mall-im" options="-parameters" />
|
||||
<module name="mall-pay" options="-parameters" />
|
||||
<module name="mall-search" options="-parameters" />
|
||||
<module name="mall-shop" options="-parameters" />
|
||||
<module name="mall-sns" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/encodings.xml
Normal file
19
.idea/encodings.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/mall-account/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-admin/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-auth/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-cms/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-im/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-pay/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-pay/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-search/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-shop/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall-sns/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
40
.idea/jarRepositories.xml
Normal file
40
.idea/jarRepositories.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="ali-maven" />
|
||||
<option name="name" value="ali-maven" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/central" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="repo.maven.apache.org" />
|
||||
<option name="name" value="repo.maven.apache.org" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/misc.xml
Normal file
12
.idea/misc.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
194
mall-account/pom.xml
Normal file
194
mall-account/pom.xml
Normal file
@ -0,0 +1,194 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.suisung.mall</groupId>
|
||||
<artifactId>mall-account</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mall-account</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.suisung.mall</groupId>
|
||||
<artifactId>mall-suite</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.seata</groupId>
|
||||
<artifactId>seata-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.suisung.mall</groupId>
|
||||
<artifactId>mall-common</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.11.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!-- 邮箱 -->
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<!-- google登录 -->
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.32.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client-jetty</artifactId>
|
||||
<version>1.32.1</version>
|
||||
</dependency>
|
||||
<!-- rabbitMQ消息队列 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<!--本地环境 -->
|
||||
<profile>
|
||||
<id>local</id>
|
||||
<properties>
|
||||
<profiles.active>local</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<!--开发环境 -->
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<profiles.active>dev</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<!--测试环境 -->
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<properties>
|
||||
<profiles.active>test</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<!--uat环境 -->
|
||||
<profile>
|
||||
<id>uat</id>
|
||||
<properties>
|
||||
<profiles.active>uat</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<!--生产环境 -->
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<profiles.active>prod</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>application.yml</include>
|
||||
<include>bootstrap.yml</include>
|
||||
<include>bootstrap-${profiles.active}.yml</include>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- 指定仓库为阿里云与阿帕奇 -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>ali-maven</id>
|
||||
<url>https://maven.aliyun.com/repository/central</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo.maven.apache.org</id>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@ -0,0 +1,27 @@
|
||||
package com.suisung.mall.account;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
|
||||
/**
|
||||
* 应用启动入口
|
||||
*/
|
||||
@ComponentScan({"com.suisung.mall.common", "com.suisung.mall.core", "org.springframework.data.redis.core", "org.springframework.data.redis.core", "com.suisung.mall.account"})
|
||||
@EnableFeignClients(basePackages = {"com.suisung.mall.common.feignService"})
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
@EnableRabbit
|
||||
@EnableAsync
|
||||
public class MallAccountApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MallAccountApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.suisung.mall.common.utils.CookieUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 获取用户信息相关配置
|
||||
*/
|
||||
@Configuration
|
||||
public class CookieUtil extends CookieUtils {
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.suisung.mall.common.constant.AuthConstant;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class FeignConfig {
|
||||
|
||||
@Bean("requestInterceptor")
|
||||
public RequestInterceptor requestInterceptor() {
|
||||
return new RequestInterceptor() {
|
||||
@Override
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (requestAttributes == null) return;
|
||||
HttpServletRequest request = requestAttributes.getRequest();// 老请求
|
||||
String authorization = request.getHeader(AuthConstant.USER_TOKEN_HEADER);
|
||||
requestTemplate.header(AuthConstant.USER_TOKEN_HEADER, authorization);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
|
||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class I18nConfig implements WebMvcConfigurer {
|
||||
/**
|
||||
* session区域解析器
|
||||
* @return
|
||||
*/
|
||||
// @Bean
|
||||
// public LocaleResolver localeResolver() {
|
||||
// SessionLocaleResolver resolver = new SessionLocaleResolver();
|
||||
// //这里通过设置China.US可以进行中英文转化
|
||||
// resolver.setDefaultLocale(Locale.US);
|
||||
//
|
||||
// return resolver;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* cookie区域解析器
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
CookieLocaleResolver slr = new CookieLocaleResolver();
|
||||
//设置默认区域,
|
||||
slr.setCookieName("source_lang");
|
||||
slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
|
||||
slr.setCookieMaxAge(3600*30*12);//设置cookie有效期.
|
||||
|
||||
return slr;
|
||||
}
|
||||
|
||||
/*
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
FixedLocaleResolver slr = new FixedLocaleResolver();
|
||||
//设置默认区域,
|
||||
slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
|
||||
|
||||
return slr;
|
||||
}
|
||||
*/
|
||||
|
||||
@Bean
|
||||
public LocaleChangeInterceptor localeChangeInterceptor() {
|
||||
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
|
||||
// 设置请求地址的参数,默认为:locale
|
||||
//lci.setParamName(LocaleChangeInterceptor.DEFAULT_PARAM_NAME);
|
||||
lci.setParamName("source_lang");
|
||||
|
||||
return lci;
|
||||
}
|
||||
|
||||
/* 拦截器配置 */
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(localeChangeInterceptor());
|
||||
}
|
||||
|
||||
@Bean(name = "messageSource")
|
||||
public ResourceBundleMessageSource getMessageSource() throws Exception {
|
||||
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
|
||||
resourceBundleMessageSource.setDefaultEncoding("UTF-8");
|
||||
resourceBundleMessageSource.setBasenames("i18n/messages");
|
||||
return resourceBundleMessageSource;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* MyBatis配置类
|
||||
* Created by Xinze on 2019/4/8.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@MapperScan({"com.suisung.mall.account.mapper"})
|
||||
public class MyBatisConfig {
|
||||
/**
|
||||
* 分页插件和乐观锁插件配置
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
|
||||
// 添加分页插件
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
|
||||
// 添加乐观锁插件
|
||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,130 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.suisung.mall.common.constant.MqConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class RabbitMqConfig {
|
||||
|
||||
/**
|
||||
* 反序列化
|
||||
*
|
||||
*/
|
||||
@Bean
|
||||
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory){
|
||||
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
||||
factory.setConnectionFactory(connectionFactory);
|
||||
factory.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||
factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认交换机
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Exchange eventExchange() {
|
||||
return new TopicExchange(MqConstant.ACCOUNT_EXCHANGE, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户经验队列配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Queue experienceQueue() {
|
||||
Queue queue = new Queue(MqConstant.ACCOUNT_EXPERIENCE_QUEUE, true, false, false);
|
||||
return queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户经验路由键配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Binding experienceBinding() {
|
||||
return new Binding(MqConstant.ACCOUNT_EXPERIENCE_QUEUE,
|
||||
Binding.DestinationType.QUEUE,
|
||||
MqConstant.ACCOUNT_EXCHANGE,
|
||||
MqConstant.ACCOUNT_EXPERIENCE_ROUTING_KEY,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户详细信息队列配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Queue userInfoQueue() {
|
||||
Queue queue = new Queue(MqConstant.ACCOUNT_INFO_QUEUE, true, false, false);
|
||||
return queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户详细信息路由键配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Binding userInfoBinding() {
|
||||
return new Binding(MqConstant.ACCOUNT_INFO_QUEUE,
|
||||
Binding.DestinationType.QUEUE,
|
||||
MqConstant.ACCOUNT_EXCHANGE,
|
||||
MqConstant.ACCOUNT_INFO_ROUTING_KEY,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户角色信息队列配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Queue analyticsQueue() {
|
||||
Queue queue = new Queue(MqConstant.ACCOUNT_ANALYTICS_QUEUE, true, false, false);
|
||||
return queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户角色信息路由键配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Binding analyticsBinding() {
|
||||
return new Binding(MqConstant.ACCOUNT_ANALYTICS_QUEUE,
|
||||
Binding.DestinationType.QUEUE,
|
||||
MqConstant.ACCOUNT_EXCHANGE,
|
||||
MqConstant.ACCOUNT_ANALYTICS_ROUTING_KEY,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户升级信息队列配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Queue upgradeQueue() {
|
||||
Queue queue = new Queue(MqConstant.ACCOUNT_UPGRADE_QUEUE, true, false, false);
|
||||
return queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户升级信息路由键配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Binding upgradeBinding() {
|
||||
return new Binding(MqConstant.ACCOUNT_UPGRADE_QUEUE,
|
||||
Binding.DestinationType.QUEUE,
|
||||
MqConstant.ACCOUNT_EXCHANGE,
|
||||
MqConstant.ACCOUNT_UPGRADE_ROUTING_KEY,
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.suisung.mall.core.config.BaseRedisConfig;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Redis相关配置
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig extends BaseRedisConfig {
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.suisung.mall.common.config.BaseSwaggerConfig;
|
||||
import com.suisung.mall.common.domain.SwaggerProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* Swagger API文档相关配置
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig extends BaseSwaggerConfig {
|
||||
|
||||
@Override
|
||||
public SwaggerProperties swaggerProperties() {
|
||||
return SwaggerProperties.builder()
|
||||
.apiBasePackage("com.suisung.mall.account.controller")
|
||||
.title("mall 后台系统")
|
||||
.description("mall 后台相关接口文档")
|
||||
.contactName("suisung")
|
||||
.version("1.0")
|
||||
.enableSecurity(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
public class ThreadConfig {
|
||||
|
||||
@Bean
|
||||
public ThreadPoolExecutor threadPoolExecutor() {
|
||||
return new ThreadPoolExecutor(20, 200,
|
||||
10, TimeUnit.SECONDS, new LinkedBlockingDeque<>(1000000),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.suisung.mall.account.config;
|
||||
|
||||
import com.suisung.mall.common.config.BaseUserInfoConfig;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 获取用户信息相关配置
|
||||
*/
|
||||
@Configuration
|
||||
public class UserInfoConfig extends BaseUserInfoConfig {
|
||||
|
||||
}
|
||||
@ -0,0 +1,212 @@
|
||||
package com.suisung.mall.account.controller;
|
||||
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.AuthConstant;
|
||||
import com.suisung.mall.common.constant.RedisConstant;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.UserInfoService;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户基本信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-03-30
|
||||
*/
|
||||
@Api(tags = "用户基本信息表")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/login")
|
||||
public class LoginController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@ApiOperation(value = "登录以后返回token")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "user_account", value = "账号", paramType = "query", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "user_password", value = "密码", paramType = "query", required = false, dataType = "String"),
|
||||
})
|
||||
@RequestMapping(value = "/doLogin", method = RequestMethod.GET)
|
||||
public CommonResult doLogin(@RequestParam(name = "user_account", required = false) String user_account,
|
||||
@RequestParam(name = "user_password", required = false) String user_password) {
|
||||
if (StrUtil.isEmpty(user_account) || StrUtil.isEmpty(user_password)) {
|
||||
return CommonResult.failed(I18nUtil._("用户名或密码不能为空!"));
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", AuthConstant.MOBILE_CLIENT_ID);
|
||||
params.put("client_secret", AuthConstant.AUTHORITY_MOBILE_SECRET);
|
||||
params.put("grant_type", "password");
|
||||
params.put("username", user_account);
|
||||
params.put("password", user_password);
|
||||
|
||||
CommonResult result = accountUserBaseService.login(params);
|
||||
|
||||
//user_account判断是否手机号
|
||||
if (result.getStatus() != 200 && Validator.isNumber(user_account)) {
|
||||
user_account = "+86" + user_account;
|
||||
if (PhoneNumberUtils.isValidNumber(user_account)) {
|
||||
//尝试手机号绑定登录
|
||||
result = accountUserBaseService.doMobileBindLogin(user_account, user_password);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登录以后返回token")
|
||||
@RequestMapping(value = "/doPcLogin", method = RequestMethod.GET)
|
||||
public CommonResult doPcLogin(@RequestParam(name = "user_account", required = false) String user_account,
|
||||
@RequestParam(name = "user_password", required = false) String user_password,
|
||||
@RequestParam(name = "verify_code") String verificationCode,
|
||||
@RequestParam(name = "verify_token") String verify_token) {
|
||||
if (StrUtil.isEmpty(user_account) || StrUtil.isEmpty(user_password)) {
|
||||
return CommonResult.failed(I18nUtil._("用户名或密码不能为空!"));
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", AuthConstant.MOBILE_CLIENT_ID);
|
||||
params.put("client_secret", AuthConstant.AUTHORITY_MOBILE_SECRET);
|
||||
params.put("grant_type", "password");
|
||||
params.put("username", user_account);
|
||||
params.put("password", user_password);
|
||||
params.put("verify_code", RedisConstant.Verifycode_NameSpace + verify_token + verificationCode);
|
||||
CommonResult result = accountUserBaseService.login(params);
|
||||
|
||||
//user_account判断是否手机号
|
||||
if (result.getStatus() != 200 && Validator.isNumber(user_account)) {
|
||||
user_account = "+86" + user_account;
|
||||
if (PhoneNumberUtils.isValidNumber(user_account)) {
|
||||
//尝试手机号绑定登录
|
||||
result = accountUserBaseService.doMobileBindLogin(user_account, user_password);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/register", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public CommonResult register(
|
||||
@RequestParam(name = "user_account", required = false) String user_account,
|
||||
@RequestParam(name = "user_email", required = false) String user_email,
|
||||
@RequestParam(name = "user_mobile", required = false) String user_mobile,
|
||||
@RequestParam(name = "verify_code", required = false) String verify_code,
|
||||
@RequestParam(name = "rand_key", required = false) String rand_key,
|
||||
@RequestParam(name = "verify_token", required = false) String verify_token,
|
||||
@RequestParam(name = "user_password") String user_password
|
||||
) {
|
||||
Map info = new HashMap();
|
||||
info.put("user_account", user_account);
|
||||
info.put("user_email", user_email);
|
||||
info.put("user_password", user_password);
|
||||
info.put("user_mobile", user_mobile);
|
||||
info.put("verify_code", verify_code);
|
||||
info.put("verify_token", verify_token);
|
||||
info.put("rand_key", rand_key);
|
||||
|
||||
// 注册
|
||||
accountUserBaseService.register(info);
|
||||
|
||||
// 登录
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", AuthConstant.ADMIN_CLIENT_ID);
|
||||
params.put("client_secret", AuthConstant.AUTHORITY_ADMIN_SECRET);
|
||||
params.put("grant_type", "password");
|
||||
params.put("username", user_account);
|
||||
params.put("password", user_password);
|
||||
|
||||
return accountUserBaseService.login(params);
|
||||
}
|
||||
|
||||
@ApiOperation("退出登录")
|
||||
@RequestMapping(value = "/doLogout", method = RequestMethod.GET)
|
||||
public CommonResult doLogout() {
|
||||
return CommonResult.success(accountUserBaseService.logout());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前登录用户信息")
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public CommonResult info() {
|
||||
//todo 用户信息封装
|
||||
Map<String, Object> currentAdmin = accountUserBaseService.getUserInfo(userInfoService.getUserId());
|
||||
return CommonResult.success(currentAdmin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取互联登录配置信息,为移动端使用
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "读取互联登录配置信息,为移动端使用")
|
||||
@RequestMapping(value = "/getConnectInfo", method = RequestMethod.GET)
|
||||
public CommonResult getConnectInfo() {
|
||||
Map connectInfo = accountUserBaseService.getConnectInfo();
|
||||
return CommonResult.success(connectInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ifLogin", method = RequestMethod.GET)
|
||||
public CommonResult ifLogin() {
|
||||
return accountUserBaseService.ifLogin();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户协议")
|
||||
@RequestMapping(value = "/protocol", method = RequestMethod.GET)
|
||||
public CommonResult protocol(@RequestParam(name = "document_type", required = false) String document_type,
|
||||
@RequestParam(name = "state", defaultValue = "0") Integer state,
|
||||
@RequestParam(name = "protocols_key", required = false) String protocols_key,
|
||||
@RequestParam(name = "reg_protocols_description", required = false) String reg_protocols_description) {
|
||||
protocols_key = ObjectUtil.defaultIfNull(protocols_key, reg_protocols_description);
|
||||
return accountUserInfoService.protocol(document_type, protocols_key, state);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户密码")
|
||||
@RequestMapping(value = "/setNewPassword", method = RequestMethod.GET)
|
||||
public CommonResult setNewPassword(@RequestParam(name = "channel_verify_key") String channel_verify_key,
|
||||
@RequestParam(name = "pwd") String pwd,
|
||||
@RequestParam(name = "channel_verify_code") String channel_verify_code,
|
||||
@RequestParam(name = "channel") String channel) {
|
||||
return CommonResult.success(accountUserBaseService.setNewPassword(channel_verify_key, channel_verify_code, pwd, channel));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "手机验证码登录")
|
||||
@RequestMapping(value = "/doSmsLogin", method = RequestMethod.GET)
|
||||
public CommonResult doSmsLogin(@RequestParam(name = "user_mobile") String user_mobile,
|
||||
@RequestParam(name = "rand_key") String rand_key,
|
||||
@RequestParam(name = "verify_code") String verify_code) {
|
||||
return accountUserBaseService.doSmsLogin(user_mobile, rand_key, verify_code);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "APP互联登录")
|
||||
@RequestMapping(value = "/doAppConnectLogin", method = RequestMethod.GET)
|
||||
public CommonResult doAppConnectLogin(@RequestParam(name = "bind_name") String bind_name,
|
||||
@RequestParam(name = "code") String code) {
|
||||
return CommonResult.success(accountUserBaseService.doAppConnectLogin(bind_name, code));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,227 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.suisung.mall.account.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.account.service.impl.AccountBaseConfigServiceImpl;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.RedisConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.feignService.AdminService;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseConfig;
|
||||
import com.suisung.mall.common.support.Auth;
|
||||
import com.suisung.mall.core.consts.ConstantRedis;
|
||||
import com.suisung.mall.core.web.model.SmsDto;
|
||||
import com.suisung.mall.core.web.service.CloundService;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统参数设置表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
@Api(tags = "系统参数设置表")
|
||||
@RestController("admin-account-base-config")
|
||||
@RequestMapping("/admin/account/account-base-config")
|
||||
public class AccountBaseConfigController {
|
||||
|
||||
@Resource
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private AdminService adminService;
|
||||
|
||||
@Autowired
|
||||
private CloundService cloundService;
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "系统参数设置", notes = "系统参数设置")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountBaseConfig accountBaseConfig) {
|
||||
Map<String, AccountBaseConfig> configMap = AccountBaseConfigServiceImpl.configMap;
|
||||
List<AccountBaseConfig> list = Convert.toList(AccountBaseConfig.class, configMap.values());
|
||||
|
||||
String config_type = accountBaseConfig.getConfig_type();
|
||||
if (StrUtil.isNotBlank(config_type)) {
|
||||
list = list.stream().filter(config -> config.getConfig_type().equals(config_type)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
list = list.stream().sorted(Comparator.comparing(AccountBaseConfig::getConfig_key)).collect(Collectors.toList());
|
||||
Map<String, String> map = list.stream().collect(Collectors.toMap(AccountBaseConfig::getConfig_key, AccountBaseConfig::getConfig_value, (k1, k2) -> k2));
|
||||
|
||||
return CommonResult.success(map);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "系统参数设置表-通过config_key查询", notes = "系统参数设置表-通过config_key查询")
|
||||
@RequestMapping(value = "/get", method = RequestMethod.GET)
|
||||
public CommonResult get(@RequestParam(name = "config_key") String config_key) {
|
||||
AccountBaseConfig accountBaseConfig = accountBaseConfigService.get(config_key);
|
||||
return CommonResult.success(accountBaseConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "系统参数设置表-编辑", notes = "系统参数设置表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(String param) {
|
||||
if (StrUtil.isBlank(param)) return CommonResult.failed();
|
||||
Map map = JSONUtil.toBean(param, Map.class);
|
||||
List<AccountBaseConfig> configs = new ArrayList<>(map.size());
|
||||
map.forEach((k, v) -> {
|
||||
AccountBaseConfig config = new AccountBaseConfig();
|
||||
config.setConfig_key((String) k);
|
||||
config.setConfig_value(String.valueOf(v));
|
||||
configs.add(config);
|
||||
});
|
||||
boolean flag = accountBaseConfigService.saveOrUpdate(configs);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级表-平台-分页列表查询", notes = "用户等级表-平台-分页列表查询")
|
||||
@RequestMapping(value = "/languageList", method = RequestMethod.GET)
|
||||
public CommonResult languageList(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
Map data = accountBaseConfigService.languageList(pageNum, pageSize);
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "系统参数设置表-编辑", notes = "系统参数设置表-编辑")
|
||||
@RequestMapping(value = "/editLanguage", method = RequestMethod.POST)
|
||||
public CommonResult editLanguage(@RequestParam(name = "language_id") Integer language_id,
|
||||
@RequestParam(name = "language_status") Integer language_status) {
|
||||
boolean flag = accountBaseConfigService.editLanguage(language_id, language_status);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过config_key删除
|
||||
*
|
||||
* @param config_key
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "系统参数设置表-通过config_key删除", notes = "系统参数设置表-通过config_key删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "config_key") String config_key) {
|
||||
boolean flag = accountBaseConfigService.remove(config_key);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param config_keys
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "系统参数设置表-批量删除", notes = "系统参数设置表-批量删除")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.POST)
|
||||
public CommonResult deleteBatch(@RequestParam(name = "config_keys") String config_keys) {
|
||||
boolean flag = this.accountBaseConfigService.remove(Arrays.asList(config_keys.split(",")));
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "清理系统缓存", notes = "安全清理缓存接口,避免清理部分可能需要持久化的数据")
|
||||
@RequestMapping(value = "/cleanCache", method = RequestMethod.POST)
|
||||
public CommonResult cleanCache(@Auth(isPlatform = true) UserDto user) {
|
||||
Set<String> c_keys = redisService.keys(ConstantRedis.Cache_NameSpace + "*");
|
||||
Set<String> b_keys = redisService.keys("base:*");
|
||||
Set<String> s_keys = redisService.keys("store:*");
|
||||
Set<String> roles_keys = redisService.keys("auth:resourceRolesMap");
|
||||
Set<String> config_cache_key = redisService.keys(RedisConstant.Config_Cache_Key);
|
||||
Set<String> config_cache_version = redisService.keys(RedisConstant.Config_Cache_Version);
|
||||
|
||||
|
||||
Set<String> store_cate_keys = redisService.keys("storeCate:*");
|
||||
Set<String> productCategoryList = redisService.keys("productCategoryList:*");
|
||||
Set<String> product_cate_keys = redisService.keys("productCategoryTree:*");
|
||||
|
||||
redisService.del(c_keys);
|
||||
redisService.del(b_keys);
|
||||
redisService.del(s_keys);
|
||||
redisService.del(roles_keys);
|
||||
redisService.del(config_cache_key);
|
||||
redisService.del(config_cache_version);
|
||||
|
||||
redisService.del(store_cate_keys);
|
||||
redisService.del(productCategoryList);
|
||||
redisService.del(product_cate_keys);
|
||||
|
||||
AccountBaseConfigServiceImpl.configMap = null;
|
||||
|
||||
CommonResult res = adminService.initResourceRolesMap();
|
||||
res.checkFenResult();
|
||||
return CommonResult.success(null, "缓存清理成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "消息记录-分页列表查询", notes = "消息记录-分页列表查询")
|
||||
@RequestMapping(value = "/smsRecord", method = RequestMethod.GET)
|
||||
public CommonResult smsRecord(@RequestParam(name = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(name = "rows", defaultValue = "10") Integer rows) {
|
||||
String serviceUserId = accountBaseConfigService.getConfig("service_user_id", "");
|
||||
String serviceAppKey = accountBaseConfigService.getConfig("service_app_key", "");
|
||||
|
||||
//从云服务器读取
|
||||
SmsDto smsDto = new SmsDto();
|
||||
smsDto.setServiceUserId(serviceUserId);
|
||||
smsDto.setServiceAppKey(serviceAppKey);
|
||||
|
||||
Map data = null;
|
||||
try {
|
||||
data = cloundService.listSmsRecords(smsDto, page, rows);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
List<Map> items = Convert.toList(Map.class, data.get("items"));
|
||||
|
||||
if (CollectionUtil.isEmpty(items)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
for (Map item : items) {
|
||||
String sms_res = Convert.toStr(item.get("sms_res"));
|
||||
|
||||
if (StrUtil.isEmpty(sms_res)) {
|
||||
item.remove("sms_res");
|
||||
}
|
||||
}
|
||||
data.put("items", items);
|
||||
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.service.AccountBaseUserLevelService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.AccountService;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseUserLevel;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级表-平台 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
@Api(tags = "用户等级表-平台")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-base-user-level")
|
||||
public class AccountBaseUserLevelController {
|
||||
|
||||
@Autowired
|
||||
private AccountBaseUserLevelService accountBaseUserLevelService;
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param accountBaseUserLevel
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级表-平台-分页列表查询", notes = "用户等级表-平台-分页列表查询")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountBaseUserLevel accountBaseUserLevel,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize) {
|
||||
|
||||
QueryWrapper<AccountBaseUserLevel> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("user_level_id");
|
||||
|
||||
IPage<AccountBaseUserLevel> data = accountBaseUserLevelService.lists(queryWrapper, pageNum, pageSize);
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param accountBaseUserLevel
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级表-平台-编辑", notes = "用户等级表-平台-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountBaseUserLevel accountBaseUserLevel) {
|
||||
boolean flag = accountBaseUserLevelService.saveOrUpdate(accountBaseUserLevel);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过user_level_id删除
|
||||
*
|
||||
* @param user_level_id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级表-平台-通过user_level_id删除", notes = "用户等级表-平台-通过user_level_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "user_level_id") String user_level_id) {
|
||||
|
||||
Boolean isUse = accountService.isUseLevel(user_level_id);
|
||||
if (isUse) {
|
||||
throw new ApiException(I18nUtil._("该等级正在被使用中!"));
|
||||
}
|
||||
return CommonResult.success(accountBaseUserLevelService.remove(user_level_id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,435 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.service.*;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.*;
|
||||
import com.suisung.mall.common.utils.MybatisPlusQueryUtil;
|
||||
import io.seata.core.context.RootContext;
|
||||
import io.seata.core.exception.TransactionException;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import io.seata.tm.api.GlobalTransactionContext;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "远程调用使用接口")
|
||||
@RestController()
|
||||
@RequestMapping("/admin/account/accountController")
|
||||
public class AccountController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@Autowired
|
||||
AccountUserAnalyticsService accountUserAnalyticsService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserLoginService accountUserLoginService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseUserLevelService accountBaseUserLevelService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseRoleLevelService accountBaseRoleLevelService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserSnsService accountUserSnsService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserBindConnectService accountUserBindConnectService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserChainService accountUserChainService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserTypeService accountUserTypeService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccountController.class);
|
||||
|
||||
@ApiOperation(value = "用户基本信息", notes = "用户基本信息")
|
||||
@RequestMapping(value = "/getUserBase", method = RequestMethod.GET)
|
||||
public AccountUserBase getUserBase(@RequestParam(name = "user_id") Integer user_id) {
|
||||
AccountUserBase accountUserBase = accountUserBaseService.get(user_id);
|
||||
// 清除敏感信息
|
||||
if (ObjectUtil.isNotNull(accountUserBase)) {
|
||||
accountUserBase.setUser_password("");
|
||||
accountUserBase.setUser_salt("");
|
||||
accountUserBase.setUser_token("");
|
||||
|
||||
}
|
||||
return accountUserBase;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "用户最后登录日志", notes = "用户最后登录日志")
|
||||
@RequestMapping(value = "/getUserLoginInfo", method = RequestMethod.GET)
|
||||
public AccountUserLogin getUserLoginInfo(@RequestParam(name = "user_id") Integer user_id) {
|
||||
AccountUserLogin accountUserLogin = accountUserLoginService.get(user_id);
|
||||
// 清除敏感信息
|
||||
if (ObjectUtil.isNotNull(accountUserLogin)) {
|
||||
}
|
||||
|
||||
return accountUserLogin;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "判断用户是否存在", notes = "判断用户是否存在")
|
||||
@RequestMapping(value = "/findUserBaseUserAccount", method = RequestMethod.GET)
|
||||
public CommonResult findUserBaseUserAccount(@RequestParam(name = "user_account") String user_account) {
|
||||
QueryWrapper<AccountUserBase> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("user_account", user_account);
|
||||
AccountUserBase accountUserBase = accountUserBaseService.findOne(wrapper);
|
||||
// 清除敏感信息
|
||||
if (ObjectUtil.isNotNull(accountUserBase)) {
|
||||
accountUserBase.setUser_password("");
|
||||
accountUserBase.setUser_salt("");
|
||||
accountUserBase.setUser_token("");
|
||||
}
|
||||
return CommonResult.success(accountUserBase);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户基本信息", notes = "用户基本信息")
|
||||
@RequestMapping(value = "/getUserInfo", method = RequestMethod.GET)
|
||||
public AccountUserInfo getUserInfo(@RequestParam(name = "user_id") Integer user_id) {
|
||||
return accountUserInfoService.get(user_id);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getUserInfoList", method = RequestMethod.GET)
|
||||
public List<AccountUserInfo> getUserInfoList(@RequestParam(name = "user_ids") List<Integer> user_ids) {
|
||||
return accountUserInfoService.gets(user_ids);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUser", method = RequestMethod.POST)
|
||||
public List<Map> getUser(@RequestBody List<Integer> user_ids) {
|
||||
return accountUserInfoService.getUser(user_ids);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户基本信息", notes = "用户基本信息")
|
||||
@RequestMapping(value = "/getUserBaseList", method = RequestMethod.GET)
|
||||
public List<AccountUserBase> getUserBaseList(@RequestParam(name = "user_ids") List<Integer> user_ids) {
|
||||
return accountUserBaseService.gets(user_ids);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据主键查询等级", notes = "根据主键查询等级")
|
||||
@RequestMapping(value = "/getUserLevel", method = RequestMethod.GET)
|
||||
public AccountBaseUserLevel getUserLevel(@RequestParam(name = "user_level_id") Integer user_level_id) {
|
||||
return accountBaseUserLevelService.get(user_level_id);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询等级", notes = "查询等级")
|
||||
@RequestMapping(value = "/getUserLevelList", method = RequestMethod.GET)
|
||||
public List<AccountBaseUserLevel> getUserLevelList() {
|
||||
return accountBaseUserLevelService.find(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* rows中添加用户信息
|
||||
*
|
||||
* @param row
|
||||
* @param fix_user_account 是否将user_account一起读取
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/fixUserAvatar", method = RequestMethod.POST)
|
||||
public Map fixUserAvatar(@RequestBody Map row,
|
||||
@RequestParam(name = "fix_user_account", defaultValue = "false") Boolean fix_user_account) {
|
||||
return accountUserBaseService.fixUserAvatar(row, fix_user_account);
|
||||
}
|
||||
|
||||
/**
|
||||
* rows中添加用户信息
|
||||
*
|
||||
* @param rows
|
||||
* @param fix_user_account 是否将user_account一起读取
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/fixUserAvatars", method = RequestMethod.POST)
|
||||
public List<Map> fixUserAvatar(@RequestBody List<Map> rows,
|
||||
@RequestParam(name = "fix_user_account", defaultValue = "false") Boolean fix_user_account) {
|
||||
return accountUserBaseService.fixUserAvatar(rows, fix_user_account);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据主键查询角色等级", notes = "根据主键查询角色等级")
|
||||
@RequestMapping(value = "/findRoleLevel", method = RequestMethod.GET)
|
||||
public List<AccountBaseRoleLevel> findRoleLevel() {
|
||||
return accountBaseRoleLevelService.find(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户基本信息", notes = "用户基本信息")
|
||||
@RequestMapping(value = "/getUserBaseInfoSns", method = RequestMethod.GET)
|
||||
public Map getUserBaseInfoSns(@RequestParam(name = "user_id") Integer user_id) {
|
||||
return accountUserBaseService.getUserBaseInfoSns(user_id);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户基本信息", notes = "用户基本信息")
|
||||
@RequestMapping(value = "/getsAccountUserSns", method = RequestMethod.GET)
|
||||
public List<AccountUserSns> getsAccountUserSns(@RequestParam(name = "user_ids") List<Integer> user_ids) {
|
||||
return accountUserSnsService.gets(user_ids);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户SNS信息", notes = "用户SNS信息")
|
||||
@RequestMapping(value = "/getAccountUserSns", method = RequestMethod.GET)
|
||||
public AccountUserSns getAccountUserSns(@RequestParam(name = "user_id") Integer user_id) {
|
||||
return accountUserSnsService.get(user_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/checkUpdateUserLevel", method = RequestMethod.POST)
|
||||
@GlobalTransactional
|
||||
public CommonResult checkUpdateUserLevel(
|
||||
@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_exp_total") BigDecimal user_exp_total,
|
||||
@RequestParam(name = "user_fans_total") Integer user_fans_total,
|
||||
@RequestParam(name = "user_spend_total") BigDecimal user_spend_total,
|
||||
@RequestParam(name = "user_store_total") Integer user_store_total,
|
||||
@RequestParam(name = "user_fans_vip_total", defaultValue = "0") Integer user_fans_vip_total,
|
||||
@RequestParam(name = "user_fans_team_total", defaultValue = "0") Integer user_fans_team_total) {
|
||||
return CommonResult.success(accountUserInfoService.checkUpdateUserLevel(user_id, user_exp_total, user_fans_total, user_spend_total, user_store_total, user_fans_vip_total, user_fans_team_total));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/checkUpdateUserLevelById", method = RequestMethod.POST)
|
||||
public CommonResult checkUpdateUserLevelById(
|
||||
@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_exp_total") BigDecimal user_exp_total,
|
||||
@RequestParam(name = "user_fans_total") Integer user_fans_total) {
|
||||
AccountUserAnalytics analytics = accountUserAnalyticsService.get(user_id);
|
||||
return CommonResult.success(accountUserInfoService.checkUpdateUserLevel(user_id, user_exp_total, user_fans_total, analytics.getUser_spend(), 0, 0, 0));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户SNS信息", notes = "用户SNS信息")
|
||||
@RequestMapping(value = "/getBind", method = RequestMethod.GET)
|
||||
public Map getBind(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "bind_type") Integer bind_type) {
|
||||
return accountUserBindConnectService.getBind(user_id, bind_type);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserInfoAndBase", method = RequestMethod.GET)
|
||||
public Map getUserInfoAndBase(@RequestParam(name = "user_id") Integer user_id) {
|
||||
return accountUserBaseService.getUserInfoAndBase(user_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserInfoAndBaseList", method = RequestMethod.GET)
|
||||
public List<Map> getUserInfoAndBaseMap(@RequestParam(name = "user_ids") List<Integer> user_ids) {
|
||||
return accountUserBaseService.getUserInfoAndBaseMap(user_ids);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getListBase", method = RequestMethod.POST)
|
||||
public Map getListBase(@RequestBody Map wrapper,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if (ObjectUtil.isNotNull(wrapper.get("user_account"))) {
|
||||
queryWrapper.like("user_account", Convert.toStr(wrapper.get("user_account")));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(wrapper.get("user_nickname"))) {
|
||||
queryWrapper.like("user_nickname", Convert.toStr(wrapper.get("user_nickname")));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(wrapper.get("user_is_admin"))) {
|
||||
queryWrapper.like("user_is_admin", Convert.toInt(wrapper.get("user_is_admin")));
|
||||
}
|
||||
if (Convert.toBool(wrapper.get("user_paotuiers"))) {
|
||||
queryWrapper.eq("user_id", 0);
|
||||
} else {
|
||||
List<Integer> user_ids = (List<Integer>) wrapper.get("user_id");
|
||||
queryWrapper.in("user_id", user_ids);
|
||||
}
|
||||
|
||||
Map data = accountUserInfoService.getLists(queryWrapper, pageNum, pageSize);
|
||||
String user_nickname = Convert.toStr(wrapper.get("user_nickname"));
|
||||
if (ObjectUtil.isNotNull(user_nickname) && ObjectUtil.isEmpty(data) && StringUtils.isNumeric(user_nickname)) {
|
||||
|
||||
QueryWrapper<AccountUserBase> baseQueryWrapper = new QueryWrapper<>();
|
||||
baseQueryWrapper.eq("user_id", user_nickname);
|
||||
data = accountUserInfoService.getLists(baseQueryWrapper, pageNum, pageSize);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findOneUserLevel", method = RequestMethod.POST)
|
||||
public AccountBaseUserLevel findOneUserLevel(@RequestBody Map<String, Object> query) {
|
||||
QueryWrapper<AccountBaseUserLevel> queryWrapper = MybatisPlusQueryUtil.getQueryWrapper(AccountBaseUserLevel.class, query);
|
||||
return accountBaseUserLevelService.findOne(queryWrapper);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveOrUpdateUserInfo", method = RequestMethod.POST)
|
||||
public boolean saveOrUpdateUserInfo(@RequestBody AccountUserInfo accountUserInfo) {
|
||||
return accountUserInfoService.saveOrUpdate(accountUserInfo);
|
||||
}
|
||||
|
||||
@GlobalTransactional
|
||||
@RequestMapping(value = "/saveAndCheckUpdateUserLevel", method = RequestMethod.POST)
|
||||
public boolean saveAndCheckUpdateUserLevel(@RequestBody AccountUserSns accountUserSns) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
flag = accountUserInfoService.saveAndCheckUpdateUserLevel(accountUserSns);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
GlobalTransactionContext.reload(RootContext.getXID()).rollback();
|
||||
} catch (TransactionException ex) {
|
||||
logger.error("seata 事务异常!");
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findAccountUserBase", method = RequestMethod.POST)
|
||||
public CommonResult findAccountUserBase(@RequestBody Map params) {
|
||||
List<AccountUserBase> data = accountUserBaseService.find(MybatisPlusQueryUtil.getQueryWrapper(AccountUserBase.class, params));
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||
public CommonResult register(@RequestBody Map userInfo) {
|
||||
return CommonResult.success(accountUserBaseService.register(userInfo));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getAccountUserChain", method = RequestMethod.GET)
|
||||
public CommonResult getAccountUserChain(@RequestParam(name = "user_id") Integer user_id) {
|
||||
return CommonResult.success(accountUserChainService.get(user_id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveOrUpdateAccountUserChain", method = RequestMethod.POST)
|
||||
public AccountUserChain saveOrUpdateAccountUserChain(@RequestBody AccountUserChain chain) {
|
||||
if (!accountUserChainService.saveOrUpdate(chain)) return null;
|
||||
return chain;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveOrUpdateAccountUserSns", method = RequestMethod.POST)
|
||||
public boolean saveOrUpdateAccountUserSns(@RequestBody AccountUserSns sns) {
|
||||
try {
|
||||
return accountUserSnsService.saveOrUpdate(sns);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/userInfoListPage", method = RequestMethod.POST)
|
||||
public Map userInfoListPage(@RequestBody Map params,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
QueryWrapper queryWrapper = MybatisPlusQueryUtil.getQueryWrapper(AccountUserInfo.class, params);
|
||||
return accountUserInfoService.getLists(queryWrapper, pageNum, pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveOrUpdateUserAnalytics", method = RequestMethod.POST)
|
||||
public boolean saveOrUpdateUserAnalytics(@RequestBody AccountUserAnalytics accountUserAnalytics) {
|
||||
return accountUserAnalyticsService.saveOrUpdate(accountUserAnalytics);
|
||||
}
|
||||
|
||||
// 该方法不能走缓存,该方法查询的数据是事务没提交的数据(IBaseService 接口下的查询都走缓存)
|
||||
@RequestMapping(value = "/getUserAnalytics", method = RequestMethod.GET)
|
||||
public AccountUserAnalytics getUserAnalytics(@RequestParam(name = "user_id") Integer user_id) {
|
||||
return accountUserAnalyticsService.getUserAnalyticsByUserId(user_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveOrUpdateUserBase", method = RequestMethod.POST)
|
||||
public boolean saveOrUpdateUserBase(@RequestBody AccountUserBase accountUserBase) {
|
||||
return accountUserBaseService.saveOrUpdate(accountUserBase);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/editPassword", method = RequestMethod.POST)
|
||||
public CommonResult editPassword(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_password") String user_password) {
|
||||
return CommonResult.success(accountUserBaseService.editPassword(user_id, user_password));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/editJbState", method = RequestMethod.POST)
|
||||
public boolean editJbState(
|
||||
@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_password") Integer user_jb_state) {
|
||||
return accountUserInfoService.editJbState(user_id, user_jb_state);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/editState", method = RequestMethod.POST)
|
||||
public boolean editState(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_state") Integer user_state) {
|
||||
return accountUserBaseService.editState(user_id, user_state);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserRegTimeline", method = RequestMethod.GET)
|
||||
public List<Map> getUserRegTimeline(@RequestParam(name = "day", defaultValue = "7") Integer day) {
|
||||
return accountUserLoginService.getUserDate(day);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserNum", method = RequestMethod.GET)
|
||||
public Long getUserNum() {
|
||||
return (Long) accountUserBaseService.getUserList(1, 1).get("records");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserCertificationNum", method = RequestMethod.GET)
|
||||
public long getUserCertificationNum() {
|
||||
return accountUserInfoService.count(new QueryWrapper<AccountUserInfo>()
|
||||
.eq("user_certification", 2));
|
||||
}
|
||||
|
||||
@GlobalTransactional
|
||||
@RequestMapping(value = "/editEmployeeInfo", method = RequestMethod.POST)
|
||||
public CommonResult editEmployeeInfo(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestBody Map userInfo) {
|
||||
return CommonResult.success(accountUserBaseService.editEmployeeInfo(user_id, userInfo));
|
||||
}
|
||||
|
||||
@GlobalTransactional
|
||||
@RequestMapping(value = "/experience", method = RequestMethod.POST)
|
||||
public CommonResult experience(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "exp") BigDecimal exp,
|
||||
@RequestParam(name = "exp_type_id") Integer exp_type_id,
|
||||
@RequestParam(name = "desc") String desc) {
|
||||
return CommonResult.success(accountUserInfoService.experience(user_id, exp, exp_type_id, desc));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/isUseLevel", method = RequestMethod.GET)
|
||||
public boolean isUseLevel(@RequestParam(name = "user_level_id") String user_level_id) {
|
||||
QueryWrapper<AccountUserInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_level_id", user_level_id);
|
||||
return accountUserInfoService.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateUserFriendNum", method = RequestMethod.GET)
|
||||
public boolean updateUserFriendNum(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "friend_id") Integer friend_id,
|
||||
@RequestParam(name = "num") Integer num) {
|
||||
return accountUserSnsService.updateUserFriendNum(user_id, friend_id, num);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getAccountUserType", method = RequestMethod.GET)
|
||||
public AccountUserType getAccountUserType(@RequestParam(name = "user_type_id") Integer user_type_id) {
|
||||
return accountUserTypeService.get(user_type_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findOneUserConnect", method = RequestMethod.POST)
|
||||
public AccountUserBindConnect findOneUserConnect(@RequestBody Map queryParams) {
|
||||
return accountUserBindConnectService.findOne(MybatisPlusQueryUtil.getQueryWrapper(AccountUserBindConnect.class, queryParams));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getByNickname", method = RequestMethod.GET)
|
||||
public AccountUserBase getByNickname(@RequestParam(name = "nickname") String nickname) {
|
||||
return accountUserBaseService.getByNickname(nickname);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserBaseByQueryMap", method = RequestMethod.POST)
|
||||
public List<AccountUserBase> getUserBaseByQueryMap(@RequestBody Map queryParams) {
|
||||
return accountUserBaseService.find(MybatisPlusQueryUtil.getQueryWrapper(AccountUserBase.class, queryParams));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUserInfoByQueryMap", method = RequestMethod.POST)
|
||||
public List<AccountUserInfo> getUserInfoByQueryMap(@RequestBody Map queryParams) {
|
||||
return accountUserInfoService.find(MybatisPlusQueryUtil.getQueryWrapper(AccountUserBase.class, queryParams));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "account服务 开放接口")
|
||||
@RestController()
|
||||
@RequestMapping("/admin/account/open")
|
||||
public class AccountOpenController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@ApiOperation(value = "手机号注册", notes = "手机号注册")
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||
public CommonResult register(@RequestParam(value = "user_mobile") String user_mobile,
|
||||
@RequestParam(value = "user_password") String user_password) {
|
||||
Map<String, Object> userInfo = new HashMap<>();
|
||||
userInfo.put("user_mobile", user_mobile);
|
||||
userInfo.put("user_password", user_password);
|
||||
return CommonResult.success(accountUserBaseService.register(userInfo));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,167 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.account.service.AccountUserLoginService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.AuthConstant;
|
||||
import com.suisung.mall.common.constant.RedisConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiUserException;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户基本信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-03-30
|
||||
*/
|
||||
@Api(tags = "用户基本信息表")
|
||||
@RestController("admin-account-user-base")
|
||||
@RequestMapping("/admin/account/account-user-base")
|
||||
public class AccountUserBaseController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserLoginService accountUserLoginService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*/
|
||||
@RequestMapping(value = "/getUserDate", method = RequestMethod.GET)
|
||||
public CommonResult getUserDate(@RequestParam(name = "days", defaultValue = "7") Integer days) {
|
||||
return CommonResult.success(accountUserLoginService.getUserDate(days));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户基本信息", notes = "用户基本信息")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
Map result = accountUserBaseService.getUserList(pageNum, pageSize);
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "用户基本信息表-条件列表查询", notes = "用户基本信息表-条件列表查询")
|
||||
@RequestMapping(value = "/getAccounts", method = RequestMethod.GET)
|
||||
public CommonResult getAccounts(AccountUserBase accountUserBase) {
|
||||
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
|
||||
String user_nickname = accountUserBase.getUser_nickname();
|
||||
if (StrUtil.isNotBlank(user_nickname)) queryWrapper.like("user_nickname", user_nickname);
|
||||
queryWrapper.orderByAsc("user_id");
|
||||
List<AccountUserBase> userBaseList = accountUserBaseService.find(queryWrapper);
|
||||
|
||||
List<Map<String, Object>> baseRes = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(userBaseList)) {
|
||||
baseRes = userBaseList.stream().map(base -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("user_id", base.getUser_id());
|
||||
map.put("user_nickname", base.getUser_nickname());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return CommonResult.success(baseRes);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户基本信息", notes = "修改用户基本信息")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit() {
|
||||
return accountUserBaseService.editUser();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户基本信息表-通过user_id删除", notes = "用户基本信息表-通过user_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@GlobalTransactional
|
||||
public CommonResult delete(@RequestParam(name = "user_ids") String user_ids) {
|
||||
return CommonResult.success(accountUserBaseService.removeUser(Convert.toList(Integer.class, user_ids)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取当前登录用户信息")
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public CommonResult info() {
|
||||
UserDto user = getCurrentUser();
|
||||
Integer user_id = user.getId();
|
||||
Integer site_id = user.getSite_id();
|
||||
if (user_id == null) {
|
||||
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||
}
|
||||
Map currentAdmin = accountUserBaseService.getUserInfo(user_id);
|
||||
currentAdmin.put("site_id", site_id);
|
||||
currentAdmin.put("config", accountBaseConfigService.getSystemConfig());
|
||||
return CommonResult.success(currentAdmin);
|
||||
}
|
||||
|
||||
@ApiOperation("根据用户名获取通用用户信息")
|
||||
@RequestMapping(value = "/loadByUsername", method = RequestMethod.GET)
|
||||
public UserDto loadUserByUsername(@RequestParam String user_account) {
|
||||
return accountUserBaseService.loadUserByUsername(user_account);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登录以后返回token") // app 和 pc 的 登录最好分开,这样容易区分从哪个端进来,方便处理逻辑(验证码)
|
||||
@RequestMapping(value = "/doLogin", method = RequestMethod.POST)
|
||||
public CommonResult doLogin(@RequestParam(name = "user_account", required = false) String user_account,
|
||||
@RequestParam(name = "user_password", required = false) String user_password,
|
||||
@RequestParam(name = "verify_code") String verificationCode,
|
||||
@RequestParam(name = "verify_token") String verify_token) {
|
||||
if (StrUtil.isEmpty(user_account) || StrUtil.isEmpty(user_password)) {
|
||||
return CommonResult.failed(I18nUtil._("用户名或密码不能为空!"));
|
||||
}
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", AuthConstant.ADMIN_CLIENT_ID);
|
||||
params.put("client_secret", AuthConstant.AUTHORITY_ADMIN_SECRET);
|
||||
params.put("grant_type", "password");
|
||||
params.put("username", user_account);
|
||||
params.put("password", user_password);
|
||||
params.put("verify_code", RedisConstant.Verifycode_NameSpace + verify_token + verificationCode);
|
||||
CommonResult result = accountUserBaseService.login(params);
|
||||
|
||||
//user_account判断是否手机号
|
||||
if (result.getStatus() != 200 && Validator.isNumber(user_account)) {
|
||||
user_account = "+86" + user_account;
|
||||
if (PhoneNumberUtils.isValidNumber(user_account)) {
|
||||
//尝试手机号绑定登录
|
||||
result = accountUserBaseService.doMobileBindLogin(user_account, user_password);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("退出登录")
|
||||
@RequestMapping(value = "/logout", method = RequestMethod.GET)
|
||||
public CommonResult logout() {
|
||||
return CommonResult.success(accountUserBaseService.logout());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.service.AccountUserBindConnectService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户绑定表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
@Api(tags = "用户绑定表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-bind-connect")
|
||||
public class AccountUserBindConnectController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBindConnectService accountUserBindConnectService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param accountUserBindConnect
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户绑定", notes = "用户绑定")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserBindConnect accountUserBindConnect,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("bind_id");
|
||||
|
||||
IPage<AccountUserBindConnect> pageList = accountUserBindConnectService.lists(queryWrapper, pageNum, pageSize);
|
||||
return CommonResult.success(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param accountUserBindConnect
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户绑定表-编辑", notes = "用户绑定表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountUserBindConnect accountUserBindConnect) {
|
||||
boolean flag = accountUserBindConnectService.saveOrUpdate(accountUserBindConnect);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过bind_id删除
|
||||
*
|
||||
* @param bind_id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户绑定表-通过bind_id删除", notes = "用户绑定表-通过bind_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "bind_id") String bind_id) {
|
||||
boolean flag = accountUserBindConnectService.remove(bind_id);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.service.AccountUserChainService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChain;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 门店顾客关系表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
@Api(tags = "门店顾客关系表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-chain")
|
||||
public class AccountUserChainController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserChainService accountUserChainService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param accountUserChain
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "门店顾客关系", notes = "门店顾客关系")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserChain accountUserChain,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
QueryWrapper<AccountUserChain> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("user_id");
|
||||
IPage<AccountUserChain> data = accountUserChainService.lists(queryWrapper, pageNum, pageSize);
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param accountUserChain
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "门店顾客关系表-编辑", notes = "门店顾客关系表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountUserChain accountUserChain) {
|
||||
boolean flag = accountUserChainService.saveOrUpdate(accountUserChain);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过user_id删除
|
||||
*
|
||||
* @param user_id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "门店顾客关系表-通过user_id删除", notes = "门店顾客关系表-通过user_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "user_id") String user_id) {
|
||||
boolean flag = accountUserChainService.remove(user_id);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.suisung.mall.account.service.AccountUserChannelBringService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelBring;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Api(tags = "渠道引流表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-channel-bring")
|
||||
public class AccountUserChannelBringController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserChannelBringService channelBringService;
|
||||
|
||||
@ApiOperation(value = "渠道引流表-列表查询", notes = "渠道引流表-列表查询")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserChannelBring accountUserChannelBring,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
return CommonResult.success(channelBringService.getList(accountUserChannelBring, pageNum, pageSize));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出-指定渠道引流数据", notes = "导出-指定渠道引流数据")
|
||||
@RequestMapping(value = "/exportFile", method = RequestMethod.POST)
|
||||
public void exportFile(HttpServletResponse response, @RequestParam(name = "ucb_ids") String ucb_ids) {
|
||||
channelBringService.exportFile(response, Convert.toList(Integer.class, ucb_ids));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.suisung.mall.account.service.AccountUserChannelCodeService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelCode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道邀请码表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
@Api(tags = "用户渠道邀请码表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-channel-code")
|
||||
public class AccountUserChannelCodeController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserChannelCodeService accountUserChannelCodeService;
|
||||
|
||||
|
||||
@ApiOperation(value = "用户渠道邀请码", notes = "用户渠道邀请码")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserChannelCode accountUserChannelCode,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize) {
|
||||
|
||||
return CommonResult.success(accountUserChannelCodeService.getList(accountUserChannelCode, pageNum, pageSize));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户渠道邀请码表-添加", notes = "用户渠道邀请码表-添加")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public CommonResult add(AccountUserChannelCode accountUserChannelCode) {
|
||||
boolean success = accountUserChannelCodeService.addChannelCode(accountUserChannelCode);
|
||||
|
||||
if (success) {
|
||||
return CommonResult.success("添加成功!");
|
||||
}
|
||||
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户渠道邀请码表-编辑", notes = "用户渠道邀请码表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountUserChannelCode accountUserChannelCode) {
|
||||
boolean success = accountUserChannelCodeService.edit(accountUserChannelCode);
|
||||
|
||||
if (success) {
|
||||
return CommonResult.success("编辑成功!");
|
||||
}
|
||||
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户渠道邀请码表-通过ucc_id删除", notes = "用户渠道邀请码表-通过ucc_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "ucc_id") String ucc_id) {
|
||||
boolean success = accountUserChannelCodeService.removeById(ucc_id);
|
||||
|
||||
if (success) {
|
||||
return CommonResult.success("删除成功!");
|
||||
}
|
||||
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取小程序码", notes = "获取小程序码")
|
||||
@RequestMapping(value = "/poster", method = {RequestMethod.POST})
|
||||
public CommonResult poster(@RequestParam(name = "ucc_id") Integer ucc_id,
|
||||
@RequestParam(name = "ucc_code") String ucc_code) throws IOException {
|
||||
return CommonResult.success(accountUserChannelCodeService.getWxQrCode(ucc_id, ucc_code));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.service.AccountUserChannelService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
@Api(tags = "用户渠道表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-channel")
|
||||
public class AccountUserChannelController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserChannelService accountUserChannelService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param accountUserChannel
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户渠道", notes = "用户渠道")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserChannel accountUserChannel,
|
||||
@RequestParam(name="pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name="pageSize", defaultValue = "20") Integer pageSize) {
|
||||
QueryWrapper<AccountUserChannel> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("user_channel_id");
|
||||
|
||||
if (accountUserChannel.getUser_channel_enable() != null) {
|
||||
queryWrapper.eq("user_channel_enable", accountUserChannel.getUser_channel_enable());
|
||||
}
|
||||
|
||||
return CommonResult.success(accountUserChannelService.lists(queryWrapper, pageNum, pageSize));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户渠道表-编辑", notes = "用户渠道表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountUserChannel accountUserChannel) {
|
||||
|
||||
if (accountUserChannel.getUser_channel_buildin() == null) {
|
||||
accountUserChannel.setUser_channel_buildin(0);
|
||||
}
|
||||
|
||||
boolean success = accountUserChannelService.saveOrUpdate(accountUserChannel);
|
||||
|
||||
if (success) {
|
||||
return CommonResult.success("编辑成功!");
|
||||
}
|
||||
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过user_channel_id删除
|
||||
*
|
||||
* @param user_channel_id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户渠道表-通过user_channel_id删除", notes = "用户渠道表-通过user_channel_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name="user_channel_id") String user_channel_id) {
|
||||
boolean success = accountUserChannelService.removeById(user_channel_id);
|
||||
|
||||
if (success) {
|
||||
return CommonResult.success("删除成功!");
|
||||
}
|
||||
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,62 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户详细信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Api(tags = "用户详细信息表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-info")
|
||||
public class AccountUserInfoController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@ApiOperation(value = "用户详细信息表-通过user_id删除", notes = "用户详细信息表-通过user_id删除")
|
||||
@RequestMapping(value = "/exportFile", method = RequestMethod.GET)
|
||||
public void exportFile(HttpServletResponse response,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
accountUserInfoService.exportFile(response, pageNum, pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/editCertification", method = RequestMethod.POST)
|
||||
public CommonResult editCertification(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_certification") Integer user_certification) {
|
||||
UserDto user = getCurrentUser();
|
||||
if (user.isPlatform()) {
|
||||
AccountUserInfo accountUserInfo = new AccountUserInfo();
|
||||
accountUserInfo.setUser_id(user_id);
|
||||
accountUserInfo.setUser_certification(user_certification);
|
||||
if (!accountUserInfoService.edit(accountUserInfo)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
} else {
|
||||
throw new ApiException(ResultCode.FORBIDDEN);
|
||||
}
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.service.AccountUserLevelLogService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserLevelLog;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级记录表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
@Api(tags = "用户等级记录表")
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/account-user-level-log")
|
||||
public class AccountUserLevelLogController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserLevelLogService accountUserLevelLogService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param accountUserLevelLog
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级记录", notes = "用户等级记录")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserLevelLog accountUserLevelLog,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
QueryWrapper<AccountUserLevelLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("ull_time");
|
||||
if (CheckUtil.isNotEmpty(accountUserLevelLog.getUser_id())) {
|
||||
queryWrapper.eq("user_id", accountUserLevelLog.getUser_id());
|
||||
}
|
||||
|
||||
IPage<AccountUserLevelLog> data = accountUserLevelLogService.lists(queryWrapper, pageNum, pageSize);
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户等级记录表-通过user_level_log_id查询", notes = "用户等级记录表-通过user_level_log_id查询")
|
||||
@RequestMapping(value = "/{user_level_log_id}", method = RequestMethod.GET)
|
||||
public CommonResult get(@PathVariable Long user_level_log_id) {
|
||||
AccountUserLevelLog accountUserLevelLog = accountUserLevelLogService.get(user_level_log_id);
|
||||
return CommonResult.success(accountUserLevelLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param accountUserLevelLog
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级记录表-编辑", notes = "用户等级记录表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountUserLevelLog accountUserLevelLog) {
|
||||
boolean flag = accountUserLevelLogService.saveOrUpdate(accountUserLevelLog);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过user_level_log_id删除
|
||||
*
|
||||
* @param user_level_log_id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户等级记录表-通过user_level_log_id删除", notes = "用户等级记录表-通过user_level_log_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "user_level_log_id") String user_level_log_id) {
|
||||
boolean flag = accountUserLevelLogService.remove(user_level_log_id);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.service.AccountUserSnsService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserSns;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户SNS信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-20
|
||||
*/
|
||||
@Api(tags = "用户SNS信息表")
|
||||
@RestController
|
||||
@RequestMapping("/account/account-user-sns")
|
||||
public class AccountUserSnsController {
|
||||
|
||||
@Autowired
|
||||
private AccountUserSnsService accountUserSnsService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param accountUserSns
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户SNS信息", notes = "用户SNS信息")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public CommonResult list(AccountUserSns accountUserSns,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
|
||||
QueryWrapper<AccountUserSns> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("user_id");
|
||||
|
||||
IPage<AccountUserSns> data = accountUserSnsService.lists(queryWrapper, pageNum, pageSize);
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑更新
|
||||
*
|
||||
* @param accountUserSns
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户SNS信息表-编辑", notes = "用户SNS信息表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(AccountUserSns accountUserSns) {
|
||||
boolean flag = accountUserSnsService.saveOrUpdate(accountUserSns);
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过user_id删除
|
||||
*
|
||||
* @param user_ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户SNS信息表-通过user_id删除", notes = "用户SNS信息表-通过user_id删除")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public CommonResult delete(@RequestParam(name = "user_ids") String user_ids) {
|
||||
boolean flag = accountUserSnsService.remove(Arrays.asList(user_ids.split(",")));
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.suisung.mall.account.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.suisung.mall.account.service.AnalyticsUserService;
|
||||
import com.suisung.mall.core.web.CommonRes;
|
||||
import com.suisung.mall.common.pojo.input.TimelineInput;
|
||||
import com.suisung.mall.common.pojo.output.AnalyticsNumOutput;
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.req.TimelineReq;
|
||||
import com.suisung.mall.common.pojo.res.DashboardTopRes;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/account/analytics")
|
||||
public class AnalyticsController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AnalyticsUserService analyticsUserService;
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "获取新增用户")
|
||||
@RequestMapping(value = "/user/getRegUser", method = RequestMethod.GET)
|
||||
public CommonRes<DashboardTopRes> getRegUser() {
|
||||
DashboardTopRes topRes = analyticsUserService.getRegUser();
|
||||
|
||||
return success(topRes);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增用户")
|
||||
@RequestMapping(value = "/user/getUserTimeLine", method = RequestMethod.GET)
|
||||
public CommonRes<List<TimelineOutput>> getUserTimeLine(TimelineReq req) {
|
||||
TimelineInput timelineInput = BeanUtil.copyProperties(req, TimelineInput.class);
|
||||
List<TimelineOutput> timelineRes = analyticsUserService.getUserTimeLine(timelineInput);
|
||||
|
||||
return success(timelineRes);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增用户")
|
||||
@RequestMapping(value = "/user/getUserTimeLineInfo", method = RequestMethod.GET)
|
||||
public List<TimelineOutput> getUserTimeLineInfo(@RequestParam("startTime") Long startTime, @RequestParam("endTime") Long endTime) {
|
||||
TimelineInput timelineInput = new TimelineInput();
|
||||
timelineInput.setStime(startTime);
|
||||
timelineInput.setEtime(endTime);
|
||||
List<TimelineOutput> timelineRes = analyticsUserService.getUserTimeLine(timelineInput);
|
||||
|
||||
return timelineRes;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取新增用户")
|
||||
@RequestMapping(value = "/user/getUserNum", method = RequestMethod.GET)
|
||||
public CommonRes<AnalyticsNumOutput> getUserNum(TimelineReq req) {
|
||||
TimelineInput timelineInput = BeanUtil.copyProperties(req, TimelineInput.class);
|
||||
AnalyticsNumOutput timelineRes = analyticsUserService.getUserNum(timelineInput);
|
||||
|
||||
return success(timelineRes);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.suisung.mall.account.controller.mobile;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.suisung.mall.account.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.account.service.AccountUserChannelBringService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统参数设置表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
@Api(tags = "系统参数设置表")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/config")
|
||||
public class ConfigController {
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserChannelBringService channelBringService;
|
||||
|
||||
@ApiOperation(value = "系统参数设置", notes = "系统参数设置")
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public CommonResult info() {
|
||||
Map info = channelBringService.info();
|
||||
return CommonResult.success(info);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "系统参数设置", notes = "系统参数设置")
|
||||
@RequestMapping(value = "/getConfigs", method = RequestMethod.GET)
|
||||
public CommonResult getConfigs(@RequestParam(name = "config_key") String config_key) {
|
||||
return CommonResult.success(accountBaseConfigService.getConfigs(Convert.toList(String.class, config_key)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "读取移动端语言包数据", notes = "读取移动端语言包数据")
|
||||
@RequestMapping(value = "/listTranslateLang", method = RequestMethod.GET)
|
||||
public CommonResult listTranslateLang() {
|
||||
// todo listTranslateLang
|
||||
return CommonResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.suisung.mall.account.controller.mobile;
|
||||
|
||||
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Api(tags = "google互联登录控制器")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/google")
|
||||
public class GoogleController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
|
||||
@ApiOperation(value = "google互联登录 - 回调登录")
|
||||
@RequestMapping(value = "/callbackGoogleLogin", method = RequestMethod.GET)
|
||||
public void callbackGoogleLogin(HttpServletResponse response, @RequestParam(name = "result") String result) {
|
||||
|
||||
accountUserBaseService.callbackGoogleLogin(response, result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "google互联登录 - 跳转登录")
|
||||
@RequestMapping(value = "/googleLogin", method = RequestMethod.GET)
|
||||
public void googleLogin(HttpServletResponse response) {
|
||||
|
||||
accountUserBaseService.googleLogin(response);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "google互联登录 - 回调")
|
||||
@RequestMapping(value = "/callback", method = RequestMethod.GET)
|
||||
public void callback(HttpServletResponse response, @RequestParam(name = "code") String code) {
|
||||
|
||||
accountUserBaseService.callbackGoogle(response, code);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,315 @@
|
||||
package com.suisung.mall.account.controller.mobile;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.suisung.mall.account.service.*;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.PayService;
|
||||
import com.suisung.mall.common.feignService.ShopService;
|
||||
import com.suisung.mall.common.modules.account.*;
|
||||
import com.suisung.mall.common.modules.distribution.ShopDistributionUser;
|
||||
import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommission;
|
||||
import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户基本信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-03-30
|
||||
*/
|
||||
@Api(tags = "用户基本信息表")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/user")
|
||||
public class UserController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseRoleLevelService accountBaseRoleLevelService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseUserLevelService accountBaseUserLevelService;
|
||||
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserSnsService accountUserSnsService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private ThreadPoolExecutor executor;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
/**
|
||||
* 用户基本信息管理界面
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "读取登录用户的所有信息")
|
||||
@RequestMapping(value = "/overview", method = RequestMethod.GET)
|
||||
public CommonResult overview() {
|
||||
Map resultMap = new HashMap();
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
|
||||
if (ObjectUtil.isEmpty(user)) {
|
||||
throw new ApiException(ResultCode.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
Integer user_id = user.getId();
|
||||
|
||||
Map<String, Object> base = new HashMap<>();
|
||||
AccountUserBase userBase = accountUserBaseService.get(user_id);
|
||||
base.put("chain_ids", Convert.toList(String.class, userBase.getChain_ids()));
|
||||
base.put("rights_group_id", Convert.toList(Integer.class, userBase.getRights_group_id()));
|
||||
base.put("store_ids", Convert.toList(Integer.class, userBase.getStore_ids()));
|
||||
base.put("user_account", userBase.getUser_account());
|
||||
base.put("user_id", userBase.getUser_id());
|
||||
base.put("user_is_admin", userBase.getUser_is_admin());
|
||||
base.put("user_nickname", userBase.getUser_nickname());
|
||||
base.put("user_quickcode", userBase.getUser_quickcode());
|
||||
base.put("user_state", userBase.getUser_state());
|
||||
resultMap.put("base", base);
|
||||
|
||||
//用户资源 pay_user_resource
|
||||
Map<String, Object> member_info = new HashMap<>();
|
||||
|
||||
Map<String, Object> user_info_row = accountUserBaseService.getUserInfo(user_id);
|
||||
Integer user_level_id = Convert.toInt(user_info_row.get("user_level_id"));
|
||||
AccountBaseUserLevel user_level_row = accountBaseUserLevelService.get(user_level_id);
|
||||
|
||||
ServletRequestAttributes reqAttr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
CompletableFuture<Void> overviewFuture1 = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(reqAttr, true);
|
||||
// 收藏店铺数量 商品数量
|
||||
Map<String, Object> UserFavoritesNumMap = shopService.getUserFavoritesNum(user_id);
|
||||
if (CollUtil.isNotEmpty(UserFavoritesNumMap)) {
|
||||
member_info.putAll(UserFavoritesNumMap);
|
||||
} else {
|
||||
member_info.put("favorites_store", 0);
|
||||
member_info.put("favorites_goods", 0);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
// 获取订单统计信息
|
||||
CompletableFuture<Void> overviewFuture2 = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(reqAttr, true);
|
||||
Map orderStatisticsInfo = shopService.getOrderStatisticsInfo(user_id);
|
||||
if (CollUtil.isNotEmpty(orderStatisticsInfo)) {
|
||||
member_info.putAll(orderStatisticsInfo);
|
||||
} else {
|
||||
member_info.put("cancel_num", 0);
|
||||
member_info.put("wait_shipping_num", 0);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
//TODO 待评价商品数
|
||||
CompletableFuture<Void> overviewFuture3 = CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(reqAttr, true);
|
||||
Integer wait_comment_num = shopService.waitCommentNum();
|
||||
member_info.put("wait_comment_num", wait_comment_num);
|
||||
|
||||
member_info.put("user_mobile", user_info_row.get("user_mobile"));
|
||||
member_info.put("user_email", user_info_row.get("user_email"));
|
||||
member_info.put("user_avatar", user_info_row.get("user_avatar"));
|
||||
member_info.put("user_sign", user_info_row.get("user_sign"));
|
||||
member_info.put("user_birthday", user_info_row.get("user_birthday"));
|
||||
member_info.put("user_nickname", base.get("user_nickname"));
|
||||
member_info.put("user_level_id", user_level_id);
|
||||
member_info.put("user_level_card", user_info_row.get("user_level_card"));
|
||||
member_info.put("user_level_validity_time", user_info_row.get("user_level_validity_time"));
|
||||
|
||||
Date user_level_validity_time = Convert.toDate(user_info_row.get("user_level_validity_time"));
|
||||
int compare = DateUtil.compare(user_level_validity_time, new Date());
|
||||
String user_level_name = ObjectUtil.defaultIfNull(user_level_row.getUser_level_name(), "V1");
|
||||
BigDecimal user_level_rate = ObjectUtil.defaultIfNull(user_level_row.getUser_level_rate(), BigDecimal.valueOf(100));
|
||||
|
||||
member_info.put("user_level_active", compare > 0 ? 1 : 0);
|
||||
member_info.put("user_level_name", user_level_name);
|
||||
member_info.put("user_level_rate", user_level_rate);
|
||||
|
||||
// 读取用户身份
|
||||
ShopDistributionUser shopDistributionUser = shopService.getDistributionUser(user_id);
|
||||
Map<String, Object> user_role_row = Convert.toMap(String.class, Object.class, shopDistributionUser);
|
||||
if (shopDistributionUser != null) {
|
||||
// 角色等级
|
||||
Integer role_level_id = shopDistributionUser.getRole_level_id();
|
||||
user_role_row.put("role_level_name", "");
|
||||
if (role_level_id != null) {
|
||||
AccountBaseRoleLevel accountBaseRoleLevel = accountBaseRoleLevelService.get(role_level_id);
|
||||
if (accountBaseRoleLevel != null) {
|
||||
user_role_row.put("role_level_name", accountBaseRoleLevel.getRole_level_name());
|
||||
}
|
||||
}
|
||||
// ($user_role_row['user_is_sp'] ? '服务商' : '') . ($user_role_row['user_is_da'] ? '区代理' : '') . ($user_role_row['user_is_ca'] ? '市代理' : '');
|
||||
Integer user_is_sp = Convert.toInt(user_role_row.get("user_is_sp"));
|
||||
Integer user_is_da = Convert.toInt(user_role_row.get("user_is_da"));
|
||||
Integer user_is_ca = Convert.toInt(user_role_row.get("user_is_ca"));
|
||||
String user_role_name = (CheckUtil.isNotEmpty(user_is_sp) ? I18nUtil._("服务商") : "") + (CheckUtil.isNotEmpty(user_is_da) ? I18nUtil._("区代理") : "") + (CheckUtil.isNotEmpty(user_is_ca) ? I18nUtil._("市代理") : "");
|
||||
user_role_row.put("user_role_name", user_role_name);
|
||||
}
|
||||
|
||||
resultMap.put("user_role", user_role_row);
|
||||
|
||||
// 用户其它资源, 临时直接读取
|
||||
AccountUserSns accountUserSns = accountUserSnsService.get(user_id);
|
||||
if (accountUserSns != null) {
|
||||
Map<String, Object> sns_row = Convert.toMap(String.class, Object.class, accountUserSns);
|
||||
member_info.putAll(sns_row);
|
||||
}
|
||||
|
||||
// 佣金问题, 临时直接读取
|
||||
ShopDistributionUserCommission disUserCommission = shopService.getDisUserCommission(user_id);
|
||||
if (disUserCommission != null) {
|
||||
Map<String, Object> user_commission = Convert.toMap(String.class, Object.class, disUserCommission);
|
||||
member_info.putAll(user_commission);
|
||||
|
||||
// 可用佣金 = 历史总佣金 - 已结算
|
||||
BigDecimal commission_amount = disUserCommission.getCommission_amount();
|
||||
BigDecimal commission_settled = disUserCommission.getCommission_settled();
|
||||
member_info.put("user_commission", NumberUtil.sub(commission_amount, commission_settled));
|
||||
} else {
|
||||
member_info.put("user_commission", BigDecimal.ZERO);
|
||||
member_info.put("commission_amount", BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
// 读取商家身份
|
||||
if (user.isStore()) {
|
||||
CommonResult commonResult = shopService.getStoreBase(Convert.toInt(user.getStore_id()));
|
||||
Map storeMap = Convert.toMap(String.class, Object.class, commonResult.getData());
|
||||
member_info.put("store_type", storeMap.get("store_type"));
|
||||
}
|
||||
|
||||
// 用户经验值
|
||||
member_info.put("user_growth", user_info_row.get("user_exp_total"));
|
||||
|
||||
PayUserResource payUserResource = payService.getPayUserResource(user_id);
|
||||
if (payUserResource != null) {
|
||||
Map user_resource_row = Convert.toMap(String.class, Object.class, payUserResource);
|
||||
member_info.putAll(user_resource_row);
|
||||
}
|
||||
|
||||
// 余额总数
|
||||
BigDecimal user_money = payUserResource.getUser_money();
|
||||
BigDecimal user_money_frozen = payUserResource.getUser_money_frozen();
|
||||
member_info.put("user_amount", NumberUtil.add(user_money, user_money_frozen));
|
||||
|
||||
// 聊天管理员信息
|
||||
Integer im_user_id = accountBaseConfigService.getConfig("site_im", 10001);
|
||||
member_info.put("im_user_id", im_user_id);
|
||||
|
||||
// $puid = Zero_Model::getPlantformUid($im_user_id);
|
||||
// member_info.put("puid", puid);
|
||||
resultMap.put("member_info", member_info);
|
||||
|
||||
// 用户详细信息
|
||||
AccountUserInfo userInfo = accountUserInfoService.get(user_id);
|
||||
member_info.put("user_gender", userInfo.getUser_gender());
|
||||
|
||||
member_info.put("rid", user.getRole_id());
|
||||
}, executor);
|
||||
|
||||
try {
|
||||
CompletableFuture.allOf(overviewFuture1, overviewFuture2, overviewFuture3).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
return CommonResult.success(resultMap);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户端用户信息")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.GET)
|
||||
public CommonResult edit() {
|
||||
boolean flag = accountUserBaseService.editMobileUser();
|
||||
return CommonResult.success(flag);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取手机验证码")
|
||||
@RequestMapping(value = "/verifyCode", method = RequestMethod.GET)
|
||||
public CommonResult getVerifyCode(@RequestParam(name = "mobile", required = false) String mobile,
|
||||
@RequestParam(name = "email", required = false) String email) {
|
||||
if (StrUtil.isNotBlank(mobile) && !PhoneNumberUtils.isValidNumber(mobile)) {
|
||||
throw new ApiException(I18nUtil._("请输入正确的手机号!"));
|
||||
}
|
||||
else if (StrUtil.isNotBlank(email) && !CheckUtil.isEmail(email)) {
|
||||
throw new ApiException(I18nUtil._("请输入正确邮箱格式!"));
|
||||
}
|
||||
|
||||
String number = StrUtil.blankToDefault(mobile, email);
|
||||
|
||||
return CommonResult.success(accountUserBaseService.getVerifyCode(number));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取邮箱验证码找回密码")
|
||||
@RequestMapping(value = "/emailVerifyCode", method = RequestMethod.GET)
|
||||
public CommonResult getEmailMobileVerifyCode(@RequestParam(name = "mobile", required = false) String mobile,
|
||||
@RequestParam(name = "email", required = false) String email) {
|
||||
if (StrUtil.isNotBlank(mobile) && !PhoneUtil.isMobile(mobile)) {
|
||||
throw new ApiException(I18nUtil._("请输入正确的手机号!"));
|
||||
}
|
||||
String number = StrUtil.blankToDefault(mobile, email);
|
||||
return CommonResult.success(accountUserBaseService.getEmailMobileVerifyCode(number));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户签名")
|
||||
@RequestMapping(value = "/editSign", method = RequestMethod.POST)
|
||||
public CommonResult editSign(@RequestParam(name = "user_sign") String user_sign) {
|
||||
UserDto user = getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiException(I18nUtil._("用户信息异常!"));
|
||||
}
|
||||
AccountUserInfo userInfo = new AccountUserInfo();
|
||||
userInfo.setUser_id(user.getId());
|
||||
userInfo.setUser_sign(user_sign);
|
||||
if (!accountUserInfoService.edit(userInfo)) {
|
||||
throw new ApiException(I18nUtil._("签名修改失败!"));
|
||||
}
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package com.suisung.mall.account.controller.mobile;
|
||||
|
||||
import com.suisung.mall.account.service.AccountBaseUserLevelService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "用户等级")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/userLevel")
|
||||
public class UserLevelController {
|
||||
|
||||
@Autowired
|
||||
private AccountBaseUserLevelService accountBaseUserLevelService;
|
||||
|
||||
@ApiOperation(value = "读取平台用户等级")
|
||||
@RequestMapping(value = "/listBaseUserLevel", method = RequestMethod.GET)
|
||||
public CommonResult listBaseUserLevel() {
|
||||
Map data = accountBaseUserLevelService.listBaseUserLevel();
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.suisung.mall.account.controller.mobile;
|
||||
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiUserException;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "用户基本信息表")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/userSecurity")
|
||||
public class UserSecurityController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
|
||||
@ApiOperation(value = "实名认证页面", notes = "实名认证页面")
|
||||
@RequestMapping(value = "/certification", method = RequestMethod.GET)
|
||||
public CommonResult certification() {
|
||||
return CommonResult.success(accountUserInfoService.certification());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "短信绑定验证", notes = "短信绑定验证")
|
||||
@RequestMapping(value = "/bindMobile", method = RequestMethod.GET)
|
||||
public CommonResult bindMobile() {
|
||||
return accountUserBaseService.bindMobile();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "实名认证保存接口", notes = "实名认证保存接口")
|
||||
@RequestMapping(value = "/saveCertificate", method = RequestMethod.GET)
|
||||
public CommonResult saveCertificate(@RequestParam(name = "user_realname") String user_realname,
|
||||
@RequestParam(name = "user_idcard") String user_idcard,
|
||||
@RequestParam(name = "user_idcard_images") String user_idcard_images) {
|
||||
AccountUserInfo userInfo = new AccountUserInfo();
|
||||
|
||||
userInfo.setUser_realname(user_realname);
|
||||
userInfo.setUser_idcard(user_idcard);
|
||||
userInfo.setUser_idcard_images(user_idcard_images);
|
||||
userInfo.setUser_certification(StateCode.USER_CERTIFICATION_VERIFY);
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||
}
|
||||
userInfo.setUser_id(user.getId());
|
||||
return accountUserInfoService.saveCertificate(userInfo);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,129 @@
|
||||
package com.suisung.mall.account.controller.mobile;
|
||||
|
||||
import com.suisung.mall.account.service.WeiXinService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "微信操作控制器")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/weiXin")
|
||||
public class WeiXinController extends BaseControllerImpl {
|
||||
|
||||
@Autowired
|
||||
private WeiXinService weiXinService;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 验证推送过来的消息的正确性
|
||||
* </pre>
|
||||
*
|
||||
* @param signature 消息签名
|
||||
* @param timestamp 时间戳
|
||||
* @param nonce 随机数
|
||||
* @return the boolean
|
||||
*/
|
||||
|
||||
@ApiOperation(value = "验证签名")
|
||||
@RequestMapping(value = "/index", method = RequestMethod.GET)
|
||||
public String checkSignature(@RequestParam(name = "timestamp") String timestamp,
|
||||
@RequestParam(name = "signature") String signature,
|
||||
@RequestParam(name = "nonce") String nonce,
|
||||
@RequestParam(name = "echostr") String echostr) {
|
||||
return weiXinService.checkSignature(timestamp, nonce, signature) == true ? echostr : null;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "公众号登录 - 获取code请求")
|
||||
@RequestMapping(value = "/redirectToWxCode", method = RequestMethod.GET)
|
||||
public void redirectToWxCode(HttpServletRequest request, HttpServletResponse response) {
|
||||
weiXinService.redirectToWxCode(request, response);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "公众号登录 - 公众号授权回调")
|
||||
@RequestMapping(value = "/callbackMp", method = RequestMethod.GET)
|
||||
public void callbackMp(HttpServletResponse response,
|
||||
@RequestParam(name = "activity_id") String activity_id,
|
||||
@RequestParam(name = "code") String code) {
|
||||
weiXinService.callbackMp(response, activity_id, code);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户登录验证")
|
||||
@RequestMapping(value = "/checkAppLogin", method = RequestMethod.GET)
|
||||
public CommonResult checkAppLogin(@RequestParam(name = "code") String code) {
|
||||
Map<String, Object> checkAppLogin = weiXinService.checkAppLogin(code);
|
||||
if (checkAppLogin != null) {
|
||||
return CommonResult.success(checkAppLogin);
|
||||
}
|
||||
return CommonResult.failed(I18nUtil._("请先登录"));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取微信配置请求")
|
||||
@RequestMapping(value = "/wxConfig", method = RequestMethod.GET)
|
||||
public CommonResult wxConfig(@RequestParam(name = "href") String url) {
|
||||
return CommonResult.success(weiXinService.wxConfig(url));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户注册")
|
||||
@RequestMapping(value = "/jsCode2Session", method = RequestMethod.GET)
|
||||
public CommonResult jsCode2Session(@RequestParam(name = "code") String code,
|
||||
@RequestParam(name = "encryptedData") String encryptedData,
|
||||
@RequestParam(name = "iv") String iv,
|
||||
@RequestParam(name = "activity_id") String activity_id,
|
||||
@RequestParam(name = "user_info") String user_info) {
|
||||
return CommonResult.success(weiXinService.jsCode2Session(code, encryptedData, iv, activity_id, user_info));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "小程序获取手机号")
|
||||
@RequestMapping(value = "/getUserPhoneNumber", method = RequestMethod.GET)
|
||||
public CommonResult getUserPhoneNumber(@RequestParam(name = "code") String code) {
|
||||
return CommonResult.success(weiXinService.getUserPhoneNumber(code, getCurrentUser()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取AccessToken-向外提供")
|
||||
@RequestMapping(value = "/getMpAccessToken", method = RequestMethod.GET)
|
||||
public String getMpAccessToken(@RequestParam(name = "useCacheFlag") boolean useCacheFlag) {
|
||||
return weiXinService.getMpAccessToken(useCacheFlag);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取getXcxAccessToken-向外提供")
|
||||
@RequestMapping(value = "/getXcxAccessToken", method = RequestMethod.GET)
|
||||
public String getXcxAccessToken(@RequestParam(name = "useCacheFlag") boolean useCacheFlag) {
|
||||
return weiXinService.getXcxAccessToken(useCacheFlag);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据code 获取openid")
|
||||
@RequestMapping(value = "/getOpenIdByCode", method = RequestMethod.GET)
|
||||
public CommonResult getOpenIdByCode(@RequestParam(name = "code") String code) {
|
||||
return CommonResult.success(weiXinService.getOpenIdByCode(code, getCurrentUser()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "微信通知消息回调")
|
||||
@RequestMapping(value = "/callbackMessage", method = RequestMethod.GET)
|
||||
public CommonResult callbackMessage() {
|
||||
return CommonResult.success(weiXinService.callbackMessage());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "微信网页登录生成二维码")
|
||||
@RequestMapping(value = "/getQrCode", method = RequestMethod.GET)
|
||||
public CommonResult getQrCode() {
|
||||
return CommonResult.success(weiXinService.getQrCode());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "二维码登录 - 微信网页回调")
|
||||
@RequestMapping(value = "/callbackPc", method = RequestMethod.GET)
|
||||
public void callbackPc(String code, HttpServletResponse response) {
|
||||
weiXinService.callbackPc(code, response);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.suisung.mall.account.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.suisung.mall.account.service.AccountUserAnalyticsService;
|
||||
import com.suisung.mall.common.constant.MqConstant;
|
||||
import com.suisung.mall.common.modules.account.AccountUserAnalytics;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RabbitListener(queues = MqConstant.ACCOUNT_ANALYTICS_QUEUE)
|
||||
public class DealUserAnalyticsListener {
|
||||
|
||||
@Autowired
|
||||
private AccountUserAnalyticsService accountUserAnalyticsService;
|
||||
|
||||
@RabbitHandler
|
||||
public void listener(String data, Channel channel, Message message) throws IOException, InterruptedException {
|
||||
AccountUserAnalytics accountUserAnalytics = JSONUtil.toBean(data, AccountUserAnalytics.class);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
|
||||
try {
|
||||
boolean flag = accountUserAnalyticsService.saveOrUpdate(accountUserAnalytics);
|
||||
if (flag) {
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
} else {
|
||||
log.error("消息消费失败,执行dealUserAnalytics异常,当前用户编号:{}", accountUserAnalytics.getUser_id());
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("消息消费失败,执行dealUserAnalytics异常,当前用户编号:{},失败原因", accountUserAnalytics.getUser_id(), e);
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.suisung.mall.account.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.constant.MqConstant;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RabbitListener(queues = MqConstant.ACCOUNT_INFO_QUEUE)
|
||||
public class DealUserInfoListener {
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@RabbitHandler
|
||||
public void listener(String data, Channel channel, Message message) throws IOException, InterruptedException {
|
||||
AccountUserInfo accountUserInfo = JSONUtil.toBean(data, AccountUserInfo.class);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
|
||||
try {
|
||||
boolean flag = accountUserInfoService.saveOrUpdate(accountUserInfo);
|
||||
if (flag) {
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
} else {
|
||||
log.error("消息消费失败,执行dealUserInfo异常,当前用户编号:{}", accountUserInfo.getUser_id());
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("消息消费失败,执行dealUserInfo异常,当前用户编号:{},失败原因:", accountUserInfo.getUser_id(), e);
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.suisung.mall.account.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.constant.MqConstant;
|
||||
import com.suisung.mall.common.pojo.to.ExperienceTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RabbitListener(queues = MqConstant.ACCOUNT_EXPERIENCE_QUEUE)
|
||||
public class ExperienceListener {
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@RabbitHandler
|
||||
public void listener(String data, Channel channel, Message message) throws IOException, InterruptedException {
|
||||
ExperienceTO experienceTO = JSONUtil.toBean(data, ExperienceTO.class);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
|
||||
try {
|
||||
boolean flag = accountUserInfoService.experience(experienceTO.getUser_id(), experienceTO.getExp(), experienceTO.getExp_type_id(), experienceTO.getDesc());
|
||||
if (flag) {
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
} else {
|
||||
log.error("消息消费失败,执行experience异常,当前用户编号:{}", experienceTO.getUser_id());
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("消息消费失败,执行experience异常,当前用户编号:{},失败原因:", experienceTO.getUser_id(), e);
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.suisung.mall.account.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.constant.MqConstant;
|
||||
import com.suisung.mall.common.pojo.to.UserLevelTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RabbitListener(queues = MqConstant.ACCOUNT_UPGRADE_QUEUE)
|
||||
public class UpgradeUserLevelListener {
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@RabbitHandler
|
||||
public void listener(String data, Channel channel, Message message) throws IOException, InterruptedException {
|
||||
UserLevelTO userLevelTO = JSONUtil.toBean(data, UserLevelTO.class);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
|
||||
try {
|
||||
boolean flag = accountUserInfoService.checkUpdateUserLevel(userLevelTO.getUser_id(), userLevelTO.getUser_exp_total(), userLevelTO.getUser_fans_total(), userLevelTO.getUser_spend_total(), 0, 0, 0);
|
||||
if (flag) {
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
} else {
|
||||
log.error("消息消费失败,执行upgradeUserLevel异常,当前用户编号:{}", userLevelTO.getUser_id());
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("消息消费失败,执行upgradeUserLevel异常,当前用户编号:{},失败原因:", userLevelTO.getUser_id(), e);
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseConfig;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统参数设置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountBaseConfigMapper extends BaseMapper<AccountBaseConfig> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseRoleLevel;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色等级表-平台 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-28
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountBaseRoleLevelMapper extends BaseMapper<AccountBaseRoleLevel> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseUserLevel;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级表-平台 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountBaseUserLevelMapper extends BaseMapper<AccountBaseUserLevel> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserAnalytics;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-09-28
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserAnalyticsMapper extends BaseMapper<AccountUserAnalytics> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户基本信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-03-30
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserBaseMapper extends BaseMapper<AccountUserBase> {
|
||||
IPage<Map> getUserIdList(Page<Map> page, @Param("param") Map param);
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户绑定表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserBindConnectMapper extends BaseMapper<AccountUserBindConnect> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChain;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 门店顾客关系表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserChainMapper extends BaseMapper<AccountUserChain> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelBring;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 渠道引流表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author yanhelong
|
||||
*/
|
||||
@Repository
|
||||
public interface AccountUserChannelBringMapper extends BaseMapper<AccountUserChannelBring> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelCode;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道邀请码表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserChannelCodeMapper extends BaseMapper<AccountUserChannelCode> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannel;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserChannelMapper extends BaseMapper<AccountUserChannel> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户详细信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserInfoMapper extends BaseMapper<AccountUserInfo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserLevelLog;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级记录表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserLevelLogMapper extends BaseMapper<AccountUserLevelLog> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserLogin;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户登录信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-27
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserLoginMapper extends BaseMapper<AccountUserLogin> {
|
||||
|
||||
List<Map> getUserRegTimeline(@Param("order_time") Long order_time);
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserSns;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户SNS信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-20
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserSnsMapper extends BaseMapper<AccountUserSns> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.account.AccountUserType;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-08-25
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface AccountUserTypeMapper extends BaseMapper<AccountUserType> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.vo.RegUserVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AnalyticsUserDao {
|
||||
RegUserVo getRegUser(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||
|
||||
List<TimelineOutput> getUserTimeLine(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.suisung.mall.account.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.user.ShopUserExpHistory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员经验日志表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-10-15
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface ShopUserExpHistoryMapper extends BaseMapper<ShopUserExpHistory> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountBaseConfig;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统参数设置表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
public interface AccountBaseConfigService extends IBaseService<AccountBaseConfig> {
|
||||
|
||||
String getConfig(String config_key);
|
||||
|
||||
boolean getConfig(String config_key, Boolean defaultValue);
|
||||
|
||||
String getConfig(String config_key, String defaultValue);
|
||||
|
||||
Integer getConfig(String config_key, Integer defaultValue);
|
||||
|
||||
Float getConfig(String config_key, Float defaultValue);
|
||||
|
||||
Map getConfigFormatByType(String config_type);
|
||||
|
||||
Map languageList(Integer pageNum, Integer pageSize);
|
||||
|
||||
boolean editLanguage(Integer language_id, Integer language_status);
|
||||
|
||||
Map getSystemConfig();
|
||||
|
||||
List<AccountBaseConfig> getConfigs(List<String> keys);
|
||||
|
||||
boolean saveOrUpdate(Collection<AccountBaseConfig> configs);
|
||||
boolean saveOrUpdate(AccountBaseConfig config);
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountBaseRoleLevel;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色等级表-平台 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-28
|
||||
*/
|
||||
public interface AccountBaseRoleLevelService extends IBaseService<AccountBaseRoleLevel> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountBaseUserLevel;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级表-平台 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
public interface AccountBaseUserLevelService extends IBaseService<AccountBaseUserLevel> {
|
||||
|
||||
Map listBaseUserLevel();
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserAnalytics;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-09-28
|
||||
*/
|
||||
public interface AccountUserAnalyticsService extends IBaseService<AccountUserAnalytics> {
|
||||
|
||||
AccountUserAnalytics getUserAnalyticsByUserId(Integer userId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,144 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户基本信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-03-30
|
||||
*/
|
||||
public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
|
||||
AccountUserBase register(Map userInfo);
|
||||
|
||||
CommonResult login(Map<String, String> params);
|
||||
|
||||
Map<String, Object> getUserInfo(Integer user_id);
|
||||
|
||||
UserDto loadUserByUsername(String user_account);
|
||||
|
||||
boolean logout();
|
||||
|
||||
Map getConnectInfo();
|
||||
|
||||
Map fixUserAvatar(Map row, Boolean fix_user_account);
|
||||
|
||||
List<Map> fixUserAvatar(List<Map> rows, Boolean fix_user_account);
|
||||
|
||||
Map getUserBaseInfoSns(Integer user_id);
|
||||
|
||||
CommonResult ifLogin();
|
||||
|
||||
Map getUserInfoAndBase(Integer user_id);
|
||||
|
||||
List<Map> getUserInfoAndBaseMap(List<Integer> user_id);
|
||||
|
||||
Map getUserList(Integer pageNum, Integer pageSize);
|
||||
|
||||
CommonResult editUser();
|
||||
|
||||
boolean doResetPasswd(String user_account, String user_password, String old_password);
|
||||
|
||||
boolean editPassword(Integer user_id, String user_password);
|
||||
|
||||
/**
|
||||
* 删除用户账号
|
||||
*
|
||||
* @param user_ids
|
||||
*/
|
||||
boolean removeUser(List<Integer> user_ids);
|
||||
|
||||
Boolean editState(Integer user_id, Integer user_state);
|
||||
|
||||
Boolean editEmployeeInfo(Integer user_id, Map userInfo);
|
||||
|
||||
boolean editMobileUser();
|
||||
|
||||
CommonResult bindMobile();
|
||||
|
||||
/**
|
||||
* 绑定手机号操作
|
||||
*
|
||||
* @param user_intl 手机区号
|
||||
* @param currentUser 用户登录信息
|
||||
*/
|
||||
Integer doBindMobile(String user_intl, String mobile, UserDto currentUser);
|
||||
|
||||
AccountUserBase getByAccount(String user_account);
|
||||
|
||||
boolean getVerifyCode(String number);
|
||||
|
||||
boolean getEmailMobileVerifyCode(String number);
|
||||
|
||||
AccountUserBase getByNickname(String nickname);
|
||||
|
||||
boolean setNewPassword(String channel_verify_key, String channel_verify_code, String pwd, String channel);
|
||||
|
||||
CommonResult doSmsLogin(String user_mobile, String rand_key, String verify_code);
|
||||
|
||||
Map<String, Object> doAppConnectLogin(String bind_name, String code);
|
||||
|
||||
CommonResult doMobileBindLogin(String user_mobile, String verify_code);
|
||||
|
||||
/**
|
||||
* 用户来源
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Integer getSourceUserId();
|
||||
|
||||
/**
|
||||
* 添加分销来源用户 - 台推广员功能,佣金平台出
|
||||
*
|
||||
* @param user_id
|
||||
* @param user_parent_id
|
||||
* @return
|
||||
*/
|
||||
boolean addSourceUserId(Integer user_id, Integer user_parent_id);
|
||||
|
||||
/**
|
||||
* 渠道来源
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getSourceChannelCode();
|
||||
|
||||
/**
|
||||
* 渠道来源
|
||||
*
|
||||
* @param user_id
|
||||
* @param source_ucc_code
|
||||
* @return
|
||||
*/
|
||||
boolean addChannelSourceUserId(Integer user_id, String source_ucc_code);
|
||||
|
||||
/**
|
||||
* google互联登录 - 回调登录
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
void callbackGoogleLogin(HttpServletResponse response, String result);
|
||||
|
||||
/**
|
||||
* 跳转登录
|
||||
* @param response
|
||||
*/
|
||||
void googleLogin(HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* google互联登录 - 回调
|
||||
* @param response
|
||||
* @param code
|
||||
*/
|
||||
void callbackGoogle(HttpServletResponse response, String code);
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户绑定表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
public interface AccountUserBindConnectService extends IBaseService<AccountUserBindConnect> {
|
||||
|
||||
Map getBind(Integer user_id, int bind_type);
|
||||
|
||||
boolean checkBind(String bind_id, int bind_type, Integer user_id, AccountUserBindConnect user_info_row);
|
||||
|
||||
boolean checkAccessToken(Integer bind_type, AccountUserBindConnect bind_data, Integer user_id);
|
||||
|
||||
/**
|
||||
* 传入各渠道数据信息,完成绑定操作,包含注册绑定
|
||||
*
|
||||
* @param user_info_row bind_connect数据
|
||||
* @param reg_flag 是否需要注册新账号
|
||||
* @source_user_id 父级用户id
|
||||
* @activity_id 活动id
|
||||
* @access public
|
||||
*/
|
||||
Integer doUserBind(AccountUserBindConnect user_info_row, String activity_id, boolean reg_flag);
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserChain;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 门店顾客关系表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
public interface AccountUserChainService extends IBaseService<AccountUserChain> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelBring;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 渠道引流表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author yanhelong
|
||||
* @since 2023-08-30
|
||||
*/
|
||||
public interface AccountUserChannelBringService extends IBaseService<AccountUserChannelBring> {
|
||||
|
||||
/**
|
||||
* 渠道引流表-列表查询
|
||||
* @param accountUserChannelBring
|
||||
* @return
|
||||
*/
|
||||
IPage<AccountUserChannelBring> getList(AccountUserChannelBring accountUserChannelBring, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 导出-指定渠道引流数据
|
||||
* @param response
|
||||
* @param ucb_ids
|
||||
*/
|
||||
void exportFile(HttpServletResponse response, List<Integer> ucb_ids);
|
||||
|
||||
Map info();
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelCode;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道邀请码表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
public interface AccountUserChannelCodeService extends IBaseService<AccountUserChannelCode> {
|
||||
|
||||
/**
|
||||
* 用户渠道邀请码
|
||||
* @param accountUserChannelCode
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
IPage<AccountUserChannelCode> getList(AccountUserChannelCode accountUserChannelCode, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 用户渠道邀请码表-添加
|
||||
* @param accountUserChannelCode
|
||||
* @return
|
||||
*/
|
||||
boolean addChannelCode(AccountUserChannelCode accountUserChannelCode);
|
||||
|
||||
/**
|
||||
* 获取小程序码
|
||||
* @param ucc_id
|
||||
* @param uccCode
|
||||
* @return
|
||||
*/
|
||||
String getWxQrCode(Integer ucc_id, String uccCode);
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannel;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
public interface AccountUserChannelService extends IBaseService<AccountUserChannel> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.common.modules.account.AccountUserSns;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户详细信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
public interface AccountUserInfoService extends IBaseService<AccountUserInfo> {
|
||||
|
||||
Map certification();
|
||||
|
||||
Map getLists(QueryWrapper<AccountUserBase> queryWrapper, Integer page, Integer rows);
|
||||
|
||||
boolean checkUpdateUserLevel(Integer user_id, BigDecimal user_exp_total, Integer user_fans_total, BigDecimal user_spend_total, Integer user_store_total, Integer user_fans_vip_total, Integer user_fans_team_total);
|
||||
|
||||
BigDecimal getDistUserLevelConfig(String key, Integer user_id, BigDecimal defaultValue);
|
||||
|
||||
boolean upgradeUserLevel(Integer user_id, Integer user_level_id, String user_level_name);
|
||||
|
||||
boolean editUser(Integer user_id, Map data);
|
||||
|
||||
boolean saveAndCheckUpdateUserLevel(AccountUserSns accountUserSns);
|
||||
|
||||
List<Map> getUser(List<Integer> user_ids);
|
||||
|
||||
boolean editJbState(Integer user_id, Integer user_jb_state);
|
||||
|
||||
boolean editAccount(Integer user_id, Map userInfo);
|
||||
|
||||
boolean initUserExperience(Integer user_id);
|
||||
|
||||
CommonResult saveCertificate(AccountUserInfo userInfo);
|
||||
|
||||
boolean experience(Integer user_id, BigDecimal exp, Integer exp_type_id, String desc);
|
||||
|
||||
void exportFile(HttpServletResponse response, Integer pageNum, Integer pageSize);
|
||||
|
||||
CommonResult protocol(String document_type, String protocols_key, Integer state);
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserLevelLog;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
public interface AccountUserLevelLogService extends IBaseService<AccountUserLevelLog> {
|
||||
|
||||
boolean addLevelLog(Integer user_id, Integer user_level_id, String ull_note, Integer admin_id);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserLogin;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户登录信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-27account_user_type
|
||||
*/
|
||||
public interface AccountUserLoginService extends IBaseService<AccountUserLogin> {
|
||||
|
||||
List<Map> getUserDate(Integer days);
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserSns;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户SNS信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-20
|
||||
*/
|
||||
public interface AccountUserSnsService extends IBaseService<AccountUserSns> {
|
||||
|
||||
boolean updateUserFriendNum(Integer user_id, Integer friend_id, Integer num);
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.account.AccountUserType;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-08-25
|
||||
*/
|
||||
public interface AccountUserTypeService extends IBaseService<AccountUserType> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.pojo.input.TimelineInput;
|
||||
import com.suisung.mall.common.pojo.output.AnalyticsNumOutput;
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.res.DashboardTopRes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnalyticsUserService {
|
||||
|
||||
DashboardTopRes getRegUser();
|
||||
|
||||
/**
|
||||
* 会员数统计
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
List<TimelineOutput> getUserTimeLine(TimelineInput input);
|
||||
|
||||
|
||||
/**
|
||||
* 会员数
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
AnalyticsNumOutput getUserNum(TimelineInput input);
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.modules.user.ShopUserExpHistory;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员经验日志表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-10-15
|
||||
*/
|
||||
public interface ShopUserExpHistoryService extends IBaseService<ShopUserExpHistory> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.suisung.mall.account.service;
|
||||
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 微信操作服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
public interface WeiXinService {
|
||||
|
||||
boolean checkSignature(String timestamp, String nonce, String signature);
|
||||
|
||||
Map<String, String> parseRequest(InputStream is);
|
||||
|
||||
void redirectToWxCode(HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
void callbackMp(HttpServletResponse response, String activity_id, String code);
|
||||
|
||||
//todo 不需要重新设置一个cliend id
|
||||
String getWxUserToken(Integer user_id);
|
||||
|
||||
//todo 应该放入AccountUserBaseService中
|
||||
Map<String, Object> getUserInfo(Integer user_id);
|
||||
|
||||
Map<String, Object> checkAppLogin(String code);
|
||||
|
||||
Map jsCode2Session(String code, String encryptedData, String iv, String activity_id, String user_info);
|
||||
|
||||
Map getUserPhoneNumber(String code, UserDto user);
|
||||
|
||||
Map wxConfig(String url);
|
||||
|
||||
String getMpAccessToken(boolean useCacheFlag);
|
||||
|
||||
String getMpToken();
|
||||
|
||||
String getXcxAccessToken(boolean useCacheFlag);
|
||||
|
||||
Map getOpenIdByCode(String code, UserDto user);
|
||||
|
||||
AccountUserBindConnect getVxMiniAppUserBindConnect(String code, String encryptedData, String iv, String user_info);
|
||||
|
||||
boolean callbackMessage();
|
||||
|
||||
String getQrCode();
|
||||
|
||||
void callbackPc(String code, HttpServletResponse response);
|
||||
|
||||
}
|
||||
@ -0,0 +1,372 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.mapper.AccountBaseConfigMapper;
|
||||
import com.suisung.mall.account.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.common.constant.RedisConstant;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseConfig;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.CommonUtil;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统参数设置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AccountBaseConfigServiceImpl extends BaseServiceImpl<AccountBaseConfigMapper, AccountBaseConfig> implements AccountBaseConfigService, CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
public static Map<String, AccountBaseConfig> configMap;
|
||||
|
||||
public static Long version = 0L;
|
||||
|
||||
/**
|
||||
* 根据config_key 获取 config_value
|
||||
*
|
||||
* @param config_key
|
||||
* @return
|
||||
*/
|
||||
public String getConfig(String config_key) {
|
||||
if (configMap == null) syncCache(false);
|
||||
AccountBaseConfig accountBaseConfig = configMap.get(config_key);
|
||||
if (ObjectUtil.isNull(accountBaseConfig) || CheckUtil.isEmpty(accountBaseConfig.getConfig_enable())) return "";
|
||||
return accountBaseConfig.getConfig_value();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据config_key 获取 config_value
|
||||
* config_value为空则返回默认值
|
||||
*
|
||||
* @param config_key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public boolean getConfig(String config_key, Boolean defaultValue) {
|
||||
String config_value = getConfig(config_key);
|
||||
boolean isNumber = NumberUtil.isNumber(config_value);
|
||||
if (!isNumber) return defaultValue;
|
||||
return "1".equals(config_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据config_key 获取 config_value
|
||||
* config_value为空则返回默认值
|
||||
*
|
||||
* @param config_key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public String getConfig(String config_key, String defaultValue) {
|
||||
String config_value = getConfig(config_key);
|
||||
if (StrUtil.isBlank(config_value)) return defaultValue;
|
||||
return config_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据config_key 获取 config_value
|
||||
* config_value为空则返回默认值
|
||||
*
|
||||
* @param config_key
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public Integer getConfig(String config_key, Integer defaultValue) {
|
||||
String config_value = getConfig(config_key);
|
||||
boolean isNumber = NumberUtil.isNumber(config_value);
|
||||
if (!isNumber) return defaultValue;
|
||||
return Convert.toInt(config_value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getConfig(String config_key, Float defaultValue) {
|
||||
String config_value = getConfig(config_key);
|
||||
boolean isNumber = NumberUtil.isNumber(config_value);
|
||||
if (!isNumber) return defaultValue;
|
||||
return Convert.toFloat(config_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 返回值
|
||||
*
|
||||
* @param configs 容器数据
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private String getConfig(Map<String, Object> configs, String key) {
|
||||
return (String) configs.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 返回值 没有则返回默认值
|
||||
*
|
||||
* @param configs 容器数据
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private String getConfig(Map<String, Object> configs, String key, String defaultValue) {
|
||||
String value = getConfig(configs, key);
|
||||
if (StrUtil.isBlank(value)) return defaultValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 返回值 没有则返回默认值
|
||||
*
|
||||
* @param configs 容器数据
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private Boolean getConfig(Map<String, Object> configs, String key, Boolean defaultValue) {
|
||||
String value = getConfig(configs, key);
|
||||
if (StrUtil.isBlank(value)) return defaultValue;
|
||||
return "1".equals(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 返回值 没有则返回默认值
|
||||
*
|
||||
* @param configs 容器数据
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private Integer getConfig(Map<String, Object> configs, String key, Integer defaultValue) {
|
||||
String value = getConfig(configs, key);
|
||||
if (StrUtil.isBlank(value)) return defaultValue;
|
||||
return Convert.toInt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 返回值 没有则返回默认值
|
||||
*
|
||||
* @param configs 容器数据
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private Float getConfig(Map<String, Object> configs, String key, Float defaultValue) {
|
||||
String value = getConfig(configs, key);
|
||||
if (StrUtil.isBlank(value)) return defaultValue;
|
||||
return Convert.toFloat(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getConfigFormatByType(String config_type) {
|
||||
if (StrUtil.isBlank(config_type)) return new HashMap();
|
||||
QueryWrapper<AccountBaseConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("config_type", config_type).eq("config_enable", 1);
|
||||
List<AccountBaseConfig> configList = find(queryWrapper);
|
||||
Map<String, String> configMap = configList.stream().collect(Collectors.toMap(AccountBaseConfig::getConfig_key, AccountBaseConfig::getConfig_value, (key1, key2) -> key2));
|
||||
return configMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map languageList(Integer pageNum, Integer pageSize) {
|
||||
QueryWrapper<AccountBaseConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("config_key", "language_settings");
|
||||
AccountBaseConfig language_settings = findOne(queryWrapper);
|
||||
|
||||
String config_value = language_settings.getConfig_value();
|
||||
Map data = handleLanguagePage(config_value, pageNum, pageSize);
|
||||
List<Map> items = (List<Map>) data.get("items");
|
||||
|
||||
AccountBaseConfig defaultLanguage = ObjectUtil.defaultIfNull(get("language_id"), new AccountBaseConfig());
|
||||
String default_language_code = defaultLanguage.getConfig_value();
|
||||
for (Map item : items) {
|
||||
Integer language_id = Convert.toInt(item.get("language_id"));
|
||||
if (CheckUtil.isNotEmpty(language_id)) {
|
||||
String language_code = Convert.toStr(item.get("language_code"));
|
||||
if (ObjectUtil.equal(language_code, default_language_code)) {
|
||||
String language_name = Convert.toStr(item.get("language_name")) + "(默认)";
|
||||
item.put("language_is_default", 1);
|
||||
item.put("language_name", language_name);
|
||||
}
|
||||
} else {
|
||||
item.put("language_status", 0);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editLanguage(Integer language_id, Integer language_status) {
|
||||
QueryWrapper<AccountBaseConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("config_key", "language_settings");
|
||||
AccountBaseConfig language_settings = findOne(queryWrapper);
|
||||
|
||||
String config_value = language_settings.getConfig_value();
|
||||
Map<String, Map> map_language_settings = ObjectUtil.defaultIfNull(JSONUtil.toBean(config_value, Map.class), new HashMap());
|
||||
Map map_language_setting = map_language_settings.get(String.valueOf(language_id));
|
||||
if (map_language_setting == null) return false;
|
||||
|
||||
map_language_setting.put("language_status", language_status);
|
||||
|
||||
AccountBaseConfig accountBaseConfig = new AccountBaseConfig();
|
||||
accountBaseConfig.setConfig_key("language_settings");
|
||||
accountBaseConfig.setConfig_value(JSONUtil.toJsonStr(map_language_settings));
|
||||
return saveOrUpdate(accountBaseConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getSystemConfig() {
|
||||
List<String> keys = ListUtil.toList("default_image");
|
||||
List<AccountBaseConfig> list = gets(keys);
|
||||
Map<String, String> result = list.stream().collect(Collectors.toMap(AccountBaseConfig::getConfig_key, AccountBaseConfig::getConfig_value, (k1, k2) -> k2));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据keys 获取config
|
||||
*
|
||||
* @param config_keys
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<AccountBaseConfig> getConfigs(List<String> config_keys) {
|
||||
return gets(config_keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页数据 并处理json 数据
|
||||
*
|
||||
* @param config_value json 数据
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
private Map handleLanguagePage(String config_value, Integer pageNum, Integer pageSize) {
|
||||
Map data = new HashMap();
|
||||
List items = new ArrayList();
|
||||
|
||||
Map<String, Map> map_language_settings = ObjectUtil.defaultIfNull(JSONUtil.toBean(config_value, Map.class), new HashMap());
|
||||
List language_settings = map_language_settings.entrySet().stream().map(s -> s.getValue()).collect(Collectors.toList());
|
||||
|
||||
int total = language_settings.size();
|
||||
int start = (pageNum - 1) * pageSize;
|
||||
int end = start + pageSize;
|
||||
|
||||
if (total > start && total >= end) {
|
||||
for (int i = start; i < end; i++) {
|
||||
items.add(language_settings.get(i));
|
||||
}
|
||||
} else if (total > start && total < end) {
|
||||
for (int i = start; i < total; i++) {
|
||||
items.add(language_settings.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
data.put("total", total);
|
||||
data.put("items", items);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步配置表缓存
|
||||
*
|
||||
* @param loop
|
||||
*/
|
||||
@Async
|
||||
public void syncCache(boolean loop) {
|
||||
while (true) {
|
||||
// 订阅binlog + 消息队列更优
|
||||
Long cacheVersion = Convert.toLong(redisService.get(RedisConstant.Config_Cache_Version), 0L);
|
||||
|
||||
// 对比缓存和本地版本号,不一致就更新
|
||||
if (!version.equals(cacheVersion) || configMap == null) {
|
||||
|
||||
log.info("config data changes perform updates");
|
||||
|
||||
List<AccountBaseConfig> baseConfigs;
|
||||
|
||||
// 从缓存中取
|
||||
Boolean hasKey = redisService.hasKey(RedisConstant.Config_Cache_Key);
|
||||
if (hasKey) {
|
||||
// 本地存储
|
||||
Object o = redisService.hGetAll(RedisConstant.Config_Cache_Key);
|
||||
configMap = Convert.toMap(String.class, AccountBaseConfig.class, o);
|
||||
} else {
|
||||
// 查询数据库更新到缓存中
|
||||
baseConfigs = this.baseMapper.selectList(new QueryWrapper<>());
|
||||
|
||||
// 本地存储
|
||||
configMap = baseConfigs.stream()
|
||||
.collect(Collectors.toMap(AccountBaseConfig::getConfig_key, config -> config));
|
||||
|
||||
redisService.hSetAll(RedisConstant.Config_Cache_Key, configMap);
|
||||
// 放发通知
|
||||
redisService.incr(RedisConstant.Config_Cache_Version, 1);
|
||||
}
|
||||
|
||||
version = cacheVersion;
|
||||
}
|
||||
|
||||
// 如果不循环则执行初始化的一次就退出
|
||||
if (!loop) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(Collection<AccountBaseConfig> configs) {
|
||||
boolean b = super.saveOrUpdate(configs);
|
||||
|
||||
if (b) {
|
||||
// 如果是配置表则更新缓存数据并更新版本号
|
||||
List<AccountBaseConfig> configList = Convert.toList(AccountBaseConfig.class, configs);
|
||||
List<String> configKeys = CommonUtil.column(configList, AccountBaseConfig::getConfig_key);
|
||||
|
||||
// 实体可能不携带其他字段,这里必须查询完整的数据
|
||||
configList = Convert.toList(AccountBaseConfig.class, listByIds(configKeys));
|
||||
Map<String, AccountBaseConfig> configMap = configList.stream()
|
||||
.collect(Collectors.toMap(AccountBaseConfig::getConfig_key, config -> config));
|
||||
redisService.hSetAll(RedisConstant.Config_Cache_Key, configMap);
|
||||
redisService.incr(RedisConstant.Config_Cache_Version, 1);
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(AccountBaseConfig config) {
|
||||
List<AccountBaseConfig> configs = new ArrayList<>();
|
||||
configs.add(config);
|
||||
return saveOrUpdate(configs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void run(String... args) throws Exception {
|
||||
syncCache(true);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.AccountBaseRoleLevelMapper;
|
||||
import com.suisung.mall.account.service.AccountBaseRoleLevelService;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseRoleLevel;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色等级表-平台 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-28
|
||||
*/
|
||||
@Service
|
||||
public class AccountBaseRoleLevelServiceImpl extends BaseServiceImpl<AccountBaseRoleLevelMapper, AccountBaseRoleLevel> implements AccountBaseRoleLevelService {
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.account.mapper.AccountBaseUserLevelMapper;
|
||||
import com.suisung.mall.account.service.AccountBaseUserLevelService;
|
||||
import com.suisung.mall.common.modules.account.AccountBaseUserLevel;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级表-平台 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
@Service
|
||||
public class AccountBaseUserLevelServiceImpl extends BaseServiceImpl<AccountBaseUserLevelMapper, AccountBaseUserLevel> implements AccountBaseUserLevelService {
|
||||
|
||||
@Override
|
||||
public Map listBaseUserLevel() {
|
||||
return getLists(new QueryWrapper<AccountBaseUserLevel>(), 1, 500);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取分页列表
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @param page 当前页码 默认值 1
|
||||
* @param rows 每页显示记录数 默认值 500
|
||||
*/
|
||||
private Map getLists(QueryWrapper<AccountBaseUserLevel> queryWrapper, int page, int rows) {
|
||||
Page<AccountBaseUserLevel> userLevelPage = lists(queryWrapper, page, rows);
|
||||
return toMobileResult(userLevelPage);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.AccountUserAnalyticsMapper;
|
||||
import com.suisung.mall.account.service.AccountUserAnalyticsService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserAnalytics;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-09-28
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserAnalyticsServiceImpl extends BaseServiceImpl<AccountUserAnalyticsMapper, AccountUserAnalytics> implements AccountUserAnalyticsService {
|
||||
|
||||
@Override
|
||||
public AccountUserAnalytics getUserAnalyticsByUserId(Integer userId) {
|
||||
return this.baseMapper.selectById(userId);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,256 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.mapper.AccountUserBindConnectMapper;
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.account.service.AccountUserBindConnectService;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户绑定表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUserBindConnectMapper, AccountUserBindConnect> implements AccountUserBindConnectService {
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
/**
|
||||
* 获取有效绑定
|
||||
*
|
||||
* @param user_id
|
||||
* @param bind_type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map getBind(Integer user_id, int bind_type) {
|
||||
|
||||
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", user_id)
|
||||
.eq("bind_active", 1)
|
||||
.eq("bind_type", bind_type);
|
||||
AccountUserBindConnect bindConnect = findOne(queryWrapper);
|
||||
|
||||
return Convert.toMap(String.class, Object.class, bindConnect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkBind(String bind_id, int bind_type, Integer user_id, AccountUserBindConnect user_info_row) {
|
||||
|
||||
AccountUserBindConnect bind_row = get(bind_id);
|
||||
if (bind_row != null && CheckUtil.isNotEmpty(bind_row.getUser_id())) {
|
||||
// 验证通过, 登录成功.
|
||||
Integer bind_user_id = bind_row.getUser_id();
|
||||
if (CheckUtil.isNotEmpty(user_id) && ObjectUtil.equal(user_id, bind_user_id)) {
|
||||
throw new ApiException(I18nUtil._("非法请求,已经登录用户不应该访问到此页面-重复绑定"));
|
||||
} else if (CheckUtil.isEmpty(user_id) && ObjectUtil.equal(user_id, bind_user_id)) {
|
||||
throw new ApiException(I18nUtil._("非法请求,错误绑定数据"));
|
||||
}
|
||||
} else if (bind_row != null && CheckUtil.isEmpty(bind_row.getUser_id())) {
|
||||
|
||||
user_info_row.setUser_id(user_id);
|
||||
user_info_row.setBind_id(bind_id);
|
||||
|
||||
if (!saveOrUpdate(user_info_row)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
} else if (bind_row == null) {
|
||||
|
||||
// todo 头像会变动, 需要本地缓存, 生成新网址.
|
||||
user_info_row.setBind_id(bind_id);
|
||||
user_info_row.setBind_type(bind_type);
|
||||
user_info_row.setUser_id(user_id);
|
||||
|
||||
if (!saveOrUpdate(user_info_row)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean checkAccessToken(Integer bind_type, AccountUserBindConnect bind_data, Integer user_id) {
|
||||
|
||||
String bind_id = bind_data.getBind_id();
|
||||
|
||||
// todo 验证验证码
|
||||
if (true) {
|
||||
bind_data.setBind_active(1);
|
||||
bind_data.setUser_id(user_id);
|
||||
bind_data.setBind_type(bind_type);
|
||||
|
||||
// 判断是否已经绑定
|
||||
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("bind_id", bind_id).eq("bind_type", bind_type);
|
||||
AccountUserBindConnect bind_row = findOne(queryWrapper);
|
||||
|
||||
if (bind_row != null) {
|
||||
Integer bind_active = bind_row.getBind_active();
|
||||
|
||||
if (bind_active == 1) {
|
||||
Integer bind_user_id = bind_row.getUser_id();
|
||||
if (ObjectUtil.equal(bind_user_id, user_id)) {
|
||||
return true;
|
||||
} else {
|
||||
throw new ApiException(I18nUtil._("其它用户已绑定!"));
|
||||
}
|
||||
} else {
|
||||
if (!edit(bind_data)) {
|
||||
throw new ApiException(I18nUtil._("绑定修改失败!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AccountUserInfo userInfo = new AccountUserInfo();
|
||||
switch (bind_type) {
|
||||
case 1:
|
||||
String user_intl = ObjectUtil.defaultIfNull(getParameter("user_intl"), "+86");
|
||||
String sub_user_intl = bind_id.substring(0, user_intl.length());
|
||||
if (StrUtil.equals(user_intl, sub_user_intl)) {
|
||||
userInfo.setUser_mobile(StrUtil.removePrefix(bind_id, sub_user_intl));
|
||||
userInfo.setUser_intl(user_intl);
|
||||
} else {
|
||||
userInfo.setUser_mobile(bind_id);
|
||||
}
|
||||
bind_data.setBind_openid(bind_id);
|
||||
break;
|
||||
case 2:
|
||||
userInfo.setUser_email(bind_id);
|
||||
bind_data.setBind_openid(bind_id);
|
||||
break;
|
||||
}
|
||||
|
||||
userInfo.setUser_id(user_id);
|
||||
if (!accountUserInfoService.edit(userInfo)) {
|
||||
throw new ApiException(I18nUtil._("保存用户数据失败!"));
|
||||
}
|
||||
|
||||
if (!saveOrUpdate(bind_data)) {
|
||||
throw new ApiException(I18nUtil._("保存用户绑定失败!"));
|
||||
}
|
||||
} else {
|
||||
throw new ApiException(I18nUtil._("验证码错误!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer doUserBind(AccountUserBindConnect user_info_row, String activity_id, boolean reg_flag) {
|
||||
|
||||
Integer user_id = null;
|
||||
|
||||
String bind_id = user_info_row.getBind_id();
|
||||
AccountUserBase user_base_row = accountUserBaseService.getByAccount(bind_id);
|
||||
|
||||
//unionId 获取,如果存在
|
||||
if (user_info_row.getBind_unionid() != null) {
|
||||
//检测unionId, 判断用户
|
||||
if (user_base_row == null) {
|
||||
//根据unionId,判断已经绑定的用户
|
||||
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("bind_unionid", user_info_row.getBind_unionid());
|
||||
AccountUserBindConnect find_bind_row = findOne(queryWrapper);
|
||||
if (find_bind_row != null) {
|
||||
user_base_row = accountUserBaseService.get(find_bind_row.getUser_id());
|
||||
|
||||
//运行到此处
|
||||
//判断bind openid是否存在,不存在则需要添加
|
||||
//支付地方需要调用到openid, 此处必须冗余存放openid
|
||||
AccountUserBindConnect open_bind_row = get(bind_id);
|
||||
|
||||
if (null == open_bind_row) {
|
||||
user_info_row.setBind_active(1);
|
||||
user_info_row.setBind_type(user_info_row.getBind_type());
|
||||
save(user_info_row);
|
||||
}
|
||||
AccountUserBase accountUserBase = accountUserBaseService.get(find_bind_row.getUser_id());
|
||||
if (accountUserBase != null) {
|
||||
user_id = accountUserBase.getUser_id();
|
||||
AccountUserBindConnect userBindConnect = new AccountUserBindConnect();
|
||||
userBindConnect.setBind_id(bind_id);
|
||||
userBindConnect.setUser_id(user_id);
|
||||
edit(userBindConnect);
|
||||
return user_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//throw new Exception(__('unionId 不存在'));
|
||||
}
|
||||
|
||||
//自动注册用户
|
||||
if (user_base_row != null) {
|
||||
user_id = user_base_row.getUser_id();
|
||||
} else {
|
||||
boolean flag = false;
|
||||
//需要注册用户
|
||||
if (reg_flag) {
|
||||
Map reg_info = new HashMap();
|
||||
reg_info.put("user_account", bind_id);
|
||||
reg_info.put("user_password", "Ss@123" + UUID.randomUUID().toString());
|
||||
reg_info.put("user_nickname", user_info_row.getBind_nickname());
|
||||
reg_info.put("activity_id", activity_id);
|
||||
|
||||
user_base_row = accountUserBaseService.register(reg_info);
|
||||
|
||||
if (user_base_row != null) {
|
||||
user_id = user_base_row.getUser_id();
|
||||
|
||||
//添加user info
|
||||
Map info = new HashMap();
|
||||
info.put("user_nickname", user_info_row.getBind_nickname());// 名称
|
||||
info.put("user_avatar", user_info_row.getBind_icon());
|
||||
info.put("user_gender", user_info_row.getBind_gender()); // 性别 1:男 2:女
|
||||
|
||||
/*
|
||||
if ($qy_userid)
|
||||
{
|
||||
$info['user_level_id'] = 1006 ; // 性别 1:男 2:女
|
||||
$info['user_notename'] = $qy_userid ; //
|
||||
}
|
||||
*/
|
||||
|
||||
flag = accountUserInfoService.editAccount(user_id, info);
|
||||
flag = checkBind(bind_id, user_info_row.getBind_type(), user_id, user_info_row);
|
||||
}
|
||||
} else {
|
||||
//读取用户信息
|
||||
user_id = user_info_row.getUser_id();
|
||||
flag = checkBind(bind_id, user_info_row.getBind_type(), user_id, user_info_row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return user_id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.AccountUserChainMapper;
|
||||
import com.suisung.mall.account.service.AccountUserChainService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChain;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 门店顾客关系表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-28
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserChainServiceImpl extends BaseServiceImpl<AccountUserChainMapper, AccountUserChain> implements AccountUserChainService {
|
||||
}
|
||||
@ -0,0 +1,489 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.mapper.AccountUserChannelBringMapper;
|
||||
import com.suisung.mall.account.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.account.service.AccountUserChannelBringService;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.common.constant.RedisConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.PayService;
|
||||
import com.suisung.mall.common.feignService.ShopService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelBring;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.common.modules.pay.PayPaymentChannel;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.pojo.vo.UserChannelBringVO;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.excel.ExcelUtil;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 渠道引流表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author yanhelong
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserChannelBringServiceImpl extends BaseServiceImpl<AccountUserChannelBringMapper, AccountUserChannelBring> implements AccountUserChannelBringService {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService userBaseService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Override
|
||||
public IPage<AccountUserChannelBring> getList(AccountUserChannelBring accountUserChannelBring, Integer pageNum, Integer pageSize) {
|
||||
if (CheckUtil.isEmpty(accountUserChannelBring.getUcc_id())) {
|
||||
throw new ApiException(I18nUtil._("渠道编号不能为空!"));
|
||||
}
|
||||
QueryWrapper<AccountUserChannelBring> bringQueryWrapper = new QueryWrapper<>();
|
||||
bringQueryWrapper.eq("ucc_id", accountUserChannelBring.getUcc_id());
|
||||
bringQueryWrapper.orderByAsc("ucb_id");
|
||||
IPage<AccountUserChannelBring> channelBringPage = lists(bringQueryWrapper, pageNum, pageSize);
|
||||
|
||||
|
||||
if (channelBringPage != null && CollectionUtil.isNotEmpty(channelBringPage.getRecords())) {
|
||||
List<AccountUserChannelBring> userChannelBrings = channelBringPage.getRecords();
|
||||
List<Integer> userIds = userChannelBrings.stream().map(AccountUserChannelBring::getUser_id).distinct().collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(userIds)) {
|
||||
Map<Integer, String> nickNameMap = getNickNameMap(userIds);
|
||||
Map<Integer, String> mobileMap = getMobileMap(userIds);
|
||||
|
||||
//填充数据
|
||||
for (AccountUserChannelBring userChannelBring : userChannelBrings) {
|
||||
if (!nickNameMap.isEmpty()) {
|
||||
userChannelBring.setUser_nickname(nickNameMap.get(userChannelBring.getUser_id()));
|
||||
}
|
||||
|
||||
if (!mobileMap.isEmpty()) {
|
||||
userChannelBring.setUser_mobile(mobileMap.get(userChannelBring.getUser_id()));
|
||||
}
|
||||
|
||||
if (userChannelBring.getUcb_scan_time() != null) {
|
||||
String scan_time = DateUtil.format(userChannelBring.getUcb_scan_time(), "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (scan_time.equals("1970-01-02 00:00:00")) {
|
||||
userChannelBring.setUcb_scan_time(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return channelBringPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportFile(HttpServletResponse response, List<Integer> ucb_ids) {
|
||||
List<AccountUserChannelBring> channelBrings = gets(ucb_ids);
|
||||
|
||||
if (CollectionUtil.isEmpty(channelBrings)) {
|
||||
throw new ApiException(I18nUtil._("选中数据为空!"));
|
||||
}
|
||||
List<Integer> userIds = channelBrings.stream().map(AccountUserChannelBring::getUser_id).distinct().collect(Collectors.toList());
|
||||
Map<Integer, String> nickNameMap = getNickNameMap(userIds);
|
||||
Map<Integer, String> mobileMap = getMobileMap(userIds);
|
||||
List<UserChannelBringVO> channelBringVOS = new ArrayList<>();
|
||||
for (AccountUserChannelBring channelBring : channelBrings) {
|
||||
UserChannelBringVO bringVO = new UserChannelBringVO();
|
||||
bringVO.setUcb_id(channelBring.getUcb_id());
|
||||
bringVO.setUser_id(channelBring.getUser_id());
|
||||
|
||||
if (!nickNameMap.isEmpty()) {
|
||||
bringVO.setUser_nickname(nickNameMap.get(channelBring.getUser_id()));
|
||||
}
|
||||
|
||||
if (!mobileMap.isEmpty()) {
|
||||
bringVO.setUser_mobile(mobileMap.get(channelBring.getUser_id()));
|
||||
}
|
||||
|
||||
if (channelBring.getUcb_scan_time() != null) {
|
||||
String scan_time = DateUtil.format(channelBring.getUcb_scan_time(), "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (scan_time.equals("1970-01-02 00:00:00")) {
|
||||
bringVO.setUcb_scan_time(null);
|
||||
} else {
|
||||
bringVO.setUcb_scan_time(scan_time);
|
||||
}
|
||||
}
|
||||
channelBringVOS.add(bringVO);
|
||||
}
|
||||
ExcelUtil.exportReport(response, 1, "渠道引流用户信息", channelBringVOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> info() {
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
data.put("config", config);
|
||||
// 获取配置文件
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
Integer user_id = ObjectUtil.isNotNull(user) ? user.getId() : null;
|
||||
|
||||
data.put("store_type", 0);
|
||||
if (user != null && user.isStore()) {
|
||||
ShopStoreBase shopStoreBase = shopService.getShopStoreBase(Convert.toInt(user.getStore_id()));
|
||||
if (null != shopStoreBase) {
|
||||
data.put("store_type", shopStoreBase.getStore_type());
|
||||
}
|
||||
}
|
||||
|
||||
// 站点状态
|
||||
Integer site_status = accountBaseConfigService.getConfig("site_status", 0);
|
||||
String site_email = accountBaseConfigService.getConfig("site_email");
|
||||
|
||||
Integer plantform_fx_enable = accountBaseConfigService.getConfig("plantform_fx_enable", 0);
|
||||
Integer sale_prize_sp_enable = accountBaseConfigService.getConfig("sale_prize_sp_enable", 0);
|
||||
|
||||
// 最低佣金结算余额
|
||||
Integer plantform_fx_gift_point = accountBaseConfigService.getConfig("plantform_fx_gift_point", 0);
|
||||
// 最低佣金结算余额
|
||||
Integer plantform_fx_withdraw_min_amount = accountBaseConfigService.getConfig("plantform_fx_withdraw_min_amount", 0);
|
||||
Integer withdraw_min_amount = accountBaseConfigService.getConfig("withdraw_min_amount", 0);
|
||||
Integer withdraw_received_day = accountBaseConfigService.getConfig("withdraw_received_day", 0);
|
||||
String withdraw_monthday = accountBaseConfigService.getConfig("withdraw_monthday", "");
|
||||
Integer withdraw_fee_rate = accountBaseConfigService.getConfig("withdraw_fee_rate", 0);
|
||||
String version = accountBaseConfigService.getConfig("site_version", "1.01");
|
||||
String name = accountBaseConfigService.getConfig("site_name");
|
||||
String site_logo = accountBaseConfigService.getConfig("site_logo");
|
||||
String logo = accountBaseConfigService.getConfig("textmini_site_logo");
|
||||
String logo_code = accountBaseConfigService.getConfig("textmini_site_logo");
|
||||
// pc 首页banner
|
||||
String index_banner_pc_html = accountBaseConfigService.getConfig("index_banner_pc_html");
|
||||
Integer index_banner_pc_enable = accountBaseConfigService.getConfig("index_banner_pc_enable", 0);
|
||||
// pc 首页弹窗
|
||||
String index_pop_pc_img = accountBaseConfigService.getConfig("index_pop_pc_img");
|
||||
String index_pop_pc_url = accountBaseConfigService.getConfig("index_pop_pc_url");
|
||||
Integer index_pop_pc_enable = accountBaseConfigService.getConfig("index_pop_pc_enable", 0);
|
||||
|
||||
String copyright = accountBaseConfigService.getConfig("copyright");
|
||||
String site_icon = accountBaseConfigService.getConfig("site_icon");
|
||||
Integer pc_enable = accountBaseConfigService.getConfig("pc_enable", 0);
|
||||
String icp_number = accountBaseConfigService.getConfig("icp_number");
|
||||
Integer plantform_template = Convert.toInt(accountBaseConfigService.getConfig("plantform_template"));
|
||||
String statistics_code = accountBaseConfigService.getConfig("statistics_code");
|
||||
String site_meta_description = accountBaseConfigService.getConfig("site_meta_description");
|
||||
String site_meta_keyword = accountBaseConfigService.getConfig("site_meta_keyword");
|
||||
String site_company_name = accountBaseConfigService.getConfig("site_company_name");
|
||||
String site_address = accountBaseConfigService.getConfig("site_address");
|
||||
String site_tel = accountBaseConfigService.getConfig("site_tel");
|
||||
String site_im = accountBaseConfigService.getConfig("site_im");
|
||||
Integer donwload_app_enable = getConfigIntFlag("donwload_app_enable", false);
|
||||
String promotion = accountBaseConfigService.getConfig("site_promotion", name);
|
||||
String AppIconPath = "https://static.lancerdt.com/xcxfile/appicon/";
|
||||
BigDecimal plantform_fx_cps_rate_1 = NumberUtil.div(userInfoService.getDistUserLevelConfig("plantform_fx_cps_rate_1", user_id, BigDecimal.ZERO), 100);
|
||||
BigDecimal plantform_fx_cps_rate_2 = NumberUtil.div(userInfoService.getDistUserLevelConfig("plantform_fx_cps_rate_2", user_id, BigDecimal.ZERO), 100);
|
||||
data.put("plantform_fx_gift_point", plantform_fx_gift_point);
|
||||
data.put("plantform_fx_withdraw_min_amount", plantform_fx_withdraw_min_amount);
|
||||
data.put("withdraw_min_amount", withdraw_min_amount);
|
||||
data.put("withdraw_received_day", withdraw_received_day);
|
||||
data.put("withdraw_monthday", withdraw_monthday);
|
||||
data.put("withdraw_fee_rate", withdraw_fee_rate);
|
||||
data.put("version", version);
|
||||
data.put("name", name);
|
||||
data.put("site_logo", site_logo);
|
||||
data.put("logo", logo);
|
||||
data.put("logo_code", logo_code);
|
||||
|
||||
data.put("index_banner_pc_html", index_banner_pc_html);
|
||||
data.put("index_banner_pc_enable", index_banner_pc_enable);
|
||||
data.put("index_pop_pc_img", index_pop_pc_img);
|
||||
data.put("index_pop_pc_url", index_pop_pc_url);
|
||||
data.put("index_pop_pc_enable", index_pop_pc_enable);
|
||||
|
||||
data.put("copyright", copyright);
|
||||
data.put("site_icon", site_icon);
|
||||
data.put("pc_enable", pc_enable);
|
||||
data.put("icp_number", icp_number);
|
||||
data.put("plantform_template", plantform_template);
|
||||
data.put("statistics_code", statistics_code);
|
||||
data.put("site_meta_description", site_meta_description);
|
||||
data.put("site_meta_keyword", site_meta_keyword);
|
||||
data.put("site_company_name", site_company_name);
|
||||
data.put("site_address", site_address);
|
||||
data.put("site_tel", site_tel);
|
||||
data.put("site_im", site_im);
|
||||
data.put("donwload_app_enable", donwload_app_enable);
|
||||
data.put("promotion", promotion);
|
||||
data.put("AppIconPath", AppIconPath);
|
||||
data.put("plantform_fx_cps_rate_1", plantform_fx_cps_rate_1);
|
||||
data.put("plantform_fx_cps_rate_2", plantform_fx_cps_rate_2);
|
||||
data.put("site_email", site_email);
|
||||
|
||||
|
||||
Integer multishop_enable = Convert.toInt(accountBaseConfigService.getConfig("multishop_enable"));
|
||||
Integer evaluation_enable = Convert.toInt(accountBaseConfigService.getConfig("evaluation_enable"));
|
||||
Integer saas_status = Convert.toInt(accountBaseConfigService.getConfig("saas_status"));
|
||||
Integer virtual_enable = Convert.toInt(accountBaseConfigService.getConfig("virtual_enable"));
|
||||
Integer o2o_enable = Convert.toInt(accountBaseConfigService.getConfig("o2o_enable"));
|
||||
Integer chain_enable = Convert.toInt(accountBaseConfigService.getConfig("chain_enable"));
|
||||
Float points_vaue_rate = accountBaseConfigService.getConfig("points_vaue_rate", 0.01f);
|
||||
Float sp_vaue_rate = accountBaseConfigService.getConfig("sp_vaue_rate", 0.01f);
|
||||
|
||||
// 三级分销
|
||||
// Integer plantform_fx_enable = accountBaseConfigService.getConfig(configs, "plantform_fx_enable", 0);
|
||||
Integer store_fx_enable = accountBaseConfigService.getConfig("store_fx_enable", 0);
|
||||
|
||||
// 销售奖
|
||||
// Integer sale_prize_sp_enable = Convert.toInt(sale_prize_sp_enable);
|
||||
|
||||
// todo 代理模式
|
||||
Integer Plugin_DistributionAgent = accountBaseConfigService.getConfig("Plugin_DistributionAgent", 0);
|
||||
Integer plantform_fx_agent_enable = (plantform_fx_enable != 0 && Plugin_DistributionAgent != 0) ? 1 : 0;
|
||||
|
||||
// 城市合伙人
|
||||
Integer Plugin_DistributionPartner = accountBaseConfigService.getConfig("Plugin_DistributionPartner", 0);
|
||||
Integer plantform_fx_pt_enable = (plantform_fx_enable != 0 && Plugin_DistributionPartner != 0) ? 1 : 0;
|
||||
|
||||
Integer Plugin_DistributionWeStore = accountBaseConfigService.getConfig("plantform_fx_westore_enable", 0);
|
||||
Integer plantform_fx_westore_enable = (plantform_fx_enable != 0 && Plugin_DistributionWeStore != 0) ? 1 : 0;
|
||||
Integer delivery_time_enable = accountBaseConfigService.getConfig("delivery_time_enable", 0);
|
||||
Integer user_level_rate_enable = accountBaseConfigService.getConfig("user_level_rate_enable", 0);
|
||||
|
||||
Integer plantform_rebate_enable = accountBaseConfigService.getConfig("plantform_rebate_enable", 0);
|
||||
Integer plantform_commission_withdraw_mode = accountBaseConfigService.getConfig("plantform_commission_withdraw_mode", 0);
|
||||
Integer redpacket_enable = accountBaseConfigService.getConfig("redpacket_enable", 0);
|
||||
Integer credit_enable = accountBaseConfigService.getConfig("credit_enable", 0);
|
||||
Integer point_enable = accountBaseConfigService.getConfig("point_enable", 0);
|
||||
Integer point_sp_enable = accountBaseConfigService.getConfig("point_sp_enable", 0);
|
||||
Integer exchangecard_enable = accountBaseConfigService.getConfig("exchangecard_enable", 0);
|
||||
Integer money_transfer_enable = accountBaseConfigService.getConfig("money_transfer_enable", 0);
|
||||
|
||||
Integer sns_enable = accountBaseConfigService.getConfig("sns_enable", 0);
|
||||
Integer im_enable = accountBaseConfigService.getConfig("im_enable", 0);
|
||||
Integer subsite_enable = accountBaseConfigService.getConfig("subsite_enable", 0);
|
||||
|
||||
Integer cache_expire = accountBaseConfigService.getConfig("client_cache_expire", 3600);
|
||||
Integer force_bind_mobile = accountBaseConfigService.getConfig("force_bind_mobile", 0);
|
||||
Integer chat_global = accountBaseConfigService.getConfig("chat_global", 1);
|
||||
Integer hall_b2b_enable = accountBaseConfigService.getConfig("hall_b2b_enable", 0);
|
||||
Integer b2b_flag = accountBaseConfigService.getConfig("b2b_flag", 0);
|
||||
Integer prodcut_addcart_flag = accountBaseConfigService.getConfig("prodcut_addcart_flag", 0);
|
||||
Integer hall_enterprise_enable = accountBaseConfigService.getConfig("hall_enterprise_enable", 0);
|
||||
Integer wechat_connect_auto = accountBaseConfigService.getConfig("wechat_connect_auto", 0);
|
||||
Integer cache = accountBaseConfigService.getConfig("client_cache", 0);
|
||||
config.put("multishop_enable", multishop_enable);
|
||||
config.put("evaluation_enable", evaluation_enable);
|
||||
config.put("saas_status", saas_status);
|
||||
config.put("virtual_enable", virtual_enable);
|
||||
config.put("o2o_enable", o2o_enable);
|
||||
config.put("chain_enable", chain_enable);
|
||||
config.put("points_vaue_rate", points_vaue_rate);
|
||||
config.put("sp_vaue_rate", sp_vaue_rate);
|
||||
config.put("site_status", site_status);
|
||||
config.put("plantform_fx_enable", plantform_fx_enable);
|
||||
config.put("sale_prize_sp_enable", sale_prize_sp_enable);
|
||||
config.put("plantform_fx_agent_enable", plantform_fx_agent_enable);
|
||||
config.put("plantform_fx_pt_enable", plantform_fx_pt_enable);
|
||||
config.put("plantform_fx_westore_enable", plantform_fx_westore_enable);
|
||||
config.put("delivery_time_enable", delivery_time_enable);
|
||||
config.put("user_level_rate_enable", user_level_rate_enable);
|
||||
config.put("plantform_rebate_enable", plantform_rebate_enable);
|
||||
config.put("plantform_commission_withdraw_mode", plantform_commission_withdraw_mode);
|
||||
config.put("redpacket_enable", redpacket_enable);
|
||||
config.put("credit_enable", credit_enable);
|
||||
config.put("point_enable", point_enable);
|
||||
config.put("point_sp_enable", point_sp_enable);
|
||||
config.put("exchangecard_enable", exchangecard_enable);
|
||||
config.put("money_transfer_enable", money_transfer_enable);
|
||||
config.put("sns_enable", sns_enable);
|
||||
config.put("im_enable", im_enable);
|
||||
config.put("subsite_enable", subsite_enable);
|
||||
config.put("cache_expire", cache_expire);
|
||||
config.put("force_bind_mobile", force_bind_mobile);
|
||||
config.put("chat_global", chat_global);
|
||||
config.put("b2b_flag", b2b_flag);
|
||||
config.put("hall_b2b_enable", hall_b2b_enable);
|
||||
config.put("hall_enterprise_enable", hall_b2b_enable);
|
||||
config.put("prodcut_addcart_flag", prodcut_addcart_flag);
|
||||
config.put("cache", cache);
|
||||
config.put("wechat_connect_auto", wechat_connect_auto);
|
||||
|
||||
config.put("multilang_enable", accountBaseConfigService.getConfig("multilang_enable", 0));
|
||||
config.put("product_salenum_flag", accountBaseConfigService.getConfig("product_salenum_flag", 0));
|
||||
config.put("product_ziti_flag", accountBaseConfigService.getConfig("product_ziti_flag", 0));
|
||||
|
||||
config.put("supplier_market_enable", accountBaseConfigService.getConfig("supplier_market_enable", false));
|
||||
config.put("edu_enable", accountBaseConfigService.getConfig("edu_enable", false));
|
||||
config.put("esearch_enable", accountBaseConfigService.getConfig("esearch_enable", false));
|
||||
config.put("product_spec_edit", accountBaseConfigService.getConfig("product_spec_edit", false));
|
||||
|
||||
// SEO参数
|
||||
Map seoParams = new HashMap();
|
||||
seoParams.put("article_content_description", accountBaseConfigService.getConfig("article_content_description"));
|
||||
seoParams.put("article_content_keywords", accountBaseConfigService.getConfig("article_content_keywords"));
|
||||
seoParams.put("article_content_title", accountBaseConfigService.getConfig("article_content_title"));
|
||||
seoParams.put("article_description", accountBaseConfigService.getConfig("article_description"));
|
||||
seoParams.put("article_keywords", accountBaseConfigService.getConfig("article_keywords"));
|
||||
seoParams.put("article_title", accountBaseConfigService.getConfig("article_title"));
|
||||
seoParams.put("brand_content_description", accountBaseConfigService.getConfig("brand_content_description"));
|
||||
seoParams.put("brand_content_keywords", accountBaseConfigService.getConfig("brand_content_keywords"));
|
||||
seoParams.put("brand_content_title", accountBaseConfigService.getConfig("brand_content_title"));
|
||||
seoParams.put("brand_description", accountBaseConfigService.getConfig("brand_description"));
|
||||
seoParams.put("brand_keywords", accountBaseConfigService.getConfig("brand_keywords"));
|
||||
seoParams.put("brand_title", accountBaseConfigService.getConfig("brand_title"));
|
||||
seoParams.put("category_description", accountBaseConfigService.getConfig("category_description"));
|
||||
seoParams.put("category_keywords", accountBaseConfigService.getConfig("category_keywords"));
|
||||
seoParams.put("category_title", accountBaseConfigService.getConfig("category_title"));
|
||||
seoParams.put("gb_content_description", accountBaseConfigService.getConfig("gb_content_description"));
|
||||
seoParams.put("gb_content_keywords", accountBaseConfigService.getConfig("gb_content_keywords"));
|
||||
seoParams.put("gb_content_title", accountBaseConfigService.getConfig("gb_content_title"));
|
||||
seoParams.put("gb_description", accountBaseConfigService.getConfig("gb_description"));
|
||||
seoParams.put("gb_keywords", accountBaseConfigService.getConfig("gb_keywords"));
|
||||
seoParams.put("gb_title", accountBaseConfigService.getConfig("gb_title"));
|
||||
seoParams.put("point_content_description", accountBaseConfigService.getConfig("point_content_description"));
|
||||
seoParams.put("point_content_keywords", accountBaseConfigService.getConfig("point_content_keywords"));
|
||||
seoParams.put("point_content_title", accountBaseConfigService.getConfig("point_content_title"));
|
||||
seoParams.put("point_description", accountBaseConfigService.getConfig("point_description"));
|
||||
seoParams.put("point_keywords", accountBaseConfigService.getConfig("point_keywords"));
|
||||
seoParams.put("point_title", accountBaseConfigService.getConfig("point_title"));
|
||||
seoParams.put("product_description", accountBaseConfigService.getConfig("product_description"));
|
||||
seoParams.put("product_keywords", accountBaseConfigService.getConfig("product_keywords"));
|
||||
seoParams.put("product_title", accountBaseConfigService.getConfig("product_title"));
|
||||
seoParams.put("site_description", accountBaseConfigService.getConfig("site_description"));
|
||||
seoParams.put("site_keywords", accountBaseConfigService.getConfig("site_keywords"));
|
||||
seoParams.put("site_title", accountBaseConfigService.getConfig("site_title"));
|
||||
seoParams.put("sns_description", accountBaseConfigService.getConfig("sns_description"));
|
||||
seoParams.put("sns_keywords", accountBaseConfigService.getConfig("sns_keywords"));
|
||||
seoParams.put("sns_title", accountBaseConfigService.getConfig("sns_title"));
|
||||
seoParams.put("store_description", accountBaseConfigService.getConfig("store_description"));
|
||||
seoParams.put("store_keywords", accountBaseConfigService.getConfig("store_keywords"));
|
||||
seoParams.put("store_title", accountBaseConfigService.getConfig("store_title"));
|
||||
|
||||
config.put("seo", seoParams);
|
||||
|
||||
// todo 有效支付渠道
|
||||
List<PayPaymentChannel> payment_channel_rows = new ArrayList();
|
||||
// isWeixin
|
||||
if (false) {
|
||||
|
||||
} else {
|
||||
Map queryParams = new HashMap();
|
||||
queryParams.put("payment_channel_enable:eq", 1);
|
||||
queryParams.put("store_id:eq", 0);
|
||||
queryParams.put("chain_id:eq", 0);
|
||||
queryParams.put("payment_channel_id:asc", "");
|
||||
payment_channel_rows = payService.findPayChannel(queryParams);
|
||||
}
|
||||
|
||||
List<String> payment_channel_code_row = payment_channel_rows.stream()
|
||||
.map(s -> s.getPayment_channel_code())
|
||||
.collect(Collectors.toList());
|
||||
data.put("payment_channel_code_row", payment_channel_code_row);
|
||||
if (payment_channel_code_row.contains("wx_native")) {
|
||||
payment_channel_code_row.add("wxpay");
|
||||
}
|
||||
|
||||
String source_ucc_code = getParameter("source_ucc_code");
|
||||
if (StrUtil.isNotEmpty(source_ucc_code)) {
|
||||
source_ucc_code = RedisConstant.ucckey_NameSpace + source_ucc_code;
|
||||
try {
|
||||
Set<String> keys = redisService.keys(RedisConstant.ucckey_NameSpace + "*");
|
||||
if (keys.contains(source_ucc_code)) {
|
||||
String cacheKey = Convert.toStr(redisService.get(source_ucc_code));
|
||||
Map<String, Object> cacheVale = Convert.toMap(String.class, Object.class, redisService.get(cacheKey));
|
||||
Integer ucc_id = Convert.toInt(cacheVale.get("ucc_id"));
|
||||
|
||||
Date date = new Date();
|
||||
AccountUserChannelBring channelBring = new AccountUserChannelBring();
|
||||
//判断用户是否注册登录
|
||||
if (user != null && CheckUtil.isNotEmpty(user.getId())) {
|
||||
Integer userId = user.getId();
|
||||
//一个用户 一个渠道 只记录一次
|
||||
QueryWrapper<AccountUserChannelBring> channelBringQueryWrapper = new QueryWrapper<>();
|
||||
channelBringQueryWrapper.eq("ucc_id", ucc_id);
|
||||
channelBringQueryWrapper.eq("user_id", userId);
|
||||
long count = count(channelBringQueryWrapper);
|
||||
|
||||
if (count < 1) {
|
||||
channelBring.setUser_id(userId);
|
||||
channelBring.setUcc_id(ucc_id);
|
||||
channelBring.setUcb_scan_time(date);
|
||||
add(channelBring);
|
||||
}
|
||||
} else {
|
||||
//没有就只记录扫码时间
|
||||
channelBring.setUcc_id(ucc_id);
|
||||
channelBring.setUcb_scan_time(date);
|
||||
add(channelBring);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("错误信息:", e);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key 返回值 没有则返回默认值
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private Integer getConfigIntFlag(String key, Boolean defaultValue) {
|
||||
boolean flag = accountBaseConfigService.getConfig(key, defaultValue);
|
||||
return flag ? 1 : 0;
|
||||
}
|
||||
|
||||
private Map<Integer, String> getMobileMap(List<Integer> userIds) {
|
||||
Map<Integer, String> mobileMap = new HashMap<>();
|
||||
List<AccountUserInfo> userInfos = userInfoService.gets(userIds);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(userInfos)) {
|
||||
mobileMap = userInfos.stream().collect(Collectors.toMap(AccountUserInfo::getUser_id, AccountUserInfo::getUser_mobile, (k1, k2) -> k1));
|
||||
}
|
||||
|
||||
return mobileMap;
|
||||
}
|
||||
|
||||
private Map<Integer, String> getNickNameMap(List<Integer> userIds) {
|
||||
Map<Integer, String> nickNameMap = new HashMap<>();
|
||||
List<AccountUserBase> userBaseList = userBaseService.gets(userIds);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(userBaseList)) {
|
||||
nickNameMap = userBaseList.stream().collect(Collectors.toMap(AccountUserBase::getUser_id, AccountUserBase::getUser_nickname, (k1, k2) -> k1));
|
||||
}
|
||||
|
||||
return nickNameMap;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,160 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.suisung.mall.account.mapper.AccountUserChannelCodeMapper;
|
||||
import com.suisung.mall.account.service.AccountUserChannelBringService;
|
||||
import com.suisung.mall.account.service.AccountUserChannelCodeService;
|
||||
import com.suisung.mall.account.service.AccountUserChannelService;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.ConfigConstant;
|
||||
import com.suisung.mall.common.constant.RedisConstant;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.ShopService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannel;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelBring;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannelCode;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.IdUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道邀请码表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserChannelCodeServiceImpl extends BaseServiceImpl<AccountUserChannelCodeMapper, AccountUserChannelCode> implements AccountUserChannelCodeService {
|
||||
|
||||
@Autowired
|
||||
private AccountUserChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserChannelBringService channelBringService;
|
||||
|
||||
@Override
|
||||
public IPage<AccountUserChannelCode> getList(AccountUserChannelCode accountUserChannelCode, Integer pageNum, Integer pageSize) {
|
||||
QueryWrapper<AccountUserChannelCode> codeQueryWrapper = new QueryWrapper<>();
|
||||
codeQueryWrapper.orderByDesc("ucc_id");
|
||||
|
||||
if (CheckUtil.isNotEmpty(accountUserChannelCode.getUser_channel_id())) {
|
||||
codeQueryWrapper.eq("user_channel_id", accountUserChannelCode.getUser_channel_id());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(accountUserChannelCode.getUcc_code())) {
|
||||
codeQueryWrapper.like("ucc_code",accountUserChannelCode.getUcc_code());
|
||||
}
|
||||
IPage<AccountUserChannelCode> channelCodePage = lists(codeQueryWrapper, pageNum, pageSize);
|
||||
|
||||
if (channelCodePage != null && CollectionUtil.isNotEmpty(channelCodePage.getRecords())) {
|
||||
List<AccountUserChannelCode> userChannelCodeList = channelCodePage.getRecords();
|
||||
List<Integer> channelIdList = userChannelCodeList.stream().map(AccountUserChannelCode::getUser_channel_id).collect(Collectors.toList());
|
||||
List<AccountUserChannel> userChannelList = channelService.gets(channelIdList);
|
||||
Map<Integer, String> channelNameMap = new HashMap<>();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(userChannelList)) {
|
||||
channelNameMap = userChannelList.stream().collect(Collectors.toMap(AccountUserChannel::getUser_channel_id, AccountUserChannel::getUser_channel_name, (k1, k2) -> k1));
|
||||
}
|
||||
for (AccountUserChannelCode userChannelCode : userChannelCodeList) {
|
||||
|
||||
if (!channelNameMap.isEmpty()) {
|
||||
userChannelCode.setUser_channel_name(channelNameMap.get(userChannelCode.getUser_channel_id()));
|
||||
}
|
||||
//渠道引流人数
|
||||
QueryWrapper<AccountUserChannelBring> channelBringQueryWrapper = new QueryWrapper<>();
|
||||
channelBringQueryWrapper.eq("ucc_id", userChannelCode.getUcc_id());
|
||||
userChannelCode.setBring_num(channelBringService.count(channelBringQueryWrapper));
|
||||
}
|
||||
}
|
||||
|
||||
return channelCodePage;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean addChannelCode(AccountUserChannelCode accountUserChannelCode) {
|
||||
accountUserChannelCode.setUcc_use_time(0L);
|
||||
accountUserChannelCode.setUcc_create_time(new Date().getTime());
|
||||
accountUserChannelCode.setUcc_is_unique(0);
|
||||
|
||||
if (!save(accountUserChannelCode)) {
|
||||
throw new ApiException(I18nUtil._("保存用户渠道邀请码信息失败"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序码
|
||||
* @param ucc_id
|
||||
* @param uccCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getWxQrCode(Integer ucc_id, String uccCode) {
|
||||
|
||||
// 调用生成小程序太阳码公用方法
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("uccCode", uccCode);
|
||||
|
||||
String cacheKey = RedisConstant.UccCode_NameSpace + uccCode;
|
||||
if (redisService.hasKey(cacheKey)) {
|
||||
Map<String, Object> cacheVale = Convert.toMap(String.class, Object.class, redisService.get(cacheKey));
|
||||
return Convert.toStr(cacheVale.get("wxQrcode"));
|
||||
}
|
||||
String path = ConfigConstant.URL_H5 + uccCode;
|
||||
|
||||
// 生成token令牌,这里url可以随意填,注意令牌不可生成太长
|
||||
String keyValue = IdUtil.generateCustomUUID(8);
|
||||
try {
|
||||
URL url = new URL(path);
|
||||
String query = url.getQuery();
|
||||
if (StrUtil.isEmpty(query)) {
|
||||
path = path + "?ucccode=" + keyValue;
|
||||
} else {
|
||||
path = path + "&ucccode=" + keyValue;
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
throw new ApiException(I18nUtil._("URL地址错误"));
|
||||
}
|
||||
|
||||
CommonResult res = shopService.getWxQrCode(path, params);
|
||||
res.checkFenResult();
|
||||
|
||||
String wxQrcode = Convert.toStr(res.getData());
|
||||
Map<String, Object> valMap = new HashMap<>();
|
||||
valMap.put("wxQrcode", wxQrcode);
|
||||
valMap.put("ucc_id", ucc_id);
|
||||
redisService.set(cacheKey, valMap);
|
||||
redisService.set(RedisConstant.ucckey_NameSpace + keyValue, cacheKey);
|
||||
|
||||
return wxQrcode;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.AccountUserChannelMapper;
|
||||
import com.suisung.mall.account.service.AccountUserChannelService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserChannel;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户渠道表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2022-08-15
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserChannelServiceImpl extends BaseServiceImpl<AccountUserChannelMapper, AccountUserChannel> implements AccountUserChannelService {
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,829 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.account.mapper.AccountUserInfoMapper;
|
||||
import com.suisung.mall.account.service.*;
|
||||
import com.suisung.mall.common.api.*;
|
||||
import com.suisung.mall.common.constant.AuthConstant;
|
||||
import com.suisung.mall.common.constant.ConfigConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.exception.ApiUserException;
|
||||
import com.suisung.mall.common.feignService.PayService;
|
||||
import com.suisung.mall.common.feignService.ShopService;
|
||||
import com.suisung.mall.common.modules.account.*;
|
||||
import com.suisung.mall.common.modules.distribution.ShopDistributionPlantformUser;
|
||||
import com.suisung.mall.common.modules.user.ShopUserExpHistory;
|
||||
import com.suisung.mall.common.utils.CSVUtils;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户详细信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserInfoServiceImpl extends BaseServiceImpl<AccountUserInfoMapper, AccountUserInfo> implements AccountUserInfoService {
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserLoginService accountUserLoginServicel;
|
||||
|
||||
@Autowired
|
||||
private AccountUserLevelLogService accountUserLevelLogService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseUserLevelService accountBaseUserLevelService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserSnsService accountUserSnsService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserExpHistoryService shopUserExpHistoryService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AccountUserInfoServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 实名认证页面
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map certification() {
|
||||
|
||||
Map data = new HashMap();
|
||||
UserDto user = getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||
}
|
||||
|
||||
AccountUserInfo userInfo = get(user.getId());
|
||||
data.put("user_certification", userInfo.getUser_certification());
|
||||
data.put("user_gender", userInfo.getUser_gender());
|
||||
data.put("user_address", userInfo.getUser_address());
|
||||
data.put("user_realname", userInfo.getUser_realname());
|
||||
data.put("user_idcard", userInfo.getUser_idcard());
|
||||
data.put("user_idcard_images", Convert.toList(String.class, userInfo.getUser_idcard_images()));
|
||||
|
||||
// dealUserCertification(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取分页列表
|
||||
*
|
||||
* @param queryWrapper
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map getLists(QueryWrapper<AccountUserBase> queryWrapper, Integer page, Integer rows) {
|
||||
|
||||
|
||||
Page<AccountUserBase> basePage = accountUserBaseService.lists(queryWrapper, page, rows);
|
||||
Map data = toMobileResult(basePage);
|
||||
|
||||
List<AccountUserBase> userBaseList = basePage.getRecords();
|
||||
List<Integer> user_id_row = userBaseList.stream().map(s -> s.getUser_id()).distinct().collect(Collectors.toList());
|
||||
|
||||
List<AccountUserInfo> user_info_rows = gets(user_id_row);
|
||||
List<AccountUserLogin> user_login_rows = accountUserLoginServicel.gets(user_id_row);
|
||||
|
||||
List<Map> items = (List<Map>) data.get("items");
|
||||
|
||||
|
||||
for (Map row : items) {
|
||||
Integer user_id = Convert.toInt(row.get("user_id"));
|
||||
|
||||
Optional<AccountUserInfo> userInfoOpl = user_info_rows.stream().filter(s -> ObjectUtil.equal(user_id, s.getUser_id())).findFirst();
|
||||
AccountUserInfo userInfo = userInfoOpl.orElseGet(AccountUserInfo::new);
|
||||
|
||||
Optional<AccountUserLogin> userLoginOpl = user_login_rows.stream().filter(s -> ObjectUtil.equal(user_id, s.getUser_id())).findFirst();
|
||||
AccountUserLogin userLogin = userLoginOpl.orElseGet(AccountUserLogin::new);
|
||||
|
||||
row.putAll(Convert.toMap(String.class, Object.class, userInfo));
|
||||
row.put("user_reg_datetime", userLogin.getUser_reg_datetime());
|
||||
row.put("user_reg_ip", userLogin.getUser_reg_ip());
|
||||
row.put("user_lastlogin_time", userLogin.getUser_lastlogin_time());
|
||||
row.put("user_lastlogin_ip", userLogin.getUser_lastlogin_ip());
|
||||
|
||||
row.remove("user_key");
|
||||
row.remove("user_password");
|
||||
row.remove("user_salt");
|
||||
row.remove("user_token");
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkUpdateUserLevel(Integer user_id, BigDecimal user_exp_total, Integer user_fans_total, BigDecimal user_spend_total, Integer user_store_total, Integer user_fans_vip_total, Integer user_fans_team_total) {
|
||||
AccountBaseUserLevel level_row = null;
|
||||
|
||||
if (CheckUtil.isNotEmpty(user_exp_total)) {
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_exp", user_exp_total)
|
||||
.gt("user_level_exp", 0).orderByDesc("user_level_exp");
|
||||
level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(user_fans_total)) {
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_fans_user", user_fans_total)
|
||||
.gt("user_level_fans_user", 0).orderByDesc("user_level_fans_user");
|
||||
level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(user_spend_total)) {
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_spend", user_spend_total)
|
||||
.gt("user_level_spend", 0).orderByDesc("user_level_spend");
|
||||
level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(user_store_total)) {
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_fans_store", user_store_total)
|
||||
.gt("user_level_fans_store", 0).orderByDesc("user_level_fans_store");
|
||||
level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(user_fans_vip_total)) {
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_fans_vip", user_fans_vip_total)
|
||||
.gt("user_level_fans_vip", 0).orderByDesc("user_level_fans_vip");
|
||||
level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(user_fans_team_total)) {
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_fans_team", user_fans_team_total)
|
||||
.gt("user_level_fans_team", 0).orderByDesc("user_level_fans_team");
|
||||
level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
}
|
||||
|
||||
if (level_row != null && CheckUtil.isNotEmpty(level_row.getUser_level_id())) {
|
||||
Integer user_level_id = level_row.getUser_level_id();
|
||||
String user_level_name = level_row.getUser_level_name();
|
||||
if (!upgradeUserLevel(user_id, user_level_id, user_level_name)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户升级
|
||||
*
|
||||
* @param user_id 用户编号
|
||||
* @param user_level_id 升级等级
|
||||
* @param user_level_name
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
public boolean upgradeUserLevel(Integer user_id, Integer user_level_id, String user_level_name) {
|
||||
AccountUserInfo user_info_row = get(user_id);
|
||||
|
||||
// 判断是否需要更新用户等级
|
||||
Integer _user_level_id = user_info_row.getUser_level_id();
|
||||
if (CheckUtil.isNotEmpty(user_level_id) && _user_level_id < user_level_id) {
|
||||
AccountUserInfo info_data = new AccountUserInfo();
|
||||
info_data.setUser_level_id(user_level_id);
|
||||
|
||||
// 更新用户等级。
|
||||
info_data.setUser_id(user_id);
|
||||
if (!this.edit(info_data)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
// 更新用户关系冗余等级
|
||||
ShopDistributionPlantformUser plantformUser = new ShopDistributionPlantformUser();
|
||||
plantformUser.setUser_id(user_id);
|
||||
plantformUser.setUser_level_id(user_level_id);
|
||||
|
||||
if (!shopService.saveOrUpdateDistributionPlantformUser(plantformUser)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
// 执行升级关联事件
|
||||
BigDecimal plantform_fx_member_points = getDistUserLevelConfig("plantform_fx_member_points", user_id, BigDecimal.ZERO);
|
||||
if (ObjectUtil.compare(plantform_fx_member_points, BigDecimal.ZERO) > 0) {
|
||||
String desc = String.format(I18nUtil._("升级 %s 送积分 %s"), user_level_name, plantform_fx_member_points);
|
||||
if (!payService.points(user_id, plantform_fx_member_points, PointsType.POINTS_TYPE_UP_SP, desc, 0, null, null)) {
|
||||
throw new ApiException(I18nUtil._("积分操作失败!"));
|
||||
}
|
||||
}
|
||||
|
||||
} else if (CheckUtil.isNotEmpty(user_level_id) && _user_level_id > user_level_id) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public BigDecimal getDistUserLevelConfig(String key, Integer user_id, BigDecimal defaultValue) {
|
||||
|
||||
List<Map> fx_level_config_rows = Convert.toList(Map.class, JSONUtil.parseArray(accountBaseConfigService.getConfig("fx_level_config", "[]")));
|
||||
if (CheckUtil.isNotEmpty(user_id)) {
|
||||
//动态修正分销相关参数
|
||||
//根据等级修正,使用表格设定数据
|
||||
String[] config_tmp_row = {"plantform_fx_cps_rate_1",
|
||||
"plantform_fx_cps_rate_2",
|
||||
"plantform_fx_cps_rate_3",
|
||||
"sale_prize_sp_rate_1",
|
||||
"sale_prize_sp_rate_2",
|
||||
"buy_prize_da_rate",
|
||||
"buy_prize_ca_rate",
|
||||
"sale_prize_da_rate",
|
||||
"sale_prize_ca_rate",
|
||||
"buy_prize_pt_rate",
|
||||
"sale_prize_pt_rate",
|
||||
"sale_prize_distributor_rate",
|
||||
"sale_prize_salesperson_rate",
|
||||
"plantform_fx_member_points",
|
||||
"plantform_fx_rebate"};
|
||||
if (ArrayUtil.contains(config_tmp_row, key)) {
|
||||
//读取当前登录用户等级,规避线下下单操作
|
||||
AccountUserInfo user_row = get(user_id);
|
||||
|
||||
//用户等级
|
||||
Integer user_level_id = 1001;
|
||||
|
||||
if (user_row != null) {
|
||||
user_level_id = user_row.getUser_level_id();
|
||||
}
|
||||
|
||||
if (CheckUtil.isEmpty(user_level_id)) {
|
||||
user_level_id = 1001;
|
||||
}
|
||||
|
||||
Map fx_level_config_row_result = new HashMap();
|
||||
for (Map fx_level_config_row : fx_level_config_rows) {
|
||||
if (Objects.equals(user_level_id, Convert.toInt(fx_level_config_row.get("user_level_id")))) {
|
||||
fx_level_config_row_result = fx_level_config_row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fx_level_config_row_result != null) {
|
||||
return Convert.toBigDecimal(fx_level_config_row_result.get(key), defaultValue);
|
||||
}
|
||||
} else {
|
||||
// throw new Exception(I18nUtil._("分销配置信息异常"));
|
||||
}
|
||||
} else {
|
||||
Integer user_level_id = 1001;
|
||||
|
||||
Map fx_level_config_row_result = new HashMap();
|
||||
for (Map fx_level_config_row : fx_level_config_rows) {
|
||||
if (Objects.equals(user_level_id, Convert.toInt(fx_level_config_row.get("user_level_id")))) {
|
||||
fx_level_config_row_result = fx_level_config_row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal result = Convert.toBigDecimal(fx_level_config_row_result.get(key));
|
||||
if (result != null) return result;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean editUser(Integer user_id, Map data) {
|
||||
AccountUserBase user_row = accountUserBaseService.get(user_id);
|
||||
|
||||
if (user_row != null) {
|
||||
String user_password = (String) data.get("user_password");
|
||||
if (StrUtil.isNotBlank(user_password)) {
|
||||
String user_account = user_row.getUser_account();
|
||||
if (!accountUserBaseService.doResetPasswd(user_account, user_password, null)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
data.remove("user_password");
|
||||
}
|
||||
String user_nickname = (String) data.get("user_nickname");
|
||||
if (StrUtil.isNotBlank(user_nickname)) {
|
||||
AccountUserBase base_data = new AccountUserBase();
|
||||
base_data.setUser_nickname(user_nickname);
|
||||
|
||||
Integer user_state = (Integer) data.get("user_state");
|
||||
base_data.setUser_state(user_state);
|
||||
base_data.setUser_id(user_id);
|
||||
|
||||
String rights_group_id = (String) data.get("rights_group_id");
|
||||
if (StrUtil.isNotBlank(rights_group_id)) {
|
||||
base_data.setRights_group_id(rights_group_id);
|
||||
base_data.setUser_is_admin(checkIsAdmin(rights_group_id));
|
||||
}
|
||||
|
||||
data.remove("user_account");
|
||||
data.remove("user_nickname");
|
||||
data.remove("user_state");
|
||||
|
||||
if (!accountUserBaseService.saveOrUpdate(base_data)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
data.remove("user_account");
|
||||
data.remove("user_nickname");
|
||||
data.remove("user_state");
|
||||
if (CollUtil.isNotEmpty(data)) {
|
||||
data.put("user_id", user_id);
|
||||
AccountUserInfo userInfo = Convert.convert(AccountUserInfo.class, data);
|
||||
if (!edit(userInfo)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 是否admin 用户
|
||||
private Integer checkIsAdmin(String rights_group_ids) {
|
||||
if (StrUtil.isBlank(rights_group_ids)) return 0;
|
||||
List<Integer> ids = Convert.toList(Integer.class, rights_group_ids);
|
||||
return ids.contains(1) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存并检测AccountUserSns
|
||||
*
|
||||
* @param accountUserSns
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAndCheckUpdateUserLevel(AccountUserSns accountUserSns) {
|
||||
if (!accountUserSnsService.saveOrUpdate(accountUserSns)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
Integer user_id = accountUserSns.getUser_id();
|
||||
Integer user_fans = 1;
|
||||
AccountUserSns userSns = accountUserSnsService.get(user_id);
|
||||
if (userSns == null) {
|
||||
if (!accountUserSnsService.saveOrUpdate(accountUserSns)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
} else {
|
||||
user_fans += userSns.getUser_fans();
|
||||
userSns.setUser_fans(user_fans);
|
||||
if (!accountUserSnsService.saveOrUpdate(userSns)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkUpdateUserLevel(user_id, BigDecimal.ZERO, user_fans, BigDecimal.ZERO, 0, 0, 0)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getUser(List<Integer> user_ids) {
|
||||
List<AccountUserBase> user_base_rows = accountUserBaseService.gets(user_ids);
|
||||
List<Map> user_info_rows = Convert.toList(Map.class, gets(user_ids));
|
||||
|
||||
for (Map user_info_row : user_info_rows) {
|
||||
Integer user_id = (Integer) user_info_row.get("user_id");
|
||||
Optional<AccountUserBase> accountUserBaseOpl = user_base_rows.stream().filter(s -> ObjectUtil.equal(user_id, s.getUser_id())).findFirst();
|
||||
AccountUserBase accountUserBase = accountUserBaseOpl.orElseGet(AccountUserBase::new);
|
||||
user_info_row.put("user_state", accountUserBase.getUser_state());
|
||||
user_info_row.put("user_nickname", accountUserBase.getUser_nickname());
|
||||
user_info_row.put("user_account", accountUserBase.getUser_account());
|
||||
}
|
||||
|
||||
return user_info_rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editJbState(Integer user_id, Integer user_jb_state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean editAccount(Integer user_id, Map userInfo) {
|
||||
|
||||
String user_nickname = (String) userInfo.get("user_nickname");
|
||||
if (user_nickname != null) {
|
||||
AccountUserBase base = new AccountUserBase();
|
||||
base.setUser_id(user_id);
|
||||
base.setUser_nickname(user_nickname);
|
||||
|
||||
if (!accountUserBaseService.edit(base)) {
|
||||
throw new ApiException(I18nUtil._("保存用户基础数据失败!"));
|
||||
}
|
||||
}
|
||||
|
||||
AccountUserInfo accountUserInfo = new AccountUserInfo();
|
||||
|
||||
String user_avatar = (String) userInfo.get("user_avatar");
|
||||
if (StrUtil.isNotBlank(user_avatar)) {
|
||||
accountUserInfo.setUser_avatar(user_avatar);
|
||||
}
|
||||
|
||||
String user_mobile = (String) userInfo.get("user_mobile");
|
||||
if (StrUtil.isNotBlank(user_mobile)) {
|
||||
accountUserInfo.setUser_mobile(user_mobile);
|
||||
}
|
||||
|
||||
Integer user_gender = (Integer) userInfo.get("user_gender");
|
||||
if (user_gender != null) {
|
||||
accountUserInfo.setUser_gender(user_gender);
|
||||
}
|
||||
|
||||
String user_intl = (String) userInfo.get("user_intl");
|
||||
if (StrUtil.isNotBlank(user_intl)) {
|
||||
accountUserInfo.setUser_intl(user_intl);
|
||||
}
|
||||
|
||||
String user_email = (String) userInfo.get("user_email");
|
||||
if (StrUtil.isNotBlank(user_email)) {
|
||||
accountUserInfo.setUser_email(user_email);
|
||||
}
|
||||
|
||||
String user_sign = (String) userInfo.get("user_sign");
|
||||
if (StrUtil.isNotBlank(user_sign)) {
|
||||
accountUserInfo.setUser_sign(user_sign);
|
||||
}
|
||||
|
||||
String user_idcard = (String) userInfo.get("user_idcard");
|
||||
if (StrUtil.isNotBlank(user_idcard)) {
|
||||
accountUserInfo.setUser_idcard(user_idcard);
|
||||
}
|
||||
|
||||
String user_birthday = (String) userInfo.get("user_birthday");
|
||||
if (StrUtil.isNotBlank(user_birthday)) {
|
||||
accountUserInfo.setUser_birthday(DateUtil.parse(user_birthday, "yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
String user_realname = (String) userInfo.get("user_realname");
|
||||
if (StrUtil.isNotBlank(user_realname)) {
|
||||
accountUserInfo.setUser_realname(user_realname);
|
||||
}
|
||||
|
||||
accountUserInfo.setUser_id(user_id);
|
||||
if (!edit(accountUserInfo)) {
|
||||
throw new ApiException(I18nUtil._("操作失败!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化用户经验等级
|
||||
*
|
||||
* @param user_id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean initUserExperience(Integer user_id) {
|
||||
String str_exp_reg = accountBaseConfigService.getConfig("exp_reg");
|
||||
BigDecimal exp_reg = Convert.toBigDecimal(str_exp_reg, BigDecimal.ZERO);
|
||||
experience(user_id, exp_reg, LevelCode.EXP_TYPE_REG, I18nUtil._("用户注册"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// todo 实名认证
|
||||
@Override
|
||||
public CommonResult saveCertificate(AccountUserInfo userInfo) {
|
||||
|
||||
Integer user_id = userInfo.getUser_id();
|
||||
AccountUserInfo user_info_row = get(user_id);
|
||||
|
||||
Integer user_certification = user_info_row.getUser_certification();
|
||||
if (user_certification != StateCode.USER_CERTIFICATION_YES) {
|
||||
// todo 百度实名认证
|
||||
|
||||
if (!edit(userInfo)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
} else {
|
||||
throw new ApiException(I18nUtil._("已提交,请勿重复提交!"));
|
||||
}
|
||||
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
public boolean experience(Integer user_id, BigDecimal exp, Integer exp_type_id, String desc) {
|
||||
|
||||
Date cur_time = new Date();
|
||||
DateTime cur_date = DateUtil.parse(DateUtil.format(cur_time, "yyyy-MM-dd"));
|
||||
Integer exp_kind_id = 2;
|
||||
|
||||
// 通用判断, 注册和
|
||||
switch (exp_type_id) {
|
||||
case LevelCode.EXP_TYPE_REG:
|
||||
// 注册只可以触发一次
|
||||
QueryWrapper<ShopUserExpHistory> regWrapper = new QueryWrapper<>();
|
||||
regWrapper.eq("user_id", user_id).eq("exp_type_id", exp_type_id);
|
||||
List<Serializable> reg_exp_log_id = shopUserExpHistoryService.findKey(regWrapper);
|
||||
|
||||
if (CollUtil.isNotEmpty(reg_exp_log_id)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
break;
|
||||
case LevelCode.EXP_TYPE_LOGIN:
|
||||
//登录,每天只可以触发一次
|
||||
QueryWrapper<ShopUserExpHistory> loginWrapper = new QueryWrapper<>();
|
||||
loginWrapper.eq("user_id", user_id).eq("exp_type_id", exp_type_id).eq("exp_log_date", cur_date);
|
||||
List<Serializable> login_exp_log_id = shopUserExpHistoryService.findKey(loginWrapper);
|
||||
|
||||
if (CollUtil.isNotEmpty(login_exp_log_id)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
break;
|
||||
|
||||
case LevelCode.EXP_TYPE_EVALUATE_PRODUCT:
|
||||
break;
|
||||
case LevelCode.EXP_TYPE_EVALUATE_STORE:
|
||||
break;
|
||||
case LevelCode.EXP_TYPE_CONSUME:
|
||||
break;
|
||||
case LevelCode.EXP_TYPE_OTHER:
|
||||
break;
|
||||
case LevelCode.EXP_TYPE_EXCHANGE_PRODUCT:
|
||||
break;
|
||||
case LevelCode.EXP_TYPE_EXCHANGE_VOUCHER:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (exp.intValue() > 0) {
|
||||
exp_kind_id = 1;
|
||||
} else {
|
||||
exp_kind_id = 2;
|
||||
}
|
||||
|
||||
ShopUserExpHistory expHistory = new ShopUserExpHistory();
|
||||
expHistory.setExp_kind_id(exp_kind_id); // 类型(ENUM):1-获取积分;2-消费积分;
|
||||
expHistory.setExp_type_id(exp_type_id); // 积分类型(ENUM):1-会员注册;2-会员登录;3-商品评论;4-购买商品;5-管理员操作;7-积分换购商品;8-积分兑换优惠券
|
||||
expHistory.setUser_id(user_id); // 会员编号
|
||||
expHistory.setExp_log_value(NumberUtil.max(exp.longValue(), 1)); // 改变积分值
|
||||
expHistory.setExp_log_desc(desc); // 描述
|
||||
expHistory.setExp_log_time(cur_time); // 积分日期
|
||||
expHistory.setExp_log_date(cur_date); // 积分日期
|
||||
expHistory.setExp_log_desc(desc);
|
||||
|
||||
return addExp(expHistory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportFile(HttpServletResponse response, Integer pageNum, Integer pageSize) {
|
||||
|
||||
String[] head = {I18nUtil._("用户编号"), I18nUtil._("用户名"), I18nUtil._("用户昵称"), I18nUtil._("备注名称"), I18nUtil._("来源编号"), I18nUtil._("状态"), I18nUtil._("用户类别"), I18nUtil._("用户等级"), I18nUtil._("用户等级"),
|
||||
I18nUtil._("用户组"), I18nUtil._("性别"), I18nUtil._("真实姓名"), I18nUtil._("实名认证"), I18nUtil._("生日"), I18nUtil._("手机号码"), I18nUtil._("电话"), I18nUtil._("用户邮箱"), "QQ", I18nUtil._("阿里旺旺"), I18nUtil._("省"), I18nUtil._("省"),
|
||||
I18nUtil._("城市"), I18nUtil._("城市"), I18nUtil._("县"), I18nUtil._("县"), I18nUtil._("详细地址"), I18nUtil._("签名"), I18nUtil._("注册时间"), I18nUtil._("注册IP"), I18nUtil._("登录时间"), I18nUtil._("登录IP")};
|
||||
|
||||
Map userInfoPage = accountUserBaseService.getUserList(pageNum, pageSize);
|
||||
List<Map> items = (List<Map>) userInfoPage.get("items");
|
||||
|
||||
/*Map<Integer, String> service_type_id_row = new HashMap<>();
|
||||
service_type_id_row.put(1, I18nUtil._("换货"));
|
||||
service_type_id_row.put(2, I18nUtil._("退货"));
|
||||
service_type_id_row.put(3, I18nUtil._("维修"));
|
||||
|
||||
Map<Integer, String> order_is_shipped_row = new HashMap<>();
|
||||
service_type_id_row.put(3030, I18nUtil._("未发货"));
|
||||
service_type_id_row.put(3031, I18nUtil._("部分发货"));
|
||||
service_type_id_row.put(3032, I18nUtil._("已发货"));*/
|
||||
|
||||
List<String[]> values = new ArrayList<>();
|
||||
for (Map order_row : items) {
|
||||
String user_id = Convert.toStr(order_row.get("user_id"));
|
||||
String user_account = Convert.toStr(order_row.get("user_account"));
|
||||
String user_nickname = Convert.toStr(order_row.get("user_nickname"));
|
||||
String user_notename = Convert.toStr(order_row.get("user_notename"));
|
||||
String user_parent_id = Convert.toStr(order_row.get("user_parent_id"));
|
||||
String user_state = Convert.toStr(order_row.get("user_state"));
|
||||
String user_type_id = Convert.toStr(order_row.get("user_type_id"));
|
||||
String user_level_id = Convert.toStr(order_row.get("user_level_id"));
|
||||
String user_level_name = Convert.toStr(order_row.get("user_level_name"));
|
||||
String user_group = Convert.toStr(order_row.get("user_group"));
|
||||
String user_gender = Convert.toStr(order_row.get("user_gender"));
|
||||
String user_realname = Convert.toStr(order_row.get("user_realname"));
|
||||
String user_certification = Convert.toStr(order_row.get("user_certification"));
|
||||
String user_birthday = Convert.toStr(order_row.get("user_birthday"));
|
||||
String user_mobile = Convert.toStr(order_row.get("user_mobile"));
|
||||
String user_tel = Convert.toStr(order_row.get("user_tel"));
|
||||
String user_email = Convert.toStr(order_row.get("user_email"));
|
||||
String user_qq = Convert.toStr(order_row.get("user_qq"));
|
||||
String user_ww = Convert.toStr(order_row.get("user_ww"));
|
||||
String user_province_id = Convert.toStr(order_row.get("user_province_id"));
|
||||
String user_province_name = Convert.toStr(order_row.get("user_province_name"));
|
||||
String user_city_id = Convert.toStr(order_row.get("user_city_id"));
|
||||
String user_city_name = Convert.toStr(order_row.get("user_city_name"));
|
||||
String user_county_id = Convert.toStr(order_row.get("user_county_id"));
|
||||
String user_county_name = Convert.toStr(order_row.get("user_county_name"));
|
||||
String user_address = Convert.toStr(order_row.get("user_address"));
|
||||
String user_sign = Convert.toStr(order_row.get("user_sign"));
|
||||
String user_reg_datetime = DateUtil.format((Date) order_row.get("user_reg_datetime"), "yyyy-MM-dd HH:mm:ss");
|
||||
String user_reg_ip = Convert.toStr(order_row.get("user_reg_ip"));
|
||||
String user_lastlogin_time = DateUtil.format((Date) order_row.get("user_lastlogin_time"), "yyyy-MM-dd HH:mm:ss");
|
||||
String user_lastlogin_ip = Convert.toStr(order_row.get("user_lastlogin_ip"));
|
||||
|
||||
String[] value = {user_id, user_account, user_nickname, user_notename, user_parent_id, user_state, user_type_id,
|
||||
user_level_id, user_level_name, user_group, user_gender, user_realname, user_certification, user_birthday,
|
||||
user_mobile, user_tel, user_email, user_qq, user_ww, user_province_id, user_province_name, user_city_id,
|
||||
user_city_name, user_county_id, user_county_name, user_address, user_sign, user_reg_datetime, user_reg_ip,
|
||||
user_lastlogin_time, user_lastlogin_ip};
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
try {
|
||||
CSVUtils.downloadFile(response, CSVUtils.makeTempCSV(I18nUtil._("用户数据"), head, values));
|
||||
} catch (IOException e) {
|
||||
logger.error("导出售后数据异常!" + e.getMessage(), e);
|
||||
throw new ApiException(I18nUtil._("导出售后数据异常!"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户协议
|
||||
*
|
||||
* @param document_type
|
||||
* @param protocols_key
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
public CommonResult protocol(String document_type, String protocols_key, Integer state) {
|
||||
|
||||
Map data = new HashMap();
|
||||
data.put("state", state);
|
||||
|
||||
if ("store".equals(document_type)) {
|
||||
data.put("document", accountBaseConfigService.getConfig("open_store_description"));
|
||||
} else {
|
||||
data.put("document", accountBaseConfigService.getConfig(protocols_key));
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
Integer user_id = ObjectUtil.isNotNull(user) ? user.getId() : null;
|
||||
|
||||
if (user_id != null) {
|
||||
// 修改签订状态
|
||||
if (CheckUtil.isNotEmpty(state)) {
|
||||
if ("withdraw_protocols_description".equals(protocols_key)) {
|
||||
// 提现协议确认
|
||||
AccountUserInfo userInfo = new AccountUserInfo();
|
||||
userInfo.setUser_id(user_id);
|
||||
userInfo.setUser_withdraw_state(1);
|
||||
accountUserInfoService.edit(userInfo);
|
||||
data.put("state", 1);
|
||||
}
|
||||
} else {
|
||||
if ("withdraw_protocols_description".equals(protocols_key)) {
|
||||
// 读取签订状态
|
||||
AccountUserInfo info_row = accountUserInfoService.get(user_id);
|
||||
data.put("state", info_row.getUser_withdraw_state());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return CommonResult.success(data);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Boolean addExp(ShopUserExpHistory expHistory) {
|
||||
|
||||
Integer user_id = expHistory.getUser_id();
|
||||
|
||||
// 当前积分
|
||||
AccountUserInfo user_info_row = get(user_id);
|
||||
Long user_exp_total = ObjectUtil.defaultIfNull(user_info_row.getUser_exp_total(), 0l);
|
||||
|
||||
expHistory.setUser_exp(user_exp_total);
|
||||
if (!shopUserExpHistoryService.saveOrUpdate(expHistory)) {
|
||||
throw new ApiException(I18nUtil._("保存数据失败!"));
|
||||
}
|
||||
|
||||
Long exp_log_value = expHistory.getExp_log_value();
|
||||
Long _user_exp_total = user_exp_total + exp_log_value;
|
||||
|
||||
AccountUserInfo info_data = new AccountUserInfo();
|
||||
info_data.setUser_exp_total(_user_exp_total);
|
||||
|
||||
// 需要设置经验值,设置为0否则忽略不计
|
||||
QueryWrapper<AccountBaseUserLevel> levelQueryWrapper = new QueryWrapper<>();
|
||||
levelQueryWrapper.le("user_level_exp", _user_exp_total).gt("user_level_exp", 0).orderByDesc("user_level_exp");
|
||||
|
||||
AccountBaseUserLevel level_row = accountBaseUserLevelService.findOne(levelQueryWrapper);
|
||||
|
||||
// 判断是否需要更新用户等级
|
||||
Integer user_level_id = user_info_row.getUser_level_id();
|
||||
if (level_row != null && user_level_id < level_row.getUser_level_id()) {
|
||||
info_data.setUser_level_id(level_row.getUser_level_id());
|
||||
}
|
||||
|
||||
// 更新用户等级。
|
||||
info_data.setUser_id(user_id);
|
||||
if (!accountUserInfoService.edit(info_data)) {
|
||||
throw new ApiException(I18nUtil._("保存数据失败!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean edit(AccountUserInfo accountUserInfo) {
|
||||
// 判断是否更新到用户等级
|
||||
Integer user_level_id = accountUserInfo.getUser_level_id();
|
||||
if (user_level_id != null) {
|
||||
Integer user_id = accountUserInfo.getUser_id();
|
||||
accountUserLevelLogService.addLevelLog(user_id, user_level_id, "", 0);
|
||||
}
|
||||
return super.edit(accountUserInfo);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理用户实名信息
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void dealUserCertification(Map data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountUserInfo> gets(Collection<? extends Serializable> ids) {
|
||||
|
||||
List<AccountUserInfo> list = super.gets(ids);
|
||||
|
||||
UserDto currentUser = getCurrentUser();
|
||||
|
||||
if ((currentUser!=null&¤tUser.getClient_id().equals(AuthConstant.ADMIN_CLIENT_ID)) && ConfigConstant.URL_BASE.equals("https://demo.lancerdt.com")) {
|
||||
for (AccountUserInfo it : list) {
|
||||
if (ObjectUtil.isNotEmpty(it)) {
|
||||
String phoneNumber = it.getUser_mobile();
|
||||
if (phoneNumber.length() == 11) {
|
||||
phoneNumber = phoneNumber.substring(0, 3) + "****" + phoneNumber.substring(7);
|
||||
}
|
||||
|
||||
it.setUser_mobile(phoneNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.suisung.mall.account.mapper.AccountUserLevelLogMapper;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.account.service.AccountUserLevelLogService;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.modules.account.AccountUserInfo;
|
||||
import com.suisung.mall.common.modules.account.AccountUserLevelLog;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户等级记录表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-25
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserLevelLogServiceImpl extends BaseServiceImpl<AccountUserLevelLogMapper, AccountUserLevelLog> implements AccountUserLevelLogService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService accountUserInfoService;
|
||||
|
||||
@Override
|
||||
public boolean addLevelLog(Integer user_id, Integer user_level_id, String ull_note, Integer admin_id) {
|
||||
|
||||
admin_id = ObjectUtil.defaultIfNull(admin_id, 0);
|
||||
AccountUserInfo user_info_row = accountUserInfoService.get(user_id);
|
||||
Integer user_level_pre_id = user_info_row.getUser_level_id();
|
||||
|
||||
if (ObjectUtil.notEqual(user_level_pre_id, user_level_id)) {
|
||||
AccountUserLevelLog data = new AccountUserLevelLog();
|
||||
data.setUser_id(user_id); // 用户编号
|
||||
data.setUser_level_id(user_level_id); // 等级编号
|
||||
data.setUser_level_pre_id(user_level_pre_id); // 之前等级
|
||||
data.setUll_time(new Date()); // 操作时间
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
if (user != null) {
|
||||
if (user.isPlatform()) {
|
||||
if (StrUtil.isBlank(ull_note)) {
|
||||
ull_note = I18nUtil._("管理员操作");
|
||||
}
|
||||
admin_id = user.getId();
|
||||
} else {
|
||||
if (StrUtil.isBlank(ull_note)) {
|
||||
ull_note = I18nUtil._("用户升级");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.isBlank(ull_note)) {
|
||||
ull_note = I18nUtil._("用户升级");
|
||||
}
|
||||
}
|
||||
|
||||
data.setUll_note(ull_note);
|
||||
data.setAdmin_id(admin_id);
|
||||
return saveOrUpdate(data);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.suisung.mall.account.mapper.AccountUserLoginMapper;
|
||||
import com.suisung.mall.account.service.AccountUserLoginService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserLogin;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户登录信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-27
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserLoginServiceImpl extends BaseServiceImpl<AccountUserLoginMapper, AccountUserLogin> implements AccountUserLoginService {
|
||||
|
||||
@Autowired
|
||||
private AccountUserLoginMapper accountUserLoginMapper;
|
||||
|
||||
/**
|
||||
* 用户注册数据
|
||||
*
|
||||
* @param days days天之前
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map> getUserDate(Integer days) {
|
||||
Date endTime = new Date();
|
||||
DateTime startTime = DateUtil.offsetDay(DateUtil.beginOfDay(new Date()), -(days - 1));
|
||||
List<Map> order_num_rows = accountUserLoginMapper.getUserRegTimeline(startTime.getTime());
|
||||
return formatTimeline(order_num_rows, "user_reg_date", startTime, endTime);
|
||||
}
|
||||
|
||||
|
||||
private List<Map> formatTimeline(List<Map> order_num_rows, String key_name, Date start_time, Date end_time) {
|
||||
|
||||
Map timeline_rows = new HashMap();
|
||||
for (Map order_num_row : order_num_rows) {
|
||||
Date value = (Date) order_num_row.get(key_name);
|
||||
if (value != null) {
|
||||
timeline_rows.put(DateUtil.format(value, "yyyy-MM-dd"), order_num_row);
|
||||
}
|
||||
}
|
||||
|
||||
List<Map> data = new ArrayList<>();
|
||||
for (Date startTime = start_time; DateUtil.compare(startTime, end_time) < 0; startTime = DateUtil.offsetDay(startTime, 1)) {
|
||||
int month = DateUtil.month(startTime) + 1;
|
||||
int day = DateUtil.dayOfMonth(startTime);
|
||||
int year = DateUtil.year(startTime);
|
||||
String key = DateUtil.format(startTime, "yyyy-MM-dd");
|
||||
|
||||
Map order_num_row = (Map) timeline_rows.get(key);
|
||||
if (CollUtil.isEmpty(order_num_row)) {
|
||||
order_num_row = new HashMap();
|
||||
order_num_row.put("num", 0);
|
||||
order_num_row.put("val", 0);
|
||||
order_num_row.put("time", month + "/" + day);
|
||||
order_num_row.put("year", year);
|
||||
order_num_row.put("month", month);
|
||||
order_num_row.put("day", day);
|
||||
} else {
|
||||
order_num_row.put("time", month + "/" + day);
|
||||
}
|
||||
|
||||
data.add(order_num_row);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.AccountUserSnsMapper;
|
||||
import com.suisung.mall.account.service.AccountUserSnsService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserSns;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户SNS信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-07-20
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserSnsServiceImpl extends BaseServiceImpl<AccountUserSnsMapper, AccountUserSns> implements AccountUserSnsService {
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateUserFriendNum(Integer user_id, Integer friend_id, Integer num) {
|
||||
//我的好友数量
|
||||
AccountUserSns accountUserSns = get(user_id);
|
||||
if (accountUserSns == null) {
|
||||
accountUserSns = new AccountUserSns();
|
||||
accountUserSns.setUser_id(user_id);
|
||||
accountUserSns.setUser_friend(0);
|
||||
}
|
||||
accountUserSns.setUser_friend(accountUserSns.getUser_friend() + num);
|
||||
saveOrUpdate(accountUserSns);
|
||||
|
||||
//好友粉丝数量
|
||||
|
||||
AccountUserSns accountFriendSns = get(friend_id);
|
||||
if (accountFriendSns == null) {
|
||||
accountFriendSns = new AccountUserSns();
|
||||
accountFriendSns.setUser_id(user_id);
|
||||
accountFriendSns.setUser_fans(0);
|
||||
}
|
||||
|
||||
accountFriendSns.setUser_fans(accountFriendSns.getUser_fans() + num);
|
||||
saveOrUpdate(accountFriendSns);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.AccountUserTypeMapper;
|
||||
import com.suisung.mall.account.service.AccountUserTypeService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserType;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-08-25
|
||||
*/
|
||||
@Service
|
||||
public class AccountUserTypeServiceImpl extends BaseServiceImpl<AccountUserTypeMapper, AccountUserType> implements AccountUserTypeService {
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.account.mapper.AnalyticsUserDao;
|
||||
import com.suisung.mall.account.service.AccountUserInfoService;
|
||||
import com.suisung.mall.account.service.AccountUserLoginService;
|
||||
import com.suisung.mall.account.service.AnalyticsUserService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserLogin;
|
||||
import com.suisung.mall.common.pojo.input.AnalyticsProductInput;
|
||||
import com.suisung.mall.common.pojo.input.TimelineInput;
|
||||
import com.suisung.mall.common.pojo.output.AnalyticsNumOutput;
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.res.AdminDashBoardRes;
|
||||
import com.suisung.mall.common.pojo.res.DashboardTopRes;
|
||||
import com.suisung.mall.common.pojo.vo.CommonNumVo;
|
||||
import com.suisung.mall.common.pojo.vo.RegUserVo;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.TimeRange;
|
||||
import com.suisung.mall.common.utils.TimeUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AnalyticsUserServiceImpl implements AnalyticsUserService {
|
||||
|
||||
@Autowired
|
||||
private AnalyticsUserDao analyticsUserDao;
|
||||
|
||||
@Autowired
|
||||
private AccountUserInfoService userInfoRepository;
|
||||
|
||||
@Autowired
|
||||
private AccountUserLoginService userLoginRepository;
|
||||
|
||||
/**
|
||||
* 计算本月新增用户量,今日新增用户量,昨日新增用户量,以及日环比
|
||||
*
|
||||
* @return DashboardTopRes
|
||||
*/
|
||||
@Override
|
||||
public DashboardTopRes getRegUser() {
|
||||
DashboardTopRes topRes = new DashboardTopRes();
|
||||
|
||||
// 获取当日新增用户量
|
||||
TimeRange range = TimeUtil.today();
|
||||
RegUserVo todayRegUser = analyticsUserDao.getRegUser(range.getStart(), range.getEnd());
|
||||
if (todayRegUser != null) {
|
||||
topRes.setToday(todayRegUser.getNum());
|
||||
}
|
||||
|
||||
//昨日
|
||||
range = TimeUtil.yestoday();
|
||||
RegUserVo yestodayRegUser = analyticsUserDao.getRegUser(range.getStart(), range.getEnd());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(yestodayRegUser)) {
|
||||
topRes.setYestoday(yestodayRegUser.getNum());
|
||||
|
||||
// 计算日环比 日环比 = (当日数据 - 前一日数据) / 前一日数据 * 100%
|
||||
BigDecimal daym2m = BigDecimal.ZERO;
|
||||
if (yestodayRegUser.getNum().compareTo(BigDecimal.ZERO) != 0) {
|
||||
daym2m = (todayRegUser.getNum().subtract(yestodayRegUser.getNum())).divide(yestodayRegUser.getNum(), 2, BigDecimal.ROUND_HALF_UP);
|
||||
//.multiply(new BigDecimal("100"));
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
topRes.setDaym2m(daym2m);
|
||||
}
|
||||
|
||||
//本月
|
||||
range = TimeUtil.month();
|
||||
RegUserVo monthRegUser = analyticsUserDao.getRegUser(range.getStart(), range.getEnd());
|
||||
if (ObjectUtil.isNotEmpty(monthRegUser)) {
|
||||
topRes.setMonth(monthRegUser.getNum());
|
||||
}
|
||||
|
||||
return topRes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimelineOutput> getUserTimeLine(TimelineInput input) {
|
||||
return analyticsUserDao.getUserTimeLine(input.getStime(), input.getEtime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员数
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AnalyticsNumOutput getUserNum(TimelineInput input) {
|
||||
|
||||
AnalyticsNumOutput topRes = new AnalyticsNumOutput();
|
||||
|
||||
// 获取当前周期内数据
|
||||
RegUserVo regUser = analyticsUserDao.getRegUser(input.getStime(), input.getEtime());
|
||||
CommonNumVo currentRegNum = BeanUtil.copyProperties(regUser, CommonNumVo.class);
|
||||
|
||||
if (currentRegNum != null) {
|
||||
topRes.setCurrent(currentRegNum.getNum());
|
||||
}
|
||||
|
||||
//上个周期
|
||||
AnalyticsProductInput preInput = BeanUtil.copyProperties(input, AnalyticsProductInput.class);
|
||||
|
||||
if (CheckUtil.isNotEmpty(input.getStime()) && CheckUtil.isNotEmpty(input.getEtime())) {
|
||||
preInput.setStime(input.getStime() - (input.getEtime() - input.getStime()));
|
||||
preInput.setEtime(input.getStime());
|
||||
|
||||
|
||||
RegUserVo preRegUser = analyticsUserDao.getRegUser(preInput.getStime(), preInput.getEtime());
|
||||
CommonNumVo preRegNum = BeanUtil.copyProperties(preRegUser, CommonNumVo.class);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(preRegNum)) {
|
||||
topRes.setPre(preRegNum.getNum());
|
||||
|
||||
// 计算日环比 日环比 = (当日数据 - 前一日数据) / 前一日数据 * 100%
|
||||
BigDecimal daym2m = BigDecimal.ZERO;
|
||||
if (preRegNum.getNum().compareTo(BigDecimal.ZERO) != 0) {
|
||||
daym2m = (currentRegNum.getNum().subtract(preRegNum.getNum())).divide(preRegNum.getNum(), 2, BigDecimal.ROUND_HALF_UP);
|
||||
//.multiply(new BigDecimal("100"));
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
topRes.setDaym2m(daym2m);
|
||||
}
|
||||
}
|
||||
|
||||
return topRes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户总数和用户近一周增长率
|
||||
*/
|
||||
public void getUserCertificationData(AdminDashBoardRes dashBoardRes, DateTime recentOneWeek, DateTime recentTwoWeek) {
|
||||
// 会员总数
|
||||
Long userCertificationNum = userInfoRepository.count(new QueryWrapper<>());
|
||||
dashBoardRes.setUserCertificationNum(userCertificationNum);
|
||||
|
||||
// 会员近一周增长率
|
||||
LambdaQueryWrapper<AccountUserLogin> loginQueryWrapper = new LambdaQueryWrapper<>();
|
||||
loginQueryWrapper.gt(AccountUserLogin::getUser_reg_time, recentOneWeek);
|
||||
Long recentOneWeekCertificationNum = userLoginRepository.getBaseMapper().selectCount(loginQueryWrapper);
|
||||
loginQueryWrapper.gt(AccountUserLogin::getUser_reg_time, recentTwoWeek);
|
||||
Long recentTwoWeekCertificationNum = userLoginRepository.getBaseMapper().selectCount(loginQueryWrapper);
|
||||
|
||||
Double userCertificationNumIncreaseRate = 0.0;
|
||||
if (userCertificationNum != 0 && recentOneWeekCertificationNum != 0) {
|
||||
userCertificationNumIncreaseRate = Convert.toDouble(((recentOneWeekCertificationNum - recentTwoWeekCertificationNum) / recentOneWeekCertificationNum) * 100);
|
||||
}
|
||||
dashBoardRes.setUserCertificationNumIncreaseRate(userCertificationNumIncreaseRate);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import com.suisung.mall.account.mapper.ShopUserExpHistoryMapper;
|
||||
import com.suisung.mall.account.service.ShopUserExpHistoryService;
|
||||
import com.suisung.mall.common.modules.user.ShopUserExpHistory;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会员经验日志表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-10-15
|
||||
*/
|
||||
@Service
|
||||
public class ShopUserExpHistoryServiceImpl extends BaseServiceImpl<ShopUserExpHistoryMapper, ShopUserExpHistory> implements ShopUserExpHistoryService {
|
||||
}
|
||||
@ -0,0 +1,611 @@
|
||||
package com.suisung.mall.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nimbusds.jose.JWSObject;
|
||||
import com.suisung.mall.account.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.account.service.AccountUserBaseService;
|
||||
import com.suisung.mall.account.service.AccountUserBindConnectService;
|
||||
import com.suisung.mall.account.service.WeiXinService;
|
||||
import com.suisung.mall.common.api.BindCode;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.AuthConstant;
|
||||
import com.suisung.mall.common.constant.ConfigConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.AuthService;
|
||||
import com.suisung.mall.common.feignService.SnsService;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.CookieUtils;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.WxHttpUtil;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统参数设置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Xinze
|
||||
* @since 2021-04-14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WeiXinServiceImpl implements WeiXinService {
|
||||
|
||||
private static final String GET_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
|
||||
|
||||
@Autowired
|
||||
private AccountUserBindConnectService accountUserBindConnectService;
|
||||
|
||||
@Autowired
|
||||
private AccountUserBaseService accountUserBaseService;
|
||||
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
|
||||
@Autowired
|
||||
private SnsService snsService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(WeiXinServiceImpl.class);
|
||||
|
||||
/**
|
||||
* 接入校验
|
||||
*
|
||||
* @param timestamp
|
||||
* @param nonce
|
||||
* @param signature
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkSignature(String timestamp, String nonce, String signature) {
|
||||
// 1.将token、timestamp、nonce三个参数进行字典序排序
|
||||
String wechat_token = accountBaseConfigService.getConfig("wechat_token");
|
||||
String[] arr = new String[]{wechat_token, timestamp, nonce};
|
||||
Arrays.sort(arr);
|
||||
// 2.将三个参数字符串拼接成一个字符串进行sha1加密
|
||||
String str = arr[0] + arr[1] + arr[2];
|
||||
str = DigestUtils.sha1Hex(str);
|
||||
// 3.将加密后的字符串和signature比较
|
||||
return str.equalsIgnoreCase(signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将接受到的消息转化成map
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> parseRequest(InputStream is) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
// 1.通过io流得到文档对象
|
||||
SAXReader saxReader = new SAXReader();
|
||||
Document document = null;
|
||||
try {
|
||||
document = saxReader.read(is);
|
||||
} catch (DocumentException e) {
|
||||
logger.error(I18nUtil._("io流读取文档对象异常!") + e.getMessage(), e);
|
||||
}
|
||||
// 2.通过文档对象得到根节点对象
|
||||
Element root = document.getRootElement();
|
||||
// 3.通过根节点对象获取所有子节点对象
|
||||
List<Element> elements = root.elements();
|
||||
// 4.将所有节点放入map
|
||||
for (Element element : elements) {
|
||||
map.put(element.getName(), element.getStringValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redirectToWxCode(HttpServletRequest request, HttpServletResponse response) {
|
||||
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE#wechat_redirect";
|
||||
// 获取活动id
|
||||
String activity_id = request.getParameter("activity_id");
|
||||
try {
|
||||
String wechat_callback_url = URLEncoder.encode(ConfigConstant.URL_API_MOBILE + "/account/weiXin/callbackMp?activity_id=" + activity_id, "UTF-8");
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("wechat_app_id");
|
||||
url = url.replace("APPID", wechat_app_id).replace("REDIRECT_URI", wechat_callback_url).replace("SCOPE", "snsapi_userinfo");
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送get请求获取AccessToken
|
||||
*/
|
||||
public String getMpToken() {
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("wechat_app_id");
|
||||
String wechat_app_secret = accountBaseConfigService.getConfig("wechat_app_secret");
|
||||
String url = GET_TOKEN_URL.replace("APPID", wechat_app_id).replace("APPSECRET", wechat_app_secret);
|
||||
String tokenStr = HttpUtil.get(url);
|
||||
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(tokenStr);
|
||||
String token = (String) jsonObject.get("access_token");
|
||||
Integer expiresIn = Convert.toInt(jsonObject.get("expires_in"), 0);
|
||||
if (StrUtil.isBlank(token)) {
|
||||
String errmsg = Convert.toStr(jsonObject.get("errmsg"));
|
||||
logger.error("获取公众号access_token失败!失败原因:{}", errmsg);
|
||||
throw new ApiException(I18nUtil._("获取公众号access_token失败!"));
|
||||
}
|
||||
redisService.set(StateCode.WX_MP_ACCESSTOKEN, Convert.toStr(jsonObject.get("access_token")), expiresIn);
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param useCacheFlag 是否从缓存中读取
|
||||
* 获取AccessToken 向外提供
|
||||
*/
|
||||
public String getMpAccessToken(boolean useCacheFlag) {
|
||||
if (useCacheFlag) {
|
||||
if (!redisService.hasKey(StateCode.WX_MP_ACCESSTOKEN)) {
|
||||
return getMpToken();
|
||||
}
|
||||
return Convert.toStr(redisService.get(StateCode.WX_MP_ACCESSTOKEN));
|
||||
} else {
|
||||
return getMpToken();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送get请求获取AccessToken
|
||||
*/
|
||||
private String getXcxToken() {
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("wechat_xcx_app_id");
|
||||
String wechat_app_secret = accountBaseConfigService.getConfig("wechat_xcx_app_secret");
|
||||
String url = GET_TOKEN_URL.replace("APPID", wechat_app_id).replace("APPSECRET", wechat_app_secret);
|
||||
String tokenStr = HttpUtil.get(url);
|
||||
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(tokenStr);
|
||||
String token = (String) jsonObject.get("access_token");
|
||||
Integer expiresIn = Convert.toInt(jsonObject.get("expires_in"), 0);
|
||||
if (StrUtil.isBlank(token)) {
|
||||
String errmsg = Convert.toStr(jsonObject.get("errmsg"));
|
||||
logger.error("获取小程序access_token失败!失败原因:{}", errmsg);
|
||||
throw new ApiException(I18nUtil._("获取小程序access_token失败!"));
|
||||
}
|
||||
redisService.set(StateCode.WX_XCX_ACCESSTOKEN, Convert.toStr(jsonObject.get("access_token")), expiresIn);
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取AccessToken 向外提供
|
||||
*/
|
||||
public String getXcxAccessToken(boolean useCacheFlag) {
|
||||
if (useCacheFlag) {
|
||||
if (!redisService.hasKey(StateCode.WX_XCX_ACCESSTOKEN)) {
|
||||
return getXcxToken();
|
||||
}
|
||||
return Convert.toStr(redisService.get(StateCode.WX_XCX_ACCESSTOKEN));
|
||||
} else {
|
||||
return getXcxToken();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
public void callbackMp(HttpServletResponse response, String activity_id, String code) {
|
||||
String vxUserInfo = getVxUserInfo(code);
|
||||
AccountUserBindConnect vxUserBindConnect = getVxMpUserBindConnect(vxUserInfo);
|
||||
Integer user_id = accountUserBindConnectService.doUserBind(vxUserBindConnect, activity_id, true);
|
||||
String wxUserToken = getWxUserToken(user_id);
|
||||
//Callback Url
|
||||
String redirectUrl = ConfigConstant.URL_H5 + "/pages/login/login?uid=" + user_id + "&ukey=" + wxUserToken;
|
||||
try {
|
||||
response.sendRedirect(redirectUrl);
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(I18nUtil._("微信登录跳转失败!"));
|
||||
}
|
||||
}
|
||||
|
||||
public String getWxUserToken(Integer user_id) {
|
||||
AccountUserBase accountUserBase = accountUserBaseService.get(user_id);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("client_id", AuthConstant.WX_CLIENT_ID);
|
||||
params.put("client_secret", AuthConstant.AUTHORITY_WX_SECRET);
|
||||
params.put("grant_type", "password");
|
||||
params.put("username", accountUserBase.getUser_account());
|
||||
CommonResult accessToken = authService.getAccessToken(params);
|
||||
|
||||
Map tokenData = (Map) accessToken.getData();
|
||||
if (accessToken.getStatus() != 200 || CollUtil.isEmpty(tokenData)) {
|
||||
throw new ApiException(I18nUtil._("获取用户token失败!"));
|
||||
}
|
||||
return (String) tokenData.get("token");
|
||||
}
|
||||
|
||||
private String getVxUserInfo(String code) {
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("wechat_app_id");
|
||||
String wechat_app_secret = accountBaseConfigService.getConfig("wechat_app_secret");
|
||||
//通过code获取网页授权的access_token
|
||||
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
|
||||
url = url.replace("APPID", wechat_app_id).replace("CODE", code).replace("SECRET", wechat_app_secret);
|
||||
String string = HttpUtil.get(url);
|
||||
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(string);
|
||||
String accessToken = (String) jsonObject.get("access_token");
|
||||
String openid = (String) jsonObject.get("openid");
|
||||
//通过token获取用户信息
|
||||
String getUserInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN";
|
||||
getUserInfoUrl = getUserInfoUrl.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openid);
|
||||
return HttpUtil.get(getUserInfoUrl);
|
||||
}
|
||||
|
||||
private String getVxUserInfo(String access_token, String openid) {
|
||||
//通过token获取用户信息
|
||||
String getUserInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN";
|
||||
getUserInfoUrl = getUserInfoUrl.replace("ACCESS_TOKEN", access_token).replace("OPENID", openid);
|
||||
return HttpUtil.get(getUserInfoUrl);
|
||||
}
|
||||
|
||||
private AccountUserBindConnect getVxMpUserBindConnect(String vxUserInfo) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(vxUserInfo);
|
||||
String openid = (String) jsonObject.get("openid");
|
||||
String unionid = (String) jsonObject.get("unionid");
|
||||
String nickname = (String) jsonObject.get("nickname");
|
||||
Integer sex = (Integer) jsonObject.get("sex");
|
||||
String city = (String) jsonObject.get("city");
|
||||
String province = (String) jsonObject.get("province");
|
||||
String country = (String) jsonObject.get("country");
|
||||
String headimgurl = (String) jsonObject.get("headimgurl");
|
||||
AccountUserBindConnect accountUserBindConnect = new AccountUserBindConnect();
|
||||
accountUserBindConnect.setBind_id(openid);
|
||||
accountUserBindConnect.setBind_openid(openid);
|
||||
accountUserBindConnect.setBind_unionid(unionid);
|
||||
accountUserBindConnect.setBind_nickname(nickname);
|
||||
accountUserBindConnect.setBind_gender(sex);
|
||||
accountUserBindConnect.setBind_city(city);
|
||||
accountUserBindConnect.setBind_province(province);
|
||||
accountUserBindConnect.setBind_country(country);
|
||||
accountUserBindConnect.setBind_icon(headimgurl);
|
||||
accountUserBindConnect.setBind_type(BindCode.WEIXIN);
|
||||
accountUserBindConnect.setBind_active(1);
|
||||
return accountUserBindConnect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> checkAppLogin(String code) {
|
||||
if (StrUtil.isEmpty(code)) {
|
||||
throw new ApiException(I18nUtil._("传入的code值为空"));
|
||||
}
|
||||
Map<String, String> data = getJsCode2Session(code);
|
||||
if (data == null) {
|
||||
throw new ApiException(I18nUtil._("数据异常"));
|
||||
}
|
||||
AccountUserBindConnect accountUserBindConnect = new AccountUserBindConnect();
|
||||
accountUserBindConnect.setBind_id(data.get("openid"));
|
||||
accountUserBindConnect.setBind_openid(data.get("openid"));
|
||||
accountUserBindConnect.setBind_unionid(data.get("unionid"));
|
||||
accountUserBindConnect.setBind_type(BindCode.WEIXIN_XCX);
|
||||
|
||||
AccountUserBindConnect userBindConnect = accountUserBindConnectService.get(data.get("openid"));
|
||||
|
||||
//判断是否存在bind_unionid
|
||||
if (userBindConnect == null && ObjectUtil.isNotEmpty(data.get("unionid")))
|
||||
{
|
||||
QueryWrapper<AccountUserBindConnect> where = new QueryWrapper<>();
|
||||
where.eq("bind_unionid", data.get("unionid"));
|
||||
userBindConnect = accountUserBindConnectService.findOne(where);
|
||||
}
|
||||
|
||||
Integer user_id = null;
|
||||
if (userBindConnect != null) {
|
||||
user_id = userBindConnect.getUser_id();
|
||||
return getUserInfo(user_id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Object> getUserInfo(Integer user_id) {
|
||||
String wxUserToken = getWxUserToken(user_id);
|
||||
JWSObject jwsObject = null;
|
||||
try {
|
||||
jwsObject = JWSObject.parse(wxUserToken);
|
||||
} catch (ParseException e) {
|
||||
logger.error("解析微信用户token异常!" + e.getMessage(), e);
|
||||
}
|
||||
UserDto userDto = JSONUtil.toBean(jwsObject.getPayload().toString(), UserDto.class);
|
||||
Integer rid = userDto.getRole_id();
|
||||
Map<String, Object> userInfo = accountUserBaseService.getUserInfo(userDto.getId());
|
||||
Map bind = accountUserBindConnectService.getBind(user_id, BindCode.MOBILE);
|
||||
userInfo.put("id", user_id);
|
||||
userInfo.put("k", wxUserToken);
|
||||
userInfo.put("key", wxUserToken);
|
||||
userInfo.put("rid", rid);
|
||||
if (null != bind) {
|
||||
CookieUtils.setCookie("as", "1");
|
||||
userInfo.put("as", 1);
|
||||
} else {
|
||||
CookieUtils.setCookie("as", "0");
|
||||
userInfo.put("as", 0);
|
||||
}
|
||||
|
||||
// IM连接配置信息
|
||||
userInfo.put("im", snsService.getImConfig(user_id));
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
private Map<String, String> getJsCode2Session(String code) {
|
||||
//从微信服务器获得session_key,openid,unionid
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
|
||||
|
||||
String wechat_xcx_app_id = accountBaseConfigService.getConfig("wechat_xcx_app_id");
|
||||
String wechat_xcx_app_secret = accountBaseConfigService.getConfig("wechat_xcx_app_secret");
|
||||
|
||||
url = url.replace("APPID", wechat_xcx_app_id)
|
||||
.replace("SECRET", wechat_xcx_app_secret)
|
||||
.replace("JSCODE", code);
|
||||
String wxResult = HttpUtil.get(url);
|
||||
|
||||
JSONObject jsonObject = JSONUtil.parseObj(wxResult);
|
||||
String sessionKey = (String) jsonObject.get("session_key");
|
||||
String unionid = (String) jsonObject.get("unionid");
|
||||
String openid = (String) jsonObject.get("openid");
|
||||
|
||||
if (StrUtil.isEmpty(sessionKey) || StrUtil.isEmpty(openid)) {
|
||||
throw new ApiException(I18nUtil._("微信登录,调用官方接口失败"));
|
||||
}
|
||||
Map<String, String> data = new HashMap();
|
||||
data.put("sessionKey", sessionKey);
|
||||
data.put("unionid", unionid);
|
||||
data.put("openid", openid);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
public Map jsCode2Session(String code, String encryptedData, String iv, String activity_id, String user_info) {
|
||||
AccountUserBindConnect vxUserBindConnect = getVxMiniAppUserBindConnect(code, encryptedData, iv, user_info);
|
||||
Integer user_id = accountUserBindConnectService.doUserBind(vxUserBindConnect, activity_id, true);
|
||||
|
||||
/*
|
||||
String wxUserToken = getWxUserToken(user_id);
|
||||
Map data = new HashMap();
|
||||
data.put("user_id", user_id);
|
||||
data.put("key", wxUserToken);
|
||||
*/
|
||||
|
||||
Map<String, Object> userInfo = getUserInfo(user_id);
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getUserPhoneNumber(String code, UserDto userDto) {
|
||||
String accessToken = getXcxAccessToken(true);
|
||||
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
|
||||
Map params = new HashMap();
|
||||
params.put("code", code);
|
||||
JSON parseParam = JSONUtil.parse(params);
|
||||
String responseStr = WxHttpUtil.request(WxHttpUtil.MethodType.POST, WxHttpUtil.WxType.XCX, accessToken, url, null, Convert.toStr(parseParam));
|
||||
JSONObject jsonObject = JSONUtil.parseObj(responseStr);
|
||||
Integer errcode = jsonObject.get("errcode", Integer.class);
|
||||
|
||||
if (CheckUtil.isNotEmpty(errcode.intValue()) || errcode != 0) {
|
||||
throw new ApiException(I18nUtil._("获取手机号失败"));
|
||||
}
|
||||
|
||||
Object phone_info_obj = jsonObject.get("phone_info");
|
||||
JSONObject phone_info = JSONUtil.parseObj(phone_info_obj);
|
||||
String phoneNumber = Convert.toStr(phone_info.get("phoneNumber"));
|
||||
String user_intl = "+" + Convert.toStr(phone_info.get("countryCode"));
|
||||
Integer user_id = accountUserBaseService.doBindMobile(user_intl, phoneNumber, userDto);
|
||||
|
||||
if (user_id == null) {
|
||||
throw new ApiException(I18nUtil._("绑定手机号失败"));
|
||||
}
|
||||
|
||||
Map<String, Object> userInfo = getUserInfo(user_id);
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public AccountUserBindConnect getVxMiniAppUserBindConnect(String code, String encryptedData, String iv, String user_info) {
|
||||
//解析用户基本信息
|
||||
JSONObject jsonObject = JSONUtil.parseObj(user_info);
|
||||
String nickName = (String) jsonObject.get("nickName");
|
||||
Integer gender = (Integer) jsonObject.get("gender");
|
||||
String language = (String) jsonObject.get("language");
|
||||
String city = (String) jsonObject.get("city");
|
||||
String province = (String) jsonObject.get("province");
|
||||
String country = (String) jsonObject.get("country");
|
||||
String avatarUrl = (String) jsonObject.get("avatarUrl");
|
||||
|
||||
AccountUserBindConnect accountUserBindConnect = new AccountUserBindConnect();
|
||||
|
||||
Map<String, String> data = getJsCode2Session(code);
|
||||
String sessionKey = data.get("sessionKey");
|
||||
accountUserBindConnect.setBind_id(data.get("openid"));
|
||||
accountUserBindConnect.setBind_openid(data.get("openid"));
|
||||
accountUserBindConnect.setBind_unionid(data.get("unionid"));
|
||||
accountUserBindConnect.setBind_nickname(nickName);
|
||||
accountUserBindConnect.setBind_gender(gender);
|
||||
accountUserBindConnect.setBind_city(city);
|
||||
accountUserBindConnect.setBind_province(province);
|
||||
accountUserBindConnect.setBind_country(country);
|
||||
accountUserBindConnect.setBind_icon(avatarUrl);
|
||||
accountUserBindConnect.setBind_type(BindCode.WEIXIN_XCX);
|
||||
|
||||
return accountUserBindConnect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map wxConfig(String url) {
|
||||
return getTicketSignature(getJsapiTicket(), url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code 获取openid
|
||||
*
|
||||
* @param code
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map getOpenIdByCode(String code, UserDto user) {
|
||||
Map data = new HashMap();
|
||||
if (user != null && CheckUtil.isNotEmpty(user.getId())) {
|
||||
Map bind_row = accountUserBindConnectService.getBind(user.getId(), BindCode.WEIXIN_XCX);
|
||||
if (CollUtil.isNotEmpty(bind_row) && StrUtil.isNotBlank(Convert.toStr(bind_row.get("bind_openid")))) {
|
||||
data.put("openid", bind_row.get("bind_openid"));
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank((CharSequence) data.get("openid"))) {
|
||||
Map<String, String> code2session = getJsCode2Session(code);
|
||||
data.put("openid", code2session.get("openid"));
|
||||
}
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信 jsapi_ticket
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getJsapiTicket() {
|
||||
String accessToken = getMpAccessToken(true);
|
||||
String requestUrl = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?";
|
||||
String params = "access_token=" + accessToken + "&type=jsapi";
|
||||
String result = HttpUtil.get(requestUrl + params);
|
||||
return com.alibaba.fastjson.JSONObject.parseObject(result).getString("ticket");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信 jsapi_ticket 签名
|
||||
*
|
||||
* @param url
|
||||
* @param jsapi_ticket
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getTicketSignature(String url, String jsapi_ticket) {
|
||||
String nonce_str = IdUtil.simpleUUID();
|
||||
String timestamp = Long.toString(System.currentTimeMillis() / 1000);
|
||||
String signature = "jsapi_ticket=" + jsapi_ticket + "&noncestr=" + nonce_str + "×tamp=" + timestamp + "&url=" + url;
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("wechat_app_id");
|
||||
signature = SecureUtil.sha1(signature);
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("url", url);
|
||||
data.put("appId", wechat_app_id);
|
||||
// data.put("jsapi_ticket", jsapi_ticket);
|
||||
data.put("nonceStr", nonce_str);
|
||||
data.put("timestamp", timestamp);
|
||||
data.put("signature", signature);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callbackMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信网页登录生成二维码
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getQrCode() {
|
||||
String baseUrl = "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_login&state=%s#wechat_redirect";
|
||||
String redirectUrl = ConfigConstant.URL_BASE + "/mobile/account/weiXin/callbackPc";
|
||||
try {
|
||||
redirectUrl = URLEncoder.encode(redirectUrl, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String weixin_status = accountBaseConfigService.getConfig("weixin_status");
|
||||
if (CheckUtil.isEmpty(weixin_status)) {
|
||||
throw new ApiException("网页登录功能未启用");
|
||||
}
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("weixin_app_id");
|
||||
|
||||
String url = String.format(baseUrl, wechat_app_id, redirectUrl, "lancerdt");
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信网页登录回调
|
||||
* @param code
|
||||
* @param response
|
||||
*/
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
public void callbackPc(String code, HttpServletResponse response) {
|
||||
String baseAccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
|
||||
String wechat_app_id = accountBaseConfigService.getConfig("weixin_app_id");
|
||||
String wechat_app_secret = accountBaseConfigService.getConfig("weixin_app_key");
|
||||
String accessTokenUrl = String.format(baseAccessTokenUrl, wechat_app_id, wechat_app_secret, code);
|
||||
|
||||
String result = HttpUtil.get(accessTokenUrl);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(result);
|
||||
Integer errcode = Convert.toInt(jsonObject.get("errcode"));
|
||||
if (CheckUtil.isNotEmpty(errcode)) {
|
||||
String errmsg = Convert.toStr(jsonObject.get("errmsg"));
|
||||
log.error("扫码登录失败,失败原因:{}", errmsg);
|
||||
throw new ApiException("扫码登录失败!");
|
||||
}
|
||||
|
||||
String openid = Convert.toStr(jsonObject.get("openid"));
|
||||
String unionid = Convert.toStr(jsonObject.get("unionid"));
|
||||
String access_token = Convert.toStr(jsonObject.get("access_token"));
|
||||
|
||||
AccountUserBindConnect accountUserBindConnect = new AccountUserBindConnect();
|
||||
accountUserBindConnect.setBind_id(openid);
|
||||
accountUserBindConnect.setBind_openid(openid);
|
||||
accountUserBindConnect.setBind_unionid(unionid);
|
||||
accountUserBindConnect.setBind_type(BindCode.WEIXIN);
|
||||
|
||||
String vxUserInfo = getVxUserInfo(access_token, openid);
|
||||
AccountUserBindConnect vxUserBindConnect = getVxMpUserBindConnect(vxUserInfo);
|
||||
Integer user_id = accountUserBindConnectService.doUserBind(vxUserBindConnect, null, true);
|
||||
String wxUserToken = getWxUserToken(user_id);
|
||||
String redirectUrl = ConfigConstant.URL_PC + "/login/login?ukey=" + wxUserToken;
|
||||
try {
|
||||
response.sendRedirect(redirectUrl);
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(I18nUtil._("微信登录跳转失败!"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
34
mall-account/src/main/resources/application.yml
Normal file
34
mall-account/src/main/resources/application.yml
Normal file
@ -0,0 +1,34 @@
|
||||
server:
|
||||
port: 8088
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/mapper/**/*.xml
|
||||
global-config:
|
||||
field-strategy: 1
|
||||
db-config:
|
||||
id-type: auto
|
||||
configuration:
|
||||
auto-mapping-behavior: partial
|
||||
map-underscore-to-camel-case: false
|
||||
|
||||
management: #开启SpringBoot Admin的监控
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*" # 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*'
|
||||
enabled-by-default: false
|
||||
endpoint:
|
||||
health:
|
||||
show-details: ALWAYS # 是否展示健康检查详情
|
||||
|
||||
# info信息会显示到SpringBootAdmin的server端,这里取的是pom文件中的数据
|
||||
info:
|
||||
version: @project.version@
|
||||
groupId: @project.groupId@
|
||||
artifactId: @project.artifactId@
|
||||
|
||||
feign:
|
||||
okhttp:
|
||||
enabled: true
|
||||
ribbon:
|
||||
ConnectTimeout: 60000 #服务请求连接超时时间(毫秒)
|
||||
ReadTimeout: 60000 #服务请求处理超时时间(毫秒)
|
||||
111
mall-account/src/main/resources/bootstrap-dev.yml
Normal file
111
mall-account/src/main/resources/bootstrap-dev.yml
Normal file
@ -0,0 +1,111 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://172.16.0.11:3306/fafamall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&&zeroDateTimeBehavior=convertToNull
|
||||
username: fafamall
|
||||
password: brCnv0qLt8s0VqhI
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
async-init: true
|
||||
initial-size: 5
|
||||
max-active: 20
|
||||
min-idle: 5
|
||||
max-wait: 60000
|
||||
validationQuery: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
filters: stat,wall,slf4j
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
db-type: mysql
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 10
|
||||
aop-patterns: com.suisung.mall.common.service.impl.*,com.suisung.mall.core.web.service.impl.*,com.suisung.mall.account.*
|
||||
redis:
|
||||
host: @redis.host@ # Redis服务器地址
|
||||
database: @redis.database@ # Redis数据库索引(默认为0)
|
||||
port: @redis.port@ # Redis服务器连接端口
|
||||
password: @redis.password@ # Redis服务器连接密码(默认为空)
|
||||
timeout: 3000ms # 连接超时时间(毫秒)
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 64
|
||||
max-wait: -1ms
|
||||
max-idle: 64
|
||||
min-idle: 0
|
||||
rabbitmq:
|
||||
host: @rabbitmq.host@
|
||||
port: @rabbitmq.port@
|
||||
virtual-host: @rabbitmq.virtual-host@
|
||||
listener:
|
||||
simple:
|
||||
acknowledge-mode: manual #手动确认消息,不使用默认的消费端确认
|
||||
username: @rabbitmq.username@
|
||||
password: @rabbitmq.password@
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.server.address@
|
||||
config:
|
||||
server-addr: @nacos.server.address@
|
||||
file-extension: yaml
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: @sentinel.transport.dashboard@
|
||||
eager: true
|
||||
seata:
|
||||
# 开启自动装配
|
||||
enabled: true
|
||||
# 本客户端的微服务名称
|
||||
application-id: mall-account
|
||||
data-source-proxy-mode: AT
|
||||
# 读取哪个事务分组
|
||||
# 例如此时会读取 SEATA_GROUP 这个分组下的 service.vgroupMapping.my_test_tx_group 这个属性的值。从上面的配置可以知道笔者此处的最终值为 testCluster。后面程序运行会找到 testCluster 这个集群的seata服务端,进行通讯。
|
||||
tx-service-group: @seata.tx-service-group@
|
||||
enable-auto-data-source-proxy: true
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
service:
|
||||
vgroup-mapping:
|
||||
my_test_tx_group: default
|
||||
# 控制台日志信息
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
suisung:
|
||||
mall:
|
||||
account:
|
||||
mapper: debug
|
||||
sun:
|
||||
mail: error
|
||||
baomidou: error
|
||||
alibaba:
|
||||
cloud:
|
||||
seata: error
|
||||
nacos:
|
||||
client:
|
||||
naming: error
|
||||
config: error
|
||||
netflix: error
|
||||
org: error
|
||||
io: error
|
||||
reactor: error
|
||||
springfox: error
|
||||
logstash:
|
||||
host: @logstash.host@
|
||||
111
mall-account/src/main/resources/bootstrap-local.yml
Normal file
111
mall-account/src/main/resources/bootstrap-local.yml
Normal file
@ -0,0 +1,111 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&&zeroDateTimeBehavior=convertToNull
|
||||
username: fafamall
|
||||
password: brCnv0qLt8s0VqhI
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
async-init: true
|
||||
initial-size: 5
|
||||
max-active: 20
|
||||
min-idle: 5
|
||||
max-wait: 60000
|
||||
validationQuery: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
filters: stat,wall,slf4j
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
db-type: mysql
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 10
|
||||
aop-patterns: com.suisung.mall.common.service.impl.*,com.suisung.mall.core.web.service.impl.*,com.suisung.mall.account.*
|
||||
redis:
|
||||
host: @redis.host@ # Redis服务器地址
|
||||
database: @redis.database@ # Redis数据库索引(默认为0)
|
||||
port: @redis.port@ # Redis服务器连接端口
|
||||
password: @redis.password@ # Redis服务器连接密码(默认为空)
|
||||
timeout: 3000ms # 连接超时时间(毫秒)
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 64
|
||||
max-wait: -1ms
|
||||
max-idle: 64
|
||||
min-idle: 0
|
||||
rabbitmq:
|
||||
host: @rabbitmq.host@
|
||||
port: @rabbitmq.port@
|
||||
virtual-host: @rabbitmq.virtual-host@
|
||||
listener:
|
||||
simple:
|
||||
acknowledge-mode: manual #手动确认消息,不使用默认的消费端确认
|
||||
username: @rabbitmq.username@
|
||||
password: @rabbitmq.password@
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.server.address@
|
||||
config:
|
||||
server-addr: @nacos.server.address@
|
||||
file-extension: yaml
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: @sentinel.transport.dashboard@
|
||||
eager: true
|
||||
seata:
|
||||
# 开启自动装配
|
||||
enabled: true
|
||||
# 本客户端的微服务名称
|
||||
application-id: mall-account
|
||||
data-source-proxy-mode: AT
|
||||
# 读取哪个事务分组
|
||||
# 例如此时会读取 SEATA_GROUP 这个分组下的 service.vgroupMapping.my_test_tx_group 这个属性的值。从上面的配置可以知道笔者此处的最终值为 testCluster。后面程序运行会找到 testCluster 这个集群的seata服务端,进行通讯。
|
||||
tx-service-group: @seata.tx-service-group@
|
||||
enable-auto-data-source-proxy: true
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
service:
|
||||
vgroup-mapping:
|
||||
my_test_tx_group: default
|
||||
# 控制台日志信息
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
suisung:
|
||||
mall:
|
||||
account:
|
||||
mapper: debug
|
||||
sun:
|
||||
mail: error
|
||||
baomidou: error
|
||||
alibaba:
|
||||
cloud:
|
||||
seata: error
|
||||
nacos:
|
||||
client:
|
||||
naming: error
|
||||
config: error
|
||||
netflix: error
|
||||
org: error
|
||||
io: error
|
||||
reactor: error
|
||||
springfox: error
|
||||
logstash:
|
||||
host: @logstash.host@
|
||||
111
mall-account/src/main/resources/bootstrap-prod.yml
Normal file
111
mall-account/src/main/resources/bootstrap-prod.yml
Normal file
@ -0,0 +1,111 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://172.16.0.11:3306/fafamall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&&zeroDateTimeBehavior=convertToNull
|
||||
username: fafamall
|
||||
password: brCnv0qLt8s0VqhI
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
async-init: true
|
||||
initial-size: 10
|
||||
max-active: 500
|
||||
min-idle: 10
|
||||
max-wait: 60000
|
||||
validationQuery: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
filters: stat,wall,slf4j
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
db-type: mysql
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 10
|
||||
aop-patterns: com.suisung.mall.common.service.impl.*,com.suisung.mall.core.web.service.impl.*,com.suisung.mall.account.*
|
||||
redis:
|
||||
host: @redis.host@ # Redis服务器地址
|
||||
database: @redis.database@ # Redis数据库索引(默认为0)
|
||||
port: @redis.port@ # Redis服务器连接端口
|
||||
password: @redis.password@ # Redis服务器连接密码(默认为空)
|
||||
timeout: 3000ms # 连接超时时间(毫秒)
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 64
|
||||
max-wait: -1ms
|
||||
max-idle: 64
|
||||
min-idle: 0
|
||||
rabbitmq:
|
||||
host: @rabbitmq.host@
|
||||
port: @rabbitmq.port@
|
||||
virtual-host: @rabbitmq.virtual-host@
|
||||
listener:
|
||||
simple:
|
||||
acknowledge-mode: manual #手动确认消息,不使用默认的消费端确认
|
||||
username: @rabbitmq.username@
|
||||
password: @rabbitmq.password@
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.server.address@
|
||||
config:
|
||||
server-addr: @nacos.server.address@
|
||||
file-extension: yaml
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: @sentinel.transport.dashboard@
|
||||
eager: true
|
||||
seata:
|
||||
# 开启自动装配
|
||||
enabled: true
|
||||
# 本客户端的微服务名称
|
||||
application-id: mall-account
|
||||
data-source-proxy-mode: AT
|
||||
# 读取哪个事务分组
|
||||
# 例如此时会读取 SEATA_GROUP 这个分组下的 service.vgroupMapping.my_test_tx_group 这个属性的值。从上面的配置可以知道笔者此处的最终值为 testCluster。后面程序运行会找到 testCluster 这个集群的seata服务端,进行通讯。
|
||||
tx-service-group: @seata.tx-service-group@
|
||||
enable-auto-data-source-proxy: true
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
service:
|
||||
vgroup-mapping:
|
||||
my_test_tx_group: default
|
||||
# 控制台日志信息
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
suisung:
|
||||
mall:
|
||||
account:
|
||||
mapper: debug
|
||||
sun:
|
||||
mail: error
|
||||
baomidou: error
|
||||
alibaba:
|
||||
cloud:
|
||||
seata: error
|
||||
nacos:
|
||||
client:
|
||||
naming: error
|
||||
config: error
|
||||
netflix: error
|
||||
org: error
|
||||
io: error
|
||||
reactor: error
|
||||
springfox: error
|
||||
logstash:
|
||||
host: @logstash.host@
|
||||
111
mall-account/src/main/resources/bootstrap-test.yml
Normal file
111
mall-account/src/main/resources/bootstrap-test.yml
Normal file
@ -0,0 +1,111 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://172.16.0.11:3306/fafamall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&&zeroDateTimeBehavior=convertToNull
|
||||
username: fafamall
|
||||
password: brCnv0qLt8s0VqhI
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
async-init: true
|
||||
initial-size: 5
|
||||
max-active: 20
|
||||
min-idle: 5
|
||||
max-wait: 60000
|
||||
validationQuery: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
filters: stat,wall,slf4j
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
db-type: mysql
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 10
|
||||
aop-patterns: com.suisung.mall.common.service.impl.*,com.suisung.mall.core.web.service.impl.*,com.suisung.mall.account.*
|
||||
redis:
|
||||
host: @redis.host@ # Redis服务器地址
|
||||
database: @redis.database@ # Redis数据库索引(默认为0)
|
||||
port: @redis.port@ # Redis服务器连接端口
|
||||
password: @redis.password@ # Redis服务器连接密码(默认为空)
|
||||
timeout: 3000ms # 连接超时时间(毫秒)
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 64
|
||||
max-wait: -1ms
|
||||
max-idle: 64
|
||||
min-idle: 0
|
||||
rabbitmq:
|
||||
host: @rabbitmq.host@
|
||||
port: @rabbitmq.port@
|
||||
virtual-host: @rabbitmq.virtual-host@
|
||||
listener:
|
||||
simple:
|
||||
acknowledge-mode: manual #手动确认消息,不使用默认的消费端确认
|
||||
username: @rabbitmq.username@
|
||||
password: @rabbitmq.password@
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: @nacos.server.address@
|
||||
config:
|
||||
server-addr: @nacos.server.address@
|
||||
file-extension: yaml
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: @sentinel.transport.dashboard@
|
||||
eager: true
|
||||
seata:
|
||||
# 开启自动装配
|
||||
enabled: true
|
||||
# 本客户端的微服务名称
|
||||
application-id: mall-account
|
||||
data-source-proxy-mode: AT
|
||||
# 读取哪个事务分组
|
||||
# 例如此时会读取 SEATA_GROUP 这个分组下的 service.vgroupMapping.my_test_tx_group 这个属性的值。从上面的配置可以知道笔者此处的最终值为 testCluster。后面程序运行会找到 testCluster 这个集群的seata服务端,进行通讯。
|
||||
tx-service-group: @seata.tx-service-group@
|
||||
enable-auto-data-source-proxy: true
|
||||
registry:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
config:
|
||||
type: nacos
|
||||
nacos:
|
||||
server-addr: @nacos.server.address@
|
||||
group: @seata.group@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
service:
|
||||
vgroup-mapping:
|
||||
my_test_tx_group: default
|
||||
# 控制台日志信息
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
suisung:
|
||||
mall:
|
||||
account:
|
||||
mapper: debug
|
||||
sun:
|
||||
mail: error
|
||||
baomidou: error
|
||||
alibaba:
|
||||
cloud:
|
||||
seata: error
|
||||
nacos:
|
||||
client:
|
||||
naming: error
|
||||
config: error
|
||||
netflix: error
|
||||
org: error
|
||||
io: error
|
||||
reactor: error
|
||||
springfox: error
|
||||
logstash:
|
||||
host: @logstash.host@
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user